Jelajahi Sumber

Merge branch 'qas' of yinet2020/YinetOASystemWeb into master

ly 4 tahun lalu
induk
melakukan
5db8fe4b8a
2 mengubah file dengan 126 tambahan dan 3 penghapusan
  1. 17 0
      src/api/duty/duty.js
  2. 109 3
      src/views/system/duty/duty.vue

+ 17 - 0
src/api/duty/duty.js

@@ -62,3 +62,20 @@ export function listTime(query) {
     params: query
   })
 }
+
+// 下载用户导入模板
+export function importTemplate() {
+  return request({
+    url: '/system/duty/importTemplate',
+    method: 'get'
+  })
+}
+
+//导出
+export function exporDuty(query) {
+  return request({
+    url: '/system/duty/export',
+    method: 'get',
+    params: query
+  })
+}

+ 109 - 3
src/views/system/duty/duty.vue

@@ -3,9 +3,16 @@
     <!-- 列表 -->
     <el-card class="box-card">
       <div class="search">
-        <el-button-group>
+        <el-button-group style="margin-right: 15px">
           <el-button  type="primary" @click="dialogVisible = true" class="addbtn">新增排班</el-button>
         </el-button-group>
+        <el-button-group>
+          <el-button
+            type="success"
+            icon="el-icon-upload2"
+            @click="handleImport"
+          >导入排班</el-button>
+        </el-button-group>
       </div>
       <!-- 信息 -->
       <el-tabs type="border-card" v-model="activeName2" @tab-click="handleClick" style="margin-top: 20px;">
@@ -63,9 +70,12 @@
                   <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                   <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                 </el-form-item>
-                <el-form-item>
+                <el-form-item v-if="queryParams.id == null" style="margin-right: 0px;">
                   <el-button type="success" icon="el-icon-s-claim" size="mini" @click="handleQuery1">上月值班</el-button>
                 </el-form-item>
+                <el-form-item v-if="queryParams.id == '1'">
+                  <el-button type="success" icon="el-icon-s-claim" size="mini" @click="resetQuery">本月值班</el-button>
+                </el-form-item>
               </el-form>
             </el-col>
             <el-col :span="24">
@@ -192,18 +202,66 @@
     <select-user-by-dept ref="selectUserByDept1" :title="title" :open="open1" :inputName="receiverName" :inputAccount="receiverAccount" append-to-body @ok="selectOK1"/>
     <select-user-by-dept ref="selectUserByDept2" :title="title" :open="open2" :inputName="receiverName" :inputAccount="receiverAccount" append-to-body @ok="selectOK2"/>
     <select-user-by-dept ref="selectUserByDept3" :title="title" :open="open3" :inputName="receiverName" :inputAccount="receiverAccount" append-to-body @ok="selectOK3"/>
+
+    <!-- 用户导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          将文件拖到此处,或
+          <em>点击上传</em>
+        </div>
+        <div class="el-upload__tip" slot="tip">
+<!--          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
+          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
+        </div>
+        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
 
-  import { listDuty,getDuty,addDuty,updateDuty,selMonth,listTime} from "@/api/duty/duty";
+  import { listDuty,getDuty,addDuty,updateDuty,selMonth,listTime,exporDuty,importTemplate} from "@/api/duty/duty";
   import SelectUserByDept from "@/components/SelectRen/selectUserByDept";
+  import { getToken } from "@/utils/auth";
 
   export default {
     components: {SelectUserByDept},
     data() {
       return {
+        // 用户导入参数
+        upload: {
+          // 是否显示弹出层(用户导入)
+          open: false,
+          // 弹出层标题(用户导入)
+          title: "",
+          // 是否禁用上传
+          isUploading: false,
+          // 是否更新已经存在的用户数据
+          updateSupport: 0,
+          // 设置上传的请求头部
+          headers: { Authorization: "Bearer " + getToken() },
+          // 上传的地址
+          url: process.env.VUE_APP_BASE_API + "/system/duty/importData"
+        },
         leader: "",
         am:'',
         noon:'',
@@ -293,6 +351,36 @@
     mounted() {
     },
     methods: {
+      /** 导入按钮操作 */
+      handleImport() {
+        this.upload.title = "用户导入";
+        this.upload.open = true;
+      },
+      /** 下载模板操作 */
+      importTemplate() {
+        importTemplate().then(response => {
+          this.download(response.msg);
+        });
+      },
+      // 文件上传中处理
+      handleFileUploadProgress(event, file, fileList) {
+        this.upload.isUploading = true;
+      },
+      // 文件上传成功处理
+      handleFileSuccess(response, file, fileList) {
+        this.upload.open = false;
+        this.upload.isUploading = false;
+        this.$refs.upload.clearFiles();
+        // this.msgSuccess("导入成功");
+        this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+        this.dutyList = [];
+        this.getList();
+      },
+      // 提交上传文件
+      submitFileForm() {
+        this.$refs.upload.submit();
+      },
+
       handleSelect() {
         this.$refs.selectUserByDept.childOpen=true;
         this.open = true;
@@ -441,6 +529,24 @@
         this.queryParams.endTime = undefined;
         this.getselMonth();
       },
+      /** 导出按钮操作 */
+      handleExport() {
+        const queryParams = this.queryParams;
+        this.$confirm('是否确认导出所有用户数据项?', "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }).then(function() {
+          return exportUser(queryParams);
+        }).then(response => {
+          this.download(response.msg);
+        }).catch(function() {});
+      },
+      /** 导入按钮操作 */
+      handleImport() {
+        this.upload.title = "用户导入";
+        this.upload.open = true;
+      },