From 80c7b8f79ebd7b053a59d2fca99b90db66798f0c Mon Sep 17 00:00:00 2001 From: value <z1292839451@163.com> Date: 星期四, 30 五月 2024 22:36:12 +0800 Subject: [PATCH] 大改客户和用户 --- src/components/view/person-manage.vue | 195 ++++++++++++++++++++++-------------------------- 1 files changed, 90 insertions(+), 105 deletions(-) diff --git a/src/components/view/person-manage.vue b/src/components/view/person-manage.vue index 5938846..780fe23 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}"> @@ -203,28 +201,27 @@ <el-dialog title="鑾峰彇浜轰簨绯荤粺浜哄憳淇℃伅" :visible.sync="addthirdParty" width="70%"> <div class="body"> <el-row> - <el-col :span="9" style="height: 70vh;overflow: hidden;"> + <el-col :span="8" style="height: 70vh;overflow: hidden;"> <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="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' @@ -290,7 +289,8 @@ type: 'text', method: 'doDiy', field: ['roleName', '瑙掕壊=roleId', '瀵嗙爜=password', - '濮撳悕EN=nameEn','骞撮緞=age','閭=email','鍗曚綅=company','绛惧悕=pictureUrl','鏈汉鐓�=signatureUrl'] + '濮撳悕EN=nameEn', '骞撮緞=age', '閭=email', '鍗曚綅=company', '绛惧悕=pictureUrl', '鏈汉鐓�=signatureUrl' + ] }], tagField: { state: { @@ -319,7 +319,8 @@ }, roleId: { select: [] - } + }, + company: {select: []} }, /* cascaderField:{ departId:{ @@ -349,24 +350,24 @@ delStandardTree: true, addDia0: false, addOb: { - fatherId: '', + fatherId: 10001, name: '', }, search: null, list: [], selectTree: '', treeLoad: false, - expandedKeys: [], addLoad: false, personList: [], - personListCopy:[], + personListCopy: [], treeLoad: false, personLoad: false, search2: '', multipleSelection: [], - companiesList:[], + companiesList: [], currentCompaniesList: [], - userSearch2:'' + userSearch2: '', + searchEmployeeID: null } }, // watch: { @@ -375,6 +376,7 @@ mounted() { this.selectTreeList() this.selectRole() + this.selectCustomEnum() this.entityCopy = this.HaveJson(this.componentData.entity) this.getPower() }, @@ -382,40 +384,23 @@ openthirdParty() { this.addthirdParty = 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) - } - } + this.companiesList = this.HaveJson(res.data); + this.datathirdParty = this.tranListToTreeData(res.data, "ROOT"); }) + if(this.componentData.entity.roleId > 10000)this.$message.warning('鐢变簬鏈�変腑鍏蜂綋瑙掕壊锛屾柊澧炵敤鎴峰皢鎴愪负榛樿瑙掕壊') }, - 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: [] - }) - list.splice(ai, 1) - ai-- - break - } else { - this.getOrganizational(a, ai, b.children, list) + 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() @@ -438,10 +423,6 @@ }) }, 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 }, @@ -490,13 +471,7 @@ this.addUserPower = addUserPower }, handleAdd() { - console.log(`output->this.addOb.fatherId`,this.addOb.fatherId) - console.log(`output->this.addOb.name`,this.addOb.name) - if (this.addOb.fatherId||this.addOb.name=='鍏ㄩ儴') { - this.addDia = true; - } else { - this.$message.error('璇烽�夋嫨涓�涓灦鏋勫眰绾�') - } + this.addDia = true; }, searchFilter() { this.$refs.tree.filter(this.search) @@ -505,13 +480,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 = '' @@ -523,15 +497,14 @@ 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') @@ -560,16 +533,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() }) }, @@ -593,7 +558,6 @@ this.selectTreeList() this.addLoad = false this.addOb.name = '' - this.addOb.fatherId = '' }).catch(e => { this.addDia = false this.addLoad = false @@ -601,10 +565,10 @@ }, nodeClick2(ob, node, el) { this.getNodeParent(node) - if (ob.id !== 'SC21') { + 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 @@ -613,20 +577,20 @@ }) } }, - getNodeParent(val){ - this.currentCompaniesList[val.level-1] = val.data.id - if(val.parent!=null){ + 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--) { @@ -636,14 +600,15 @@ } } */ let arr = [] - this.currentCompaniesList.forEach(b=>{ - 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' @@ -656,23 +621,43 @@ this.$message.success('鎿嶄綔鎴愬姛') this.multipleSelection = [] this.$refs.personTable.clearSelection() - this.addthirdParty = false this.addLoad = false - this.personList = [] 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