diff --git a/apps/web-antd/src/locales/langs/en-US/abp.json b/apps/web-antd/src/locales/langs/en-US/abp.json index ba94a93..f4a1e6a 100644 --- a/apps/web-antd/src/locales/langs/en-US/abp.json +++ b/apps/web-antd/src/locales/langs/en-US/abp.json @@ -276,6 +276,10 @@ "BelongingProductName": "Belonging ProductName", "CommunicationAddress": "Communication Address", "CommunicationAddressTLS": "TLS Communication Address", - "DeviceThingModelFileName": "DeviceThingModelFileName" + "DeviceThingModelFileName": "DeviceThingModelFileName", + "IoTPlatformProductUpdateTime": "ProductUpdateTime", + "IoTPlatformProductCreateTime": "ProductCreateTime", + "CreationTime": "CreationTime", + "LastModificationTime": "LastModificationTime" } } diff --git a/apps/web-antd/src/locales/langs/en-US/common.json b/apps/web-antd/src/locales/langs/en-US/common.json index e45fe19..e7a15b3 100644 --- a/apps/web-antd/src/locales/langs/en-US/common.json +++ b/apps/web-antd/src/locales/langs/en-US/common.json @@ -55,5 +55,7 @@ "getDataFailed": "Failed to get data", "PhoneNumberFormatError": "PhoneNumber Format Error", "IoTPlatform": "IoTPlatform", - "note": "note" + "note": "note", + "creationTime": "CreationTime", + "lastModificationTime": "LastModificationTime" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/abp.json b/apps/web-antd/src/locales/langs/zh-CN/abp.json index 1ff6540..031acea 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/abp.json +++ b/apps/web-antd/src/locales/langs/zh-CN/abp.json @@ -278,6 +278,10 @@ "BelongingProductName": "所属产品", "CommunicationAddress": "通讯地址", "CommunicationAddressTLS": "TLS通讯地址", - "DeviceThingModelFileName": "物模型文件" + "DeviceThingModelFileName": "物模型文件", + "IoTPlatformProductUpdateTime": "平台更新时间", + "IoTPlatformProductCreateTime": "平台创建时间", + "CreationTime": "创建时间", + "LastModificationTime": "更新时间" } } diff --git a/apps/web-antd/src/locales/langs/zh-CN/common.json b/apps/web-antd/src/locales/langs/zh-CN/common.json index 89c6154..ad7bf75 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/common.json +++ b/apps/web-antd/src/locales/langs/zh-CN/common.json @@ -56,5 +56,7 @@ "IsEnabled": "是否启用", "PhoneNumberFormatError": "手机号码格式错误", "IoTPlatform": "物联网平台", - "note": "备注" + "note": "备注", + "creationTime": "创建时间", + "lastModificationTime": "最后更新时间" } diff --git a/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts b/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts index f81bb9c..bcf2cf7 100644 --- a/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts +++ b/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts @@ -168,14 +168,6 @@ export const addDeviceFormSchema: any = computed(() => [ message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, }), }, - { - component: 'Input', - fieldName: 'deviceName', - label: $t('abp.deviceInfos.deviceName'), - rules: z.string().min(1, { - message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceName')}`, - }), - }, { component: 'Input', fieldName: 'deviceAddress', @@ -184,14 +176,6 @@ export const addDeviceFormSchema: any = computed(() => [ message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`, }), }, - { - component: 'Input', - fieldName: 'platformPassword', - label: $t('abp.deviceInfos.platformPassword'), - rules: z.string().min(1, { - message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`, - }), - }, ]); export const editDeviceFormSchemaEdit: any = computed(() => [ diff --git a/apps/web-antd/src/views/onenetmanagement/privateProduct/index.vue b/apps/web-antd/src/views/onenetmanagement/privateProduct/index.vue index 75c1a65..1b8703d 100644 --- a/apps/web-antd/src/views/onenetmanagement/privateProduct/index.vue +++ b/apps/web-antd/src/views/onenetmanagement/privateProduct/index.vue @@ -2,7 +2,7 @@ import type { VbenFormProps } from '#/adapter/form'; import type { VxeGridProps } from '#/adapter/vxe-table'; -import { h, ref, nextTick } from 'vue'; +import { h, nextTick, ref } from 'vue'; import { useRouter } from 'vue-router'; import { Page, useVbenModal } from '@vben/common-ui'; @@ -12,12 +12,13 @@ import { message as Message, Tag } from 'ant-design-vue'; import { useVbenForm } from '#/adapter/form'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { - postOneNetProductInsertAsync, + postFilesDownload, + postFilesUpload, postOneNetProductDeleteAsync, + postOneNetProductInsertAsync, postOneNetProductListAsync, postOneNetProductModifyAsync, - postFilesUpload, - postFilesDownload, + postOneNetProductProductStatusChangeAsync, } from '#/api-client'; import { TableAction } from '#/components/table-action'; import { $t } from '#/locales'; @@ -26,8 +27,8 @@ import { addProductFormSchema, editProductFormSchemaEdit, querySchema, - tableSchema, setFileSelectedCallback, + tableSchema, } from './schema'; defineOptions({ @@ -148,12 +149,14 @@ const [EditForm, editFormApi] = useVbenForm({ async function submit() { const isEdit = !!editRow.value.id; const formApi = isEdit ? editFormApi : addFormApi; - const api = isEdit ? postOneNetProductModifyAsync : postOneNetProductInsertAsync; + const api = isEdit + ? postOneNetProductModifyAsync + : postOneNetProductInsertAsync; const { valid } = await formApi.validate(); if (!valid) return; const formValues = await formApi.getValues(); - + // 提交前校验 if (!formValues.deviceThingModelFileName) { Message.error('请选择设备模型文件'); @@ -180,7 +183,7 @@ async function submit() { userModalApi.setState({ loading: false, confirmLoading: false }); return; } - } catch (error) { + } catch { Message.error('文件上传失败'); userModalApi.setState({ loading: false, confirmLoading: false }); return; @@ -191,15 +194,15 @@ async function submit() { selectedFile = null; // 继续后续表单提交逻辑 - + const fetchParams: any = isEdit ? { - id: editRow.value.id, - ...formValues, - } + id: editRow.value.id, + ...formValues, + } : { - ...formValues, - }; + ...formValues, + }; try { const resp = await api({ body: fetchParams }); @@ -237,7 +240,9 @@ const openAddModal = async () => { // 删除函数 async function onDel(record: any) { try { - const resp = await postOneNetProductDeleteAsync({ body: { id: record.id } }); + const resp = await postOneNetProductDeleteAsync({ + body: { id: record.id }, + }); if (resp.data) { Message.success($t('common.deleteSuccess')); // 重置文件选择 @@ -257,7 +262,7 @@ async function onDownloadFile(record: any) { Message.error('文件ID不存在,无法下载'); return; } - + try { const { data } = await postFilesDownload({ body: { id: record.deviceThingModelFileId }, @@ -266,68 +271,92 @@ async function onDownloadFile(record: any) { const url = window.URL.createObjectURL(new Blob([data as Blob])); const link = document.createElement('a'); link.href = url; - link.setAttribute('download', record.deviceThingModelFileName || 'device-model-file'); + link.setAttribute( + 'download', + record.deviceThingModelFileName || 'device-model-file', + ); document.body.append(link); link.click(); link.remove(); window.URL.revokeObjectURL(url); Message.success('文件下载成功'); - } catch (error) { + } catch { Message.error('文件下载失败'); } } + +// 状态更改函数 +async function onStatusChange(record: any) { + try { + const resp = await postOneNetProductProductStatusChangeAsync({ + body: { + id: record.id, + enabled: !record.isEnabled, + }, + }); + if (resp.data) { + Message.success(record.isEnabled ? '禁用成功' : '启用成功'); + gridApi.reload(); + } else { + Message.error(record.isEnabled ? '禁用失败' : '启用失败'); + } + } catch { + Message.error(record.isEnabled ? '禁用失败' : '启用失败'); + } +}