Merge branch 'master' of ssh://118.195.187.246:10022/ysun/EdgeManager

This commit is contained in:
Yu Sun
2022-08-21 12:05:32 +08:00
6 changed files with 314 additions and 316 deletions

5
.env
View File

@@ -15,3 +15,8 @@ VUE_APP_I18N_FALLBACK_LOCALE=en
# element 颜色 # element 颜色
VUE_APP_ELEMENT_COLOR=#409EFF VUE_APP_ELEMENT_COLOR=#409EFF
VUE_APP_HSLSERVER_PASSWORD=123456
#==true出现下拉数据来源于MES
#==false 手动输入以及不渲染mes的设备编码
VUE_APP_CHOOSABLE=false

View File

@@ -53,22 +53,6 @@
</d2-crud> </d2-crud>
</el-card> </el-card>
</el-main> </el-main>
<el-dialog title="服务账号登录" :visible.sync="dialogFormVisible" :modal="false">
<el-alert title="请先输入该服务的账号密码,再进行后续操作" type="warning" style="width:400px;display: inline-block;vertical-align: middle; margin-left: 5px;" :closable="false" />
<el-form :model="userForm" :rules="userRules" ref="userForm">
<el-form-item label="账号" prop="username">
<el-input v-model="userForm.username"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input type="password" v-model="userForm.password"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="setUserInfo"> </el-button>
</div>
</el-dialog>
</el-container> </el-container>
</template> </template>
@@ -136,11 +120,6 @@ export default {
value: 'float', value: 'float',
label: 'float (浮点数)' label: 'float (浮点数)'
}, },
{
value: 'short',
label: 'short'
},
{ {
value: 'bool', value: 'bool',
label: 'bool (逻辑值)' label: 'bool (逻辑值)'
@@ -264,11 +243,6 @@ export default {
value: 'float', value: 'float',
label: 'float (浮点数)' label: 'float (浮点数)'
}, },
{
value: 'short',
label: 'short'
},
{ {
value: 'bool', value: 'bool',
label: 'bool (逻辑值)' label: 'bool (逻辑值)'
@@ -296,21 +270,7 @@ export default {
'@DisplayName': [{ required: true, type: 'string', message: '请输入显示名称', trigger: 'blur' }], '@DisplayName': [{ required: true, type: 'string', message: '请输入显示名称', trigger: 'blur' }],
'@RequestType': [{ required: true, type: 'string', message: '请输入请求类型', trigger: 'blur' }], '@RequestType': [{ required: true, type: 'string', message: '请输入请求类型', trigger: 'blur' }],
'@DataTypeCode': [{ required: true, type: 'string', message: '请选择类型', trigger: 'blur' }], '@DataTypeCode': [{ required: true, type: 'string', message: '请选择类型', trigger: 'blur' }],
'@RequestInterval': [{ required: true, message: '请输入采集周期(ms)', 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' }
]
}, },
serverData: {}, serverData: {},
devicePointData: [], devicePointData: [],
@@ -351,7 +311,6 @@ export default {
}, },
handleCellDataChange ({ rowIndex, row }) { handleCellDataChange ({ rowIndex, row }) {
this.devicePointData[rowIndex] = row this.devicePointData[rowIndex] = row
this.setDeviceConfigure()
}, },
bandingNodeTemplate ({ index }) { bandingNodeTemplate ({ index }) {
this.$refs.d2Crud.showDialog({ this.$refs.d2Crud.showDialog({
@@ -432,6 +391,9 @@ export default {
this.deviceData = await this.$api.GET_DEVICE(this.serverData.id) this.deviceData = await this.$api.GET_DEVICE(this.serverData.id)
if (this.deviceData.length > 0) { if (this.deviceData.length > 0) {
this.getDeviceConfigure(this.deviceActiveStatus) this.getDeviceConfigure(this.deviceActiveStatus)
} else {
this.devicePointData = [] // 如果没有设备,防止显示上一次打开的设备数据先清空数据
this.defaultDeviceName = ''
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@@ -478,10 +440,7 @@ export default {
}) })
}, },
async delDevice () { async delDevice () {
// 校验是否已经有账号和密码 const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD)
const userInfo = this.getUserInfo()
const deviceConfigure = await this.$api.GET_HSLSERVER_CONFIGURE('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password)
let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode
if (deviceNode !== undefined && isArray(deviceNode)) { if (deviceNode !== undefined && isArray(deviceNode)) {
deviceNode = filter(deviceNode, item => { deviceNode = filter(deviceNode, item => {
@@ -493,7 +452,7 @@ export default {
} }
try { 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 }) await this.$api.DEL_DEVICE({ action: 'remove_device', id: this.deviceData[this.deviceActiveStatus].id })
this.$message({ this.$message({
message: '删除设备成功', message: '删除设备成功',
@@ -513,18 +472,23 @@ export default {
}) })
done(false) done(false)
} else { } 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) this.devicePointData.push(row)
await this.setDeviceConfigure()
await this.getDevice()
done() done()
} }
this.formOptions.saveLoading = false this.formOptions.saveLoading = false
}, },
async delDevicePoint ({ index, row }, done) { async delDevicePoint ({ index, row }, done) {
this.devicePointData.splice(index, 1) this.$delete(this.devicePointData, index)
this.$refs.deviceConfigure.deviceConfigureModelValue.RequestNode = this.devicePointData
await this.setDeviceConfigure()
done() done()
}, },
async getDevicePoint () { async getDevicePoint () {
@@ -536,21 +500,10 @@ export default {
} }
}, },
async devicePointBandingNode ({ index, row }, done) { async devicePointBandingNode ({ index, row }, done) {
this.devicePointData[index]['@Binding'] = row.nodeCode this.$set(this.devicePointData[index], '@Binding', row.nodeCode)
this.setDeviceConfigure()
done() done()
}, },
setUserInfo () {
this.$refs.userForm.validate((valid) => {
if (valid) {
sessionStorage.setItem(this.serverData.id, JSON.stringify(this.userForm))
this.dialogFormVisible = false
}
})
},
async setDeviceConfigure () { async setDeviceConfigure () {
// 校验是否已经有账号和密码
const userInfo = this.getUserInfo()
try { try {
// 验证表单 // 验证表单
this.$refs.deviceConfigure.$refs.form.validate((valid) => { this.$refs.deviceConfigure.$refs.form.validate((valid) => {
@@ -558,11 +511,14 @@ export default {
return false 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 const deviceConfigureModelValue = this.$refs.deviceConfigure.deviceConfigureModelValue
if (this.devicePointData.length > 0) { if (this.devicePointData.length > 0) {
let devicePointData = this.devicePointData let devicePointData = this.devicePointData
devicePointData = each(devicePointData, (item) => { devicePointData = each(devicePointData, (item) => {
if (item['@DataTypeCode'] !== 'string') {
unset(item, '@Length')
}
unset(item, 'id') unset(item, 'id')
unset(item, 'showBindButton') unset(item, 'showBindButton')
unset(item, 'showCopyButton') unset(item, 'showCopyButton')
@@ -572,6 +528,7 @@ export default {
}) })
deviceConfigureModelValue.RequestNode = devicePointData deviceConfigureModelValue.RequestNode = devicePointData
} }
deviceConfigureModelValue['@Name'] = this.deviceData[this.deviceActiveStatus].name deviceConfigureModelValue['@Name'] = this.deviceData[this.deviceActiveStatus].name
let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode || [] let deviceNode = deviceConfigure.Content.Settings.GroupNode[0].DeviceNode || []
let isExist = false let isExist = false
@@ -590,7 +547,7 @@ export default {
deviceNode.push(deviceConfigureModelValue) deviceNode.push(deviceConfigureModelValue)
} }
deviceConfigure.Content.Settings.GroupNode[0].DeviceNode = deviceNode 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 deviceConfigureModelValue.DeviceTypeName = this.$refs.deviceConfigure.defaultDeviceTypeNameValue
const data = { const data = {
action: 'update_device', action: 'update_device',
@@ -607,17 +564,9 @@ export default {
console.log(e) console.log(e)
} }
}, },
getUserInfo () {
const userInfo = sessionStorage.getItem(this.serverData.id)
if (!userInfo) {
this.dialogFormVisible = true
return false
}
return JSON.parse(userInfo)
},
async getDeviceStatus () { async getDeviceStatus () {
const userInfo = this.getUserInfo() const res = await this.$api.GET_SERVER_DEVICE_STATUS('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD)
const res = await this.$api.GET_SERVER_DEVICE_STATUS('http://' + this.serverData.url + ':' + this.serverData.port, userInfo.username, userInfo.password)
if (res) { if (res) {
this.$emit('changeStatus', 'online') this.$emit('changeStatus', 'online')
const deviceStatus = {} const deviceStatus = {}

View File

@@ -9,12 +9,20 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="设备编码" v-if="choosable === 'true'">
<el-select v-model="deviceConfigureModelValue.parent_device_code" placeholder="请选择">
<el-option v-for="(item, i) in deviceCodeData" :key="i" :label="item.name" :value="item.code">
</el-option>
</el-select>
</el-form-item>
<template v-for="(item, i) in deviceConfigureFormItem"> <template v-for="(item, i) in deviceConfigureFormItem">
<el-form-item :key="i" :label="item.labelName" :prop="item.key" v-if="!item.isShow"> <el-form-item :key="i" :label="item.labelName" :prop="item.key" v-if="!item.isShow">
<template v-if="item.type === 'text'"> <template v-if="item.type === 'text'">
<el-input v-model='deviceConfigureModelValue[item.key]' :disabled="item.disabled" <el-input v-model='deviceConfigureModelValue[item.key]' :disabled="item.disabled"
:placeholder="item.placeholder"></el-input> :placeholder="item.placeholder"></el-input>
</template> </template>
<template v-if="item.type === 'number'"> <template v-if="item.type === 'number'">
<el-input-number v-model='deviceConfigureModelValue[item.key]' :disabled="item.disabled" :controls="false" <el-input-number v-model='deviceConfigureModelValue[item.key]' :disabled="item.disabled" :controls="false"
:placeholder="item.placeholder"></el-input-number> :placeholder="item.placeholder"></el-input-number>
@@ -43,7 +51,9 @@
<script> <script>
import deviceConfigureFormItemData from './deviceSetting/index.json' import deviceConfigureFormItemData from './deviceSetting/index.json'
import { each } from 'lodash' import { each, assign } from 'lodash'
// import { getDeviceAll } from '@/api/basic/device'
export default { export default {
name: 'deviceConfigure', name: 'deviceConfigure',
props: { props: {
@@ -59,7 +69,6 @@ export default {
}, },
computed: { computed: {
}, },
watch: { watch: {
defaultDeviceName: { defaultDeviceName: {
@@ -80,6 +89,9 @@ export default {
return { return {
deviceConfigureFormItem: [], deviceConfigureFormItem: [],
defaultDeviceTypeNameValue: '', defaultDeviceTypeNameValue: '',
deviceCode: '',
deviceCodeData: [],
choosable: process.env.VUE_APP_CHOOSABLE,
deviceConfigureModelValue: {}, deviceConfigureModelValue: {},
rules: {}, rules: {},
deviceSelectedVlaue: '', deviceSelectedVlaue: '',
@@ -103,11 +115,15 @@ export default {
} }
}) })
this.rules = rules this.rules = rules
this.deviceConfigureModelValue = deviceConfigureModelValue this.deviceConfigureModelValue = this.choosable === 'true' ? assign(deviceConfigureModelValue, { parent_device_code: '' }) : deviceConfigureModelValue
console.log(this.deviceConfigureModelValue)
this.deviceConfigureFormItem = deviceConfigureFormItemData[e] this.deviceConfigureFormItem = deviceConfigureFormItemData[e]
}, },
setDeviceDefaultFormItemValue (val) { setDeviceDefaultFormItemValue (val) {
const deviceConfigureModelValue = {} const deviceConfigureModelValue = {}
if (this.choosable === 'true') {
deviceConfigureModelValue.parent_device_code = val.parent_device_code
}
each(deviceConfigureFormItemData[this.defaultDeviceTypeNameValue], (item) => { each(deviceConfigureFormItemData[this.defaultDeviceTypeNameValue], (item) => {
if (item.type === 'time') { if (item.type === 'time') {
deviceConfigureModelValue[item.key] = val[item.key] ? val[item.key] : new Date() deviceConfigureModelValue[item.key] = val[item.key] ? val[item.key] : new Date()
@@ -120,9 +136,17 @@ export default {
}, },
getDeviceType () { getDeviceType () {
this.deviceTypeData = Object.keys(deviceConfigureFormItemData) this.deviceTypeData = Object.keys(deviceConfigureFormItemData)
},
getDeviceAll () {
// getDeviceAll().then(res => {
// this.deviceCodeData = res.data
// })
} }
}, },
mounted () { mounted () {
if (this.choosable === 'true') {
this.getDeviceAll()
}
this.getDeviceType() this.getDeviceType()
} }

View File

@@ -39,21 +39,6 @@
<device :server='server' @changeStatus='changeSelectedServerStatus' @changeServerConfig='changeSelectedServerConfig' /> <device :server='server' @changeStatus='changeSelectedServerStatus' @changeServerConfig='changeSelectedServerConfig' />
</el-drawer> </el-drawer>
<el-dialog title="服务账号登录" :visible.sync="dialogFormVisible">
<el-alert title="请先输入该服务的账号密码,再进行后续操作" type="warning" style="width:400px;display: inline-block;vertical-align: middle; margin-left: 5px;" :closable="false" />
<el-form :model="form" :rules="rules" ref="form">
<el-form-item label="账号" prop="username">
<el-input v-model="form.username" ></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input type="password" v-model="form.password" ></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleDialogFormVisible"> </el-button>
</div>
</el-dialog>
</d2-container> </d2-container>
</template> </template>
@@ -99,20 +84,6 @@ export default {
} }
], ],
isDrawerShow: false, isDrawerShow: false,
dialogFormVisible: false,
form: {
username: '',
password: ''
},
rules: {
username: [
{ required: true, message: '请输入账号', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
]
},
dialogFormServerId: 0,
server: {}, server: {},
serveStatus: { serveStatus: {
online: { online: {
@@ -169,7 +140,7 @@ export default {
emit: 'set-device' emit: 'set-device'
}, },
{ {
text: '配置应用', text: '重启服务',
size: 'small', size: 'small',
emit: 'exec' emit: 'exec'
} }
@@ -360,43 +331,25 @@ export default {
}) })
done() done()
}, },
async setServerExec ({ row }) { async setServerExec ({ row }) {
let userInfo = sessionStorage.getItem(row.id)
this.dialogFormServerId = row.id
if (!userInfo) {
this.dialogFormVisible = true
return false
}
userInfo = JSON.parse(userInfo)
try { try {
await this.$api.SET_SERVER_EXEC({ await this.$api.SET_SERVER_EXEC({
action: 'exec', action: 'exec',
server_id: row.id, server_id: row.id,
command: 'server_restart', command: 'server_restart',
username: userInfo.username, username: 'admin',
password: userInfo.password password: process.env.VUE_APP_HSLSERVER_PASSWORD
}) })
this.$message({ this.$message({
message: '服务应用请求成功,请求动作已添加至请求队列中,请从服务监控页面查看结果', message: '服务应用请求成功,请求动作已添加至请求队列中,请从服务监控页面查看结果',
type: 'success' type: 'success'
}) })
this.dialogFormServerId = 0
this.getServers() this.getServers()
this.dialogFormVisible = false
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
}, },
handleDialogFormVisible () {
this.$refs.form.validate((valid) => {
if (valid) {
sessionStorage.setItem(this.dialogFormServerId, JSON.stringify(this.form))
this.dialogFormVisible = false
}
})
},
handleDialogCancel (done) { handleDialogCancel (done) {
this.$message({ this.$message({
message: '用户放弃改动', message: '用户放弃改动',

View File

@@ -1,158 +1,174 @@
<template> <template>
<d2-container> <d2-container>
<div> <div>
<el-card class="box-card" v-for="(item, index) in serverData" :key="index"> <el-card
class="box-card"
v-for="(item, index) in serverData"
:key="index"
>
<div slot="header" class="device-header"> <div slot="header" class="device-header">
<span>前置服务 {{ item.server_name }} ({{ item.url }}:{{ item.port }} )</span> <span
>前置服务 {{ item.server_name }} ({{ item.url }}:{{ item.port }} )
<el-tag
:color="serveStatus[item.status].backgroundColor"
:style="{
color: serveStatus[item.status].textColor,
borderColor: serveStatus[item.status].borderColor,
}"
>
{{ serveStatus[item.status].name }}
</el-tag>
</span>
</div> </div>
<el-row :gutter="12"> <el-row :gutter="12">
<el-col :span="6" v-for="(i, k) in item.devices" :key="k"> <el-col :span="6" v-for="(i, k) in item.devices" :key="k">
<el-popover placement="top" trigger="click"> <el-popover placement="top" trigger="click">
<el-menu @select="(index) => setServerExec(i, index, item)" <el-menu
:style="{ 'borderRight': 'none' }"> @select="(index) => setDeviceExec(i, index, item)"
:style="{ borderRight: 'none' }"
>
<el-menu-item index="device_stop"> <el-menu-item index="device_stop">
<span slot="title">暂停</span> <span slot="title">暂停</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="device_continue"> <el-menu-item index="device_continue">
<span slot="title">启动</span> <span slot="title">启动</span>
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
<el-card slot="reference" <el-card
:class="{ 'box-card': true, 'online': i.deviceStatus, 'offline': !i.deviceStatus }"> slot="reference"
:class="{
'box-card': true,
online: i.deviceStatus,
offline: !i.deviceStatus,
}"
>
<div slot="header" class="header-title"> <div slot="header" class="header-title">
<span>{{ i.device_name }}</span> <span>{{ i.device_name }}</span>
</div> </div>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>设备类型</span> <span>设备类型</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.device_type }}</el-col> <el-col :span="14" style="padding-left: 0px"
>{{ i.device_type }}</el-col
>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>IP/端口</span> <span>IP/端口</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.config }} <el-col :span="14" style="padding-left: 0px"
>{{ i.config }}
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>活动时间</span> <span>活动时间</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.startTime }}</el-col> <el-col :span="14" style="padding-left: 0px"
>{{ i.startTime }}</el-col
>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>采集耗时</span> <span>采集耗时</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.captureSpendTime }}</el-col> <el-col :span="14" style="padding-left: 0px"
>{{ i.captureSpendTime }}</el-col
>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>成功次数</span> <span>成功次数</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.success }}</el-col> <el-col :span="14" style="padding-left: 0px"
>{{ i.success }}</el-col
>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="5" style="padding-right:0px;margin-bottom: 5px;"> <el-col
:span="5"
style="padding-right: 0px; margin-bottom: 5px"
>
<span>失败次数</span> <span>失败次数</span>
</el-col> </el-col>
<el-col :span="14" style="padding-left:0px;">{{ i.failed }}</el-col> <el-col :span="14" style="padding-left: 0px"
>{{ i.failed }}</el-col
>
</el-row> </el-row>
<el-row :gutter="24"> <el-row :gutter="24">
<el-alert v-if="i.failedMsg" :title="i.failedMsg" type="error" :closable="false"> <el-alert
v-if="i.failedMsg"
:title="i.failedMsg"
type="error"
:closable="false"
>
</el-alert> </el-alert>
<div v-else style="height:35px;"></div> <div v-else style="height: 35px"></div>
</el-row> </el-row>
</el-card> </el-card>
</el-popover> </el-popover>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
</div> </div>
<el-dialog title="服务账号登录" :visible.sync="dialogFormVisible">
<el-alert title="请先输入该服务的账号密码,再进行后续操作" type="warning" :closable="false" />
<el-form :model="form" :rules="rules" ref="form">
<el-form-item label="账号" prop="username">
<el-input v-model="form.username"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input type="password" v-model="form.password"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="setUserInfo"> </el-button>
</div>
</el-dialog>
</d2-container> </d2-container>
</template> </template>
<script> <script>
import { unset, map } from 'lodash' import { unset, map } from 'lodash'
export default { export default {
data () { data () {
return { return {
dialogFormVisible: false,
form: {
username: '',
password: ''
},
rules: {
username: [
{ required: true, message: '请输入账号', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
]
},
serverData: [], serverData: [],
deviceData: [], deviceData: [],
deviceCommand: {} deviceCommand: {},
serveStatus: {
online: {
name: '在线',
textColor: '#67c23a',
backgroundColor: '#f0f9eb',
borderColor: '#e1f3d8'
},
offline: {
name: '离线',
textColor: '#67c23a',
backgroundColor: '#f0f9eb',
borderColor: '#e1f3d8'
}
}
} }
}, },
methods: { methods: {
setUserInfo () { async setDeviceExec (device, command, server) {
this.$refs.form.validate(async (valid) => {
if (valid) {
sessionStorage.setItem(this.deviceCommand.serverId, JSON.stringify(this.form))
this.form = {
username: '',
password: ''
}
this.dialogFormVisible = false
}
})
},
async setServerExec (device, command, server) {
let userInfo = sessionStorage.getItem(server.id)
if (!userInfo) {
this.deviceCommand = {
serverId: server.id
}
this.dialogFormVisible = true
return false
}
userInfo = JSON.parse(userInfo)
try { try {
await this.$api.SET_SERVER_EXEC({ await this.$api.SET_SERVER_EXEC({
action: 'exec', action: 'exec',
server_id: server.id, server_id: server.id,
command: command, command: command,
device_name: device.device_name, device_name: device.device_name,
username: userInfo.username, username: 'admin',
password: userInfo.password password: process.env.VUE_APP_HSLSERVER_PASSWORD
}) })
this.$message({ this.$message({
message: '请求成功,请求动作已添加至请求队列中', message: '请求成功,请求动作已添加至请求队列中',
type: 'success' type: 'success'
}) })
this.dialogFormVisible = false
this.getServe() this.getServe()
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@@ -161,11 +177,17 @@ export default {
async getServe () { async getServe () {
this.serverData = await this.$api.QUERY_SERVERS() this.serverData = await this.$api.QUERY_SERVERS()
this.serverData.forEach((element, index) => { this.serverData.forEach((element, index) => {
this.$api.GET_SERVE_DEVICE_MONITORING('http://' + element.url + ':' + element.port, 'admin', '123456').then((deviceStatus) => { this.$api
.GET_SERVE_DEVICE_MONITORING(
'http://' + element.url + ':' + element.port,
'admin',
process.env.VUE_APP_HSLSERVER_PASSWORD
)
.then((deviceStatus) => {
if (deviceStatus.IsSuccess) { if (deviceStatus.IsSuccess) {
const data = deviceStatus.Content const data = deviceStatus.Content
unset(data, '__status') unset(data, '__status')
const deviceData = map(data, element => { const deviceData = map(data, (element) => {
const config = element.__config.split(' ') const config = element.__config.split(' ')
return { return {
config: config.length > 0 ? config[2] : '', config: config.length > 0 ? config[2] : '',
@@ -180,13 +202,17 @@ export default {
} }
}) })
this.$set(this.serverData[index], 'devices', deviceData) this.$set(this.serverData[index], 'devices', deviceData)
this.$set(this.serverData[index], 'status', 'online')
} }
}).catch(() => { })
.catch(() => {
this.$message({ this.$message({
message: this.serverData[index].name + '服务请求失败', message: this.serverData[index].name + '服务请求失败',
type: 'error' type: 'error'
}) })
this.$delete(this.serverData, index) this.$set(this.serverData[index], 'status', 'offline')
// this.$delete(this.serverData, index);
}) })
}) })
} }
@@ -226,7 +252,6 @@ export default {
} }
.header-title { .header-title {
font-size: 18px; font-size: 18px;
} }
</style> </style>

View File

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