This commit is contained in:
duanxiaohai 2024-11-01 14:05:05 +08:00
parent 724653b5fa
commit adc1339e66
6 changed files with 78 additions and 19 deletions

BIN
dist.zip Normal file

Binary file not shown.

View File

@ -4,12 +4,16 @@ export const useLoadingStore = defineStore({
id: 'loading',
state: () => ({
isLoading: false,
downloadStatus: null, // 下载状态
}),
getters: {
},
actions: {
changeIsLoading(data) {
this.isLoading = data
}
},
setDownloadStatus(status) { // 下载状态
this.downloadStatus = status;
},
},
})

View File

@ -2,7 +2,7 @@ import axios from "axios";
import { ElMessage } from "element-plus";
import tools from "@/utils/tools";
import router from "../router";
// axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/'
axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/'
axios.defaults.timeout = 120000;
// HTTP request 拦截器

View File

@ -38,23 +38,24 @@ tool.url = function (url, params) {
// 文件下载token放请求头中
tool.downloadFile = (url, params) => {
console.log(url, params);
// console.log(url, params);
let store = useLoadingStore();
store.isLoading = true;
axios
.get(url, {
headers: { token: JSON.parse(localStorage.getItem("token")) },
// responseType: "blob",
responseType: "blob",
params,
})
.then((response) => {
if (!response.data.code) {
// console.log(store);
if (store.downloadStatus == 200) {
let blob = new Blob([response.data], {
//这里的type要和后端一致
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
let Url = URL.createObjectURL(blob); //生成一个url
// console.log(Url)
// console.log('Url',Url)
const a = document.createElement("a");
a.href = Url;
// 设置文件名

View File

@ -281,25 +281,59 @@ watch(
data.columns = props.tableData.columns;
data.tableData.length = 0;
// function maskName(name) {
// if (name.length === 2) {
// // *
// return name[0] + "*";
// } else if (name.length > 2 && name.length <= 8) {
// //
// return name[0] + "*".repeat(name.length - 2) + name[name.length - 1];
// // return maskYwfzr(name);
// } else if (name.length > 8) {
// //
// return maskYwfzr(name);
// }
// return name;
// }
// function maskYwfzr(ywfzr) {
// // 使
// return ywfzr.replace(
// /([^,]+)/g,
// (match, name) => `${maskName(name.trim())}`
// );
// }
function maskName(name) {
console.log("name", name);
if (name.length === 2) {
// *
return name[0] + "*";
} else if (name.length > 2 && name.length <= 8) {
} else if (name.length > 2) {
//
return name[0] + "*".repeat(name.length - 2) + name[name.length - 1];
} else if (name.length > 8) {
//
return maskYwfzr(name);
}
return name;
return name; //
}
function maskYwfzr(ywfzr) {
// 使
return ywfzr.replace(
/([^,]+)/g,
(match, name) => `${maskName(name.trim())}`
);
//
if (ywfzr.includes("")) {
//
return ywfzr.replace(/([^]+[^,]+)/g, (match) => {
const parts = match.split(""); //
const maskedNames = parts[1]
.split(",")
.map((name) => maskName(name.trim()))
.join(", "); //
return `${parts[0]}${maskedNames}`; //
});
} else {
//
return ywfzr
.split(",")
.map((name) => maskName(name.trim()))
.join(", ");
}
}
//
function maskPhoneNumber(phone) {
@ -312,6 +346,7 @@ watch(
.map((phone) => maskPhoneNumber(phone.trim()))
.join(",");
}
if (props.tableData.data.wxs.length > 0) {
props.tableData.data.wxs.forEach((item, index) => {
let obj = {
@ -321,7 +356,7 @@ watch(
bzlx: item.bzlx,
qtbm: item.qtbm,
zrks: item.zrks,
ywfzr: maskName(item.ywfzr),
ywfzr: maskYwfzr(item.ywfzr),
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
// ywfzrsj: item.ywfzrsj.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"),
};
@ -338,7 +373,7 @@ watch(
bzlx: item.bzlx,
qtbm: item.qtbm,
zrks: item.zrks,
ywfzr: maskName(item.ywfzr),
ywfzr: maskYwfzr(item.ywfzr),
// ywfzrsj: item.ywfzrsj,
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
};

View File

@ -208,7 +208,11 @@
</div>
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel()">
<template #reference>
<el-button type="info" plain style="margin-left: 24px"
<el-button
type="info"
plain
style="margin-left: 24px"
@click="downloadTips()"
>导出Excel</el-button
>
</template>
@ -899,6 +903,21 @@ const pushStatus = (val, status) => {
};
//
const downloadTips = () => {
const store = useLoadingStore();
http
.get(`/api/ggfwyth/pg/downloadWxsbmRyxxTip?bm=${data.bm}&xh=${data.xh}`)
.then((res) => {
if (res.code == 200) {
store.setDownloadStatus(res.code);
} else {
}
})
.catch((err) => {
// console.log(err, "err");
store.setDownloadStatus(null); //
});
};
const toExcel = () => {
// loading.value = true;
let url = `/api/ggfwyth/pg/downloadWxsbmRyxx?bm=${data.bm}&xh=${data.xh}`;