From 863fbf7456b4f89b7eb933db9814a04b5d890f04 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 21 Nov 2025 09:34:28 +0800 Subject: [PATCH 1/5] =?UTF-8?q?review=EF=BC=9A=E3=80=90antd=E3=80=91?= =?UTF-8?q?=E3=80=90iot=E3=80=91=E8=AE=BE=E5=A4=87=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/iot/device/group/index.ts | 2 +- apps/web-antd/src/views/iot/device/group/index.vue | 5 +---- .../src/views/iot/device/group/modules/device-group-form.vue | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/web-antd/src/api/iot/device/group/index.ts b/apps/web-antd/src/api/iot/device/group/index.ts index 18cac3097..2c11411ae 100644 --- a/apps/web-antd/src/api/iot/device/group/index.ts +++ b/apps/web-antd/src/api/iot/device/group/index.ts @@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request'; import { requestClient } from '#/api/request'; export namespace IotDeviceGroupApi { - /** IoT 设备分组 VO */ + /** 设备分组 */ export interface DeviceGroup { id?: number; // 分组 ID name: string; // 分组名字 diff --git a/apps/web-antd/src/views/iot/device/group/index.vue b/apps/web-antd/src/views/iot/device/group/index.vue index ebf33e9be..d72341a6b 100644 --- a/apps/web-antd/src/views/iot/device/group/index.vue +++ b/apps/web-antd/src/views/iot/device/group/index.vue @@ -43,9 +43,7 @@ async function handleDelete(row: IotDeviceGroupApi.DeviceGroup) { }); try { await deleteDeviceGroup(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - }); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); } finally { hideLoading(); @@ -55,7 +53,6 @@ async function handleDelete(row: IotDeviceGroupApi.DeviceGroup) { const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), - showCollapseButton: true, }, gridOptions: { columns: useGridColumns(), diff --git a/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue b/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue index 26dfe29d0..90529de77 100644 --- a/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue +++ b/apps/web-antd/src/views/iot/device/group/modules/device-group-form.vue @@ -19,6 +19,8 @@ import { useFormSchema } from '../data'; defineOptions({ name: 'IoTDeviceGroupForm' }); +// TODO @haohao:web-antd/src/views/iot/product/category/modules/product-category-form.vue 类似问题 + const emit = defineEmits<{ success: []; }>(); From 77afbe4d646b9f94e005a978b3fafc7a9f8c144b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 21 Nov 2025 10:48:06 +0800 Subject: [PATCH 2/5] =?UTF-8?q?review=EF=BC=9A=E3=80=90antd=E3=80=91?= =?UTF-8?q?=E3=80=90iot=E3=80=91=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/iot/product/product/data.ts | 18 +++---- .../src/views/iot/product/product/index.vue | 52 ++++++++++--------- .../components/product-table-select.vue | 3 ++ .../product/product/modules/detail/index.vue | 16 ++---- .../modules/detail/product-details-header.vue | 6 ++- .../modules/detail/product-details-info.vue | 2 + .../product/modules/product-card-view.vue | 26 ++++++---- .../product/product/modules/product-form.vue | 11 ++-- 8 files changed, 72 insertions(+), 62 deletions(-) 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(() => {
+ +