|
@@ -133,6 +133,8 @@ import carrierForm from './form'
|
|
|
import carrierCategoryForm from './formCategory'
|
|
|
import carrierAbandonmentForm from './formAbandonment'
|
|
|
import { nextTick } from 'vue'
|
|
|
+import JSZip from 'jszip';
|
|
|
+import { saveAs } from 'file-saver';
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
const { carrier_status } = proxy.useDict('carrier_status')
|
|
|
const webHost = import.meta.env.VITE_APP_PRODUCTION_API
|
|
@@ -285,23 +287,46 @@ const handleUnAbandoned = (row) => {
|
|
|
.catch(() => {})
|
|
|
}
|
|
|
|
|
|
-/** 批量下载二维码 */
|
|
|
-function handleBatchDownloadQrCode() {
|
|
|
- console.log(selections.value)
|
|
|
+// /** 批量下载二维码 */
|
|
|
+// function handleBatchDownloadQrCode() {
|
|
|
+// console.log(selections.value)
|
|
|
+// for (var i = 0; i < selections.value.length; i++) {
|
|
|
+// console.log(webHost + selections.value[i].qcCode)
|
|
|
+
|
|
|
+// var link = document.createElement('a')
|
|
|
+// link.href = webHost + selections.value[i].qcCode
|
|
|
+// link.download = selections.value[i].code // 可以根据需要设置下载的文件名
|
|
|
+// link.target = '_blank' // 可以根据需要选择是否在新窗口中下载
|
|
|
+// link.click()
|
|
|
+// }
|
|
|
+// // download({}).then((res) => {
|
|
|
+// // if (res.code === 200) {
|
|
|
+// // proxy.$modal.msgSuccess('操作成功!')
|
|
|
+// // }
|
|
|
+// // })
|
|
|
+// }
|
|
|
+async function handleBatchDownloadQrCode() {
|
|
|
+ console.log(selections.value);
|
|
|
+
|
|
|
+ const zip = new JSZip();
|
|
|
+ const zipFilename = 'qrcodes.zip';
|
|
|
+
|
|
|
for (var i = 0; i < selections.value.length; i++) {
|
|
|
- console.log(webHost + selections.value[i].qcCode)
|
|
|
+ console.log(webHost + selections.value[i].qcCode);
|
|
|
+
|
|
|
+ // 下载二维码图片数据
|
|
|
+ const qrCodeResponse = await fetch(webHost + selections.value[i].qcCode);
|
|
|
+ const qrCodeBlob = await qrCodeResponse.blob();
|
|
|
|
|
|
- var link = document.createElement('a')
|
|
|
- link.href = webHost + selections.value[i].qcCode
|
|
|
- link.download = selections.value[i].code // 可以根据需要设置下载的文件名
|
|
|
- link.target = '_blank' // 可以根据需要选择是否在新窗口中下载
|
|
|
- link.click()
|
|
|
+ // 将二维码图片添加到 ZIP 文件中
|
|
|
+ zip.file(selections.value[i].code + '.png', qrCodeBlob);
|
|
|
}
|
|
|
- // download({}).then((res) => {
|
|
|
- // if (res.code === 200) {
|
|
|
- // proxy.$modal.msgSuccess('操作成功!')
|
|
|
- // }
|
|
|
- // })
|
|
|
+
|
|
|
+ // 生成 ZIP 文件并提供下载
|
|
|
+ zip.generateAsync({ type: 'blob' }).then((content) => {
|
|
|
+ // 使用 FileSaver.js 将 ZIP 文件保存到本地
|
|
|
+ saveAs(content, zipFilename);
|
|
|
+ });
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
getCategories()
|