diff --git a/src/api/cs-device-boot/cloudDeviceEntry.ts b/src/api/cs-device-boot/cloudDeviceEntry.ts index ba28b8c..5fb5885 100644 --- a/src/api/cs-device-boot/cloudDeviceEntry.ts +++ b/src/api/cs-device-boot/cloudDeviceEntry.ts @@ -144,11 +144,3 @@ export function queryPushResult() { method: 'post' }) } -//监测设备接入 -export function onlineRegister(data: any) { - return createAxios({ - url: '/access-boot/device/onlineRegister', - method: 'post', - params: data - }) -} diff --git a/src/api/cs-system-boot/device.ts b/src/api/cs-system-boot/device.ts index 534aaa3..619f2bc 100644 --- a/src/api/cs-system-boot/device.ts +++ b/src/api/cs-system-boot/device.ts @@ -103,3 +103,11 @@ export function engineeringProject() { method: 'post' }) } +//监测设备接入 +export function onlineRegister(data: any) { + return createAxios({ + url: '/access-boot/device/onlineRegister', + method: 'post', + params: data + }) +} diff --git a/src/views/govern/cloudDeviceEntry/index.vue b/src/views/govern/cloudDeviceEntry/index.vue index f949db4..6224ea3 100644 --- a/src/views/govern/cloudDeviceEntry/index.vue +++ b/src/views/govern/cloudDeviceEntry/index.vue @@ -405,9 +405,10 @@ pageStatus == 2) ) " + @change="busItem.devModel = ''" > - @@ -608,7 +611,7 @@ > {{ accessLoading ? '接入中' : '接入' }} - + --> { }) const formDevTypeOptions = computed(() => { - return [devTypeOptions2.value] + return devTypeOptions.value //[devTypeOptions2.value] }) // 电压等级选项,用于显示带单位的名称 @@ -3319,12 +3322,10 @@ const area = async () => { queryByCode('DEV_CLD') .then(res => { devTypeOptions2.value = res.data - return queryCsDictTree(res.data.id).then(res => { + queryCsDictTree(res.data.id).then(res => { devCLD.value = res.data }) - }) - .then(() => { - return queryByCode('Device_Type').then(res => { + queryByCode('Device_Type').then(res => { queryByid(res.data.id).then((list: any) => { devModelOptions.value = list.data.map((item: any, index: any) => { return { @@ -3340,6 +3341,9 @@ const area = async () => { }) }) }) + // .then(() => { + // return + // }) .catch(error => { console.error('查询过程中出现错误:', error) }) @@ -3353,22 +3357,6 @@ const area = async () => { } const accessLoading = ref(false) // 接入 -const access = (item: any) => { - accessLoading.value = true - onlineRegister({ - projectId: formData.value.projectInfoList[0].id, - nDid: item.ndid - }) - .then((res: any) => { - if (res.code == 'A0000') { - ElMessage.success(res) - accessLoading.value = false - } - }) - .catch(() => { - accessLoading.value = false - }) -} onMounted(() => { nodeData.value.level = 0 diff --git a/src/views/govern/manage/factory.vue b/src/views/govern/manage/factory.vue index da8dd54..b413aaa 100644 --- a/src/views/govern/manage/factory.vue +++ b/src/views/govern/manage/factory.vue @@ -218,7 +218,8 @@ import { portableDeviceRegister, portableDeviceAccess, getExcelTemplate, - engineeringProject + engineeringProject, + onlineRegister } from '@/api/cs-system-boot/device' import html2canvas from 'html2canvas' import { fullUrl } from '@/utils/common' @@ -271,7 +272,7 @@ const queryTheDictionary = () => { queryByCode('DEV_CLD') .then(res => { devTypeOptions2.value = res.data - return queryCsDictTree(res.data.id).then(res => { + queryCsDictTree(res.data.id).then(res => { devModelOptions2.value = res.data.map((item: any) => { return { value: item.id, @@ -280,8 +281,6 @@ const queryTheDictionary = () => { } }) }) - }) - .then(() => { queryByCode('Device_Type').then(async res => { const id = res.data.id await queryCsDictTree(id).then(res => { @@ -315,6 +314,7 @@ const queryTheDictionary = () => { await tableStore.index() }) }) + .catch(error => { console.error('查询过程中出现错误:', error) }) @@ -611,12 +611,51 @@ const tableStore = new TableStore({ // .catch(e => {}) // } // }, + // 在线设备注册 + { + title: '接入', + type: 'primary', + icon: 'el-icon-Grid', + render: 'basicButton', + loading: 'loading1', + disabled: row => { + return !( + row.devType == '123202e523be2b8defc8d0c2f118f232' && + row.associatedProject != null && + row.status != 3 + ) + }, + click: row => { + // 便携式设备手动接入 + ElMessageBox.confirm('确定接入该设备吗?', '提示', { + confirmButtonText: '确认', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + row.loading1 = true + + onlineRegister({ + projectId: row.associatedProject, + nDid: row.ndid + }) + .then(res => { + ElMessage.success(res.message) + row.loading1 = false + tableStore.index() + }) + .catch(() => { + row.loading1 = false + }) + }) + } + }, //便携式设备手动接入 { title: '接入', type: 'primary', icon: 'el-icon-Grid', render: 'basicButton', + loading: 'loading1', disabled: row => { return ( (row.devType != '8b45cf6b7f5266e777d07c166ad5fa77' && @@ -632,14 +671,18 @@ const tableStore = new TableStore({ type: 'warning' }) .then(() => { + row.loading1 = true portableDeviceAccess({ nDid: row.ndid }).then(res => { ElMessage.success(res.message) + row.loading1 = false tableStore.index() }) }) - .catch(e => {}) + .catch(e => { + row.loading1 = false + }) } }, { @@ -647,6 +690,7 @@ const tableStore = new TableStore({ type: 'primary', icon: 'el-icon-Grid', render: 'basicButton', + loading: 'loading1', disabled: row => { return ( (row.devType != '8b45cf6b7f5266e777d07c166ad5fa77' && @@ -662,24 +706,20 @@ const tableStore = new TableStore({ confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' - }) - .then(() => { - loading.value = true - portableDeviceRegister({ - nDid: row.ndid + }).then(() => { + row.loading1 = true + portableDeviceRegister({ + nDid: row.ndid + }) + .then(res => { + row.loading1 = false + ElMessage.success(res.message) + tableStore.index() }) - .then(res => { - loading.value = false - ElMessage.success(res.message) - tableStore.index() - }) - .catch(e => { - loading.value = false - }) - }) - .catch(e => { - loading.value = false - }) + .catch(e => { + row.loading1 = false + }) + }) } }, {