diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 3e112e92..d28ebe7e 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -150,6 +150,11 @@ export const DeviceApi = { return await request.get({ url: `/iot/device/devicePointList` }) }, + updateDeviceEnabled: async (id: number | string, enabled: string) => { + const data = { id, enabled } + return await request.put({ url: `/iot/device/update-enabled`, data }) + }, + // ==================== 子表(设备属性) ==================== // 获得设备属性分页 diff --git a/src/api/iot/recipeConfig/index.ts b/src/api/iot/recipeConfig/index.ts index 06931a2d..6ab87269 100644 --- a/src/api/iot/recipeConfig/index.ts +++ b/src/api/iot/recipeConfig/index.ts @@ -176,7 +176,7 @@ export const RecipeConfigApi = { }, getRecipePointDetailPage: async (params: any) => { - return await request.get({ url: `/iot/recipe-device-attribute/page`, params }) + return await request.get({ url: `/iot/recipe-device-attribute/getList`, params }) }, updateRecipeDeviceAttribute: async (data: { recipeId: string | number; ids: number[] }) => { return await request.put({ url: `/iot/recipe-device-attribute/update`, data }) diff --git a/src/locales/en.ts b/src/locales/en.ts index e8e580aa..de9490ac 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -2657,6 +2657,7 @@ export default { readDialogSubmitButtonText: 'Read', readDialogCancelButton: 'Cancel', readDeviceConfirmMessage: 'Do you want to read device data?', + readDialogOverwriteTip: 'Reading again will overwrite existing device data and manual parameters', detailTabDeviceDataLabel: 'Device Data', detailTabManualLabel: 'Manual Parameters', detailDevicePointNameColumn: 'Point Name', @@ -3591,11 +3592,13 @@ export default { placeholderUrl: 'Please enter endpoint URL', placeholderUsername: 'Please enter username', placeholderPassword: 'Please enter password', + placeholderTopic: 'Please enter subscription topic', model: 'Device Model', url: 'Endpoint URL', username: 'Username', password: 'Password', + topic: 'Subscription Topic', settingDialogTitle: 'Device Settings', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 2bb971b6..32033b45 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -2240,6 +2240,7 @@ export default { readDialogSubmitButtonText: '读 取', readDialogCancelButton: '取 消', readDeviceConfirmMessage: '是否读取设备数据?', + readDialogOverwriteTip: '再次读取会覆盖已有设备数据和手动录入参数', detailTabDeviceDataLabel: '设备数据', detailTabManualLabel: '手动录入参数', detailDevicePointNameColumn: '点位名称', @@ -3415,7 +3416,7 @@ export default { protocol: '采集协议', status: '连接状态', sampleCycle: '采集周期(s)', - isEnable: '是否启用', + isEnable: '启用', collectionTime: '采集时间', operate: '操作', @@ -3432,11 +3433,13 @@ export default { placeholderUrl: '请输入端点URL', placeholderUsername: '请输入用户名', placeholderPassword: '请输入密码', + placeholderTopic: '请输入订阅主题', model: '设备模型', url: '端点URL', username: '用户名', password: '密码', + topic: '订阅主题', settingDialogTitle: '设备设置', diff --git a/src/views/erp/moldlist/index.vue b/src/views/erp/moldlist/index.vue index d9b88117..35ecc03a 100644 --- a/src/views/erp/moldlist/index.vue +++ b/src/views/erp/moldlist/index.vue @@ -13,7 +13,7 @@ v-loading="typeTreeLoading" :data="brandTreeData" node-key="id" highlight-curren - + { pageSize, recipeId: props.recipeId }) - list.value = (data.list ?? []).map(normalizeDetail) - total.value = data.total - // 产品单位 - unitList.value = await ProductUnitApi.getProductUnitSimpleList() + const rawList = Array.isArray((data as any)?.list) + ? (data as any).list + : Array.isArray((data as any)?.data) + ? (data as any).data + : Array.isArray(data) + ? data + : [] + list.value = rawList.map(normalizeDetail) + total.value = (data as any)?.total ?? rawList.length + unitList.value = await ProductUnitApi.getProductUnitSimpleList() } finally { loading.value = false } diff --git a/src/views/formula/formulaConfig/index.vue b/src/views/formula/formulaConfig/index.vue index a5a96ec3..61970a60 100644 --- a/src/views/formula/formulaConfig/index.vue +++ b/src/views/formula/formulaConfig/index.vue @@ -663,7 +663,7 @@ const buildTransferLabel = (item: any) => { const loadConfigCandidatesByDevice = async (deviceId: number) => { const data = await DeviceApi.getDeviceAttributeList(deviceId) - const list = (data?.list ?? data?.data ?? []) as any[] + const list = (data ?? []) as any[] const deviceItems = (list ?? []) .map((item: any) => { const key = normalizeKey(item?.attributeId ?? item?.id) @@ -674,12 +674,7 @@ const loadConfigCandidatesByDevice = async (deviceId: number) => { } as TransferItem }) .filter((it: any) => it && typeof it.key === 'number') as TransferItem[] - const merged = new Map() - for (const it of deviceItems) merged.set(it.key, it) - for (const it of configSelectedItems.value) { - if (!merged.has(it.key)) merged.set(it.key, it) - } - configCandidates.value = Array.from(merged.values()) + configCandidates.value = deviceItems } const openConfigDialog = async (recipeId: number | string) => { diff --git a/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue b/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue index 4eb9bbb5..855edfcc 100644 --- a/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue +++ b/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue @@ -1,6 +1,14 @@ - - @@ -125,7 +123,10 @@ /> --> {{ t('action.edit') }} - - {{ isRowConnected(scope.row) ? t('DataCollection.Device.disconnect') : t('DataCollection.Device.connect') }} - { return 'info' } +const isDeviceEnabled = (row: DeviceVO) => { + const value = (row as any)?.isEnable + if (typeof value === 'boolean') return value + const text = String(value ?? '').toLowerCase().trim() + if (!text) return false + if (text === 'true' || text === '1' || text === 'yes') return true + return false +} + +const handleDeviceEnableChange = async (row: DeviceVO, value: boolean) => { + if (!row.id) return + const oldValue = (row as any).isEnable + ;(row as any).isEnable = value + try { + await DeviceApi.updateDeviceEnabled(row.id, value ? 'true' : 'false') + const name = (row as any).deviceName ?? (row as any).deviceCode ?? '' + const suffix = value ? '已启用' : '已停用' + if (name) { + message.success(`${name}${suffix}`) + } else { + message.success(suffix) + } + } catch { + ;(row as any).isEnable = oldValue + message.error(t('common.updateFail')) + } +} + const selectedIds = ref([]) const handleSelectionChange = (rows: any[]) => { selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? []