jz.kai 4 jaren geleden
bovenliggende
commit
c33971fe5b

+ 9 - 1
src/api/base/workSchedule.js

@@ -29,6 +29,14 @@ function update(formModel){
   });
 }
 
+function updateCompany(formModel){  
+  return request.post(constant.serverUrl + "/base/workSchedule/updateCompany", formModel,{
+    headers: {
+      "Content-Type": "application/json"
+    }
+  });
+}
+
 function remove(id){
   return request.post(constant.serverUrl + "/base/workSchedule/delete/" + id);
 }
@@ -42,5 +50,5 @@ function batchRemove(idList){
 }
 
 export default {
-  pageList,create,edit,add,update,remove,batchRemove
+  pageList,create,edit,add,update,remove,batchRemove,updateCompany
 }

+ 1 - 1
src/routers/modules/base.js

@@ -593,7 +593,7 @@ var routers = [
                 component: () => import('@/views/base/workSchedule-list.vue'),
                 meta: {
                         roles: ["admin"],
-                        title: '精细化工考勤管理'
+                        title: '班次考勤设置'
                 }
         }
 ]

+ 235 - 0
src/views/base/workSchedule-company.vue

@@ -0,0 +1,235 @@
+
+<style scoped>
+.user-panel {
+  margin: 10px auto;
+}
+</style>
+<template>
+  <el-dialog
+    :visible.sync="showDialog"
+    :title="title"
+    :modal-append-to-body="false"
+    style="text-align: left"
+    @close="closeDialog"
+    :close-on-click-modal="false"
+  >
+    <div class="user-panel" v-loading="loading">
+      <el-form
+        ref="form"
+        :model="formModel"
+        :rules="ruleValidate"
+        :label-width="'120px'"
+      >
+        <el-form-item label="考勤部门" prop="clockIn">
+          <el-tree
+           v-model="formModel.clockIn"
+            :data="companyResultData"
+            show-checkbox
+            node-key="id"
+            ref="tree"
+            highlight-current
+            :props="companyProps">
+          </el-tree>
+        </el-form-item>
+      </el-form>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="closeDialog">取 消</el-button>
+      <el-button type="primary" @click="handleSubmit" :loading="submitting"
+        >确 定</el-button
+      >
+    </span>
+  </el-dialog>
+</template>
+<script>
+import Constant from "@/constant";
+import workScheduleApi from "@/api/base/workSchedule";
+import companyInfoApi from "@/api/base/companyInfo";
+
+export default {
+  props: ["businessKey", "title"],
+  data() {
+    return {
+      formModel: {},
+      ruleValidate: {
+        name: [
+          { required: true, message: "班次名称不能为空", trigger: "blur" },
+        ],
+        weekdays: [
+          { required: true, message: "周工作日不能为空", trigger: "blur" },
+        ],
+        startTime: [
+          { required: true, message: "上班时间不能为空", trigger: "blur" },
+        ],
+        startAdvanceMinutes: [
+          { required: true, message: "上班提前分钟不能为空", trigger: "blur" },
+        ],
+        startDelayMinutes: [
+          { required: true, message: "上班延迟分钟不能为空", trigger: "blur" },
+        ],
+        endTime: [
+          { required: true, message: "下班时间不能为空", trigger: "blur" },
+        ],
+        endAdvanceMinutes: [
+          { required: true, message: "下班提前分钟不能为空", trigger: "blur" },
+        ],
+        endDelayMinutes: [
+          { required: true, message: "下班延迟分钟不能为空", trigger: "blur" },
+        ],
+      },
+      showDialog: true,
+      loading: false,
+      submitting: false,
+      options: [
+        {
+          value: "1",
+          label: "周一"
+        },
+        {
+          value: "2",
+          label: "周二"
+        },
+        {
+          value: "3",
+          label: "周三"
+        },
+        {
+          value: "4",
+          label: "周四"
+        },
+        {
+          value: "5",
+          label: "周五"
+        },
+        {
+          value: "6",
+          label: "周六"
+        },
+        {
+          value: "7",
+          label: "星期天"
+        }
+      ],
+      companyResult: [],
+      companyProps: {
+        value: "id",
+        label: "name",
+        children: "children"
+      },
+    };
+  },
+  computed: {
+    /* 转树形数据 */
+    companyResultData() {
+      //第一个节点为根节点
+      if (this.companyResult.length > 0) {
+        var rootId = this.companyResult[0].id;
+
+        let cloneData = JSON.parse(JSON.stringify(this.companyResult)); // 对源数据深度克隆
+        return cloneData.filter(father => {
+          // 循环所有项,并添加children属性
+          let branchArr = cloneData.filter(
+            child => father.id == child.parentId
+          ); // 返回每一项的子级数组
+          branchArr.length > 0 ? (father.children = branchArr) : ""; //给父级添加一个children属性,并赋值
+          return father.id == rootId || father.parentId == null; //返回第一层
+        });
+      } else {
+        return [];
+      }
+    }
+  },
+  created() {
+    var self = this;
+
+    companyInfoApi.list({scope:"all"}).then(function(response) {
+      var jsonData = response.data;
+      if (jsonData.result) {
+        self.companyResult = jsonData.data;
+      }
+    });
+  },
+  methods: {
+    closeDialog() {
+      this.$emit("close", false);
+    },
+    handleSubmit() {
+      var self = this;
+      self.formModel.clockIn = this.$refs.tree.getCheckedKeys();
+      
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          (function () {
+            var id = self.formModel.id;
+
+            if (self.formModel.weekdays != null) {
+                var weekdays = self.formModel.weekdays.join(",");
+                self.formModel.weekdays = weekdays;
+            }
+
+            
+            if (self.formModel.clockIn != null) {
+                var clockIn = self.formModel.clockIn.join(",");
+                self.formModel.clockIn = clockIn;
+            }
+
+            return workScheduleApi.updateCompany(self.formModel);
+          })().then(function (response) {
+            var jsonData = response.data;
+
+            if (jsonData.result) {
+              self.$message({
+                message: "保存成功!",
+                type: "success",
+              });
+
+              self.$emit("close", true);
+            } else {
+              self.$message({
+                message: jsonData.message + "",
+                type: "warning",
+              });
+
+              self.$emit("close", false);
+            }
+          });
+        }
+      });
+    },
+  },
+  mounted: function () {
+    var self = this;
+
+    (function () {
+      if (self.businessKey.length == 0) {
+        return workScheduleApi.create();
+      } else {
+        return workScheduleApi.edit(self.businessKey);
+      }
+    })()
+      .then((response) => {
+        var jsonData = response.data;
+        self.loading = false;
+
+        if (jsonData.result) {
+          self.formModel = jsonData.data;
+
+          var weekdays = self.formModel.weekdays;
+          if (weekdays != null) {
+            self.formModel.weekdays = weekdays.split(",");
+          }
+
+          var clockIn = self.formModel.clockIn;
+          if (clockIn != null) {
+            this.$refs.tree.setCheckedKeys(clockIn.split(","));
+          }
+        } else {
+          self.$message.error(jsonData.message + "");
+        }
+      })
+      .catch((error) => {
+        self.$message.error(error + "");
+      });
+  },
+};
+</script>

+ 13 - 44
src/views/base/workSchedule-detail.vue

@@ -20,6 +20,15 @@
         :rules="ruleValidate"
         :label-width="'120px'"
       >
+        <el-form-item label="企业名称" prop="companyId">
+          <el-select-tree
+            :props="companyProps"
+            :options="companyResult"
+            v-model="formModel.companyId"
+            style="width: 300px"
+            size="mediumn"
+          ></el-select-tree>
+        </el-form-item>
         <el-form-item label="班次名称" prop="name">
           <el-input
             v-model="formModel.name"
@@ -87,17 +96,6 @@
             style="width: 300px"
           ></el-input>
         </el-form-item>
-        <el-form-item label="考勤部门" prop="clockIn">
-          <el-tree
-           v-model="formModel.clockIn"
-            :data="companyResultData"
-            show-checkbox
-            node-key="id"
-            ref="tree"
-            highlight-current
-            :props="companyProps">
-          </el-tree>
-        </el-form-item>
       </el-form>
     </div>
     <span slot="footer" class="dialog-footer">
@@ -112,6 +110,7 @@
 import Constant from "@/constant";
 import workScheduleApi from "@/api/base/workSchedule";
 import companyInfoApi from "@/api/base/companyInfo";
+import SelectTree from "@/components/SelectTree";
 
 export default {
   props: ["businessKey", "title"],
@@ -185,27 +184,6 @@ export default {
       },
     };
   },
-  computed: {
-    /* 转树形数据 */
-    companyResultData() {
-      //第一个节点为根节点
-      if (this.companyResult.length > 0) {
-        var rootId = this.companyResult[0].id;
-
-        let cloneData = JSON.parse(JSON.stringify(this.companyResult)); // 对源数据深度克隆
-        return cloneData.filter(father => {
-          // 循环所有项,并添加children属性
-          let branchArr = cloneData.filter(
-            child => father.id == child.parentId
-          ); // 返回每一项的子级数组
-          branchArr.length > 0 ? (father.children = branchArr) : ""; //给父级添加一个children属性,并赋值
-          return father.id == rootId || father.parentId == null; //返回第一层
-        });
-      } else {
-        return [];
-      }
-    }
-  },
   created() {
     var self = this;
 
@@ -222,7 +200,6 @@ export default {
     },
     handleSubmit() {
       var self = this;
-      self.formModel.clockIn = this.$refs.tree.getCheckedKeys();
       
       this.$refs["form"].validate((valid) => {
         if (valid) {
@@ -234,12 +211,6 @@ export default {
                 self.formModel.weekdays = weekdays;
             }
 
-            
-            if (self.formModel.clockIn != null) {
-                var clockIn = self.formModel.clockIn.join(",");
-                self.formModel.clockIn = clockIn;
-            }
-
             if (id == null || id.length == 0) {
               return workScheduleApi.add(self.formModel);
             } else {
@@ -289,11 +260,6 @@ export default {
           if (weekdays != null) {
             self.formModel.weekdays = weekdays.split(",");
           }
-
-          var clockIn = self.formModel.clockIn;
-          if (clockIn != null) {
-            this.$refs.tree.setCheckedKeys(clockIn.split(","));
-          }
         } else {
           self.$message.error(jsonData.message + "");
         }
@@ -302,5 +268,8 @@ export default {
         self.$message.error(error + "");
       });
   },
+  components: {
+    "el-select-tree": SelectTree
+  },
 };
 </script>

+ 20 - 2
src/views/base/workSchedule-list.vue

@@ -6,7 +6,7 @@
         <a href="#">系统管理</a>
       </el-breadcrumb-item>
       <el-breadcrumb-item>
-        <a href="/base/workSchedule">精细化工考勤管理</a>
+        <a href="/base/workSchedule">班次考勤设置</a>
       </el-breadcrumb-item>
     </el-breadcrumb>
     <el-divider></el-divider>
@@ -119,11 +119,14 @@
         label="下班延迟分钟"
         width="180"
       ></el-table-column>
-      <el-table-column label="操作" width="150" fixed="right">
+      <el-table-column label="操作" width="210" fixed="right">
         <template slot-scope="{ row }">
           <el-button size="mini" type="warning" @click="handleEdit(row)"
             >编辑</el-button
           >
+          <el-button size="mini" type="primary" @click="handleCompany(row)"
+            >部门</el-button
+          >
           <el-button size="mini" type="danger" @click="handleDelete(row)"
             >删除</el-button
           >
@@ -144,11 +147,18 @@
       :title="modalTitle"
       @close="onDetailModalClose"
     ></workSchedule-detail>
+    <workSchedule-company
+      v-if="showModal1"
+      :businessKey="businessKey"
+      :title="modalTitle"
+      @close="onDetailModalClose"
+    ></workSchedule-company>
   </div>
 </template>
 <script>
 import Constant from "@/constant";
 import WorkScheduleDetail from "./workSchedule-detail";
+import WorkScheduleCompany from "./workSchedule-company";
 import workScheduleApi from "@/api/base/workSchedule";
 import NProgress from "nprogress"; // progress bar
 import "nprogress/nprogress.css"; // progress bar style
@@ -188,6 +198,7 @@ export default {
       pageSizeList: [10, 20, 30],
       multipleSelection: [],
       showModal: false,
+      showModal1: false,
       modalTitle: "",
       businessKey: "",
     };
@@ -260,6 +271,11 @@ export default {
       this.businessKey = record.id;
       this.showModal = true;
     },
+    handleCompany(record) {
+      this.modalTitle = "部门";
+      this.businessKey = record.id;
+      this.showModal1 = true;
+    },
     handleDelete(record) {
       var self = this;
 
@@ -315,6 +331,7 @@ export default {
     onDetailModalClose(refreshed) {
       //保存成功后回调
       this.showModal = false;
+      this.showModal1 = false;
 
       if (refreshed) {
         this.changePage(this.pageIndex);
@@ -326,6 +343,7 @@ export default {
   },
   components: {
     "workSchedule-detail": WorkScheduleDetail,
+    "workSchedule-company": WorkScheduleCompany,
   },
 };
 </script>