diff --git a/apps/web-antd/src/api/iot/device/device/index.ts b/apps/web-antd/src/api/iot/device/device/index.ts index 650fe0875..7bd59886f 100644 --- a/apps/web-antd/src/api/iot/device/device/index.ts +++ b/apps/web-antd/src/api/iot/device/device/index.ts @@ -3,7 +3,8 @@ import type { PageParam, PageResult } from '@vben/request'; import { requestClient } from '#/api/request'; export namespace IotDeviceApi { - /** IoT 设备 VO */ + // TODO @haohao:需要跟后端对齐,必要的 ReqVO、RespVO + /** 设备 */ export interface Device { id?: number; // 设备 ID,主键,自增 deviceName: string; // 设备名称 @@ -48,7 +49,7 @@ export namespace IotDeviceApi { dataSpecsList: any[]; // 数据定义列表 } - /** IoT 设备属性 VO */ + /** 设备属性 VO */ export interface DeviceProperty { identifier: string; // 属性标识符 value: string; // 最新值 @@ -62,7 +63,7 @@ export namespace IotDeviceApi { password: string; // 密码 } - /** IoT 设备发送消息 Request VO */ + /** 设备发送消息 Request VO */ export interface DeviceMessageSendReq { deviceId: number; // 设备编号 method: string; // 请求方法 @@ -77,6 +78,7 @@ export namespace IotDeviceApi { } /** IoT 设备状态枚举 */ +// TODO @haohao:packages/constants/src/biz-iot-enum.ts 枚举; export enum DeviceStateEnum { INACTIVE = 0, // 未激活 OFFLINE = 2, // 离线 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/api/iot/product/product/index.ts b/apps/web-antd/src/api/iot/product/product/index.ts index 71bc3ade3..28b2f7b2e 100644 --- a/apps/web-antd/src/api/iot/product/product/index.ts +++ b/apps/web-antd/src/api/iot/product/product/index.ts @@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request'; import { requestClient } from '#/api/request'; export namespace IotProductApi { - /** IoT 产品 VO */ + /** 产品 */ export interface Product { id?: number; // 产品编号 name: string; // 产品名称 @@ -27,6 +27,8 @@ export namespace IotProductApi { } } +// TODO @haohao:packages/constants/src/biz-iot-enum.ts 枚举; + /** IOT 产品设备类型枚举类 */ export enum DeviceTypeEnum { DEVICE = 0, // 直连设备 diff --git a/apps/web-antd/src/api/iot/rule/scene/index.ts b/apps/web-antd/src/api/iot/rule/scene/index.ts index 59c8255a7..9a8acf758 100644 --- a/apps/web-antd/src/api/iot/rule/scene/index.ts +++ b/apps/web-antd/src/api/iot/rule/scene/index.ts @@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request'; import { requestClient } from '#/api/request'; export namespace RuleSceneApi { - /** IoT 场景联动规则 VO */ + /** 场景联动规则 */ export interface SceneRule { id?: number; name: string; @@ -14,7 +14,7 @@ export namespace RuleSceneApi { createTime?: Date; } - /** IoT 场景联动规则触发器 */ + /** 场景联动规则的触发器 */ export interface Trigger { type?: string; productId?: number; @@ -26,13 +26,13 @@ export namespace RuleSceneApi { conditionGroups?: TriggerConditionGroup[]; } - /** IoT 场景联动规则触发条件组 */ + /** 场景联动规则的触发条件组 */ export interface TriggerConditionGroup { conditions?: TriggerCondition[]; operator?: string; } - /** IoT 场景联动规则触发条件 */ + /** 场景联动规则的触发条件 */ export interface TriggerCondition { productId?: number; deviceId?: number; @@ -42,7 +42,7 @@ export namespace RuleSceneApi { type?: string; } - /** IoT 场景联动规则动作 */ + /** 场景联动规则的动作 */ export interface Action { type?: string; productId?: number; @@ -53,6 +53,7 @@ export namespace RuleSceneApi { } } +// TODO @haohao:貌似下面的,和 RuleSceneApi 重复了。 /** IoT 场景联动规则 */ export interface IotSceneRule { id?: number; @@ -135,6 +136,7 @@ export function deleteSceneRule(id: number) { } /** 批量删除场景联动规则 */ +// TODO @haohao:貌似用上。 export function deleteSceneRuleList(ids: number[]) { return requestClient.delete('/iot/scene-rule/delete-list', { params: { ids: ids.join(',') }, diff --git a/apps/web-antd/src/views/iot/device/device/index.vue b/apps/web-antd/src/views/iot/device/device/index.vue index 659f6b98d..83e79c0a3 100644 --- a/apps/web-antd/src/views/iot/device/device/index.vue +++ b/apps/web-antd/src/views/iot/device/device/index.vue @@ -48,6 +48,7 @@ const viewMode = ref<'card' | 'list'>('card'); const cardViewRef = ref(); // Modal instances +// TODO @haohao:这个界面,等 product 改完,在一起看看怎么弄更好。 const [DeviceFormModal, deviceFormModalApi] = useVbenModal({ connectedComponent: DeviceForm, destroyOnClose: true, 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: []; }>(); 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(() => {
+ +