diff --git a/.env b/.env index e560c2c..2b4b17d 100644 --- a/.env +++ b/.env @@ -15,3 +15,8 @@ VUE_APP_I18N_FALLBACK_LOCALE=en # element 颜色 VUE_APP_ELEMENT_COLOR=#409EFF +VUE_APP_HSLSERVER_PASSWORD=123456 + +#==true出现下拉,数据来源于MES +#==false 手动输入,以及不渲染mes的设备编码 +VUE_APP_CHOOSABLE=false \ No newline at end of file diff --git a/src/views/edgeServer/edgeServerConfigure/device.vue b/src/views/edgeServer/edgeServerConfigure/device.vue index 1ac8de1..38506d1 100644 --- a/src/views/edgeServer/edgeServerConfigure/device.vue +++ b/src/views/edgeServer/edgeServerConfigure/device.vue @@ -53,22 +53,6 @@ - - - - - - - - - - - - - @@ -136,11 +120,6 @@ export default { value: 'float', label: 'float (浮点数)' }, - { - value: 'short', - label: 'short' - }, - { value: 'bool', label: 'bool (逻辑值)' @@ -264,11 +243,6 @@ export default { value: 'float', label: 'float (浮点数)' }, - { - value: 'short', - label: 'short' - }, - { value: 'bool', label: 'bool (逻辑值)' @@ -296,21 +270,7 @@ export default { '@DisplayName': [{ required: true, type: 'string', message: '请输入显示名称', trigger: 'blur' }], '@RequestType': [{ required: true, type: 'string', message: '请输入请求类型', trigger: 'blur' }], '@DataTypeCode': [{ required: true, type: 'string', message: '请选择类型', trigger: 'blur' }], - '@RequestInterval': [{ required: true, message: '请输入采集周期(ms)', trigger: 'blur' }], - '@Length': [{ required: true, message: '请输入长度', trigger: 'blur' }] - }, - dialogFormVisible: false, - userForm: { - username: '', - password: '' - }, - userRules: { - username: [ - { required: true, message: '请输入账号', trigger: 'blur' } - ], - password: [ - { required: true, message: '请输入密码', trigger: 'blur' } - ] + '@RequestInterval': [{ required: true, message: '请输入采集周期(ms)', trigger: 'blur' }] }, serverData: {}, devicePointData: [], @@ -351,7 +311,6 @@ export default { }, handleCellDataChange ({ rowIndex, row }) { this.devicePointData[rowIndex] = row - this.setDeviceConfigure() }, bandingNodeTemplate ({ index }) { this.$refs.d2Crud.showDialog({ @@ -432,6 +391,9 @@ export default { this.deviceData = await this.$api.GET_DEVICE(this.serverData.id) if (this.deviceData.length > 0) { this.getDeviceConfigure(this.deviceActiveStatus) + } else { + this.devicePointData = [] // 如果没有设备,防止显示上一次打开的设备数据先清空数据 + this.defaultDeviceName = '' } } catch (e) { console.log(e) @@ -478,10 +440,7 @@ export default { }) }, async delDevice () { - // 校验是否已经有账号和密码 - const userInfo = this.getUserInfo() - - const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password) + const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD) let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode if (deviceNode !== undefined && isArray(deviceNode)) { deviceNode = filter(deviceNode, item => { @@ -493,7 +452,7 @@ export default { } try { - await this.$api.SET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password, { data: deviceConfigure.Content }) + await this.$api.SET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD, { data: deviceConfigure.Content }) await this.$api.DEL_DEVICE({ action: 'remove_device', id: this.deviceData[this.deviceActiveStatus].id }) this.$message({ message: '删除设备成功', @@ -513,18 +472,23 @@ export default { }) done(false) } else { + if (row['@DataTypeCode'] === 'string' && !row['@Length']) { + this.$message({ + message: '数据类型为string,长度不能为空', + type: 'error' + }) + this.formOptions.saveLoading = false + return false + } + assign(row, { id: this.devicePointData.length + 1, showBindButton: true, showCopyButton: true, showRemoveButton: true, showSendButton: true }) this.devicePointData.push(row) - await this.setDeviceConfigure() - await this.getDevice() done() } this.formOptions.saveLoading = false }, async delDevicePoint ({ index, row }, done) { - this.devicePointData.splice(index, 1) - this.$refs.deviceConfigure.deviceConfigureModelValue.RequestNode = this.devicePointData - await this.setDeviceConfigure() + this.$delete(this.devicePointData, index) done() }, async getDevicePoint () { @@ -536,21 +500,10 @@ export default { } }, async devicePointBandingNode ({ index, row }, done) { - this.devicePointData[index]['@Binding'] = row.nodeCode - this.setDeviceConfigure() + this.$set(this.devicePointData[index], '@Binding', row.nodeCode) done() }, - setUserInfo () { - this.$refs.userForm.validate((valid) => { - if (valid) { - sessionStorage.setItem(this.serverData.id, JSON.stringify(this.userForm)) - this.dialogFormVisible = false - } - }) - }, async setDeviceConfigure () { - // 校验是否已经有账号和密码 - const userInfo = this.getUserInfo() try { // 验证表单 this.$refs.deviceConfigure.$refs.form.validate((valid) => { @@ -558,11 +511,14 @@ export default { return false } }) - const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password) + const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD) const deviceConfigureModelValue = this.$refs.deviceConfigure.deviceConfigureModelValue if (this.devicePointData.length > 0) { let devicePointData = this.devicePointData devicePointData = each(devicePointData, (item) => { + if (item['@DataTypeCode'] !== 'string') { + unset(item, '@Length') + } unset(item, 'id') unset(item, 'showBindButton') unset(item, 'showCopyButton') @@ -572,6 +528,7 @@ export default { }) deviceConfigureModelValue.RequestNode = devicePointData } + deviceConfigureModelValue['@Name'] = this.deviceData[this.deviceActiveStatus].name let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode || [] let isExist = false @@ -590,7 +547,7 @@ export default { deviceNode.push(deviceConfigureModelValue) } deviceConfigure.Content.Settings.GroupNode[0].DeviceNode = deviceNode - await this.$api.SET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password, { data: deviceConfigure.Content }) + await this.$api.SET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD, { data: deviceConfigure.Content }) deviceConfigureModelValue.DeviceTypeName = this.$refs.deviceConfigure.defaultDeviceTypeNameValue const data = { action: 'update_device', @@ -607,17 +564,9 @@ export default { console.log(e) } }, - getUserInfo () { - const userInfo = sessionStorage.getItem(this.serverData.id) - if (!userInfo) { - this.dialogFormVisible = true - return false - } - return JSON.parse(userInfo) - }, + async getDeviceStatus () { - const userInfo = this.getUserInfo() - const res = await this.$api.GET_SERVER_DEVICE_STATUS('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password) + const res = await this.$api.GET_SERVER_DEVICE_STATUS('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD) if (res) { this.$emit('changeStatus', 'online') const deviceStatus = {} diff --git a/src/views/edgeServer/edgeServerConfigure/deviceConfigure.vue b/src/views/edgeServer/edgeServerConfigure/deviceConfigure.vue index 20f10d9..ca57ea7 100644 --- a/src/views/edgeServer/edgeServerConfigure/deviceConfigure.vue +++ b/src/views/edgeServer/edgeServerConfigure/deviceConfigure.vue @@ -9,12 +9,20 @@ + + + + + + +