This commit is contained in:
parent
724653b5fa
commit
adc1339e66
|
@ -4,12 +4,16 @@ export const useLoadingStore = defineStore({
|
||||||
id: 'loading',
|
id: 'loading',
|
||||||
state: () => ({
|
state: () => ({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
downloadStatus: null, // 下载状态
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
changeIsLoading(data) {
|
changeIsLoading(data) {
|
||||||
this.isLoading = data
|
this.isLoading = data
|
||||||
}
|
},
|
||||||
|
setDownloadStatus(status) { // 下载状态
|
||||||
|
this.downloadStatus = status;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,7 @@ import axios from "axios";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import tools from "@/utils/tools";
|
import tools from "@/utils/tools";
|
||||||
import router from "../router";
|
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;
|
axios.defaults.timeout = 120000;
|
||||||
|
|
||||||
// HTTP request 拦截器
|
// HTTP request 拦截器
|
||||||
|
|
|
@ -38,23 +38,24 @@ tool.url = function (url, params) {
|
||||||
|
|
||||||
// 文件下载(token放请求头中)
|
// 文件下载(token放请求头中)
|
||||||
tool.downloadFile = (url, params) => {
|
tool.downloadFile = (url, params) => {
|
||||||
console.log(url, params);
|
// console.log(url, params);
|
||||||
let store = useLoadingStore();
|
let store = useLoadingStore();
|
||||||
store.isLoading = true;
|
store.isLoading = true;
|
||||||
axios
|
axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
headers: { token: JSON.parse(localStorage.getItem("token")) },
|
headers: { token: JSON.parse(localStorage.getItem("token")) },
|
||||||
// responseType: "blob",
|
responseType: "blob",
|
||||||
params,
|
params,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.data.code) {
|
// console.log(store);
|
||||||
|
if (store.downloadStatus == 200) {
|
||||||
let blob = new Blob([response.data], {
|
let blob = new Blob([response.data], {
|
||||||
//这里的type要和后端一致
|
//这里的type要和后端一致
|
||||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
});
|
});
|
||||||
let Url = URL.createObjectURL(blob); //生成一个url
|
let Url = URL.createObjectURL(blob); //生成一个url
|
||||||
// console.log(Url)
|
// console.log('Url',Url)
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = Url;
|
a.href = Url;
|
||||||
// 设置文件名
|
// 设置文件名
|
||||||
|
|
|
@ -281,25 +281,59 @@ watch(
|
||||||
data.columns = props.tableData.columns;
|
data.columns = props.tableData.columns;
|
||||||
data.tableData.length = 0;
|
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) {
|
function maskName(name) {
|
||||||
|
console.log("name", name);
|
||||||
|
|
||||||
if (name.length === 2) {
|
if (name.length === 2) {
|
||||||
// 两个字的姓名,第二个字替换为 *
|
// 两个字的姓名,第二个字替换为 *
|
||||||
return name[0] + "*";
|
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];
|
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) {
|
function maskYwfzr(ywfzr) {
|
||||||
// 使用正则匹配每个名字并进行替换
|
// 处理包含冒号和逗号的姓名
|
||||||
return ywfzr.replace(
|
if (ywfzr.includes(":")) {
|
||||||
/:([^,]+)/g,
|
// 处理包含冒号的情况
|
||||||
(match, name) => `:${maskName(name.trim())}`
|
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) {
|
function maskPhoneNumber(phone) {
|
||||||
|
@ -312,6 +346,7 @@ watch(
|
||||||
.map((phone) => maskPhoneNumber(phone.trim()))
|
.map((phone) => maskPhoneNumber(phone.trim()))
|
||||||
.join(",");
|
.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.tableData.data.wxs.length > 0) {
|
if (props.tableData.data.wxs.length > 0) {
|
||||||
props.tableData.data.wxs.forEach((item, index) => {
|
props.tableData.data.wxs.forEach((item, index) => {
|
||||||
let obj = {
|
let obj = {
|
||||||
|
@ -321,7 +356,7 @@ watch(
|
||||||
bzlx: item.bzlx,
|
bzlx: item.bzlx,
|
||||||
qtbm: item.qtbm,
|
qtbm: item.qtbm,
|
||||||
zrks: item.zrks,
|
zrks: item.zrks,
|
||||||
ywfzr: maskName(item.ywfzr),
|
ywfzr: maskYwfzr(item.ywfzr),
|
||||||
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
|
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
|
||||||
// ywfzrsj: item.ywfzrsj.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"),
|
// ywfzrsj: item.ywfzrsj.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"),
|
||||||
};
|
};
|
||||||
|
@ -338,7 +373,7 @@ watch(
|
||||||
bzlx: item.bzlx,
|
bzlx: item.bzlx,
|
||||||
qtbm: item.qtbm,
|
qtbm: item.qtbm,
|
||||||
zrks: item.zrks,
|
zrks: item.zrks,
|
||||||
ywfzr: maskName(item.ywfzr),
|
ywfzr: maskYwfzr(item.ywfzr),
|
||||||
// ywfzrsj: item.ywfzrsj,
|
// ywfzrsj: item.ywfzrsj,
|
||||||
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
|
ywfzrsj: maskYwfzrsj(item.ywfzrsj),
|
||||||
};
|
};
|
||||||
|
|
|
@ -208,7 +208,11 @@
|
||||||
</div>
|
</div>
|
||||||
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel()">
|
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel()">
|
||||||
<template #reference>
|
<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
|
>导出Excel</el-button
|
||||||
>
|
>
|
||||||
</template>
|
</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 = () => {
|
const toExcel = () => {
|
||||||
// loading.value = true;
|
// loading.value = true;
|
||||||
let url = `/api/ggfwyth/pg/downloadWxsbmRyxx?bm=${data.bm}&xh=${data.xh}`;
|
let url = `/api/ggfwyth/pg/downloadWxsbmRyxx?bm=${data.bm}&xh=${data.xh}`;
|
||||||
|
|
Loading…
Reference in New Issue