import {detailByUserPage, deviceLogs, devicePage, genDeviceQR, printDevLabel} from "@/api/dev/deviceInfoApi"; import {deviceChangeStatus, deviceChangeType, deviceStatus} from "@/utils/enum"; import {downloadBase64Image} from "@/utils"; import {stockQRCodeTextPDFFromTemplateFile} from "@/api/itextpdf/itextpdf"; let query = { page: 1, limit: 10, productName: null, deviceCode: null, status: deviceStatus.NORMAL.key, } let detailQuery = { page: 1, limit: 10, deviceCode: null, deptCode: null, productId: null, } export default { name: "deviceInfo", computed: { deviceChangeType() { return deviceChangeType }, deviceStatus() { return deviceStatus }, deviceChangeStatus() { return deviceChangeStatus } }, props: {isChoose: {required: false, default: false, type: Boolean}, chooseFunc: {required: false, type: Function}}, data() { return { locDeptCode: null, clickRow: null, showSearch: true, loading: false, total: .0, list: [], query: {...query}, //设备详情============================================= detailLoading: false, detailQuery: {...detailQuery}, detailList: [], detailTotal: 0, showLog: false, productRow: null, //=================================================== logList: [], } }, created() { this.locDeptCode = this.$store.getters.locDeptCode this.getList() }, methods: { downloadBase64Image, genQR(row) { genDeviceQR(row.deviceCode).then(res => { if (res.code != 20000) { this.$message.error(res.message) return } this.$set(row, 'QR', res.data) }) }, getDeviceLogs(row) { this.productRow = row deviceLogs(row.deviceCode).then(res => { if (res.code != 20000) { this.$message.error(res.message) return } this.logList = res.data || [] this.showLog = true }).catch(e => { }) }, rowClick(row) { if (this.clickRow && row.deptCode == this.clickRow.deptCode && row.productId == this.clickRow.productId && row.status == this.clickRow.status && row.checkLock == this.clickRow.checkLock) { return false } this.clickRow = row this.detailQuery = { ...detailQuery, deptCode: row.deptCode, productId: row.productId, status: row.status, checkLock: row.checkLock } this.getDetailList() }, getDetailList() { this.detailLoading = true detailByUserPage(this.detailQuery).then(res => { this.detailLoading = false if (res.code != 20000) { this.$message.error(res.message) return } this.detailList = res.data.list || [] this.detailTotal = res.data.total || 0 }).catch(e => { this.detailLoading = false }) }, search() { this.query.page = 1 this.getList() }, onReset() { this.query = {...query} this.getList() }, getList() { this.loading = true devicePage(this.query).then(res => { this.loading = false if (res.code != 20000) { this.$message.error(res.message) return } this.list = res.data.list || [] this.total = res.data.total || 0 }).catch(e => { this.loading = false }) }, printDevLabel(row) { let tQuery = { labelId: 5, deviceCode: row.deviceCode }; printDevLabel(tQuery).then((response) => { //将pdf文件转换为url。 const binaryData = []; binaryData.push(response); //获取blob链接。 let url = window.URL.createObjectURL( new Blob(binaryData, {type: "application/pdf"}) ); this.loading = false; window.open(url);//打开新标签页,预览pdf。 }).catch(() => { this.loading = false; }); } } }