Lijy 1 год назад
Родитель
Сommit
b06d8c4f03

+ 128 - 67
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/components/chooseSomeone.vue

@@ -1,8 +1,8 @@
 <template>
   <div class="chooseSomeone">
     <div class="chooseSomeone_selsect">
-      <van-search v-model="selectValue" shape="round" background="#F4F4F4" placeholder="请输入姓名"
-        @search="onSearch"></van-search>
+      <van-search v-model.trim="selectValue" shape="round" background="#F4F4F4" placeholder="请输入姓名" @search="onSearch"
+        @input="onSearch"></van-search>
     </div>
     <div class="chooseSomeone_Con contentRoll">
       <!-- 单选 -->
@@ -27,15 +27,23 @@
 
       <!-- tree -->
       <div class="treeBox" v-if="newGroupView == 3">
-        <div class="treeBox_tree_text" v-if="!newGroupViewBack && groupView" @click="newGroupViewBackCli(true, groupView)"><van-icon name="arrow-left"/>返回</div>
+        <div class="treeBox_tree_text" v-if="!newGroupViewBack && groupView"
+          @click="newGroupViewBackCli(true, groupView)"><van-icon name="arrow-left" />返回</div>
         <div class="treeBox_tree">
-          <el-tree v-model="treeVal" show-checkbox node-key="id" :data="personnelTree" :props="defaultProps"></el-tree>
+          <el-tree ref="tree" v-model="treeVal" show-checkbox node-key="id" :data="personnelTree" :props="defaultProps"
+            :filter-node-method="filterNode">
+            <span class="custom-tree-node" slot-scope="{ node, data }">
+              <span>
+                {{ node.label }}
+              </span>
+            </span>
+          </el-tree>
         </div>
       </div>
     </div>
     <div class="chooseSomeone_btn" v-if="newGroupViewBack">
       <van-button round size="small" v-if="newGroupViewBack" @click="newGroupViewBackCli(false, 3)">从其他工位选择员工</van-button>
-      <van-button round type="info" size="small"  @click="handClick()">确定</van-button>
+      <van-button round type="info" size="small" :loading="loadingBtn" @click="handClick()">确定</van-button>
     </div>
     <div class="chooseSomeone_btn" v-if="!newGroupViewBack">
       <van-button round type="info" size="small" style="width: 100%;">确定</van-button>
@@ -44,6 +52,14 @@
 </template>
 
 <script>
+/**
+ * peopleList 数据格式要求
+ * 传过来的数据必须包含 以下四个字段
+ * id: 人员id
+ * name: 人员姓名
+ * phone: 人员电话
+ * jobNumber: 人员工号
+ */
 export default {
   props: {
     groupView: {
@@ -58,8 +74,9 @@ export default {
       type: Array,
       default: () => []
     },
-    teamAllocation:{
-      type: Function
+    peopleListId: { // 选中的Id
+      type: Array,
+      default: () => []
     },
   },
   components: {},
@@ -71,41 +88,8 @@ export default {
       treeVal: [],
       // 人员数组
       personnelList: [],
-      personnelTree: [{
-        label: '一级 1',
-        children: [{
-          label: '二级 1-1',
-          children: [{
-            label: '三级 1-1-1'
-          }]
-        }]
-      }, {
-        label: '一级 2',
-        children: [{
-          label: '二级 2-1',
-          children: [{
-            label: '三级 2-1-1'
-          }]
-        }, {
-          label: '二级 2-2',
-          children: [{
-            label: '三级 2-2-1'
-          }]
-        }]
-      }, {
-        label: '一级 3',
-        children: [{
-          label: '二级 3-1',
-          children: [{
-            label: '三级 3-1-1'
-          }]
-        }, {
-          label: '二级 3-2',
-          children: [{
-            label: '三级 3-2-1'
-          }]
-        }]
-      }],
+      personnelTree: [],
+      newPersonnelTree: [],
       defaultProps: {
         children: 'children',
         label: 'label'
@@ -113,19 +97,54 @@ export default {
 
       newGroupView: '', // 组件传过来的值
       newGroupViewBack: '', // 组件传过来的值
+
+      loadingBtn: false // 确定按钮loading
     };
   },
   computed: {},
-  watch: {},
+  watch: {
+    selectValue(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
   created() { },
-  mounted() { 
-    this.newGroupView = JSON.parse(JSON.stringify(this.groupView)) 
+  mounted() {
+    this.newGroupView = JSON.parse(JSON.stringify(this.groupView))
     this.newGroupViewBack = JSON.parse(JSON.stringify(this.groupViewBack))
     this.personnelList = JSON.parse(JSON.stringify(this.peopleList))
-   },
+    let newPpeopleListId = JSON.parse(JSON.stringify(this.peopleListId))
+    if (newPpeopleListId.length > 0) {
+      if (this.groupView == 1) {
+        this.radioVal = newPpeopleListId[0]
+      } else if (this.groupView == 2) {
+        this.groupVal = newPpeopleListId
+      } else if (this.groupView == 3) {
+        // tree 额外处理
+        console.log('tree 额外处理')
+      }
+    }
+    console.log(this.groupVal)
+    if (this.peopleList.length <= 0) {
+      this.getPeople()
+    }
+    this.getDepartmentPersonnel()
+  },
   methods: {
     onSearch() {
-      console.log('搜索', this.selectValue)
+      if (!this.selectValue) {
+        this.personnelList = JSON.parse(JSON.stringify(this.peopleList))
+        return
+      }
+      if (this.groupView != 3) {
+        this.personnelList = this.personnelList.filter(item => {
+          return item.name.indexOf(this.selectValue) != -1 || item.jobNumber.indexOf(this.selectValue) != -1
+        })
+      }
+      console.log(this.personnelList)
+    },
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
     },
     newGroupViewBackCli(flg, i) {
       this.newGroupViewBack = flg
@@ -134,26 +153,66 @@ export default {
     // 获取所有人员
     getPeople() {
       this.$axios.post('/user/getSimpleActiveUserList', {})
-      .then(res => {
-        if (res.code == "ok") {
-          if(!this.peopleList) {
-            this.peopleList = res.data.map(item => {
-              return {
-                name: item.name,
-                id: item.id,
-                phone: item.phone,
-                jobNumber: item.jobNumber
-              }
-            })
+        .then(res => {
+          if (res.code == "ok") {
+            if (!this.peopleList) {
+              this.peopleList = res.data.map(item => {
+                return {
+                  name: item.name,
+                  id: item.id,
+                  phone: item.phone,
+                  jobNumber: item.jobNumber
+                }
+              })
+            }
+          } else {
+            this.$toast.clear();
+            this.$toast.fail(res.msg);
           }
-        } else {
-          this.$toast.clear();
-          this.$toast.fail(res.msg);
+        }).catch(err => { this.$toast.clear(); });
+    },
+    // 获取部门人员
+    getDepartmentPersonnel() {
+      this.$axios.post('/department/listAllMemb', {})
+        .then(res => {
+          if (res.code == "ok") {
+            let list = res.data;
+            this.setUserToDept(res.data)
+            this.personnelTree = list
+            this.newPersonnelTree = JSON.parse(JSON.stringify(list))
+            console.log(this.personnelTree)
+          } else {
+            this.$toast.clear();
+            this.$toast.fail(res.msg);
+          }
+        }).catch(err => { this.$toast.clear(); });
+    },
+    // 递归设置人员到部门
+    setUserToDept(list) {
+      for (var i in list) {
+        if (list[i].children != null) {
+          this.setUserToDept(list[i].children);
+        }
+
+        if (list[i].userList != null) {
+          if (list[i].children == null) {
+            list[i].children = [];
+          }
+          list[i].userList.forEach(element => {
+            var obj = { id: element.id, label: element.name, parentId: element.departmentId, isUser: 1 };
+            list[i].children.push(obj);
+          });
         }
-      }).catch(err => { this.$toast.clear(); });
+      }
     },
-    handClick () {
-      this.teamAllocation(this.groupVal); 
+    // 单选和复选点击确定触发的事件
+    handClick() {
+      let arr = this.groupView == 1 ? [this.radioVal] : this.groupVal
+      let newArr = this.personnelList.filter(item => {
+        return arr.includes(item.id)
+      })
+      this.loadingBtn = true
+      this.$emit('ChooseSomeoneChanhe', newArr)
     }
   },
 };
@@ -189,12 +248,14 @@ export default {
       overflow-y: auto;
       padding: 10px;
     }
-    .treeBox_tree_text{
+
+    .treeBox_tree_text {
       font-size: 14px;
       color: #999;
       display: flex;
       align-items: center;
       padding: 8px;
+
       .van-icon {
         margin-right: 6px;
       }
@@ -205,6 +266,7 @@ export default {
       height: 30px;
     }
   }
+
   .chooseSomeone_Con {
     flex: 1;
     background-color: #fff;
@@ -255,5 +317,4 @@ export default {
       width: 48%;
     }
   }
-}
-</style>
+}</style>

+ 30 - 9
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/planView/todayPlan/distribution.vue

@@ -42,7 +42,7 @@
     </div>
     <!-- 弹出层选人 -->
     <van-popup v-model="popupShow" round position="bottom" :style="{ height: '80%',background: '#F4F4F4' }" >
-      <ChooseSomeone :groupView="2" :groupViewBack="true" :peopleList="peopleList" :teamAllocation="teamAllocation"></ChooseSomeone>
+      <ChooseSomeone ref="ChooseSomeone" :groupView="2" :groupViewBack="true" :peopleList="peopleList" @ChooseSomeoneChanhe="chooseSomeoneChanhe" :peopleListId="peopleListId"></ChooseSomeone>
     </van-popup>
   </div>
 </template>
@@ -65,6 +65,7 @@ export default {
       type: '', // 传过来的type
       departmentId: '', // 部门id
       peopleList: [], // 人员数据
+      peopleListId: [], // 回显人员ID
     };
   },
   computed: {},
@@ -93,6 +94,12 @@ export default {
       console.log('点击了下单计划')
     },
     distributionProp(item, index) {
+      console.log(item, index)
+      if(item.teamIds) {
+        this.peopleListId = item.teamIds.split(',')
+      } else {
+        this.peopleListId = []
+      }
       this.distributionIndex = index
       this.popupShow = true
     },
@@ -125,28 +132,42 @@ export default {
               jobNumber: item.jobNumber
             }
           })
-          console.log(this.peopleList, '人员数据')
         } else {
           this.$toast.clear();
           this.$toast.fail(res.msg);
         }
       }).catch(err => { this.$toast.clear(); });
     },
-    teamAllocation(groupVal){
-      var that=this;
-      this.$delete(this.distributionList[this.distributionIndex], 'prodProcedure')  
+    teamAllocation(item, nameArr){
+      let newDistributionList = JSON.parse(JSON.stringify(this.distributionList[this.distributionIndex]))
+      delete newDistributionList.prodProcedure
       this.$axios.post('/plan/teamAllocation', {
-        ...this.distributionList[this.distributionIndex],
-        teamIds:groupVal.join(",")
+        ...newDistributionList,
+        teamIds: item.join(","),
+        teamNames: nameArr.join(','),
       })
       .then(res => {
+        this.$refs.ChooseSomeone['loadingBtn'] = false
         if (res.code == "ok") {
-          that.popupShow = false
+          this.distributionList[this.distributionIndex].teamNames = nameArr.join(',')
+          this.popupShow = false
         } else {
           this.$toast.clear();
           this.$toast.fail(res.msg);
         }
-      }).catch(err => { this.$toast.clear(); });
+      }).catch(err => { this.$toast.clear();this.$refs.ChooseSomeone['loadingBtn'] = false});
+    },
+
+    // 选中人员
+    chooseSomeoneChanhe(item) {
+      // console.log('当前点击的人员', item, this.distributionList[this.distributionIndex])
+      let arr = item.map(item => {
+        return item.id
+      })
+      let nameArr = item.map(item => {
+        return item.name
+      })
+      this.teamAllocation(arr, nameArr)
     }
   },
 };

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet-workshop-h5/vue.config.js

@@ -7,8 +7,8 @@ const Timestamp = new Date().getTime();
 // var ip = '47.101.180.183'
 // var ip = '47.100.37.243'
 //var ip = '192.168.2.12'
-// var ip = '192.168.2.12'
- var ip = '127.0.0.1'
+var ip = '192.168.2.12'
+//  var ip = '127.0.0.1'
 
 
 // var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip

+ 10 - 10
fhKeeper/formulahousekeeper/timesheet-workshop/config/index.js

@@ -4,17 +4,17 @@ var path = require('path')
 //var ip = '47.101.180.183'
 // var ip = '47.100.37.243'
 // var ip = '192.168.10.2'
-// var ip = '192.168.2.13' 
+var ip = '192.168.2.12' 
 
-var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
-for (var i in ifaces) {
-    for (var j in ifaces[i]) {
-        var val = ifaces[i][j]
-        if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
-            ip = val.address
-        }
-    }
-}
+// var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
+// for (var i in ifaces) {
+//     for (var j in ifaces[i]) {
+//         var val = ifaces[i][j]
+//         if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
+//             ip = val.address
+//         }
+//     }
+// }
 // 1196735749
 module.exports = {
   build: {