| | |
| | | |
| | | <script> |
| | | import InspectionForm from "./inspectionForm.vue"; |
| | | |
| | | import { |
| | | getDeviceInspectionRecordByPage, |
| | | exportDeviceInspectionRecord, |
| | | deleteDeviceInspectionRecord, |
| | | } from '@/api/cnas/resourceDemand/device.js' |
| | | export default { |
| | | name: "inspection-of-equipment", |
| | | // import 引入的组件需要注入到对象中才能使用 |
| | |
| | | // 查询 |
| | | getYearTableDetailData(deviceId) { |
| | | this.yearTableDetailDataLoading = true |
| | | this.$axios.post(this.$api.deviceInspectionRecord.getDeviceInspectionRecordByPage, { |
| | | page: { |
| | | current: this.pagination1.current, |
| | | size: this.pagination1.size, |
| | | }, |
| | | entity: { |
| | | deviceId: deviceId, |
| | | } |
| | | }, { |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | }, |
| | | noQs: true |
| | | getDeviceInspectionRecordByPage({ |
| | | current: this.pagination1.current, |
| | | size: this.pagination1.size, |
| | | deviceId: deviceId, |
| | | }).then(res => { |
| | | if (res.code == 200) { |
| | | this.yearTableDetailData = res.data.records |
| | |
| | | // 导出 |
| | | handleDownOne(id) { |
| | | this.outLoading = true |
| | | this.$axios.get(this.$api.deviceInspectionRecord.exportDeviceInspectionRecord + '?inspectionRecordId=' + id, { |
| | | responseType: "blob" |
| | | exportDeviceInspectionRecord({ |
| | | inspectionRecordId: id |
| | | }).then(res => { |
| | | this.outLoading = false |
| | | const blob = new Blob([res], { type: 'application/octet-stream' }); |
| | | //将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('导出成功') |
| | | } |
| | | } |
| | | this.$download.saveAs(blob, '设备点检记录表.doc') |
| | | }) |
| | | }, |
| | | // 删除 |
| | |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | this.$axios.get(this.$api.deviceInspectionRecord.deleteDeviceInspectionRecord + '?inspectionRecordId=' + id).then(res => { |
| | | deleteDeviceInspectionRecord({ inspectionRecordId: id }).then(res => { |
| | | this.$message.success('删除成功!'); |
| | | this.getYearTableDetailData(this.clickNodeVal.value); |
| | | }); |