|
@ -91,6 +91,76 @@ |
|
|
|
|
|
|
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
|
|
|
|
|
|
// 递归循环 qrcodeRef 组件集合 |
|
|
|
|
|
forEachQrcodeRef(el,index,elLength,wait) { |
|
|
|
|
|
let _this = this |
|
|
|
|
|
console.log('11111111111111'); |
|
|
|
|
|
console.log(index); |
|
|
|
|
|
if (index == elLength) { |
|
|
|
|
|
console.log('99999999'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
const item = el[index]; |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
console.log(el[index]); |
|
|
|
|
|
console.log(item.canvasToTempFilePath); |
|
|
|
|
|
// try{ |
|
|
|
|
|
item.canvasToTempFilePath({ |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
// 将临时路径转换成base64 |
|
|
|
|
|
pathToBase64(res.tempFilePath).then(base64 => { |
|
|
|
|
|
console.log(res.tempFilePath); |
|
|
|
|
|
_this.data[index].barcodeBase64 = base64 |
|
|
|
|
|
if (index == elLength - 1) { |
|
|
|
|
|
_this.isLoadFinish = true |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
}else { |
|
|
|
|
|
console.log(index); |
|
|
|
|
|
} |
|
|
|
|
|
this.forEachQrcodeRef(el,index+1,el.length,100) |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
this.forEachQrcodeRef(el,index+1,el.length,100) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
fail(err) { |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// }catch(e){ |
|
|
|
|
|
// console.log(e) |
|
|
|
|
|
// //TODO handle the exception |
|
|
|
|
|
// // this.forEachQrcodeRef(el,index,el.length) |
|
|
|
|
|
// } |
|
|
|
|
|
},wait); |
|
|
|
|
|
}, |
|
|
|
|
|
// stringToBase64(str) { |
|
|
|
|
|
// console.log('999999999999999'); |
|
|
|
|
|
// console.log(str); |
|
|
|
|
|
// // 对中文字符进行编码 |
|
|
|
|
|
// // var encodeUTF8 = uni.getSystemInfoSync().platform === 'android' ? 'utf-8' : 'utf8'; |
|
|
|
|
|
// // console.log('8888888888888'); |
|
|
|
|
|
// // var utf8Str = uni.encode(str, encodeUTF8); |
|
|
|
|
|
// // console.log(utf8Str); data: |
|
|
|
|
|
// // 将utf8字符串转为base64 |
|
|
|
|
|
// var base64Str = btoa(str); |
|
|
|
|
|
// console.log(base64Str); |
|
|
|
|
|
// return base64Str; |
|
|
|
|
|
// }, |
|
|
|
|
|
// getQrCodeBase64(index) { |
|
|
|
|
|
// let _this = this |
|
|
|
|
|
// // 使用setTimeout确保DOM更新完成后再获取canvas |
|
|
|
|
|
// setTimeout(() => { |
|
|
|
|
|
// const qrcodeCanvas = this.$refs.qrcodeRef.$el.querySelector('canvas'); |
|
|
|
|
|
// if (qrcodeCanvas) { |
|
|
|
|
|
// // 将canvas转换为Base64编码的图片URL |
|
|
|
|
|
// _this.data[index].barcodeBase64 = qrcodeCanvas.toDataURL('image/png'); |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.log('xxxxxxxxxxxxxxxxx') |
|
|
|
|
|
// } |
|
|
|
|
|
// }, 0); |
|
|
|
|
|
// }, |
|
|
getListData(){ |
|
|
getListData(){ |
|
|
// 获取数据 |
|
|
// 获取数据 |
|
|
// 大哥:后端添加了 制造标签 生产线 ,可根据 生产线是否有值 来判断打印的是制造标签 |
|
|
// 大哥:后端添加了 制造标签 生产线 ,可根据 生产线是否有值 来判断打印的是制造标签 |
|
@ -112,36 +182,45 @@ |
|
|
// }] |
|
|
// }] |
|
|
|
|
|
|
|
|
let _this = this |
|
|
let _this = this |
|
|
this.$nextTick(async () => { |
|
|
// this.$nextTick(async () => { |
|
|
// 获取二维码图片临时路径 |
|
|
// 获取二维码图片临时路径 |
|
|
const el = _this.$refs['qrcodeRef'] |
|
|
const el = _this.$refs['qrcodeRef'] |
|
|
let str = '' |
|
|
_this.forEachQrcodeRef(el,0,el.length,5000); |
|
|
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(); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
console.log(index); |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
fail(err) { |
|
|
|
|
|
console.log('err:::', err) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
// 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(); |
|
|
|
|
|
|
|
|
}) |
|
|
// }else { |
|
|
|
|
|
// console.log(index); |
|
|
|
|
|
// } |
|
|
|
|
|
// }).catch(err => { |
|
|
|
|
|
// console.log(err); |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
|
|
|
// fail(err) { |
|
|
|
|
|
// console.log('err:::', err) |
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
// #ifdef APP |
|
|
// #ifdef APP |
|
@ -250,7 +329,7 @@ |
|
|
}) |
|
|
}) |
|
|
this.newHtmlContent = this.newHtmlContent.replace( |
|
|
this.newHtmlContent = this.newHtmlContent.replace( |
|
|
"mainBody", str); //替换物品代码 |
|
|
"mainBody", str); //替换物品代码 |
|
|
console.log(this.newHtmlContent) |
|
|
// console.log(this.newHtmlContent) |
|
|
}); |
|
|
}); |
|
|
// #endif |
|
|
// #endif |
|
|
} |
|
|
} |
|
@ -278,7 +357,10 @@ |
|
|
this.timer = null |
|
|
this.timer = null |
|
|
} |
|
|
} |
|
|
this.data = this.originData |
|
|
this.data = this.originData |
|
|
|
|
|
console.log(287,'11111111') |
|
|
|
|
|
this.$nextTick(()=> { |
|
|
this.getListData() |
|
|
this.getListData() |
|
|
|
|
|
}) |
|
|
},1000) |
|
|
},1000) |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|