Browse Source

新增考勤数据导入

dev01 2 weeks ago
parent
commit
8a725078f8
4 changed files with 74 additions and 24 deletions
  1. BIN
      1.5.zip
  2. 7 7
      src/api/rd/record.js
  3. 1 1
      src/layout/components/Sidebar/Logo.vue
  4. 66 16
      src/views/rd/record/index.vue

BIN
1.5.zip


+ 7 - 7
src/api/rd/record.js

@@ -20,13 +20,13 @@ export function batchExamineRecord(data) {
 }
 
 // 导入考勤数据
-export function importUserClock(data) {
-  return request({
-    url: '/system/user/importUserClock',
-    method: 'post',
-    data: data
-  })
-}
+// export function importUserClock(data) {
+//   return request({
+//     url: '/system/user/importUserClock',
+//     method: 'post',
+//     data: data
+//   })
+// }
 
 // 用户打卡数据列表
 export function selectUserClock(query) {

+ 1 - 1
src/layout/components/Sidebar/Logo.vue

@@ -119,7 +119,7 @@ export default {
       color: #fff;
       font-weight: 600;
       line-height: 50px;
-      font-size: 12px;
+      font-size: 14px;
       font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
       vertical-align: middle;
       white-space: pre;

+ 66 - 16
src/views/rd/record/index.vue

@@ -489,12 +489,31 @@
       width="400px"
       append-to-body
     >
+      <template>
+        <div style="margin-bottom: 20px">
+          <el-radio-group v-model="tabPosition">
+            <el-radio-button label="template1">考勤数据</el-radio-button>
+            <el-radio-button label="template2">钉钉考勤数据</el-radio-button>
+          </el-radio-group>
+          <el-button
+            type="primary"
+            style="margin-left: 38px; background: green"
+            v-show="tabPosition == 'template1'"
+            @click="downTemplate"
+            >下载模板</el-button
+          >
+        </div>
+      </template>
       <el-upload
         ref="uploads"
         :limit="1"
         accept=".xlsx, .xls"
         :headers="uploads.headers"
-        :action="uploads.url + '?updateSupport=' + uploads.updateSupport"
+        :action="
+          (this.tabPosition == 'template1' ? uploads.url1 : uploads.url) +
+          '?updateSupport=' +
+          uploads.updateSupport
+        "
         :disabled="uploads.isUploading"
         :on-progress="handleFileUploadProgresss"
         :on-success="handleFileSuccesss"
@@ -505,6 +524,7 @@
         <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
         <div class="el-upload__tip text-center" slot="tip">
           <span>仅允许导入xls、xlsx格式文件。</span>
+          <div style="color: red; margin-top: 5px">注:请按模版格式,进行导入!!!</div>
         </div>
       </el-upload>
       <div slot="footer" class="dialog-footer">
@@ -657,7 +677,6 @@ import {
   listRecord,
   batchExamineRecord,
   selectUserClock,
-  importUserClock,
   updateAllUserClock,
   mateUserRecord,
   userRecordMerge,
@@ -682,6 +701,7 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      tabPosition: "template1",
       clockDetails: false,
       detailId: undefined,
       detailData: [],
@@ -764,6 +784,7 @@ export default {
         headers: { Authorization: "Bearer " + getToken() },
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + "/system/user/importUserClock",
+        url1: process.env.VUE_APP_BASE_API + "/api/project/importClockData",
       },
       // 查询参数
       queryParams: {
@@ -965,15 +986,20 @@ export default {
     },
     handleImports() {
       const _this = this;
-      selectUserClock().then((response) => {
-        if (!response.data || response.data.length == 0) {
-          _this.uploads.title = "数据导入";
-          _this.uploads.open = true;
-        } else {
-          _this.checkData = response.data;
-          _this.checkVisible = true;
-        }
-      });
+      if (_this.tabPosition == "template2") {
+        selectUserClock().then((response) => {
+          if (!response.data || response.data.length == 0) {
+            _this.uploads.title = "数据导入";
+            _this.uploads.open = true;
+          } else {
+            _this.checkData = response.data;
+            _this.checkVisible = true;
+          }
+        });
+      } else {
+        _this.uploads.title = "数据导入";
+        _this.uploads.open = true;
+      }
     },
     /** 下载模板操作 */
     importTemplate() {
@@ -983,6 +1009,13 @@ export default {
         `project_record_template_${new Date().getTime()}.xlsx`
       );
     },
+    downTemplate() {
+      this.download(
+        "api/project/importClockDataTemplate",
+        {},
+        `project_record_template_${new Date().getTime()}.xlsx`
+      );
+    },
     // 文件上传中处理
     handleFileUploadProgress(event, file, fileList) {
       this.upload.isUploading = true;
@@ -1017,10 +1050,24 @@ export default {
         this.$modal.msgError(response.msg);
         return;
       }
-      this.uploads.open = false;
-      this.uploads.isUploading = false;
-      this.$refs.uploads.clearFiles();
-      this.handleImports();
+      if (this.tabPosition == "template2") {
+        this.uploads.open = false;
+        this.uploads.isUploading = false;
+        this.$refs.uploads.clearFiles();
+        this.handleImports();
+      } else {
+        this.uploads.open = false;
+        this.uploads.isUploading = false;
+        this.$refs.uploads.clearFiles();
+        this.$alert(
+          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+            response.data +
+            "</div>",
+          "导入结果",
+          { dangerouslyUseHTMLString: true }
+        );
+        this.getList();
+      }
     },
     // 提交上传文件
     submitFileForms() {
@@ -1162,10 +1209,13 @@ export default {
 };
 </script>
 
-<style lang="scss" scoped>
+<style lang="scss">
 // .head-container {
 //   word-wrap: break-word;
 //   overflow: hidden;
 //   word-break: break-all;
 // }
+.el-dialog__body {
+  padding: 10px 20px 20px;
+}
 </style>