feat:【antd】【ai】write/manager 的代码优化

This commit is contained in:
YunaiV
2025-10-26 13:35:39 +08:00
parent e218be3fdf
commit 19959c79fc
3 changed files with 11 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ import { requestClient } from '#/api/request';
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD); const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
const accessStore = useAccessStore(); const accessStore = useAccessStore();
export namespace AiWriteApi { export namespace AiWriteApi {
export interface Write { export interface Write {
type: AiWriteTypeEnum.REPLY | AiWriteTypeEnum.WRITING; // 1:撰写 2:回复 type: AiWriteTypeEnum.REPLY | AiWriteTypeEnum.WRITING; // 1:撰写 2:回复

View File

@@ -8,12 +8,9 @@ import { getDictOptions } from '@vben/hooks';
import { getSimpleUserList } from '#/api/system/user'; import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils'; import { getRangePickerDefaultProps } from '#/utils';
/** 关联数据 */
let userList: SystemUserApi.User[] = []; let userList: SystemUserApi.User[] = [];
async function getUserData() { getSimpleUserList().then((data) => (userList = data));
userList = await getSimpleUserList();
}
getUserData();
/** 列表的搜索表单 */ /** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] { export function useGridFormSchema(): VbenFormSchema[] {
@@ -26,6 +23,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
api: getSimpleUserList, api: getSimpleUserList,
labelField: 'nickname', labelField: 'nickname',
valueField: 'id', valueField: 'id',
placeholder: '请选择用户',
allowClear: true,
}, },
}, },
{ {
@@ -34,6 +33,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
placeholder: '请选择写作类型',
options: getDictOptions(DICT_TYPE.AI_WRITE_TYPE, 'number'), options: getDictOptions(DICT_TYPE.AI_WRITE_TYPE, 'number'),
}, },
}, },
@@ -43,7 +43,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, allowClear: true,
options: getDictOptions(DICT_TYPE.AI_PLATFORM, 'number'), placeholder: '请选择平台',
options: getDictOptions(DICT_TYPE.AI_PLATFORM, 'string'),
}, },
}, },
{ {
@@ -78,7 +79,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'type', field: 'type',
title: '写作类型', title: '写作类型',
minWidth: 100, minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.AI_WRITE_TYPE }, props: { type: DICT_TYPE.AI_WRITE_TYPE },

View File

@@ -25,9 +25,7 @@ async function handleDelete(row: AiWriteApi.AiWritePageReq) {
}); });
try { try {
await deleteWrite(row.id as number); await deleteWrite(row.id as number);
message.success({ message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
});
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); hideLoading();
@@ -54,6 +52,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,