From 4f259d2b56233867405751edc46099ff861ea7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E8=99=B9=E7=9D=BF?= <297504645@qq.com> Date: Thu, 25 Apr 2024 17:33:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90nev-pc=E3=80=91=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E9=80=80=E6=8B=86=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fe/PC/src/components/currenForm/index.vue | 1 + .../dismantle/StepsFormTree/index.vue | 452 +++++++------- ...{index_ischeck.vue => index_tabletree.vue} | 280 +++++---- .../dismantle/StepsFormTree/index_tree.vue | 549 ------------------ ...vue => customerDismantleJob-tabletree.vue} | 143 ++--- .../dismantle/customerDismantleJob-tree.vue | 515 ---------------- .../dismantle/customerDismantleJob.vue | 101 ++-- 7 files changed, 504 insertions(+), 1537 deletions(-) rename fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/{index_ischeck.vue => index_tabletree.vue} (73%) delete mode 100644 fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tree.vue rename fe/PC/src/views/finishedProductManage/dismantle/{customerDismantleJob-new.vue => customerDismantleJob-tabletree.vue} (80%) delete mode 100644 fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tree.vue diff --git a/fe/PC/src/components/currenForm/index.vue b/fe/PC/src/components/currenForm/index.vue index a213c38b8..d9b903d30 100644 --- a/fe/PC/src/components/currenForm/index.vue +++ b/fe/PC/src/components/currenForm/index.vue @@ -439,6 +439,7 @@ :loading="loading" :style="{float:item.float}" @click="submitForm(index,item)" + :disabled="item.disabled" >{{ item.label }} diff --git a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index.vue b/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index.vue index 1cbb113d4..381ceee59 100644 --- a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index.vue +++ b/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index.vue @@ -50,51 +50,36 @@ @submitForm="editFormClick(arguments)" > - - 父级物料代码:{{ propsData.details[0].itemCode }} - + + - - - - - - - - - {filterOptionSelectHandle(item,props,val,scope)}" - @filterClearHandle="(item)=>{filterClearHandle(item,scope)}" - > - - - + @check="handleNodeCheck" + :expand-on-click-node="false"> + + {{ data.itemCode }} + + {{ data.qty }} + + {filterOptionSelectHandle(item,props,val,data)}" + @filterClearHandle="(item)=>{filterClearHandle(item,data)}" + > + + + + @@ -138,9 +123,9 @@ 重新提交 - 上一步 + > --> 退出 @@ -177,7 +162,22 @@ export default { }else if(val == 1){ this.editHandle=[ { label: "上一步", name: "cancel" }, - { label: "提交", type: "primary", name: "determine" }, + { label: "提交", type: "primary", name: "determine",disabled:true }, + ]; + } + }, + // 是否可以提交 + canCommit(val){ + console.log(171,val) + if(val && this.active == 1){ + this.editHandle=[ + { label: "上一步", name: "cancel" }, + { label: "提交", type: "primary", name: "determine",disabled:false }, + ]; + }else{ + this.editHandle=[ + { label: "上一步", name: "cancel" }, + { label: "提交", type: "primary", name: "determine",disabled:true }, ]; } }, @@ -358,8 +358,10 @@ export default { parentId:'parentId', // id:'itemCode', // parentId:'parentCode', - children:'children' + children:'children', + parent:'parent' }, + canCommit:false, } }, mounted () { @@ -371,12 +373,94 @@ export default { } }, methods: { - // 勾选表格数据 - toggleSelection(rows,type){ + // 勾选tree数据 + toggleCheckSelect(rows,type){ rows.forEach(row => { row.isCheck = type - this.$refs.bomTree_Ref.toggleRowSelection(row,type); + this.$refs.bomTree_Ref.setChecked(row,type); }); + this.$nextTick(()=>{ + this.checkCanCommit() + }) + }, + // 1、勾选 ==> ①如果有子节点:全×;②如果有父节点:全×;③同级如果没有子集:勾选;④同级如果有子集:不管; + // 2、取消 ==> ①父级/子集不管;②同级如果没有子集:选×;③同级如果有子集:不管, + // 3、全选 ==> 最底层选中 + // 4、全不选 ==> 全不不选择 + handleNodeCheck(row,node){ + if(row.id == this.CreateFormData.details[0].id){ + // todo:根据当前项更新是否为全选 + // let _selectData = this.getBomAllSelect() + // // 如果没有选中:则为不是全选 + // if(_selectData.length <= 0){ this.isAllCheck = false } + // // 如果当前选项等于所有的最底层:则为是全选 + // let _selectsIds = [] + // _selectData.forEach(item=>{_selectsIds.push(item.id)}) + // let _lastData = this.getLastFloors(this.CreateFormData.details) + // let _lastIds = [] + // _lastData.forEach(item=>{_lastIds.push(item.id)}) + // if (_selectsIds.length !== _lastIds.length) { this.isAllCheck = false } + // console.log(403,_selectsIds.every((item) => _lastIds.includes(item))) + // if(_selectsIds.every((item) => _lastIds.includes(item))){ + // this.isAllCheck = false + // }else{ + // this.isAllCheck = true + // } + + // 全不选 + if(this.isAllCheck){ + this.isAllCheck = !this.isAllCheck + console.log("全不选") + this.$refs.bomTree_Ref.setCheckedKeys([]); + this.selectData = [] + this.setAllDataNotCheck() + this.$nextTick(()=>{ + this.checkCanCommit() + }) + } + // 全选 + else{ + this.isAllCheck = !this.isAllCheck + console.log("全选") + // 获取所有底层 + this.selectData = this.getLastFloors(this.CreateFormData.details) + this.$refs.bomTree_Ref.setCheckedKeys([]); + this.setAllDataNotCheck() + this.toggleCheckSelect(this.selectData,true) + } + }else{ + // 勾选 + if(node.checkedKeys.indexOf(row.id) >= 0){ + row.isCheck = true + console.log("勾选", row) + // 当前下所有的子集(包含子集的子集) + let _allChildren = this.getAllChildren(row[this.config.children], this.config.children) + // 当前下所有父节点(包括父级的父级) + let _allParents = this.getAllParents(row.parentId) + // 所有同级(无子集) + let _allPeerNoSon = this.getPeerByFilter(row,false) + this.$nextTick(()=>{ + // 1、如果有子节点:全× + if(_allChildren){ this.toggleCheckSelect(_allChildren,false) } + // 2、如果有父节点:全× + if(_allParents){ this.toggleCheckSelect(_allParents,false) } + // 3、所有同级(没有子集的):勾选 + if(_allPeerNoSon){ this.toggleCheckSelect(_allPeerNoSon,true) } + }) + } + // 取消勾选 + else { + console.log("取消勾选") + // 同级取消勾选 + row.isCheck = false + // 所有同级(无子集) + let _allPeerNoSon = this.getPeerByFilter(row,false) + this.$nextTick(()=>{ + // 所有同级(没有子集的):勾选 + if(_allPeerNoSon){ this.toggleCheckSelect(_allPeerNoSon,false) } + }) + } + } }, // filterSelect点击option事件 filterOptionSelectHandle(item,props,val,scope){ @@ -386,158 +470,63 @@ export default { filterClearHandle(item,scope){ this.$emit("clear", item,scope); }, - // 递归:获取所有同级 - findAllPeer(row,data){ - let _peerArr = null//同级 - if(!data){data = this.CreateFormData.details} - for(let i = 0;i 0){ - const _res = this.findAllPeer(row,data[i][this.config.children]) - if(_res) _peerArr = _res - } - } - } - console.log(405,_peerArr,row[this.config.parentId]) - return _peerArr - }, - // 递归:获取所有子集 - findChildren(row,data){ - let _childrenArr = null//子集 - if(!data){data = this.CreateFormData.details} - for(let i = 0;i { + allNodes.push(node); + if (node[childProperty]) { + getNodes(node[childProperty]); + } + }); + })(nodes); + return allNodes; + }, + // 获取当前的所有父节点(包括父级的父级) + getAllParents(id,list) { + if(!list){list = this.CreateFormData.details} + for (let i in list) { + if (list[i].id == id) { + return [list[i]] } - else{ - if(data[i][this.config.children] && data[i][this.config.children].length > 0){ - const _res = this.findChildren(row,data[i][this.config.children]) - if(_res) _childrenArr = _res + if (list[i][this.config.children]) { + let node = this.getAllParents(id,list[i][this.config.children]); + if (node !== undefined) { + return node.concat(list[i]) } } } - return _childrenArr }, - // 【选中】勾选递归:获取同级(同级下的chilred未被选中的) - findPeerForCheckHandle(row,data){ - // debugger - if(!data){data = this.CreateFormData.details} + // 所有同级(包含自己) + getAllPeer(row,data){ let _peerArr = null//同级 + if(!data){data = this.CreateFormData.details} for(let i = 0;i{ - if(item[this.config.children] && item[this.config.children].length > 0){ - let sonHasCheck = 0 - item[this.config.children].forEach(son=>{ - if(son.isCheck){sonHasCheck ++} - }) - if(sonHasCheck == 0){ - item.isCheck=true - _peerArr.push(item) - } - }else{ - item.isCheck=true - _peerArr.push(item) - } - }) + _peerArr = data[i][this.config.children]; break } - else { + else{ if(data[i][this.config.children] && data[i][this.config.children].length > 0){ - const _res = this.findPeerForCheckHandle(row,data[i][this.config.children]) + const _res = this.getAllPeer(row,data[i][this.config.children]) if(_res) _peerArr = _res } } } return _peerArr }, - // 获取父级 - findParentRow(row,data){ - if(!data){data = this.CreateFormData.details} - let _parentRow = null//父级 - for(let i = 0;i 0){ - const _res = this.findParentRow(row,data[i][this.config.children]) - if(_res) _parentRow = _res - } - } - } - return _parentRow - }, - // 1、选择的时候,同级默认选择,父级的同级(子集未被勾选的)默认选择 - // 2、取消勾选的时候,同级取消选择,父级的同级如果有被勾选,则父级默认选择 - // 3、全选,最底层选中 - // 4、全不选,全不不选择 - // 选择操作 - tableHandleSelect(selection, row){ - this.selectData = selection - const isCheck = selection.length && selection.indexOf(row) !== -1 - if(selection.length <= 0){} - if (isCheck) { - row.isCheck = true - console.log("勾选",selection, row) - let _peerArr = this.findPeerForCheckHandle(row) - let _parentRow = this.findParentRow(row) - let _parentPeerArr = _parentRow ? this.findPeerForCheckHandle(_parentRow) : [] - let _allCheck = [..._peerArr,..._parentPeerArr] - let _childrenArr = this.findChildren(row) - // 勾选时:依次为将同级+父级同级(子集未选中)选中,父级清空选中,子集清空 - this.$nextTick(()=>{ - // 1、同级+父级同级(子集未选中)选中 - if(_allCheck){ this.toggleSelection(_allCheck,true) } - // 2、父级清空选中 - this.toggleSelection([_parentRow],false) - // 3、子集清空 - if(_childrenArr){ this.toggleSelection(_childrenArr,false) } - }) - }else{ - // 同级取消勾选 - row.isCheck = false - console.log("取消勾选",selection, row) - let _peerArr = this.findAllPeer(row)//同级arr - let _parentRow = this.findParentRow(row)//父级row - let _parentPeerArr = _parentRow ? this.findAllPeer(_parentRow) : []//父级同级arr - // 判断父级的同级是否有选中 - let _parentPeerShow = 0 - _parentPeerArr.forEach(item=>{if(item.isCheck){_parentPeerShow ++}}) - // let _parentPeerSonArr = []//父级同级的子集arr - // if(_parentPeerArr){ - // _parentPeerArr.forEach(item=>{ - // if(this.findChildren(item)){ - // _parentPeerSonArr = [..._parentPeerSonArr,...this.findChildren(item)] - // } - // }) - // } - console.log("父节点",_parentRow) - console.log("父级同级",_parentPeerArr) - console.log("同级",_peerArr) - // 取消时:依次为同级取消选中,父级选中(如果父级的同级有选中,且不是最外层),父级的同级的子集取消选中 - this.$nextTick(()=>{ - // 1、同级取消选中 - if(_peerArr){ this.toggleSelection(_peerArr,false) } - console.log(111,this.CreateFormData.details) - // 2、父级选中(如果父级的同级有选中,且不是最外层) - if((_parentPeerShow > 0 || row.parentId == _parentRow.id) && _parentRow.id != _parentRow.parentId){ - this.toggleSelection([_parentRow],true) - } - // // 3、父级的同级的子集取消选中 - // if(_parentPeerSonArr){ - // this.toggleSelection(_parentPeerSonArr,false) - // } - }) - } + // 获取同级(有/无子级) + getPeerByFilter(row,hasSon){ + let childProperty = this.config.children + let _allPeer = this.getAllPeer(row)//所有同级 + let _peerExcSelf = _allPeer.filter(item=>{return item.id != row.id})//排除自己的所有同级 + //排除自己的且有子集的同级 + let _peerHasSon = _peerExcSelf.filter(item=>{return item[childProperty] && item[childProperty].length > 0}) + //排除自己的且无子集的同级 + let _peerNoSon = _peerExcSelf.filter(item=>{return !item[childProperty] || item[childProperty].length <= 0}) + return hasSon ? _peerHasSon : _peerNoSon }, // 获取最底层 getLastFloors(root, onePathDeep = 1, deepArr = []){ @@ -553,21 +542,45 @@ export default { } return deepArr; }, - // 全选操作 - tableHandleSelectAll(selection){ - this.isAllCheck = !this.isAllCheck - if(this.isAllCheck){ - console.log("全选",selection) - // 获取所有底层 - this.selectData = this.getLastFloors(this.CreateFormData.details) - this.$refs.bomTree_Ref.clearSelection(); - this.toggleSelection(this.selectData,true) - }else{ - console.log("全不选",selection) - this.$refs.bomTree_Ref.clearSelection(); - this.selectData = [] - this.CreateFormData.details.forEach(item=>{item.isCheck = false}) + // 全部ischeck更改为false + setAllDataNotCheck(data){ + if(!data)data = this.CreateFormData.details + data.forEach(item=>{ + item.isCheck = false; + if(item.children){ + this.setAllDataNotCheck(item.children) + } + }) + }, + // 检验是否可提交 + checkCanCommit(){ + let _allselect = this.getBomAllSelect() + console.log(540,_allselect) + if(_allselect.length <= 0){ + this.canCommit = false + return } + let _last = this.getLastFloors(this.CreateFormData.details) + let _isError = 0 + _last.forEach(last_item=>{ + let _currentAllParents = this.getAllParents(last_item.parentId) + // 如果最底层为勾选 + if(last_item.isCheck){ + _currentAllParents.forEach(parent_item=>{ + if(parent_item.isCheck)_isError++ + }) + } + // 如果底层未勾选 + else{ + let _parentIsCheck = 0 + _currentAllParents.forEach(parent_item=>{ + if(parent_item.isCheck)_parentIsCheck++ + }) + if(_parentIsCheck != 1){ _isError++ } + } + }) + console.log(547,_isError) + this.canCommit = (_isError == 0) }, //结束退出 close (val) { @@ -600,6 +613,7 @@ export default { this.loading = false }) }, + // 获取所有已选数据 getBomAllSelect(data){ if(!data){ data = this.CreateFormData.details @@ -613,7 +627,6 @@ export default { this.getBomAllSelect(item.children) } }) - console.log(616,this.selectData) return this.selectData }, editFormClick (val) { @@ -649,8 +662,6 @@ export default { parent.PalletlFunction(this.active).then(res => { // 针对特殊环境 跳过步骤 直接到最后完成 this.loading = false - console.log(6666,this.CreateFormData.details) - console.log(6666222,this.getBomAllSelect()) parent.stepsSubmit().then(res => { this.pageStatus = 'success' this.active++ @@ -691,6 +702,12 @@ export default { this.loading = false }) }, + resultToLast(){ + this.active--; + this.isAllCheck = false, + this.selectData = [], + this.setAllDataNotCheck() + }, //添加子表 openAddNew () { const parent = this.$parent @@ -717,12 +734,33 @@ export default { \ No newline at end of file diff --git a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_ischeck.vue b/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tabletree.vue similarity index 73% rename from fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_ischeck.vue rename to fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tabletree.vue index ad3a07c90..f073de763 100644 --- a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_ischeck.vue +++ b/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tabletree.vue @@ -138,9 +138,9 @@ 重新提交 - 上一步 + > --> 退出 @@ -177,7 +177,21 @@ export default { }else if(val == 1){ this.editHandle=[ { label: "上一步", name: "cancel" }, - { label: "提交", type: "primary", name: "determine" }, + { label: "提交", type: "primary", name: "determine",disabled:true }, + ]; + } + }, + // 是否可以提交 + canCommit(val){ + if(val && this.active == 1){ + this.editHandle=[ + { label: "上一步", name: "cancel" }, + { label: "提交", type: "primary", name: "determine",disabled:false }, + ]; + }else{ + this.editHandle=[ + { label: "上一步", name: "cancel" }, + { label: "提交", type: "primary", name: "determine",disabled:true }, ]; } }, @@ -358,8 +372,10 @@ export default { parentId:'parentId', // id:'itemCode', // parentId:'parentCode', - children:'children' + children:'children', + parent:'parent' }, + canCommit:false, } }, mounted () { @@ -371,11 +387,16 @@ export default { } }, methods: { + // 勾选表格数据 toggleSelection(rows,type){ rows.forEach(row => { + row.isCheck = type this.$refs.bomTree_Ref.toggleRowSelection(row,type); }); + this.$nextTick(()=>{ + this.checkCanCommit() + }) }, // filterSelect点击option事件 filterOptionSelectHandle(item,props,val,scope){ @@ -385,144 +406,99 @@ export default { filterClearHandle(item,scope){ this.$emit("clear", item,scope); }, - // 递归:获取所有同级 - findAllPeer(row,data,isCheck){ - let _peerArr = []//同级 - if(!data){data = this.CreateFormData.details} - for(let i = 0;i 0){ - const _res = this.findAllPeer(row,data[i][this.config.children],isCheck) - if(_res) _peerArr = _res - } - } - } - return _peerArr - }, - // 递归:获取所有子集 - findChildren(row,data,isCheck){ - let _childrenArr = []//子集 - if(!data){data = this.CreateFormData.details} - for(let i = 0;i { + allNodes.push(node); + if (node[childProperty]) { + getNodes(node[childProperty]); + } + }); + })(nodes); + return allNodes; + }, + // 获取当前的所有父节点(包括父级的父级) + getAllParents(id,list) { + if(!list){list = this.CreateFormData.details} + for (let i in list) { + if (list[i].id == id) { + return [list[i]] } - else{ - if(data[i][this.config.children] && data[i][this.config.children].length > 0){ - const _res = this.findChildren(row,data[i][this.config.children],isCheck) - if(_res) _childrenArr = _res + if (list[i][this.config.children]) { + let node = this.getAllParents(id,list[i][this.config.children]); + if (node !== undefined) { + return node.concat(list[i]) } } } - return _childrenArr }, - // 【选中】勾选递归:获取同级(同级下的chilred未被选中的) - findPeerForCheckHandle(row,data,isCheck){ - // debugger - if(!data){data = this.CreateFormData.details} + // 所有同级(包含自己) + getAllPeer(row,data){ let _peerArr = null//同级 + if(!data){data = this.CreateFormData.details} for(let i = 0;i{ - if(item[this.config.children] && item[this.config.children].length > 0){ - let sonHasCheck = 0 - item[this.config.children].forEach(son=>{ - if(son.isCheck){sonHasCheck ++} - }) - if(sonHasCheck == 0){ - item.isCheck=isCheck - _peerArr.push(item) - } - }else{ - item.isCheck=isCheck - _peerArr.push(item) - } - }) + _peerArr = data[i][this.config.children]; break } - else { + else{ if(data[i][this.config.children] && data[i][this.config.children].length > 0){ - const _res = this.findPeerForCheckHandle(row,data[i][this.config.children],isCheck) + const _res = this.getAllPeer(row,data[i][this.config.children]) if(_res) _peerArr = _res } } } return _peerArr }, - // 获取父级 - findParentRow(row,data,isCheck){ - if(!data){data = this.CreateFormData.details} - let _parentRow = null//父级 - for(let i = 0;i 0){ - const _res = this.findParentRow(row,data[i][this.config.children],isCheck) - if(_res) _parentRow = _res - } - } - } - return _parentRow - }, - // 1、选择的时候,同级默认选择,父级的同级(子集未被勾选的)默认选择 - // 2、取消勾选的时候,同级取消选择,父级的同级如果有被勾选,则父级默认选择 - // 3、全选,最底层选中 - // 4、全不选,全不不选择 - // 选择操作 todo:toggleSelection时候isCheck同步问题处理 + // 获取同级(有/无子级) + getPeerByFilter(row,hasSon){ + let childProperty = this.config.children + let _allPeer = this.getAllPeer(row)//所有同级 + let _peerExcSelf = _allPeer.filter(item=>{return item.id != row.id})//排除自己的所有同级 + //排除自己的且有子集的同级 + let _peerHasSon = _peerExcSelf.filter(item=>{return item[childProperty] && item[childProperty].length > 0}) + //排除自己的且无子集的同级 + let _peerNoSon = _peerExcSelf.filter(item=>{return !item[childProperty] || item[childProperty].length <= 0}) + return hasSon ? _peerHasSon : _peerNoSon + }, + // 1、勾选 ==> ①如果有子节点:全×;②如果有父节点:全×;③同级如果没有子集:勾选;④同级如果有子集:不管; + // 2、取消 ==> ①父级/子集不管;②同级如果没有子集:选×;③同级如果有子集:不管, + // 3、全选 ==> 最底层选中 + // 4、全不选 ==> 全不不选择 + // 选择操作 tableHandleSelect(selection, row){ - this.selectData = selection const isCheck = selection.length && selection.indexOf(row) !== -1 if(selection.length <= 0){} if (isCheck) { row.isCheck = true console.log("勾选",selection, row) - let _peerArr = this.findPeerForCheckHandle(row,false,true) - let _parentRow = this.findParentRow(row,false,false) - let _parentPeerArr = _parentRow ? this.findPeerForCheckHandle(_parentRow,false,true) : [] - let _allCheck = [..._peerArr,..._parentPeerArr] - let _childrenArr = this.findChildren(row,false,false) - // 勾选时:依次为将同级及父级同级选中,父级清空选中,子集清空 + // 当前下所有的子集(包含子集的子集) + let _allChildren = this.getAllChildren(row[this.config.children], this.config.children) + // 当前下所有父节点(包括父级的父级) + let _allParents = this.getAllParents(row.parentId) + // 所有同级(无子集) + let _allPeerNoSon = this.getPeerByFilter(row,false) this.$nextTick(()=>{ - this.toggleSelection(_allCheck,true) - this.toggleSelection([_parentRow],false) - this.toggleSelection(_childrenArr,false) + // 1、如果有子节点:全× + if(_allChildren){ this.toggleSelection(_allChildren,false) } + // 2、如果有父节点:全× + if(_allParents){ this.toggleSelection(_allParents,false) } + // 3、所有同级(没有子集的):勾选 + if(_allPeerNoSon){ this.toggleSelection(_allPeerNoSon,true) } }) }else{ // 同级取消勾选 row.isCheck = false - let _peerArr = this.findAllPeer(row,false,false)//同级arr - let _parentRow = this.findParentRow(row)//父级row - let _parentPeerArr = _parentRow ? this.findAllPeer(_parentRow,false,true) : []//父级同级arr - let _parentPeerSonArr = []//父级同级的子集arr - _parentPeerArr.forEach(item=>{ - _parentPeerSonArr = [..._parentPeerSonArr,...this.findChildren(item,false,false)] - }) - let _parentPeerShow = 0 - // 判断父级的同级是否有选中 - _parentPeerArr.forEach(item=>{ - if(item.isCheck){_parentPeerShow ++} - if(item.id == _parentRow.id){_parentPeerShow ++} - }) - console.log(517,_parentRow) - // 取消时:依次为同级取消选中,父级选中(如果父级的同级有选中,且不是最外层),父级的同级的子集取消选中 + console.log("取消勾选",selection, row) + // 所有同级(无子集) + let _allPeerNoSon = this.getPeerByFilter(row,false) this.$nextTick(()=>{ - this.toggleSelection(_peerArr,false) - if(_parentPeerShow > 0 && _parentRow.parentId != _parentRow.id)this.toggleSelection([_parentRow],true) - this.toggleSelection(_parentPeerSonArr,false) + // 所有同级(没有子集的):勾选 + if(_allPeerNoSon){ this.toggleSelection(_allPeerNoSon,false) } }) - console.log("取消勾选",selection, row) } }, // 获取最底层 @@ -539,6 +515,16 @@ export default { } return deepArr; }, + // 全部ischeck更改为false + setAllDataNotCheck(data){ + if(!data)data = this.CreateFormData.details + data.forEach(item=>{ + item.isCheck = false; + if(item.children){ + this.setAllDataNotCheck(item.children) + } + }) + }, // 全选操作 tableHandleSelectAll(selection){ this.isAllCheck = !this.isAllCheck @@ -547,16 +533,46 @@ export default { // 获取所有底层 this.selectData = this.getLastFloors(this.CreateFormData.details) this.$refs.bomTree_Ref.clearSelection(); - this.selectData.forEach(item=>{ - item.isCheck = true - this.$refs.bomTree_Ref.toggleRowSelection(item,true); - }) + this.toggleSelection(this.selectData,true) }else{ console.log("全不选",selection) this.$refs.bomTree_Ref.clearSelection(); this.selectData = [] - this.CreateFormData.details.forEach(item=>{item.isCheck = false}) + this.setAllDataNotCheck() + this.$nextTick(()=>{ + this.checkCanCommit() + }) + } + }, + // 检验是否可提交 + checkCanCommit(){ + let _allselect = this.getBomAllSelect() + console.log(540,_allselect) + if(_allselect.length <= 0){ + this.canCommit = false + return } + let _last = this.getLastFloors(this.CreateFormData.details) + let _isError = 0 + _last.forEach(last_item=>{ + let _currentAllParents = this.getAllParents(last_item.parentId) + // 如果最底层为勾选 + if(last_item.isCheck){ + _currentAllParents.forEach(parent_item=>{ + if(parent_item.isCheck)_isError++ + }) + } + // 如果底层未勾选 + else{ + let _parentIsCheck = 0 + _currentAllParents.forEach(parent_item=>{ + if(parent_item.isCheck)_parentIsCheck++ + }) + if(_parentIsCheck != 1){ _isError++ } + } + }) + console.log(547,_isError) + this.canCommit = (_isError == 0) }, //结束退出 close (val) { @@ -589,6 +605,22 @@ export default { this.loading = false }) }, + // 获取所有已选数据 + getBomAllSelect(data){ + if(!data){ + data = this.CreateFormData.details + this.selectData = [] + } + data.forEach(item=>{ + if(item.isCheck){ + this.selectData.push(item) + } + if(item.children){ + this.getBomAllSelect(item.children) + } + }) + return this.selectData + }, editFormClick (val) { // Moment(this.CreateFormData.arriveTime).format() // if (val[0] == 0) { @@ -662,6 +694,12 @@ export default { this.loading = false }) }, + resultToLast(){ + this.active--; + this.isAllCheck = false, + this.selectData = [], + this.setAllDataNotCheck() + }, //添加子表 openAddNew () { const parent = this.$parent @@ -688,4 +726,12 @@ export default { \ No newline at end of file diff --git a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tree.vue b/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tree.vue deleted file mode 100644 index b51983319..000000000 --- a/fe/PC/src/views/finishedProductManage/dismantle/StepsFormTree/index_tree.vue +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - 父级物料代码:{{ propsData.details[0].itemCode }} - - - {{ data.itemCode }} - - {{ data.qty }} - - {filterOptionSelectHandle(item,props,val,data)}" - @filterClearHandle="(item)=>{filterClearHandle(item,data)}" - > - - - - - - - - - - - - {{ item.label }} - - 退出 - - - - - - - 重新提交 - 上一步 - 退出 - - - - - - - - \ No newline at end of file diff --git a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-new.vue b/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tabletree.vue similarity index 80% rename from fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-new.vue rename to fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tabletree.vue index 637ff54f9..db538f510 100644 --- a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-new.vue +++ b/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tabletree.vue @@ -180,6 +180,7 @@ export default { locationErpCode:undefined, locationGroup:undefined, warehouseCode:undefined, + parentId:undefined }], successHandle:[ { @@ -189,8 +190,8 @@ export default { }) } ], - bomList:null, submitRes:null,//提交后结果 + getBomLoading:false,//获取bom列表加载 }; }, mounted () { @@ -198,7 +199,6 @@ export default { }, methods: { FormTreePush(item,props,val,scope){ - console.log(props) if(props.prop == "locationCode"){ scope.row.locationCode = val scope.row.locationArea = item.areaCode @@ -208,41 +208,39 @@ export default { } }, FormTreeClear(item,scope){ - console.log(item) if(item.prop == "locationCode"){ scope.row.locationCode = null } }, // bom递归生成树状节点 - buildTree(list){ - let pidStr = 'parentCode'; - let idStr = 'itemCode'; - let childrenStr = 'children'; + buildTree(jsonArr){ + // 存放的最终结果树数组 + const result = []; + const id = 'id'; + const parentId = 'parentId'; + const children = 'children'; + const len = jsonArr.length; - let listOjb = {}; // 用来储存{key: obj}格式的对象 - let treeList = []; // 用来储存最终树形结构数据的数组 - - // 将数据变换成{key: obj}格式,方便下面处理数据 - for (let i = 0; i < list.length; i++) { - listOjb[list[i][idStr]] = list[i] - } + // 遍历得到以id为键名的对象(建立整棵树的索引) + const hash = {}; + jsonArr.forEach(item => { + hash[item[id]] = item; + }); - for (let j = 0; j < list.length; j++) { - // 判断父级是否存在 - let haveParent = listOjb[list[j][pidStr]] - if (haveParent) { - // 如果有没有父级children字段,就创建一个children字段 - !haveParent[childrenStr] && (haveParent[childrenStr] = []) - // 在父级里插入子项 - haveParent[childrenStr].push(list[j]) + for (let j = 0; j < len; j++) { + jsonArr[j].parent = jsonArr[j - 1] + const jsonArrItem = jsonArr[j]; + const hashItem = hash[jsonArrItem[parentId]]; + if (hashItem) { + // 如果当前项还没有children属性,则添加该属性并设置为空数组 + !hashItem[children] && (hashItem[children] = []); + hashItem[children].push(jsonArrItem); } else { - // 如果没有父级直接插入到最外层 - treeList.push(list[j]) + result.push(jsonArrItem); } } - return treeList + return result; }, - drawerbuttonHandle(val){ // 执行 if (val == "handle") { @@ -259,6 +257,7 @@ export default { locationErpCode:undefined, locationGroup:undefined, warehouseCode:undefined, + parentId:undefined }] this.theEvent = "edit" this.displayDialog.newDialog = true @@ -321,62 +320,16 @@ export default { this.Loading.appMainLoading = false }) }, - // 检查递归 - checkSelectDG(list){ - for (let i = 0; i < list.length; i++) { - } - }, - // 提交前检查所选数据,同级选择等情况处理 - checkSelectData(){ - // todo:检查所选数据,同级选择等情况处理 - let _isSelectData = this.$refs.StepsFormTree_Ref.selectData - let _select_ids = [] - _isSelectData.forEach(item=>{_select_ids.push(item.id)}) - if(!_isSelectData || _isSelectData.length <= 0){ - this.$warningMsg("请选择数据") - return - } - // this.bomList.forEach(item=>{ - // if() - // }) - // this.checkSelectDG(_isSelectData) - console.log(111,_isSelectData) - console.log(222,this.bomList) - console.log(333,_select_ids) - return - this.submitHttp() - }, - // 提交请求 - submitHttp(){ - this.bomList.forEach((item,index)=>{ - let _item = { - itemCode: item.component, - qty: _tableList[index].qty, - locationCode: _tableList[index].rawLocationCode, - locationArea: _tableList[index].rawLocationArea, - locationGroup: _tableList[index].rawLocationGroup, - locationErpCode: _tableList[index].rawLocationErpCode, - warehouseCode: _tableList[index].warehouseCode, - } - _data.details[0].materialDetails.push(_item) - }) - this.Loading.appMainLoading = true - this.submitRes = null - productionRecycleJobHandle(_jobInfo.id,_data).then(res => { - this.Loading.appMainLoading = false - this.submitRes = res - resolve(); - }).catch(err => { - this.Loading.appMainLoading = false - reject(); - }) - }, stepsSubmit (val) { // 提交 return new Promise((resolve, reject) => { - let _tableList = this.CreateFormData.details + let _isSelectData = this.$refs.StepsFormTree_Ref.getBomAllSelect() + if(!_isSelectData || _isSelectData.length <= 0){ + this.$warningMsg("请选择数据") + return + } let _empty = 0 - _tableList.forEach(item=>{ + _isSelectData.forEach(item=>{ if(!item.locationCode || item.locationCode.length <= 0){ _empty ++ } @@ -390,7 +343,28 @@ export default { let _data = JSON.parse(JSON.stringify(_jobInfo)) _data.details[0].materialDetails = [],//目前规定明细中肯定只有一个子数据 _data.details[0].qty = Number(this.CreateFormData.qty) - this.checkSelectData() + _isSelectData.forEach((item,index)=>{ + let _item = { + itemCode: item.itemCode, + qty: item.qty, + locationCode: item.locationCode, + locationArea: item.locationArea, + locationGroup: item.locationGroup, + locationErpCode: item.locationErpCode, + warehouseCode: item.warehouseCode, + } + _data.details[0].materialDetails.push(_item) + }) + this.Loading.appMainLoading = true + this.submitRes = null + productionRecycleJobHandle(_jobInfo.id,_data).then(res => { + this.Loading.appMainLoading = false + this.submitRes = res + resolve(); + }).catch(err => { + this.Loading.appMainLoading = false + reject(); + }) }); }, stepsCloseHandle(data){ @@ -406,11 +380,13 @@ export default { let _itemInfo = this.propsData.details[0] getBomByComponentTree(_itemInfo.itemCode) .then(res=>{ - this.bomList = res this.Loading.appMainLoading = false if(res.length > 0){ + let _first = this.propsData.details[0] this.CreateFormData.details = [] + let _faterLevelId = null//获取最外层在bom中的ID res.forEach(item=>{ + if(item.product == _first.itemCode){ _faterLevelId = item.remark } let _item={ id:item.id, itemCode:item.component, @@ -422,16 +398,17 @@ export default { locationGroup:_itemInfo.rawLocationGroup, locationErpCode:_itemInfo.rawLocationErpCode, warehouseCode:_itemInfo.warehouseCode, + parentId:item.remark } this.CreateFormData.details.push(_item) }) - let _first = this.propsData.details[0] let _tree = [{ - id: _first.id, + id: _faterLevelId, itemCode: _first.itemCode, parentCode: _first.itemCode, isCheck: false, - children:this.buildTree(JSON.parse(JSON.stringify(this.CreateFormData.details))) + children:this.buildTree(JSON.parse(JSON.stringify(this.CreateFormData.details))), + parentId:_faterLevelId }] this.CreateFormData.details = _tree // this.CreateFormData.details = this.buildTree(JSON.parse(JSON.stringify(this.CreateFormData.details))) diff --git a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tree.vue b/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tree.vue deleted file mode 100644 index 11371bd6a..000000000 --- a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob-tree.vue +++ /dev/null @@ -1,515 +0,0 @@ - - - - - (displayDialog.detailsDialog = val)" - @drawerbutton="drawerbuttonHandle" - @handleCommand="drawerHandle" - @close-value="closeValue" - :tableColumns="detailsTableColumns" - :totalCount="totalCountDetails" - :MaxResultCount="MaxResultCountDetails" - @alterResultCountDetails="alterResultCountDetails" - @alertoldSkipCountDetails="alertoldSkipCountDetails" - :dropdownTabsData="[]" - :firstTabs="firstTabs" - > - - - - - - \ No newline at end of file diff --git a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob.vue b/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob.vue index 08d222a11..9f996c2a6 100644 --- a/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob.vue +++ b/fe/PC/src/views/finishedProductManage/dismantle/customerDismantleJob.vue @@ -169,7 +169,7 @@ export default { { type: "filterSelect", label: "目标库位", prop: "locationCode", optionsLabel: "name", optionsValue: "code", focus: (type,val) => { return this.getFilterList(type, val, "basedata/Location",this.isFilter("type", "5"))}, // searchButton: (val) => { this.showSerarchPage(val, 'basedata/Location', 'InventoryBalance', '库位选择', this.CreateFormData) }, - width:"auto", + width:"auto",size:'mini' }, ], childTableData:[{ @@ -190,7 +190,6 @@ export default { }) } ], - bomList:null, submitRes:null,//提交后结果 getBomLoading:false,//获取bom列表加载 }; @@ -200,19 +199,17 @@ export default { }, methods: { FormTreePush(item,props,val,scope){ - console.log(props) if(props.prop == "locationCode"){ - scope.row.locationCode = val - scope.row.locationArea = item.areaCode - scope.row.locationErpCode = item.erpLocationCode - scope.row.locationGroup = item.locationGroupCode - scope.row.warehouseCode = item.warehouseCode + scope.locationCode = val + scope.locationArea = item.areaCode + scope.locationErpCode = item.erpLocationCode + scope.locationGroup = item.locationGroupCode + scope.warehouseCode = item.warehouseCode } }, FormTreeClear(item,scope){ - console.log(item) if(item.prop == "locationCode"){ - scope.row.locationCode = null + scope.locationCode = null } }, // bom递归生成树状节点 @@ -323,64 +320,16 @@ export default { this.Loading.appMainLoading = false }) }, - // 检查递归 - checkSelectDG(list){ - for (let i = 0; i < list.length; i++) { - } - }, - // 提交前检查所选数据,同级选择等情况处理 - checkSelectData(){ - // todo:提交时候去掉父级物料代码的信息 - // todo:检查所选数据,同级选择等情况处理 - let _isSelectData = this.$refs.StepsFormTree_Ref.selectData - let _select_ids = [] - _isSelectData.forEach(item=>{_select_ids.push(item.id)}) - if(!_isSelectData || _isSelectData.length <= 0){ - this.$warningMsg("请选择数据") - return - } - console.log(111,_isSelectData) - console.log(222,this.bomList) - console.log(333,_select_ids) - // this.bomList.forEach(item=>{ - // if() - // }) - // this.checkSelectDG(_isSelectData) - return - this.submitHttp() - }, - // 提交请求 - submitHttp(){ - this.bomList.forEach((item,index)=>{ - let _item = { - itemCode: item.component, - qty: _tableList[index].qty, - locationCode: _tableList[index].rawLocationCode, - locationArea: _tableList[index].rawLocationArea, - locationGroup: _tableList[index].rawLocationGroup, - locationErpCode: _tableList[index].rawLocationErpCode, - warehouseCode: _tableList[index].warehouseCode, - } - _data.details[0].materialDetails.push(_item) - }) - this.Loading.appMainLoading = true - this.submitRes = null - productionRecycleJobHandle(_jobInfo.id,_data).then(res => { - this.Loading.appMainLoading = false - this.submitRes = res - resolve(); - }).catch(err => { - this.Loading.appMainLoading = false - reject(); - }) - }, stepsSubmit (val) { // 提交 return new Promise((resolve, reject) => { - let _tableList = this.CreateFormData.details + let _isSelectData = this.$refs.StepsFormTree_Ref.getBomAllSelect() + if(!_isSelectData || _isSelectData.length <= 0){ + this.$warningMsg("请选择数据") + return + } let _empty = 0 - console.log(381,_tableList) - _tableList.forEach(item=>{ + _isSelectData.forEach(item=>{ if(!item.locationCode || item.locationCode.length <= 0){ _empty ++ } @@ -394,7 +343,28 @@ export default { let _data = JSON.parse(JSON.stringify(_jobInfo)) _data.details[0].materialDetails = [],//目前规定明细中肯定只有一个子数据 _data.details[0].qty = Number(this.CreateFormData.qty) - this.checkSelectData() + _isSelectData.forEach((item,index)=>{ + let _item = { + itemCode: item.itemCode, + qty: item.qty, + locationCode: item.locationCode, + locationArea: item.locationArea, + locationGroup: item.locationGroup, + locationErpCode: item.locationErpCode, + warehouseCode: item.warehouseCode, + } + _data.details[0].materialDetails.push(_item) + }) + this.Loading.appMainLoading = true + this.submitRes = null + productionRecycleJobHandle(_jobInfo.id,_data).then(res => { + this.Loading.appMainLoading = false + this.submitRes = res + resolve(); + }).catch(err => { + this.Loading.appMainLoading = false + reject(); + }) }); }, stepsCloseHandle(data){ @@ -410,7 +380,6 @@ export default { let _itemInfo = this.propsData.details[0] getBomByComponentTree(_itemInfo.itemCode) .then(res=>{ - this.bomList = res this.Loading.appMainLoading = false if(res.length > 0){ let _first = this.propsData.details[0]