MS-CIAZDCOIXVRW\Administrator 3 anos atrás
pai
commit
fa524085c2
3 arquivos alterados com 376 adições e 146 exclusões
  1. 219 37
      src/components/Form/index.vue
  2. 152 108
      src/components/Home/index.vue
  3. 5 1
      src/main.js

+ 219 - 37
src/components/Form/index.vue

@@ -1,50 +1,232 @@
 <template>
-  <div class="form">
-    <div class="box" v-html="tableau"></div>
+  <div>
+    <el-table :data="excelList" height="800" style="width: 100%">
+      <el-table-column prop="workName" label="姓名"> </el-table-column>
+      <el-table-column
+        prop="groupOfCheck"
+        label="考勤组"
+        width="120"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column prop="department" label="部门" show-overflow-tooltip>
+      </el-table-column>
+      <el-table-column prop="workNum" label="工号"> </el-table-column>
+      <el-table-column prop="idCard" label="身份证" width="180">
+      </el-table-column>
+      <el-table-column
+        prop="daysOfAttendanceInHuangjiahu"
+        label="黄家湖出勤天数"
+        width="130"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="daysOfcardShortageInHuangjiahu"
+        label="黄家湖缺卡天数"
+        width="180"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="recondOfcardShortageInHuangjiahu"
+        label="黄家湖缺卡记录"
+        width="180"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="sumAttendanceInHuangjiahu"
+        label="黄家湖总出勤天数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="daysOfAttendanceInMoxuanhu"
+        label="墨轩湖出勤天数"
+        width="130"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="daysOfcardShortageInMoxuanhu"
+        label="墨轩湖缺卡天数"
+        width="180"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="recondOfcardShortageInMoxuanhu"
+        label="墨轩湖缺卡记录"
+        width="180"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="sumAttendanceInMoxuanhu"
+        label="墨轩湖总出勤天数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="abnormalClockNumber"
+        label="异常地点打卡天数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="abnormalClockRecond"
+        label="异常地点打卡记录"
+        width="150"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="leTwentyLateNumber"
+        label="0-20分钟迟到次数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="lequalThirtyLateNumber"
+        label="20-30分钟迟到次数"
+        width="150"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="geThirtyLateNumber"
+        label=">30分钟迟到次数"
+        width="140"
+      >
+      </el-table-column>
+
+      <el-table-column
+        prop="lateOfRecond"
+        label="迟到次数记录"
+        width="130"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="leTwentyLeaveNumber"
+        label="0-20分钟早退次数"
+        width="150"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="lequalThirtyLeaveNumber"
+        label="20-30分钟早退次数"
+        width="150"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="geThirtyLeaveNumber"
+        label=">30分钟早退次数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="leaveOfRecond"
+        label="早退次数记录"
+        width="140"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column prop="attendanceDays" label="出勤天数">
+      </el-table-column>
+      <el-table-column
+        prop="userId"
+        label="userId"
+        width="180"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column prop="attendanceDay" label="出勤天数"> </el-table-column>
+      <el-table-column prop="restDay" label="休息天数"> </el-table-column>
+      <el-table-column
+        prop="workHours"
+        label="工作时长"
+        width="130"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column prop="numberOfLate" label="迟到次数"> </el-table-column>
+      <el-table-column prop="numberOfLateTime" label="迟到时长">
+      </el-table-column>
+      <el-table-column
+        prop="numberOfSeriousLateness"
+        label="严重迟到次数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="durationOfSevereLateness"
+        label="严重迟到时长"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column
+        prop="daysOfAbsenteeismAndLateness"
+        label="旷工迟到天数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column prop="leaveEarlyNumber" label="早退次数">
+      </el-table-column>
+      <el-table-column
+        prop="leaveEarlyTimes"
+        label="早退时长"
+        width="150"
+        show-overflow-tooltip
+      >
+      </el-table-column>
+      <el-table-column
+        prop="lackOfWorkCardTimes"
+        label="上班缺卡次数"
+        width="140"
+      >
+      </el-table-column>
+
+      <el-table-column
+        prop="lackOfMissingWorkCardTimes"
+        label="下班缺卡次数"
+        width="140"
+      >
+      </el-table-column>
+      <el-table-column prop="absenteeismDay" label="旷工天数">
+      </el-table-column>
+      <el-table-column prop="goOutDay" label="外出"> </el-table-column>
+      <el-table-column label="请假">
+        <el-table-column prop="bereavementLeave" label="丧假(天)">
+        </el-table-column>
+        <el-table-column prop="privateAffairLeaveDay" label="事假(天)">
+        </el-table-column>
+        <el-table-column prop="maternityLeaveDay" label="产假(天)">
+        </el-table-column>
+        <el-table-column prop="sickLeaveDay" label="病假(天)">
+        </el-table-column>
+        <el-table-column prop="escortFalse" label="陪护假(天)" width="90">
+        </el-table-column>
+      </el-table-column>
+
+      <template v-for="(item, index) in TemHeader">
+        <el-table-column
+          :prop="item.column_comment"
+          :label="item.column_name"
+          :key="index"
+          show-overflow-tooltip
+        >
+        </el-table-column>
+      </template>
+    </el-table>
   </div>
 </template>
 
 <script>
-import XLSX from "xlsx";
 export default {
   name: "Form",
-  data() {
-    return {
-      tableau: null,
-    };
-  },
-  mounted() {
-    // this.getForm();
-  },
-  methods: {
-    // 预览表格
-    getForm() {
-      this.$axios
-        .get("/xlsx", {
-          responseType: "arraybuffer", // 设置响应体类型为arraybuffer
-        })
-        .then(({ data }) => {
-          console.log(data);
-          // 解析数据
-          let workbook = XLSX.read(new Uint8Array(data), { type: "array" });
-          // workbook.SheetNames 下存的是该文件每个工作表名字,这里取出第一个工作表
-          var worksheet = workbook.Sheets[workbook.SheetNames[0]];
-          // 渲染
-          this.tableau = XLSX.utils.sheet_to_html(worksheet);
-        });
-    },
-  },
+  props: ["excelList", "TemHeader"],
 };
 </script>
 
 
 <style lang="scss" scoped>
-.form {
-  .box {
-    margin: 0 auto;
-    width: 1540px;
-    height: 800px;
-    background-color: skyblue;
-  }
-}
 </style>

+ 152 - 108
src/components/Home/index.vue

@@ -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 = [];
     },
 
     // 文件超出个数限制时的钩子

+ 5 - 1
src/main.js

@@ -2,7 +2,7 @@ import Vue from 'vue'
 import App from './App.vue'
 import axios from 'axios'
 
-import { Upload, Button, Message, Drawer, MessageBox, Progress, Dialog, Tabs, TabPane, Card, InputNumber, TimeSelect } from 'element-ui';
+import { Upload, Button, Message, Drawer, MessageBox, Progress, Dialog, Tabs, TabPane, Card, InputNumber, TimeSelect, Table, TableColumn ,Loading} from 'element-ui';
 import 'element-ui/lib/theme-chalk/index.css';
 
 Vue.use(Upload)
@@ -15,7 +15,11 @@ Vue.use(TabPane)
 Vue.use(Card)
 Vue.use(InputNumber)
 Vue.use(TimeSelect)
+Vue.use(Table)
+Vue.use(TableColumn)
+// Vue.use(Loading.directive);
 
+Vue.prototype.$loading = Loading.service;
 Vue.prototype.$message = Message;
 Vue.prototype.$confirm = MessageBox.confirm;