mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-13 04:33:42 +08:00
feat(ui):apiKey 语言模型 角色管理 产品
This commit is contained in:
@@ -1,4 +1,120 @@
|
||||
<script lang="ts" setup></script>
|
||||
<script lang="ts" setup>
|
||||
import { getList, save, deleting, setStatus } from "./api";
|
||||
import { ref } from "vue";
|
||||
import ChatModelForm from "./ChatModelForm.vue";
|
||||
import useCustomFormPopup from "@/composables/useCustomFormPopup";
|
||||
import { Message } from "@arco-design/web-vue";
|
||||
import SimpleTable from "@/components/SimpleTable/SimpleTable.vue";
|
||||
import { dateFormat } from "@gpt-vue/packages/utils";
|
||||
// table 配置
|
||||
const columns = [
|
||||
{
|
||||
title: "所属平台",
|
||||
dataIndex: "platform",
|
||||
},
|
||||
{
|
||||
title: "模型名称",
|
||||
dataIndex: "name",
|
||||
},
|
||||
{
|
||||
title: "模型值",
|
||||
dataIndex: "value",
|
||||
},
|
||||
{
|
||||
title: "对话权重",
|
||||
dataIndex: "weight",
|
||||
},
|
||||
{
|
||||
title: "启用状态",
|
||||
dataIndex: "enabled",
|
||||
slotName: "status",
|
||||
},
|
||||
{
|
||||
title: "开放状态",
|
||||
dataIndex: "open",
|
||||
slotName: "open",
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
dataIndex: "created_at",
|
||||
render: ({ record }) => {
|
||||
return dateFormat(record.created_at);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slotName: "action",
|
||||
},
|
||||
];
|
||||
|
||||
// 数据
|
||||
const tableData = ref([]);
|
||||
const getData = () => {
|
||||
getList().then(({ code, data }) => {
|
||||
if (code === 0) {
|
||||
tableData.value = data;
|
||||
}
|
||||
});
|
||||
};
|
||||
getData();
|
||||
|
||||
// 新增编辑
|
||||
const popup = useCustomFormPopup(ChatModelForm, save);
|
||||
|
||||
// 删除
|
||||
const handleDelete = ({ id }, reload) => {
|
||||
deleting(id).then(({ code }) => {
|
||||
if (code === 0) {
|
||||
Message.success("操作成功");
|
||||
reload();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 状态
|
||||
const handleStatusChange = ({ filed, value, record, reload }) => {
|
||||
setStatus({
|
||||
id: record.id,
|
||||
value,
|
||||
filed,
|
||||
}).then(({ code }) => {
|
||||
if (code === 0) {
|
||||
Message.success("操作成功");
|
||||
reload();
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<div></div>
|
||||
<SimpleTable :columns="columns" :request="getList">
|
||||
<template #action="{ record, reload }">
|
||||
<a-link @click="popup({ record, reload })">编辑</a-link>
|
||||
<a-popconfirm content="确定删除?" @ok="handleDelete(record, reload)">
|
||||
<a-link>删除</a-link>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
<template #header="{ reload }">
|
||||
<a-button @click="popup({ reload })" size="small"><icon-plus />新增</a-button>
|
||||
</template>
|
||||
<template #status="{ record, reload }">
|
||||
<a-switch
|
||||
v-model="record.enabled"
|
||||
@change="
|
||||
(value) => {
|
||||
handleStatusChange({ filed: 'enabled', value, record, reload });
|
||||
}
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template #open="{ record, reload }">
|
||||
<a-switch
|
||||
v-model="record.open"
|
||||
@change="
|
||||
(value) => {
|
||||
handleStatusChange({ filed: 'open', value, record, reload });
|
||||
}
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
</SimpleTable>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user