|
|
@@ -67,7 +67,12 @@
|
|
|
<div class="choose2">您的任务处理完成,用时:{{ time_s }}秒</div>
|
|
|
<div class="form_name">{{ form_name }}</div>
|
|
|
<div class="handle">
|
|
|
- <el-button type="primary" icon="el-icon-download">下载</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-download"
|
|
|
+ @click="handleDownload"
|
|
|
+ >下载</el-button
|
|
|
+ >
|
|
|
<el-button
|
|
|
type="success"
|
|
|
icon="el-icon-view"
|
|
|
@@ -190,7 +195,7 @@
|
|
|
|
|
|
<!-- 预览表格弹窗 -->
|
|
|
<el-dialog title="预览" :visible.sync="dialogVisible" fullscreen center>
|
|
|
- <Form />
|
|
|
+ <Form :excelList="excelList" :TemHeader="TemHeader" />
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -457,86 +462,42 @@ export default {
|
|
|
"sickLeaveDay",
|
|
|
"escortFalse",
|
|
|
"oneOfMonth",
|
|
|
- // "twoOfMonth",
|
|
|
- // "threeOfMonth",
|
|
|
- // "fourOfMonth",
|
|
|
- // "fiveOfMonth",
|
|
|
- // "sixOfMonth",
|
|
|
- // "sevenOfMonth",
|
|
|
- // "eightOfMonth",
|
|
|
- // "nineOfMonth",
|
|
|
- // "tenOfMonth",
|
|
|
- // "elevenOfMonth",
|
|
|
- // "twelveOfMonth",
|
|
|
- // "thirteenOfMonth",
|
|
|
- // "fourteenOfMonth",
|
|
|
- // "fifteenOfMonth",
|
|
|
- // "sixteenOfMonth",
|
|
|
- // "seventeenOfMonth",
|
|
|
- // "eighteenOfMonth",
|
|
|
- // "nineteenOfMonth",
|
|
|
- // "twentyOfMonth",
|
|
|
- // "twentyOneOfMonth",
|
|
|
- // "twentyTwoOfMonth",
|
|
|
- // "twentyThreeOfMonth",
|
|
|
- // "twentyFourOfMonth",
|
|
|
- // "twentyFiveOfMonth",
|
|
|
- // "twentySixOfMonth",
|
|
|
- // "twentySevenOfMonth",
|
|
|
- // "twentyEightOfMonth",
|
|
|
- // "twentyNineOfMonth",
|
|
|
- // "thirtyOfMonth",
|
|
|
- // "thirtyOneOfMonth",
|
|
|
+ "twoOfMonth",
|
|
|
+ "threeOfMonth",
|
|
|
+ "fourOfMonth",
|
|
|
+ "fiveOfMonth",
|
|
|
+ "sixOfMonth",
|
|
|
+ "sevenOfMonth",
|
|
|
+ "eightOfMonth",
|
|
|
+ "nineOfMonth",
|
|
|
+ "tenOfMonth",
|
|
|
+ "elevenOfMonth",
|
|
|
+ "twelveOfMonth",
|
|
|
+ "thirteenOfMonth",
|
|
|
+ "fourteenOfMonth",
|
|
|
+ "fifteenOfMonth",
|
|
|
+ "sixteenOfMonth",
|
|
|
+ "seventeenOfMonth",
|
|
|
+ "eighteenOfMonth",
|
|
|
+ "nineteenOfMonth",
|
|
|
+ "twentyOfMonth",
|
|
|
+ "twentyOneOfMonth",
|
|
|
+ "twentyTwoOfMonth",
|
|
|
+ "twentyThreeOfMonth",
|
|
|
+ "twentyFourOfMonth",
|
|
|
+ "twentyFiveOfMonth",
|
|
|
+ "twentySixOfMonth",
|
|
|
+ "twentySevenOfMonth",
|
|
|
+ "twentyEightOfMonth",
|
|
|
+ "twentyNineOfMonth",
|
|
|
+ "thirtyOfMonth",
|
|
|
+ "thirtyOneOfMonth",
|
|
|
],
|
|
|
+ TemHeader: [],
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.getTitle();
|
|
|
- this.getData();
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
- async getTitle() {
|
|
|
- let res = await this.$axios({
|
|
|
- url: "/attendance/month/title",
|
|
|
- method: "get",
|
|
|
- });
|
|
|
- // console.log(res);
|
|
|
- if (res.data.success) {
|
|
|
- this.multiHeader = [...this.multiHeader, ...res.data.data];
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.message);
|
|
|
- }
|
|
|
- },
|
|
|
- async getData() {
|
|
|
- let res = await this.$axios({
|
|
|
- url: "/attendance/month/test",
|
|
|
- method: "get",
|
|
|
- });
|
|
|
- // console.log(res);
|
|
|
- if (res.data.success) {
|
|
|
- this.excelList = res.data.data;
|
|
|
- import("@/util/Export2Excel").then((excel) => {
|
|
|
- const multiHeader = [this.multiHeader];
|
|
|
- const multiHeader2 = [this.multiHeader2];
|
|
|
- const filterVal = this.filterVal; // 表头所对应的字段
|
|
|
- const data = this.excelList.map((v) => filterVal.map((j) => v[j]));
|
|
|
- // 进行所有表头的单元格合并
|
|
|
- const merges = this.merges;
|
|
|
-
|
|
|
- excel.export_json_to_excel({
|
|
|
- multiHeader,
|
|
|
- // 这里是第一行的表头
|
|
|
- multiHeader2,
|
|
|
- // 这里是第二行的表头
|
|
|
- data,
|
|
|
- filename: "考勤",
|
|
|
- merges,
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.message);
|
|
|
- }
|
|
|
- },
|
|
|
// 保存按钮回调
|
|
|
async handleSave() {
|
|
|
let data = {
|
|
|
@@ -627,6 +588,7 @@ export default {
|
|
|
},
|
|
|
// 文件上传回调
|
|
|
async handleUpload(file) {
|
|
|
+ this.info = "上传中,请稍等";
|
|
|
if (file) {
|
|
|
this.timer_info = setInterval(() => {
|
|
|
if (this.info == "上传中,请稍等") {
|
|
|
@@ -667,9 +629,11 @@ export default {
|
|
|
this.info = "上传完成,请点击开始按钮开始解析";
|
|
|
clearInterval(this.timer_info);
|
|
|
} else {
|
|
|
- this.$message.error(res.data.message);
|
|
|
+ this.$message.error(res.data.message + "请重新选择文件上传");
|
|
|
+ clearInterval(this.timer_info);
|
|
|
this.percentage = 0;
|
|
|
this.info = res.data.message;
|
|
|
+ this.showPage = 1;
|
|
|
}
|
|
|
} else {
|
|
|
this.$message.error("请先上传文件");
|
|
|
@@ -680,39 +644,28 @@ export default {
|
|
|
// 点击开始按钮回调
|
|
|
async handleStart() {
|
|
|
if (this.showPage == 2 && this.percentage == 100) {
|
|
|
+ this.showPage = 3;
|
|
|
+ // 计算出解析的时间
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ this.time_s += 1;
|
|
|
+ this.parsePercentage += 1;
|
|
|
+ if (this.parsePercentage >= 90) {
|
|
|
+ this.parsePercentage = 90;
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
// 开始解析时的处理
|
|
|
let res = await this.$axios({
|
|
|
- url: "/attendance/late/queryLateClock",
|
|
|
+ url: "/attendance/month/downLoad",
|
|
|
method: "get",
|
|
|
});
|
|
|
- console.log(res);
|
|
|
+ // console.log(res);
|
|
|
if (res.data.success) {
|
|
|
- this.showPage = 3;
|
|
|
- // 计算出解析的时间
|
|
|
- this.timer = setInterval(async () => {
|
|
|
- this.time_s += 1;
|
|
|
- this.parsePercentage += 1;
|
|
|
- if (this.parsePercentage >= 90) {
|
|
|
- this.parsePercentage = 90;
|
|
|
- }
|
|
|
- let result = await this.$axios({
|
|
|
- url: "/attendance/late/queryLateClock",
|
|
|
- method: "get",
|
|
|
- });
|
|
|
- console.log(result);
|
|
|
- if (result.data.success) {
|
|
|
- this.parsePercentage = 100;
|
|
|
- clearInterval(this.timer);
|
|
|
- this.showPage = 4;
|
|
|
- }
|
|
|
- // this.parsePercentage += 20;
|
|
|
- // if (this.parsePercentage >= 100) {
|
|
|
- // this.parsePercentage = 100;
|
|
|
- // clearInterval(this.timer);
|
|
|
- // this.showPage = 4;
|
|
|
- // }
|
|
|
- }, 1000);
|
|
|
+ this.excelList = res.data.data;
|
|
|
+ this.parsePercentage = 100;
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.showPage = 4;
|
|
|
} else {
|
|
|
+ clearInterval(this.timer);
|
|
|
this.$message.error(res.data.message);
|
|
|
}
|
|
|
} else if (this.showPage == 3) {
|
|
|
@@ -739,9 +692,99 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ // 下载按钮回调
|
|
|
+ async handleDownload() {
|
|
|
+ let res = await this.$axios({
|
|
|
+ url: "/attendance/month/title",
|
|
|
+ method: "get",
|
|
|
+ });
|
|
|
+ // console.log(res);
|
|
|
+ if (res.data.success) {
|
|
|
+ this.multiHeader = [...this.multiHeader, ...res.data.data];
|
|
|
+ import("@/util/Export2Excel").then((excel) => {
|
|
|
+ const multiHeader = [this.multiHeader];
|
|
|
+ const multiHeader2 = [this.multiHeader2];
|
|
|
+ const filterVal = this.filterVal; // 表头所对应的字段
|
|
|
+ const data = this.excelList.map((v) => filterVal.map((j) => v[j]));
|
|
|
+ // 进行所有表头的单元格合并
|
|
|
+ const merges = this.merges;
|
|
|
+
|
|
|
+ excel.export_json_to_excel({
|
|
|
+ multiHeader,
|
|
|
+ // 这里是第一行的表头
|
|
|
+ multiHeader2,
|
|
|
+ // 这里是第二行的表头
|
|
|
+ data,
|
|
|
+ filename: "考勤",
|
|
|
+ merges,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 预览按钮回调
|
|
|
- handlePreview() {
|
|
|
- this.dialogVisible = true;
|
|
|
+ async handlePreview() {
|
|
|
+ const loading = this.$loading({
|
|
|
+ lock: true,
|
|
|
+ text: "加载中",
|
|
|
+ spinner: "el-icon-loading",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+
|
|
|
+ let res = await this.$axios({
|
|
|
+ url: "/attendance/month/title",
|
|
|
+ method: "get",
|
|
|
+ });
|
|
|
+ // console.log(res);
|
|
|
+ if (res.data.success) {
|
|
|
+ let temList = [
|
|
|
+ "oneOfMonth",
|
|
|
+ "twoOfMonth",
|
|
|
+ "threeOfMonth",
|
|
|
+ "fourOfMonth",
|
|
|
+ "fiveOfMonth",
|
|
|
+ "sixOfMonth",
|
|
|
+ "sevenOfMonth",
|
|
|
+ "eightOfMonth",
|
|
|
+ "nineOfMonth",
|
|
|
+ "tenOfMonth",
|
|
|
+ "elevenOfMonth",
|
|
|
+ "twelveOfMonth",
|
|
|
+ "thirteenOfMonth",
|
|
|
+ "fourteenOfMonth",
|
|
|
+ "fifteenOfMonth",
|
|
|
+ "sixteenOfMonth",
|
|
|
+ "seventeenOfMonth",
|
|
|
+ "eighteenOfMonth",
|
|
|
+ "nineteenOfMonth",
|
|
|
+ "twentyOfMonth",
|
|
|
+ "twentyOneOfMonth",
|
|
|
+ "twentyTwoOfMonth",
|
|
|
+ "twentyThreeOfMonth",
|
|
|
+ "twentyFourOfMonth",
|
|
|
+ "twentyFiveOfMonth",
|
|
|
+ "twentySixOfMonth",
|
|
|
+ "twentySevenOfMonth",
|
|
|
+ "twentyEightOfMonth",
|
|
|
+ "twentyNineOfMonth",
|
|
|
+ "thirtyOfMonth",
|
|
|
+ "thirtyOneOfMonth",
|
|
|
+ ];
|
|
|
+ let temList2 = res.data.data;
|
|
|
+ let size = temList.length;
|
|
|
+ for (let i = 0; i < size; i++) {
|
|
|
+ let a = {};
|
|
|
+ a.column_comment = temList[i];
|
|
|
+ a.column_name = temList2[i];
|
|
|
+ this.TemHeader.push(a);
|
|
|
+ }
|
|
|
+ this.dialogVisible = true;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ loading.close();
|
|
|
},
|
|
|
|
|
|
// 重新开始按钮回调
|
|
|
@@ -751,6 +794,7 @@ export default {
|
|
|
this.info = "上传中,请稍等";
|
|
|
this.percentage = 0;
|
|
|
this.parsePercentage = 0;
|
|
|
+ this.excelList = [];
|
|
|
},
|
|
|
|
|
|
// 文件超出个数限制时的钩子
|