| | |
| | | <script> |
| | | import { |
| | | exportMaintenanceRecord, |
| | | deviceMaintainDelete, |
| | | deleteDeviceMaintenance, |
| | | selectDeviceByCode, |
| | | addDeviceMaintenance, |
| | | getDeviceMaintenancePage, |
| | | } from '@/api/cnas/resourceDemand/device.js' |
| | | export default { |
| | | props: { |
| | |
| | | exportMaintenanceRecord({ deviceId: this.clickNodeVal.value }).then(res => { |
| | | this.outLoading = false |
| | | const blob = new Blob([res], { type: 'application/octet-stream' }); |
| | | this.$download.saveAs(blob, '设备维护保养记录.doc') |
| | | this.$message.success('导出成功') |
| | | //将Blob 对象转换成字符串 |
| | | let reader = new FileReader(); |
| | | reader.readAsText(blob, 'utf-8'); |
| | | reader.onload = () => { |
| | | try { |
| | | let result = JSON.parse(reader.result); |
| | | if (result.message) { |
| | | this.$message.error(result.message); |
| | | } else { |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '设备维护保养记录.doc'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } catch (err) { |
| | | console.log(err); |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '设备维护保养记录.doc'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | //操作详情删除 |
| | |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | deviceMaintainDelete(row.id).then(res => { |
| | | deleteDeviceMaintenance({ id: row.id }).then(res => { |
| | | }) |
| | | this.MaintainParam.splice(index, 1); |
| | | // this.MaintainParam.splice(index, 1); |
| | | this.getAllMessage(this.clickNodeVal.value) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '删除成功!' |
| | |
| | | this.$refs['form'].validate((valid) => { |
| | | if (valid) { |
| | | this.formData.deviceId = this.clickNodeVal.value; |
| | | this.$axios.post(this.$api.deviceCheck.deviceMaintainAdd, this.formData).then(res => { |
| | | addDeviceMaintenance(this.formData).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('添加成功'); |
| | | this.getAllMessage(this.clickNodeVal.value) |
| | | this.dialogVisible = false; |
| | | this.formData = {}; //清空表单 |
| | | } |
| | | }) |
| | | this.MaintainParam.push(this.formData) |
| | | this.dialogVisible = false; |
| | | this.formData = {}; //清空表单 |
| | | // this.MaintainParam.push(this.formData) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | //获取表单设备维护信息 |
| | | getAllMessage(deviceId) { |
| | | this.$axios.get(this.$api.deviceCheck.getDeviceMaintenancePage + "?deviceId=" + deviceId + "&size=" + this.search.size + "¤t=" + this.search.current + "&deviceNumber=" + this.search.deviceNumber).then(res => { |
| | | getDeviceMaintenancePage({ |
| | | deviceId, |
| | | ...this.search |
| | | }).then(res => { |
| | | if (res.code == 200) { |
| | | this.MaintainParam = res.data.records |
| | | this.search.total = res.data.total |