From 32a95699e59c5c65e18c08643266c9cbfa380ee4 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期五, 07 六月 2024 09:56:05 +0800
Subject: [PATCH] 优化设备明细、检验任务附件权限

---
 src/components/view/person-manage.vue |  259 +++++++++++++++++++++++----------------------------
 1 files changed, 119 insertions(+), 140 deletions(-)

diff --git a/src/components/view/person-manage.vue b/src/components/view/person-manage.vue
index 868ad70..5c39a75 100644
--- a/src/components/view/person-manage.vue
+++ b/src/components/view/person-manage.vue
@@ -119,8 +119,7 @@
       <el-row>
         <el-col :span="20">
           <el-input placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" suffix-icon="el-icon-search" v-model="search" size="small"
-            style="margin-bottom: 5px;" clearable @blur="searchFilter" @clear="searchFilter"
-            @keyup.enter.native="searchFilter()"></el-input>
+            style="margin-bottom: 5px;" clearable @clear="searchFilter" @keyup.enter.native="searchFilter()"></el-input>
         </el-col>
         <el-col :span="4" style="text-align: center;line-height: 30px;" v-if="addPower">
           <el-button type="primary" icon="el-icon-plus" size="mini" circle @click="handleAdd"></el-button>
@@ -128,8 +127,7 @@
       </el-row>
       <el-tree :data="list" ref="tree" :props="{ children: 'children', label: 'name' }" node-key="id"
         :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
-        @node-collapse="nodeClose" v-loading="treeLoad" :expand-on-click-node="false"
-        :default-expanded-keys="expandedKeys" :default-checked-keys="[1]">
+        @node-collapse="nodeClose" v-loading="treeLoad" :expand-on-click-node="false" default-expand-all>
         <div class="custom-tree-node" slot-scope="{ node, data }">
           <el-row style="width: 100%;">
             <el-col :span="21" :class="{sort:node.level>3}">
@@ -201,30 +199,29 @@
       </span>
     </el-dialog>
     <el-dialog title="鑾峰彇浜轰簨绯荤粺浜哄憳淇℃伅" :visible.sync="addthirdParty" width="70%">
-      <div class="body">
+      <div class="body" v-loading="thirdPartyLoading">
         <el-row>
-          <el-col :span="9" style="height: 70vh;overflow: hidden;">
+          <el-col :span="8" style="height: 70vh;overflow: hidden;" v-if="companiesList.length!=1">
             <el-input placeholder="杈撳叆鍏抽敭瀛楁悳绱�" v-model="search2" size="small" style="width: 90%;padding: 0 5% 10px 5%;"
-              clearable @blur="searchFilter2" @clear="searchFilter2" @keyup.enter.native="searchFilter2()">
+              clearable @clear="searchFilter2" @keyup.enter.native="searchFilter2()">
             </el-input>
-            <el-tree :data="datathirdParty" node-key="id" :props="defaultProps" @node-click="nodeClick2"
-              style="height: calc(100% - 42px);"
-              @node-expand="nodeOpen0" :filter-node-method="filterNode2" ref="tree2" highlight-current>
+            <el-tree :data="datathirdParty" node-key="companyId" :props="defaultProps" @node-click="nodeClick2"
+              style="height: calc(100% - 42px);" @node-expand="nodeOpen0" :filter-node-method="filterNode2" ref="tree2"
+              highlight-current>
             </el-tree>
           </el-col>
-          <el-col :span="15" style="height: 70vh;padding-left: 8px;">
-            <div class="search_thing" style="width: 360px;margin-bottom: 10px;">
-              <div class="search_label" style="width: 140px;">鍛樺伐鍙�/鍛樺伐濮撳悕锛�</div>
+          <el-col :span="companiesList.length==1?24:16" style="height: 70vh;padding-left: 8px;">
+            <div class="search_thing" style="width: 100%;margin-bottom: 10px;justify-content: right;">
+              <div class="search_label" style="width: 200px;">鍛樺伐鍙�/鍛樺伐濮撳悕锛�</div>
+              <div class="search_input" style="width: 250px;">
+                <el-input size="small" placeholder="璇疯緭鍏ュ伐鍙�/鍛樺伐濮撳悕" @clear="searchPerson" clearable v-model="userSearch2"
+                  @keyup.enter.native="searchPerson()"></el-input>
+              </div>
+              <!-- <div class="search_label" style="width: 200px;">鍛樺伐鍙凤細</div>
               <div class="search_input">
-                <el-input
-                size="small"
-                placeholder="璇疯緭鍏ュ伐鍙�/鍛樺伐濮撳悕"
-                @clear="searchPerson"
-                clearable
-                v-model="userSearch2"
-                @keyup.enter.native="searchPerson()">
-                <i slot="suffix" class="el-input__icon el-icon-search" style="cursor: pointer;" @click="searchPerson"></i></el-input>
-                </div>
+                <el-input size="small" placeholder="璇疯緭鍏ュ伐鍙�" @clear="searchPerson" clearable v-model="searchEmployeeID"
+                  @keyup.enter.native="searchPerson2()"></el-input>
+              </div> -->
             </div>
             <el-table height="67vh" border stripe :data="personList" v-loading="personLoad" ref="personTable"
               @selection-change="handleSelectionChange">
@@ -233,6 +230,8 @@
               <el-table-column prop="employeeID" label="鍛樺伐鍙�">
               </el-table-column>
               <el-table-column prop="name" label="鍛樺伐濮撳悕">
+              </el-table-column>
+              <el-table-column prop="department" label="閮ㄩ棬" min-width="200">
               </el-table-column>
               <el-table-column prop="isLive" label="宸插瓨鍦�" width="80" align="center">
                 <template slot-scope="scope">
@@ -265,7 +264,7 @@
         datathirdParty: [],
         defaultProps: {
           children: 'children',
-          label: 'label'
+          label: 'companyName'
         },
         addthirdParty: false,
         componentData: {
@@ -273,7 +272,7 @@
             name: null,
             state: null,
             company: null,
-            departId: null,
+            roleId: null,
             orderBy: {
               field: 'id',
               order: 'asc'
@@ -289,7 +288,9 @@
             font: '缂栬緫',
             type: 'text',
             method: 'doDiy',
-            field: ['createUserName', 'updateUserName', 'roleName', '瑙掕壊=roleId', '瀵嗙爜=password']
+            field: ['roleName', '瑙掕壊=roleId', '瀵嗙爜=password',
+              '濮撳悕EN=nameEn', '骞撮緞=age', '閭=email', '鍗曚綅=company', '绛惧悕=signatureUrl', '涓汉鐓х墖=pictureUrl'
+            ]
           }],
           tagField: {
             state: {
@@ -318,22 +319,11 @@
             },
             roleId: {
               select: []
-            }
-          },
-          /* cascaderField:{
-            departId:{
-              tree:[]
             },
-            // 瀛楁閰嶇疆
-            props:{
-              value:'id',
-              label:'name',
-              checkStrictly: true
-            }
-          }, */
+            company: {select: []}
+          },
           requiredAdd: ['account', 'name', 'state', 'roleId', 'password', 'nameEn', 'phone'],
           requiredUp: ['account', 'name', 'state', 'roleId', 'nameEn', 'phone'],
-          // disabledUp:['departId'],
           addUpload: ['pictureUrl', 'signatureUrl'],
           addUploadConfig: {
             accept: '.png, .jpg, .jpeg, .gif',
@@ -348,24 +338,24 @@
         delStandardTree: true,
         addDia0: false,
         addOb: {
-          fatherId: '',
+          fatherId: 10001,
           name: '',
         },
         search: null,
         list: [],
         selectTree: '',
         treeLoad: false,
-        expandedKeys: [],
         addLoad: false,
         personList: [],
-        personListCopy:[],
-        treeLoad: false,
+        personListCopy: [],
         personLoad: false,
         search2: '',
         multipleSelection: [],
-        companiesList:[],
+        companiesList: [],
         currentCompaniesList: [],
-        userSearch2:''
+        userSearch2: '',
+        searchEmployeeID: null,
+        thirdPartyLoading:false
       }
     },
     // watch: {
@@ -374,47 +364,44 @@
     mounted() {
       this.selectTreeList()
       this.selectRole()
+      this.selectCustomEnum()
       this.entityCopy = this.HaveJson(this.componentData.entity)
       this.getPower()
     },
     methods: {
       openthirdParty() {
         this.addthirdParty = true;
+        this.thirdPartyLoading = true;
         this.$axios.get(this.$api.companies.selectCompaniesList).then(res => {
-          this.companiesList = JSON.parse(JSON.stringify(res.data));
-          this.datathirdParty = []
-          for (let ai = 0; ai < res.data.length; ai++) {
-            let a = res.data[ai]
-            if (a.parentCompanyId === 'ROOT') {
-              this.datathirdParty.push({
-                id: a.companyId,
-                label: a.companyName,
-                children: []
-              })
-              res.data.splice(ai, 1)
-              ai--
-            } else {
-              this.getOrganizational(a, ai, this.datathirdParty, res.data)
-            }
-          }
-        })
-      },
-      getOrganizational(a, ai, children, list) {
-        for (let bi = 0; bi < children.length; bi++) {
-          let b = children[bi]
-          if (a.parentCompanyId === b.id) {
-            b.children.push({
-              id: a.companyId,
-              label: a.companyName,
-              children: []
+          this.companiesList = this.HaveJson(res.data);
+          if(this.companiesList.length ==1){
+            this.$axios.post(this.$api.companies.selectSimpleList, {
+              companyId: this.companiesList[0].companyId
+            }).then(res => {
+              this.thirdPartyLoading = false;
+              this.personListCopy = JSON.parse(JSON.stringify(res.data))
+              this.personList = res.data
+              this.$refs.personTable.doLayout()
             })
-            list.splice(ai, 1)
-            ai--
-            break
-          } else {
-            this.getOrganizational(a, ai, b.children, list)
+          }else{
+            this.thirdPartyLoading = false;
           }
-        }
+          this.datathirdParty = this.tranListToTreeData(res.data, "ROOT");
+        })
+        if(this.componentData.entity.roleId > 10000)this.$message.warning('鐢变簬鏈�変腑鍏蜂綋瑙掕壊锛屾柊澧炵敤鎴峰皢鎴愪负榛樿瑙掕壊')
+      },
+      tranListToTreeData(list, rootValue) {
+        const arr = [];
+        list.forEach((item) => {
+          if (item.parentCompanyId === rootValue) {
+            const children = this.tranListToTreeData(list, item.companyId);
+            if (children.length) {
+              item.children = children;
+            }
+            arr.push(item);
+          }
+        });
+        return arr;
       },
       refreshTable() {
         this.$refs['ValueTable'].selectList()
@@ -437,18 +424,8 @@
         })
       },
       opeaAdd() {
-        if (!this.addOb.fatherId || this.selectTree == '' || this.selectTree == '鍏ㄩ儴') {
-          this.$message.error('璇烽�夋嫨涓�涓粍缁�')
-          return
-        }
         this.$refs.ValueTable.openAddDia(this.$api.user.addUser);
         this.$refs['ValueTable'].upData.departId = this.selectTree
-      },
-      selectTreeList() {
-        /* this.$axios.get(this.$api.department.selectDepartment).then(res => {
-          this.componentData.cascaderField.departId.tree = this.handleTree(res.data[0].children)
-				}) */
-        this.$refs.ValueTable.selectList()
       },
       handleTree(arr) {
         arr.forEach(a => {
@@ -489,11 +466,7 @@
         this.addUserPower = addUserPower
       },
       handleAdd() {
-        if (this.addOb.fatherId||this.addOb.name=='鍏ㄩ儴') {
-          this.addDia0 = true;
-        } else {
-          this.$message.error('璇烽�夋嫨涓�涓灦鏋勫眰绾�')
-        }
+        this.addDia = true;
       },
       searchFilter() {
         this.$refs.tree.filter(this.search)
@@ -502,13 +475,12 @@
         this.$refs.tree2.filter(this.search2)
       },
       filterNode(value, data) {
-        console.log(data);
         if (!value) return true;
         return data.name.indexOf(value) !== -1;
       },
       filterNode2(value, data) {
         if (!value) return true;
-        return data.label.indexOf(value) !== -1;
+        return data['companyName'].indexOf(value) !== -1;
       },
       handleNodeClick(val, node, el) { //鏍戠殑鍊�
         this.selectTree = ''
@@ -520,24 +492,17 @@
           data2 += " - " + data[index]
         }
         this.selectTree = data2.replace(' - ', '')
-        this.addOb.fatherId = val.id;
-        this.componentData.entity.departId = val.id;
+        this.componentData.entity.roleId = val.id;
         this.refreshTable()
       },
       nodeOpen(data, node, el) {
         $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder-opened')
       },
-      nodeOpen0(data, node, el){
-        this.currentCompaniesList[node.level-1] = data.id
+      nodeOpen0(data, node, el) {
+        this.currentCompaniesList[node.level - 1] = data.id
       },
       nodeClose(data, node, el) {
         $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder')
-      },
-      getNodeParent(val) {
-        if (val.parent != null) {
-          this.selectTree += ' - ' + val.label
-          this.getNodeParent(val.parent)
-        }
       },
       remove(node, data) {
         this.$confirm("鏄惁鍒犻櫎璇ュ眰绾�", "鎻愮ず", {
@@ -557,16 +522,8 @@
         this.treeLoad = true
         this.$axios.get(this.$api.department.selectDepartment).then(res => {
           this.list = res.data
-          this.list.forEach(a => {
-            a.children.forEach(b => {
-              b.children.forEach(c => {
-                this.expandedKeys.push(c.id)
-              })
-            })
-          })
           this.treeLoad = false
-          this.componentData.entity.departId = this.list[0].id;
-          this.selectTree = '鍏ㄩ儴'
+          this.componentData.entity.roleId = this.list[0].id;
           this.refreshTable()
         })
       },
@@ -586,22 +543,21 @@
             return
           }
           this.$message.success('娣诲姞鎴愬姛')
-          this.addDia0 = false
+          this.addDia = false
           this.selectTreeList()
           this.addLoad = false
           this.addOb.name = ''
-          this.addOb.fatherId = ''
         }).catch(e => {
-          this.addDia0 = false
+          this.addDia = false
           this.addLoad = false
         })
       },
       nodeClick2(ob, node, el) {
-        this.currentCompaniesList[node.level-1] = ob.id
-        if (ob.id !== 'SC21') {
+        this.getNodeParent(node)
+        if (ob.companyId !== 'SC21') {
           this.personLoad = true
           this.$axios.post(this.$api.companies.selectSimpleList, {
-            companyId: ob.id
+            companyId: ob.companyId
           }).then(res => {
             this.personListCopy = JSON.parse(JSON.stringify(res.data))
             this.personList = res.data
@@ -610,38 +566,38 @@
           })
         }
       },
+      getNodeParent(val) {
+        this.currentCompaniesList[val.level - 1] = val.data.companyId
+        if (val.parent != null) {
+          this.getNodeParent(val.parent)
+        }
+      },
       handleSelectionChange(val) {
         this.multipleSelection = val;
       },
-      addUser2(){
-        if(this.multipleSelection.length === 0){
+      addUser2() {
+        if (this.multipleSelection.length === 0) {
           return this.$message.error('璇烽�夋嫨浜哄憳')
         }
-        if(this.currentCompaniesList.length === 0){
+        if (this.currentCompaniesList.length === 0) {
           return this.$message.error('璇烽�夋嫨缁勭粐')
         }
-        for (let index = this.currentCompaniesList.length-1; index >1; index--) {
+        /* for (let index = this.currentCompaniesList.length-1; index >1; index--) {
           let obj = this.multipleSelection.find(a=>a.companyId==this.currentCompaniesList[index])
           if(!obj){
             this.currentCompaniesList.splice(index,1)
-          }else{
-            return
           }
-        }
+        } */
         let arr = []
-        this.currentCompaniesList.forEach(b=>{
-          this.companiesList.forEach(a=>{
-            if(a.companyId===b){
-              console.log(a)
-            }
-          })
-          let obj = this.companiesList.find(a=>a.companyId==b)
+        this.currentCompaniesList.forEach(b => {
+          let obj = this.companiesList.find(a => a.companyId == b)
           arr.push(obj)
-          })
+        })
         this.addLoad = true
         this.$axios.post(this.$api.companies.addPersonUser, {
           company: arr,
-          person: this.multipleSelection
+          person: this.multipleSelection,
+          roleId: this.componentData.entity.roleId
         }, {
           headers: {
             'Content-Type': 'application/json'
@@ -652,22 +608,45 @@
             return
           }
           this.$message.success('鎿嶄綔鎴愬姛')
-          this.refresh()
           this.multipleSelection = []
           this.$refs.personTable.clearSelection()
-          this.addthirdParty = false
+          this.addLoad = false
+          this.userSearch2 = ''
+          this.selectTreeList()
         }).catch(e => {
-          this.addthirdParty = false
           this.addLoad = false
         })
       },
-      searchPerson(){
+      searchPerson() {
         let arr = JSON.parse(JSON.stringify(this.personListCopy))
-        this.personList = arr.filter(a=>{
-          if(a.employeeID.includes(this.userSearch2)||a.name.includes(this.userSearch2)){
+        this.personList = arr.filter(a => {
+          if (a.employeeID.includes(this.userSearch2) || a.name.includes(this.userSearch2)) {
             return true
           }
         })
+      },
+      searchPerson2(){
+        if(this.searchEmployeeID===null||this.searchEmployeeID===''){
+          this.searchPerson()
+          return
+        }
+        this.$axios.post(this.$api.companies.selectPersonUser, {
+          code: this.searchEmployeeID
+        }).then(res=>{
+          this.personList = []
+          this.personList.push(res.data)
+        })
+      },
+      selectCustomEnum(){
+        this.$axios.get(this.$api.user.selectCustomEnum).then(res=>{
+          this.componentData.selectField.company.select = []
+          res.data.forEach(a=>{
+            this.componentData.selectField.company.select.push({
+              label: a.company,
+              value: a.id
+            })
+          })
+        })
       }
     }
   }

--
Gitblit v1.9.3