|
@@ -46,133 +46,119 @@
|
|
|
</template>
|
|
|
</BasicTable>
|
|
|
<TokenDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
|
- <ModeDrawer @register="registerModeDrawer" @success="handleSuccess" />
|
|
|
+ <SelectAIAgentModal @register="registerAIAgentModal" @ok="handleUpdateAgent" />
|
|
|
</div>
|
|
|
</template>
|
|
|
-<script lang="ts">
|
|
|
-import {createVNode, defineComponent, onMounted, ref} from 'vue';
|
|
|
- import {Form, FormItem, message, Modal, Select} from 'ant-design-vue';
|
|
|
- import { ExclamationCircleOutlined } from '@ant-design/icons-vue/lib/icons';
|
|
|
- import { BasicTable, useTable, TableAction } from '@/components/Table';
|
|
|
- import { Button } from '@/components/Button';
|
|
|
+<script lang="ts" setup>
|
|
|
+import {createVNode, onMounted, ref} from 'vue';
|
|
|
+import {Modal} from 'ant-design-vue';
|
|
|
+import { ExclamationCircleOutlined } from '@ant-design/icons-vue/lib/icons';
|
|
|
+import { BasicTable, useTable, TableAction } from '@/components/Table';
|
|
|
+import { Button } from '@/components/Button';
|
|
|
|
|
|
- import { useDrawer } from '@/components/Drawer';
|
|
|
- import TokenDrawer from './TokenDrawer.vue';
|
|
|
- import ModeDrawer from './ModeDrawer.vue';
|
|
|
- import { useI18n } from 'vue-i18n';
|
|
|
+import { useDrawer } from '@/components/Drawer';
|
|
|
+import TokenDrawer from './TokenDrawer.vue';
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
|
|
|
- import { columns, searchFormSchema } from './token.data';
|
|
|
- import { getTokenList, deleteToken } from '@/api/wechat/token';
|
|
|
- import {updateWx} from "@/api/wechat/wx";
|
|
|
- import { getPermCode } from '@/api/sys/user';
|
|
|
- import {getAgentList} from "@/api/wechat/agent";
|
|
|
- import {getServerList} from "@/api/wechat/server";
|
|
|
- let permCode = ref('');
|
|
|
- export default defineComponent({
|
|
|
- name: 'TokenManagement',
|
|
|
- components: {Modal, Select, FormItem, Form, BasicTable, TokenDrawer, ModeDrawer, TableAction, Button },
|
|
|
- setup() {
|
|
|
- const { t } = useI18n();
|
|
|
- const selectedIds = ref<number[] | string[]>();
|
|
|
- const showDeleteButton = ref<boolean>(false);
|
|
|
- const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
- const [registerModeDrawer, { openDrawer: openModeDrawer }] = useDrawer();
|
|
|
- const [registerTable, { reload }] = useTable({
|
|
|
- title: t('wechat.token.tokenList'),
|
|
|
- api: getTokenList,
|
|
|
- columns,
|
|
|
- formConfig: {
|
|
|
- labelWidth: 120,
|
|
|
- schemas: searchFormSchema,
|
|
|
- },
|
|
|
- useSearchForm: true,
|
|
|
- showTableSetting: true,
|
|
|
- bordered: true,
|
|
|
- showIndexColumn: false,
|
|
|
- clickToRowSelect: false,
|
|
|
- actionColumn: {
|
|
|
- width: 30,
|
|
|
- title: t('common.action'),
|
|
|
- dataIndex: 'action',
|
|
|
- fixed: undefined,
|
|
|
- },
|
|
|
- rowKey: 'id',
|
|
|
- rowSelection: {
|
|
|
- type: 'checkbox',
|
|
|
- columnWidth: 20,
|
|
|
- onChange: (selectedRowKeys, _selectedRows) => {
|
|
|
- selectedIds.value = selectedRowKeys as number[];
|
|
|
- showDeleteButton.value = selectedRowKeys.length > 0;
|
|
|
- },
|
|
|
- },
|
|
|
- });
|
|
|
-
|
|
|
- onMounted(async () => {
|
|
|
- let res = await getPermCode();
|
|
|
- permCode.value = res.data[0];
|
|
|
- });
|
|
|
+import { columns, searchFormSchema } from './token.data';
|
|
|
+import { getTokenList, deleteToken, updateToken } from '@/api/wechat/token';
|
|
|
+import { getPermCode } from '@/api/sys/user';
|
|
|
+import SelectAIAgentModal from '@/views/components/ SelectAIAgentModal.vue';
|
|
|
+import { useModal } from '/@/components/Modal';
|
|
|
+let permCode = ref('');
|
|
|
+const { t } = useI18n();
|
|
|
+const selectedIds = ref<number[] | string[]>();
|
|
|
+const showDeleteButton = ref<boolean>(false);
|
|
|
+const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
+const [registerAIAgentModal, { openModal: openAIAgentModal, closeModal: closeAIAgentModal }] = useModal();
|
|
|
+const [registerTable, { reload }] = useTable({
|
|
|
+ title: t('wechat.token.tokenList'),
|
|
|
+ api: getTokenList,
|
|
|
+ columns,
|
|
|
+ formConfig: {
|
|
|
+ labelWidth: 120,
|
|
|
+ schemas: searchFormSchema,
|
|
|
+ },
|
|
|
+ useSearchForm: true,
|
|
|
+ showTableSetting: true,
|
|
|
+ bordered: true,
|
|
|
+ showIndexColumn: false,
|
|
|
+ clickToRowSelect: false,
|
|
|
+ actionColumn: {
|
|
|
+ width: 80,
|
|
|
+ title: t('common.action'),
|
|
|
+ dataIndex: 'action'
|
|
|
+ },
|
|
|
+ rowKey: 'id',
|
|
|
+ rowSelection: {
|
|
|
+ type: 'checkbox',
|
|
|
+ columnWidth: 20,
|
|
|
+ onChange: (selectedRowKeys, _selectedRows) => {
|
|
|
+ selectedIds.value = selectedRowKeys as number[];
|
|
|
+ showDeleteButton.value = selectedRowKeys.length > 0;
|
|
|
+ },
|
|
|
+ },
|
|
|
+});
|
|
|
|
|
|
- function handleCreate() {
|
|
|
- openDrawer(true, {
|
|
|
- isUpdate: false,
|
|
|
- });
|
|
|
- }
|
|
|
+onMounted(async () => {
|
|
|
+ let res = await getPermCode();
|
|
|
+ permCode.value = res.data[0];
|
|
|
+});
|
|
|
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- openDrawer(true, {
|
|
|
- record,
|
|
|
- isUpdate: true,
|
|
|
- });
|
|
|
- }
|
|
|
+function handleCreate() {
|
|
|
+ openDrawer(true, {
|
|
|
+ isUpdate: false,
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
- function handleEditMode(record: Recordable) {
|
|
|
- openModeDrawer(true, {
|
|
|
- record,
|
|
|
- });
|
|
|
- }
|
|
|
+function handleEdit(record: Recordable) {
|
|
|
+ openDrawer(true, {
|
|
|
+ record,
|
|
|
+ isUpdate: true,
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
- async function handleDelete(record: Recordable) {
|
|
|
- const result = await deleteToken({ ids: [record.id] });
|
|
|
- if (result.code === 0) {
|
|
|
- await reload();
|
|
|
- }
|
|
|
- }
|
|
|
+function handleEditMode(record: Recordable) {
|
|
|
+ const name = record.agent_info?.name == null ? '定制 AI 角色' : record.agent_info?.name;
|
|
|
+ const id = record.agent_info?.id == null ? 0 : record.agent_info?.id;
|
|
|
+ openAIAgentModal(true, {
|
|
|
+ accountId: record.id,
|
|
|
+ name,
|
|
|
+ id,
|
|
|
+ organizationId: record.organization_id
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
- async function handleBatchDelete() {
|
|
|
- Modal.confirm({
|
|
|
- title: t('common.deleteConfirm'),
|
|
|
- icon: createVNode(ExclamationCircleOutlined),
|
|
|
- async onOk() {
|
|
|
- const result = await deleteToken({ ids: selectedIds.value as number[] });
|
|
|
- if (result.code === 0) {
|
|
|
- showDeleteButton.value = false;
|
|
|
- await reload();
|
|
|
- }
|
|
|
- },
|
|
|
- onCancel() {
|
|
|
- console.log('Cancel');
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
+async function handleDelete(record: Recordable) {
|
|
|
+ const result = await deleteToken({ ids: [record.id] });
|
|
|
+ if (result.code === 0) {
|
|
|
+ await reload();
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- async function handleSuccess() {
|
|
|
+async function handleBatchDelete() {
|
|
|
+ Modal.confirm({
|
|
|
+ title: t('common.deleteConfirm'),
|
|
|
+ icon: createVNode(ExclamationCircleOutlined),
|
|
|
+ async onOk() {
|
|
|
+ const result = await deleteToken({ ids: selectedIds.value as number[] });
|
|
|
+ if (result.code === 0) {
|
|
|
+ showDeleteButton.value = false;
|
|
|
await reload();
|
|
|
}
|
|
|
-
|
|
|
- return {
|
|
|
- t,
|
|
|
- registerTable,
|
|
|
- registerDrawer,
|
|
|
- registerModeDrawer,
|
|
|
- handleCreate,
|
|
|
- handleEdit,
|
|
|
- handleEditMode,
|
|
|
- handleDelete,
|
|
|
- handleSuccess,
|
|
|
- handleBatchDelete,
|
|
|
- showDeleteButton,
|
|
|
- permCode,
|
|
|
- };
|
|
|
+ },
|
|
|
+ onCancel() {
|
|
|
+ console.log('Cancel');
|
|
|
},
|
|
|
});
|
|
|
+}
|
|
|
+
|
|
|
+async function handleSuccess() {
|
|
|
+ await reload();
|
|
|
+}
|
|
|
+async function handleUpdateAgent({id, agentId: agent_id }) {
|
|
|
+ await updateToken({ id, agent_id });
|
|
|
+ closeAIAgentModal();
|
|
|
+ reload()
|
|
|
+}
|
|
|
</script>
|