更新设备配置导入导出功能
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<div slot="header" class="menu-header">
|
<div slot="header" class="menu-header">
|
||||||
<div class="header-title">设备</div>
|
<div class="header-title">设备</div>
|
||||||
<el-dropdown size="small" style="vertical-align: middle" @command="handleCommand">
|
<el-dropdown size="small" style="vertical-align: middle" trigger="click" @command="handleCommand">
|
||||||
<el-button type="primary" round>
|
<el-button type="primary" round>
|
||||||
<i class="el-icon-s-tools" style="font-size: 14px"></i><i class="el-icon-arrow-down el-icon--right"
|
<i class="el-icon-s-tools" style="font-size: 14px"></i><i class="el-icon-arrow-down el-icon--right"
|
||||||
style="font-size: 14px"></i>
|
style="font-size: 14px"></i>
|
||||||
@@ -14,8 +14,16 @@
|
|||||||
<el-dropdown-item command="add">新加设备</el-dropdown-item>
|
<el-dropdown-item command="add">新加设备</el-dropdown-item>
|
||||||
<el-dropdown-item command="del">删除设备</el-dropdown-item>
|
<el-dropdown-item command="del">删除设备</el-dropdown-item>
|
||||||
<el-dropdown-item>设备重启</el-dropdown-item>
|
<el-dropdown-item>设备重启</el-dropdown-item>
|
||||||
<el-dropdown-item>导入配置</el-dropdown-item>
|
<el-dropdown-item>
|
||||||
<el-dropdown-item>导出配置</el-dropdown-item>
|
<el-upload
|
||||||
|
class="upload-demo"
|
||||||
|
ref="upload"
|
||||||
|
action=""
|
||||||
|
:before-upload="importDeviceConfigure">
|
||||||
|
导入配置
|
||||||
|
</el-upload>
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="export" >导出配置</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
@@ -451,6 +459,9 @@ export default {
|
|||||||
case 'del':
|
case 'del':
|
||||||
this.delDevice()
|
this.delDevice()
|
||||||
break
|
break
|
||||||
|
case 'export':
|
||||||
|
this.exportDeviceConfigure()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getCodesByWorkingSubclass (workingSubclass) {
|
async getCodesByWorkingSubclass (workingSubclass) {
|
||||||
@@ -768,6 +779,35 @@ export default {
|
|||||||
this.$emit('changeStatus', false)
|
this.$emit('changeStatus', false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
exportDeviceConfigure () {
|
||||||
|
const deviceConfigure = this.$refs.deviceConfigure.deviceConfigureModelValue
|
||||||
|
const devicePointData = this.devicePointData
|
||||||
|
deviceConfigure.DeviceNode = devicePointData
|
||||||
|
deviceConfigure.DeviceTypeName = this.$refs.deviceConfigure.defaultDeviceTypeNameValue
|
||||||
|
const deviceData = JSON.stringify(deviceConfigure)
|
||||||
|
const exportLink = document.createElement('a')
|
||||||
|
const blob = new Blob([deviceData], { type: 'text/json' })
|
||||||
|
exportLink.href = URL.createObjectURL(blob)
|
||||||
|
exportLink.download = deviceConfigure['@Name'] + '.json'
|
||||||
|
exportLink.style.display = 'none'
|
||||||
|
document.body.appendChild(exportLink)
|
||||||
|
exportLink.click()
|
||||||
|
exportLink.remove()
|
||||||
|
},
|
||||||
|
importDeviceConfigure (file) {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.readAsText(file, 'UTF-8')
|
||||||
|
const that = this
|
||||||
|
reader.onload = function (e) {
|
||||||
|
const fileData = e.target.result
|
||||||
|
const deviceConfigureData = JSON.parse(fileData)
|
||||||
|
that.devicePointData = deviceConfigureData.DeviceNode
|
||||||
|
unset(deviceConfigureData, 'DeviceNode')
|
||||||
|
that.defaultFormData = deviceConfigureData
|
||||||
|
that.defaultDeviceName = deviceConfigureData.DeviceTypeName
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
clearTime () {
|
clearTime () {
|
||||||
clearInterval(this.timing)
|
clearInterval(this.timing)
|
||||||
this.timing = null
|
this.timing = null
|
||||||
|
|||||||
Reference in New Issue
Block a user