This commit is contained in:
parent
717aaee91c
commit
618afb1cd0
|
@ -0,0 +1,15 @@
|
|||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useLoadingStore = defineStore({
|
||||
id: 'loading',
|
||||
state: () => ({
|
||||
isLoading: false,
|
||||
}),
|
||||
getters: {
|
||||
},
|
||||
actions: {
|
||||
changeIsLoading(data) {
|
||||
this.isLoading = data
|
||||
}
|
||||
},
|
||||
})
|
|
@ -0,0 +1,13 @@
|
|||
export const downloadFile = async (results, fileName) => {
|
||||
// 我们使用axios设置接口返回类型 responseType: "blob", 所以这里从后端返回的是blob。
|
||||
const a = document.createElement("a");
|
||||
a.download = fileName + ".xlsx";
|
||||
// 生成blob url。这里可以使用Blob对象或者File对象
|
||||
a.href = window.URL.createObjectURL(results);
|
||||
a.style.display = "none";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
// 释放内存
|
||||
window.URL.revokeObjectURL(a.href);
|
||||
document.body.removeChild(a);
|
||||
};
|
|
@ -150,6 +150,17 @@ var http = {
|
|||
url = url + (url.indexOf("?") > 0 ? "&" : "?") + token;
|
||||
window.open(url);
|
||||
},
|
||||
|
||||
downloadFile(url, params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios({ url, params, responseType: 'blob', }).then((res) => {
|
||||
resolve(res);
|
||||
})
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
export default http;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import axios from "axios";
|
||||
import { useLoadingStore } from "@/stores/loading.js";
|
||||
|
||||
var tool = {}
|
||||
|
||||
|
@ -32,5 +34,42 @@ tool.url = function (url, params) {
|
|||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
// 文件下载(token放请求头中)
|
||||
tool.downloadFile = (url,params) => {
|
||||
console.log(url,params);
|
||||
let store = useLoadingStore();
|
||||
store.isLoading = true;
|
||||
axios
|
||||
.get(url, {
|
||||
headers: { token: JSON.parse(localStorage.getItem("token")) },
|
||||
responseType: "blob",
|
||||
params
|
||||
})
|
||||
.then((response) => {
|
||||
let blob = new Blob([response.data], {
|
||||
//这里的type要和后端一致
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
let Url = URL.createObjectURL(blob); //生成一个url
|
||||
// console.log(Url)
|
||||
const a = document.createElement("a");
|
||||
a.href = Url;
|
||||
// 设置文件名
|
||||
var contentDispositionHeader = response.headers["content-disposition"];
|
||||
a.download = decodeURIComponent(
|
||||
contentDispositionHeader.split(";")[1].split("=")[1]
|
||||
);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(Url);
|
||||
store.isLoading = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, "err");
|
||||
store.isLoading = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export default tool
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="tablebody">
|
||||
<div class="tablebody" v-loading="loadingStore.isLoading">
|
||||
<div class="tableheader">
|
||||
<div
|
||||
class="tableheader_title"
|
||||
|
@ -17,7 +17,7 @@
|
|||
<el-table
|
||||
:data="data.tableData"
|
||||
stripe
|
||||
max-height="80vh"
|
||||
max-height="75vh"
|
||||
style="width: 100%; color: black"
|
||||
:header-cell-style="{
|
||||
background: 'rgba(231, 233, 235, 1)',
|
||||
|
@ -33,15 +33,22 @@
|
|||
:fixed="item.fixed"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-popconfirm
|
||||
title="是否确定该人员符合要求?"
|
||||
@confirm="handleEdit(scope.$index, scope.row, 1)"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button
|
||||
size="small"
|
||||
color="#2c40ea"
|
||||
v-if="scope.row.eligible == '1'"
|
||||
:disabled="scope.row.eligible == '1'"
|
||||
@click="handleEdit(scope.$index, scope.row, 1)"
|
||||
>
|
||||
完成
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<el-popconfirm
|
||||
title="是否确定该人员不符合要求?"
|
||||
@confirm="handleEdit(scope.$index, scope.row, 2)"
|
||||
|
@ -57,15 +64,16 @@
|
|||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<el-button
|
||||
size="small"
|
||||
color="#2c40ea"
|
||||
v-if="scope.row.eligible == '0'"
|
||||
@click="handleEdit(scope.$index, scope.row, 1)"
|
||||
>
|
||||
完成
|
||||
</el-button>
|
||||
|
||||
<el-popconfirm
|
||||
title="是否确定该人员符合要求?"
|
||||
v-if="scope.row.eligible == '0'"
|
||||
@confirm="handleEdit(scope.$index, scope.row, 1)"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button size="small" color="#2c40ea"> 完成 </el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
<el-popconfirm
|
||||
title="是否确定该人员不符合要求?"
|
||||
@confirm="handleEdit(scope.$index, scope.row, 2)"
|
||||
|
@ -198,6 +206,13 @@
|
|||
@current-change="handlePagination"
|
||||
/>
|
||||
</div>
|
||||
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel(1)">
|
||||
<template #reference>
|
||||
<el-button type="info" plain style="margin-left: 24px"
|
||||
>导出Excel</el-button
|
||||
>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
<div v-if="chooseTitle == '2'">
|
||||
<div class="select">
|
||||
|
@ -451,6 +466,11 @@ import { useRouter, useRoute } from "vue-router";
|
|||
import { ElMessage } from "element-plus";
|
||||
import http from "@/utils/request.js";
|
||||
import { Search } from "@element-plus/icons-vue";
|
||||
|
||||
import { useLoadingStore } from "@/stores/loading.js";
|
||||
import tools from "@/utils/tools";
|
||||
|
||||
const loadingStore = useLoadingStore();
|
||||
const router = useRouter();
|
||||
const routers = useRoute();
|
||||
const chooseTitle = ref(1);
|
||||
|
@ -486,6 +506,7 @@ var titleList = reactive([
|
|||
id: 5,
|
||||
},
|
||||
]);
|
||||
|
||||
const data = reactive({
|
||||
code: "",
|
||||
xh: "",
|
||||
|
@ -876,6 +897,16 @@ const pushStatus = (val, status) => {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 下载
|
||||
const toExcel = () => {
|
||||
// loading.value = true;
|
||||
let url = `/api/ggfwyth/pg/downloadWxsbmRyxx?bm=${data.bm}&xh=${data.xh}`;
|
||||
url = tools.url(url);
|
||||
tools.downloadFile(url);
|
||||
// loading.value = false;
|
||||
};
|
||||
|
||||
const handlePagination = (currentPage) => {
|
||||
data.pagination.current = currentPage;
|
||||
personDetails();
|
||||
|
@ -886,12 +917,10 @@ const handlePagination1 = (currentPage) => {
|
|||
};
|
||||
onMounted(() => {
|
||||
// data.tableData = JSON.parse(routers.query.personDetails);
|
||||
window.location.href =
|
||||
"taurusabc://taurusclient/page/link?url=" +
|
||||
window.location.href +
|
||||
"&container_type=ddtab";
|
||||
|
||||
console.log( window.location.href);
|
||||
// window.location.href =
|
||||
// "taurus://taurusclient/page/link?container_type=ddtab&url=" +
|
||||
// window.location.href;
|
||||
// console.log( window.location.href);
|
||||
|
||||
data.xh = routers.query.xh;
|
||||
data.bm = routers.query.bm;
|
||||
|
@ -976,7 +1005,7 @@ onMounted(() => {
|
|||
}
|
||||
.tableCss {
|
||||
width: 100%;
|
||||
height: calc(100vh - 80px);
|
||||
height: calc(100vh - 70px);
|
||||
overflow: auto;
|
||||
box-shadow: 0 0 3px 3px rgb(204 204 204 / 50%);
|
||||
//阴影
|
||||
|
|
Loading…
Reference in New Issue