diff --git a/src/views/edgeServer/edgeServerConfigure/device.vue b/src/views/edgeServer/edgeServerConfigure/device.vue index 66e4543..178a4f8 100644 --- a/src/views/edgeServer/edgeServerConfigure/device.vue +++ b/src/views/edgeServer/edgeServerConfigure/device.vue @@ -5,7 +5,7 @@ @@ -451,6 +459,9 @@ export default { case 'del': this.delDevice() break + case 'export': + this.exportDeviceConfigure() + break } }, async getCodesByWorkingSubclass (workingSubclass) { @@ -768,6 +779,35 @@ export default { 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 () { clearInterval(this.timing) this.timing = null