diff --git a/apps/web-antd/src/views/iot/product/product/data.ts b/apps/web-antd/src/views/iot/product/product/data.ts index e1d2d27fd..066cc1330 100644 --- a/apps/web-antd/src/views/iot/product/product/data.ts +++ b/apps/web-antd/src/views/iot/product/product/data.ts @@ -23,7 +23,6 @@ export function useFormSchema(formApi?: any): VbenFormSchema[] { show: () => false, }, }, - // 创建时的 ProductKey 字段(带生成按钮) { fieldName: 'productKey', label: 'ProductKey', @@ -34,7 +33,6 @@ export function useFormSchema(formApi?: any): VbenFormSchema[] { dependencies: { triggerFields: ['id'], if(values) { - // 仅在创建时显示(没有 id) return !values.id; }, }, @@ -43,6 +41,7 @@ export function useFormSchema(formApi?: any): VbenFormSchema[] { .min(1, 'ProductKey 不能为空') .max(32, 'ProductKey 长度不能超过 32 个字符'), suffix: () => { + // 创建时的 ProductKey 字段(带生成按钮) return h( Button, { @@ -55,19 +54,17 @@ export function useFormSchema(formApi?: any): VbenFormSchema[] { ); }, }, - // 编辑时的 ProductKey 字段(禁用,无按钮) { fieldName: 'productKey', label: 'ProductKey', component: 'Input', componentProps: { placeholder: '请输入 ProductKey', - disabled: true, + disabled: true, // 编辑时的 ProductKey 字段(禁用,无按钮) }, dependencies: { triggerFields: ['id'], if(values) { - // 仅在编辑时显示(有 id) return !!values.id; }, }, @@ -176,7 +173,6 @@ export function useBasicFormSchema(formApi?: any): VbenFormSchema[] { show: () => false, }, }, - // 创建时的 ProductKey 字段(带生成按钮) { fieldName: 'productKey', label: 'ProductKey', @@ -187,7 +183,6 @@ export function useBasicFormSchema(formApi?: any): VbenFormSchema[] { dependencies: { triggerFields: ['id'], if(values) { - // 仅在创建时显示(没有 id) return !values.id; }, }, @@ -208,7 +203,6 @@ export function useBasicFormSchema(formApi?: any): VbenFormSchema[] { ); }, }, - // 编辑时的 ProductKey 字段(禁用,无按钮) { fieldName: 'productKey', label: 'ProductKey', @@ -220,7 +214,6 @@ export function useBasicFormSchema(formApi?: any): VbenFormSchema[] { dependencies: { triggerFields: ['id'], if(values) { - // 仅在编辑时显示(有 id) return !!values.id; }, }, @@ -341,6 +334,7 @@ export function useAdvancedFormSchema(): VbenFormSchema[] { } /** 列表的搜索表单 */ +// TODO @haohao:貌似用不上? export function useGridFormSchema(): VbenFormSchema[] { return [ { @@ -367,7 +361,6 @@ export function useGridFormSchema(): VbenFormSchema[] { /** 列表的字段 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ - { type: 'checkbox', width: 40 }, { field: 'id', title: 'ID', @@ -413,7 +406,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { }, { title: '操作', - width: 180, + width: 220, fixed: 'right', slots: { default: 'actions' }, }, @@ -421,6 +414,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { } /** 查询产品列表 */ +// TODO @haohao:貌似可以删除? export async function queryProductList({ page }: any, searchParams: any) { return await getProductPage({ pageNo: page.currentPage, @@ -430,6 +424,7 @@ export async function queryProductList({ page }: any, searchParams: any) { } /** 创建图片预览状态 */ +// TODO @haohao:可能不一定用的上; export function useImagePreview() { const previewVisible = ref(false); const previewImage = ref(''); @@ -446,6 +441,7 @@ export function useImagePreview() { }; } +// TODO @haohao:放到对应的 form 里 /** 生成 ProductKey(包含大小写字母和数字) */ export function generateProductKey(): string { const chars = diff --git a/apps/web-antd/src/views/iot/product/product/index.vue b/apps/web-antd/src/views/iot/product/product/index.vue index e76624079..0e5dcef8c 100644 --- a/apps/web-antd/src/views/iot/product/product/index.vue +++ b/apps/web-antd/src/views/iot/product/product/index.vue @@ -26,17 +26,14 @@ import ProductForm from './modules/product-form.vue'; defineOptions({ name: 'IoTProduct' }); const router = useRouter(); -const categoryList = ref([]); +const categoryList = ref([]); // TODO @haohao:category 类型 const viewMode = ref<'card' | 'list'>('card'); const cardViewRef = ref(); - -// 搜索参数 const searchParams = ref({ name: '', productKey: '', -}); +}); // 搜索参数 -// 图片预览 const { previewVisible, previewImage, handlePreviewImage } = useImagePreview(); const [FormModal, formModalApi] = useVbenModal({ @@ -44,18 +41,19 @@ const [FormModal, formModalApi] = useVbenModal({ destroyOnClose: true, }); -// 加载产品分类列表 +/** 加载产品分类列表 */ async function loadCategories() { categoryList.value = await getSimpleProductCategoryList(); } -// 获取分类名称 +/** 获取分类名称 */ function getCategoryNameByValue(categoryId: number) { const category = categoryList.value.find((c: any) => c.id === categoryId); return category?.name || '未分类'; } -/** 搜索 */ +// TODO @haohao:要不要改成 handleRefresh,注释改成“刷新表格”,更加统一。 +/** 搜索产品 */ function handleSearch() { if (viewMode.value === 'list') { gridApi.formApi.setValues(searchParams.value); @@ -65,14 +63,14 @@ function handleSearch() { } } -/** 重置 */ +/** 重置搜索 */ function handleReset() { searchParams.value.name = ''; searchParams.value.productKey = ''; handleSearch(); } -/** 刷新 */ +/** 刷新表格 */ function handleRefresh() { if (viewMode.value === 'list') { gridApi.query(); @@ -84,7 +82,7 @@ function handleRefresh() { /** 导出表格 */ async function handleExport() { const data = await exportProduct(searchParams.value); - await downloadFileFromBlobPart({ fileName: '产品列表.xls', source: data }); + downloadFileFromBlobPart({ fileName: '产品列表.xls', source: data }); } /** 打开产品详情 */ @@ -117,12 +115,12 @@ function handleEdit(row: any) { /** 删除产品 */ async function handleDelete(row: any) { const hideLoading = message.loading({ - content: `正在删除 ${row.name}...`, + content: $t('ui.actionMessage.deleting', [row.name]), duration: 0, }); try { - await deleteProduct(row.id); - message.success(`删除 ${row.name} 成功`); + await deleteProduct(row.id!); + message.success($t('ui.actionMessage.deleteSuccess')); handleRefresh(); } finally { hideLoading(); @@ -130,6 +128,7 @@ async function handleDelete(row: any) { } const [Grid, gridApi] = useVbenVxeGrid({ + // TODO @haohao:这个不用,可以删除掉的 formOptions: { schema: [], }, @@ -156,9 +155,10 @@ const [Grid, gridApi] = useVbenVxeGrid({ refresh: true, search: true, }, - } as VxeTableGridOptions, + } as VxeTableGridOptions, // TODO @haohao:这里有个 <> 泛型 }); +/** 初始化 */ onMounted(() => { loadCategories(); }); @@ -172,22 +172,24 @@ onMounted(() => {
+ +