From b6eeb59f2dec879d1dcb13ff570ba436d017e0ae Mon Sep 17 00:00:00 2001 From: wangyufei <2267742828@qq.com> Date: Tue, 9 Jul 2024 13:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/point/index.vue | 127 +++++++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/src/pages/point/index.vue b/src/pages/point/index.vue index 60a16c58..6f8e1706 100644 --- a/src/pages/point/index.vue +++ b/src/pages/point/index.vue @@ -59,7 +59,7 @@ - + @@ -81,13 +81,67 @@ name: 'point', data() { return { - data: {}, + timer:null, + originData:[], + data: [], newHtmlContent: '', //打印传入的html isLoadFinish: false, } }, methods: { + + getListData(){ + // 获取数据 + // 大哥:后端添加了 制造标签 生产线 ,可根据 生产线是否有值 来判断打印的是制造标签 + // this.data = [{ + // itemCode:'065.051-01M', // 物品代码 + // itemName: 'PCCLARNATEA1225BLACK9999', // 物品名称 + // packName: '包装名称',// 包装名称 + // packageCode: 'PS0513-000003', // 包装号 + // batch:'20240514',//批次 + // parentNumber:'PS0513-000003',//父包装号 + // itemType:'物料类型',//物料类型 + // asnNumber:'123232',//ASN + // supplierCode: 'Fewewq', // 供应商 + // qty: '100', // 数量 + // printTimes:'2019-09-09 09:09:00', // 打印时间 + // barcodeString: 'HMQ;V1.0;Dwork1-line1;F;R2024-04-03T08:28:41;B20240403;PPN0403-000005;I399.960-12;Q5.000000;UEA;', + // barcodeBase64: '', + // productionLineCode:''//生产线 + // }] + + let _this = this + this.$nextTick(async () => { + // 获取二维码图片临时路径 + const el = _this.$refs['qrcodeRef'] + let str = '' + el.forEach(async (item, index) => { + await item.canvasToTempFilePath({ + success: async (res) => { + // 将临时路径转换成base64 + await pathToBase64(res.tempFilePath).then(base64 => { + _this.data[index].barcodeBase64 = base64 + if (index == el.length - 1) { + _this.isLoadFinish = true + uni.hideLoading(); + + } + }).catch(err => { + console.log(err); + }) + }, + fail(err) { + console.log('err:::', err) + } + }) + + }) + + }) + + + }, // #ifdef APP // 打印 printImage() { @@ -116,6 +170,7 @@ if (newVal == true) { // 读取html文件将文件中的内容图换成当前页面的数据 let str = '' + // #ifdef APP this.readFile(htmlFileUrl, (htmlContent) => { this.newHtmlContent = htmlContent this.data.forEach(item => { @@ -195,60 +250,34 @@ "mainBody", str); //替换物品代码 console.log(this.newHtmlContent) }); - + // #endif } } }, onLoad(option) { + uni.showLoading({ + title: '加载中...', + mask: true + }); if (option.points) { - this.data = JSON.parse(option.points); + this.originData = JSON.parse(option.points); + } + }, + unmounted() { + if(this.timer){ + clearTimeout(this.timer) + this.timer = null } }, - async onShow() { - // 获取数据 - // 大哥:后端添加了 制造标签 生产线 ,可根据 生产线是否有值 来判断打印的是制造标签 - // this.data = [{ - // itemCode:'065.051-01M', // 物品代码 - // itemName: 'PCCLARNATEA1225BLACK9999', // 物品名称 - // packName: '包装名称',// 包装名称 - // packageCode: 'PS0513-000003', // 包装号 - // batch:'20240514',//批次 - // parentNumber:'PS0513-000003',//父包装号 - // itemType:'物料类型',//物料类型 - // asnNumber:'123232',//ASN - // supplierCode: 'Fewewq', // 供应商 - // qty: '100', // 数量 - // printTimes:'2019-09-09 09:09:00', // 打印时间 - // barcodeString: 'HMQ;V1.0;Dwork1-line1;F;R2024-04-03T08:28:41;B20240403;PPN0403-000005;I399.960-12;Q5.000000;UEA;', - // barcodeBase64: '', - // productionLineCode:''//生产线 - // }] - this.$nextTick(async () => { - // 获取二维码图片临时路径 - const el = this.$refs['qrcodeRef'] - let str = '' - el.forEach(async (item, index) => { - await item.canvasToTempFilePath({ - success: async (res) => { - // 将临时路径转换成base64 - await pathToBase64(res.tempFilePath).then(base64 => { - this.data[index].barcodeBase64 = base64 - if (index == el.length - 1) { - this.isLoadFinish = true - } - }).catch(err => { - console.log(err); - }) - }, - fail(err) { - console.log('err:::', err) - } - }) - - }) - - }) - + onShow() { + this.timer = setTimeout(()=>{ + if(this.timer){ + clearTimeout(this.timer) + this.timer = null + } + this.data = this.originData + this.getListData() + },1000) }, }