|
@@ -33,13 +33,13 @@
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
<HcTooltip keys="write_industry_download">
|
|
|
- <el-button type="primary" hc-btn :disabled="tableInternalKeys.length <= 0">
|
|
|
+ <el-button type="primary" hc-btn :disabled="tableInternalKeys.length <= 0" @click="batchDownload" :loading="downloadLoading">
|
|
|
<HcIcon name="download"/>
|
|
|
<span>下载</span>
|
|
|
</el-button>
|
|
|
</HcTooltip>
|
|
|
<HcTooltip keys="write_industry_print">
|
|
|
- <el-button hc-btn :disabled="tableInternalKeys.length <= 0">
|
|
|
+ <el-button hc-btn :disabled="tableInternalKeys.length <= 0" :loading="printLoading" @click="batchPrint">
|
|
|
<HcIcon name="printer"/>
|
|
|
<span>打印</span>
|
|
|
</el-button>
|
|
@@ -244,4 +244,46 @@ const tableInternalSelection = (rows) => {
|
|
|
return (item??'') !== '';
|
|
|
})
|
|
|
}
|
|
|
+//拼接ID
|
|
|
+const rowsToId = (rows) => {
|
|
|
+ return rows.map((obj) => {
|
|
|
+ return obj.id;
|
|
|
+ }).join(",")
|
|
|
+}
|
|
|
+//下载
|
|
|
+const downloadLoading = ref(false)
|
|
|
+const batchDownload = async () => {
|
|
|
+ const rows = tableInternalKeys.value;
|
|
|
+ console.log(rows,'rows');
|
|
|
+ const ids = rowsToId(rows)
|
|
|
+ //批量下载
|
|
|
+ downloadLoading.value = true
|
|
|
+ const {error, disposition, res} = await queryApi.batchDownloadFileToZip({ids: ids})
|
|
|
+ //处理数据
|
|
|
+ downloadLoading.value = false
|
|
|
+ if (!error) {
|
|
|
+ if (disposition) {
|
|
|
+ downloadBlob(res, disposition)
|
|
|
+ } else {
|
|
|
+ window.$message?.error('数据异常')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//打印
|
|
|
+const printLoading = ref(false)
|
|
|
+const batchPrint = async () => {
|
|
|
+ const rows = tableInternalKeys.value;
|
|
|
+ const ids = rowsToId(rows)
|
|
|
+ //批量下载
|
|
|
+ printLoading.value = true
|
|
|
+ const {error, code, data} = await queryApi.batchPrint({ids: ids})
|
|
|
+ //处理数据
|
|
|
+ printLoading.value = false
|
|
|
+ const res = isString(data) ? data ?? '' : ''
|
|
|
+ if (!error && code === 200 && res) {
|
|
|
+ window.open(res, '_blank')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
</script>
|