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 @@
+
+
+
+
+
+
+
+
@@ -43,7 +51,9 @@
diff --git a/src/views/scada/scadaConfigure/index.vue b/src/views/scada/scadaConfigure/index.vue
index fab3746..90b9d9e 100644
--- a/src/views/scada/scadaConfigure/index.vue
+++ b/src/views/scada/scadaConfigure/index.vue
@@ -42,11 +42,13 @@
import tips from './tips.md'
import jschardet from 'jschardet'
import { assign, each, pick, pickBy, startsWith, includes, every } from 'lodash'
+// import { getWorkingsubclassAll } from '@/api/basic/device'
export default {
data () {
return {
tips,
+ choosable: process.env.VUE_APP_CHOOSABLE,
columns: [
{
title: '序号',
@@ -65,17 +67,13 @@ export default {
key: 'type'
},
{
- title: '流程',
- key: 'flow_code'
+ title: '数据类别',
+ key: 'category'
},
{
title: '工序单元',
key: 'working_subclass'
},
- {
- title: '工作站',
- key: 'workstation'
- },
{
title: '创建时间',
key: 'create_date'
@@ -145,14 +143,49 @@ export default {
span: 12
}
},
- flow_code: {
- title: '流程'
+ category: {
+ title: '数据类别',
+ value: '',
+ component: {
+ name: 'el-select',
+ options: [
+ {
+ value: 'DEVICE_STATUS',
+ label: '设备状态'
+ },
+ {
+ value: 'ITEM_ID_ITEM',
+ label: '编号'
+ },
+ {
+ value: 'DEVICE_DATA',
+ label: '运行数据'
+ },
+ {
+ value: 'PROCESS_DATA',
+ label: '过程数据'
+ },
+ {
+ value: 'RESULT_DATA',
+ label: '结果数据'
+ },
+ {
+ value: 'STATISTICAL_DATA',
+ label: '统计数据'
+ }
+ ],
+ span: 12
+ }
},
working_subclass: {
- title: '工序单元'
- },
- workstation: {
- title: '工作站'
+ title: '工序单元',
+ component: {
+ name: 'el-select',
+ filterable: true,
+ allowCreate: true,
+ options: this.WorkingsubclassData,
+ span: 12
+ }
},
note: {
title: '备注'
@@ -162,12 +195,6 @@ export default {
name: {
title: '节点名称'
},
- flow_code: {
- title: '流程'
- },
- workstation: {
- title: '工作站'
- },
note: {
title: '备注'
}
@@ -181,6 +208,7 @@ export default {
code: [{ required: true, type: 'string', message: '节点编码必须填写', trigger: 'blur' }],
name: [{ required: true, type: 'string', message: '节点名称必须填写', trigger: 'blur' }],
type: [{ required: true, message: '必须指定节点类型', trigger: 'blur' }],
+ category: [{ required: true, message: '必须指定数据类别', trigger: 'blur' }],
working_subclass: [{
required: true,
type: 'string',
@@ -206,6 +234,10 @@ export default {
},
// 普通的新增
addRow () {
+ this.$nextTick(() => {
+ this.$refs.d2Crud.handleFormTemplateMode('working_subclass').component.options = this.WorkingsubclassData
+ this.$refs.d2Crud.$forceUpdate()
+ })
this.$refs.d2Crud.showDialog({
mode: 'add'
})
@@ -294,9 +326,19 @@ export default {
type: 'warning'
})
done()
+ },
+ getWorkingsubclassAll () {
+ // getWorkingsubclassAll().then(res=>{
+ // this.WorkingsubclassData = map(res.data, (o) => {
+ // return { value: o.code, label: o.name }
+ // })
+ // })
}
},
mounted () {
+ if (this.choosable === 'true') {
+ this.getWorkingsubclassAll()
+ }
this.getNodes()
}
}