Browse Source

优化

master
陈裕财 4 years ago
parent
commit
ed889aeec2
  1. 84
      src/common/js/treeTool.js
  2. 2
      src/views/xm/core/xmMenu/XmMenuAdd.vue
  3. 2
      src/views/xm/core/xmMenu/XmMenuEdit.vue
  4. 116
      src/views/xm/core/xmMenu/XmMenuMng.vue
  5. 52
      src/views/xm/core/xmProjectPhase/XmProjectPhaseMng.vue
  6. 32
      src/views/xm/core/xmTask/XmTaskMng.vue

84
src/common/js/treeTool.js

@ -1,52 +1,50 @@
export default { export default {
reloadAllChildren: function(table,maps, parentId,parentIdName,loadChildren) {
var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap
if (maps.get(parentId)) {
const { tree, treeNode, resolve } = maps.get(parentId)
lazyTreeNodeMap[parentId]=[]
if (tree) { // 重新执行父节点加载子级操作
loadChildren(tree, treeNode, resolve)
if (tree[parentIdName]) { // 若存在爷爷结点,则执行爷爷节点加载子级操作,防止最后一个子节点被删除后父节点不显示删除按钮
const a = maps.get(tree[parentIdName])
if(a && a.tree){
this.reloadAllChildren(table,maps,tree[parentIdName],parentIdName,loadChildren)
}
}
}
}
},
reloadChildrenByCount_:function(table,maps, parentId,parentIdName,loadChildren,toCount,currCount){
var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap
if (maps.get(parentId)) {
const { tree, treeNode, resolve } = maps.get(parentId)
lazyTreeNodeMap[parentId]=[]
if (tree) { // 重新执行父节点加载子级操作
loadChildren(tree, treeNode, resolve)
if(toCount==currCount+1){
return;
}
currCount=currCount+1;
if (tree[parentIdName]) { // 若存在爷爷结点,则执行爷爷节点加载子级操作,防止最后一个子节点被删除后父节点不显示删除按钮
const a = maps.get(tree[parentIdName])
if(a && a.tree){
this.reloadChildrenByCount_(table,maps,tree[parentIdName],parentIdName,loadChildren,toCount,currCount)
}
}
}
}
reloadAllChildren: function(table,maps, rows,parentIdName,loadChildren,idMaps) {
if(!rows||rows.length==0){
return;
}
if(!maps || maps.length==0){
return;
}
if(!table){
return;
}
var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap
var parentIds=rows.map(i=>i[parentIdName])
if(idMaps==null){
idMaps=new Map();
}
if(parentIds.length==0){
return;
}
parentIds.forEach(k=>{
if(!idMaps.has(k)){
idMaps.set(k,k);
if (maps.get(k)) {
const { tree, treeNode, resolve } = maps.get(k)
lazyTreeNodeMap[k]=[]
if (tree) { // 重新执行父节点加载子级操作
loadChildren(tree, treeNode, resolve)
if(tree[parentIdName]){
this.reloadAllChildren(table,maps, [tree],parentIdName,loadChildren,idMaps)
}
}
}
}
});
}, },
reloadChildren: function(table,maps, parentId,parentIdName,loadChildren,toCount) {
if(!toCount){
this.reloadAllChildren(table,maps, parentId,parentIdName,loadChildren)
}else{
this.reloadParentByCount_(table,maps,parentId,parentIdName,loadChildren,toCount,0)
}
},
reloadChildren: function(table,maps, parentId,parentIdName,loadChildren) {
var params={};
params[parentIdName]=parentId;
this.reloadAllChildren(table,maps, [params],parentIdName,loadChildren)
},
reloadChildrenByOpType: function(table,maps, parentId,parentIdName,loadChildren,opType) { reloadChildrenByOpType: function(table,maps, parentId,parentIdName,loadChildren,opType) {
var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap
if (maps.get(parentId)) { if (maps.get(parentId)) {

2
src/views/xm/core/xmMenu/XmMenuAdd.vue

@ -154,7 +154,7 @@
this.load.add=false this.load.add=false
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
this.$emit('submit');// @submit="afterAddSubmit"
this.$emit('submit',res.data.data);// @submit="afterAddSubmit"
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.add=false); }).catch( err => this.load.add=false);

2
src/views/xm/core/xmMenu/XmMenuEdit.vue

@ -170,7 +170,7 @@ import XmMenuExchangeMng from '../xmMenuExchange/XmMenuExchangeMng.vue';
this.load.edit=false this.load.edit=false
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
this.$emit('submit');// @submit="afterAddSubmit"
this.$emit('submit',res.data.data);// @submit="afterAddSubmit"
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.edit=false); }).catch( err => this.load.edit=false);

116
src/views/xm/core/xmMenu/XmMenuMng.vue

@ -103,7 +103,7 @@
</el-popover> </el-popover>
</el-row> </el-row>
<el-row class="padding-top"> <el-row class="padding-top">
<el-table lazy :load="loadMenusLazy" stripe fit border ref="table" :height="maxTableHeight" :data="xmMenusTreeData" row-key="menuId" :tree-props="{children: 'children', hasChildren: 'childrenCnt'}" @sort-change="sortChange" highlight-current-row v-loading="load.list" @selection-change="selsChange" @row-click="rowClick">
<el-table lazy :load="loadXmMenusLazy" stripe fit border ref="table" :height="maxTableHeight" :data="xmMenusTreeData" current-row-key="menuId" row-key="menuId" :tree-props="{children: 'children', hasChildren: 'childrenCnt'}" @sort-change="sortChange" highlight-current-row v-loading="load.list" @selection-change="selsChange" @row-click="rowClick">
<el-table-column sortable type="selection" width="40"></el-table-column> <el-table-column sortable type="selection" width="40"></el-table-column>
<el-table-column prop="menuName" label="需求名称" min-width="160"> <el-table-column prop="menuName" label="需求名称" min-width="160">
<template slot-scope="scope"> <template slot-scope="scope">
@ -230,6 +230,7 @@
<script> <script>
import util from '@/common/js/util';// import util from '@/common/js/util';//
import treeTool from '@/common/js/treeTool';//
//import Sticky from '@/components/Sticky' // header //import Sticky from '@/components/Sticky' // header
//import { listOption } from '@/api/mdp/meta/itemOption';// //import { listOption } from '@/api/mdp/meta/itemOption';//
import { listXmMenu, delXmMenu, batchDelXmMenu,batchAddXmMenu,batchEditXmMenu,listXmMenuWithState,listXmMenuWithPlan } from '@/api/xm/core/xmMenu'; import { listXmMenu, delXmMenu, batchDelXmMenu,batchAddXmMenu,batchEditXmMenu,listXmMenuWithState,listXmMenuWithPlan } from '@/api/xm/core/xmMenu';
@ -261,11 +262,9 @@
'userInfo','roles' 'userInfo','roles'
]), ]),
xmMenusTreeData() {
let xmMenus =this.xmMenus;
let xmMenusTreeData = this.translateDataToTree(xmMenus);
xmMenusTreeData() {
let xmMenus = JSON.parse(JSON.stringify(this.xmMenus || []));
let xmMenusTreeData = treeTool.translateDataToTree(xmMenus,"pmenuId","id");
return xmMenusTreeData; return xmMenusTreeData;
}, },
isPmUser(){ isPmUser(){
@ -359,6 +358,7 @@
pickerOptions: util.pickerOptions('datarange'), pickerOptions: util.pickerOptions('datarange'),
productVisible:false, productVisible:false,
tagSelectVisible:false, tagSelectVisible:false,
maps:new Map(),
/**begin 自定义属性请在下面加 请加备注**/ /**begin 自定义属性请在下面加 请加备注**/
/**end 自定义属性请在上面加 请加备注**/ /**end 自定义属性请在上面加 请加备注**/
@ -437,8 +437,10 @@
} }
return params; return params;
}, },
loadMenusLazy(row, treeNode, resolve) {
var params={pmenuId:row.menuId}
loadXmMenusLazy(tree, treeNode, resolve) {
this.maps.set(tree.menuId, { tree, treeNode, resolve }) //
var params={pmenuId:tree.menuId}
params=this.getParams(params); params=this.getParams(params);
params.isTop="" params.isTop=""
this.load.list = true; this.load.list = true;
@ -465,7 +467,7 @@
total: this.pageInfo.total, total: this.pageInfo.total,
count:this.pageInfo.count count:this.pageInfo.count
}; };
this.xmMenus=[]
//this.xmMenus=[]
if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){ if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
let orderBys=[]; let orderBys=[];
for(var i=0;i<this.pageInfo.orderFields.length;i++){ for(var i=0;i<this.pageInfo.orderFields.length;i++){
@ -508,24 +510,12 @@
this.editForm = Object.assign({}, row); this.editForm = Object.assign({}, row);
}, },
// XmMenu xm_project_menu // XmMenu xm_project_menu
showAdd: function () {
if(!this.roles.some(i=>i.roleid=='productAdmin') && !this.roles.some(i=>i.roleid=='productTeamAdmin')){
this.$notify({showClose: true, message: "只有产品经理、产品组长能够修改需求", type: 'error'});
return false;
}
if(this.filters.product==null){
this.$notify({showClose: true, message: "请先选择产品", type: 'error' });
return;
}
showAdd: function () {
this.parentMenu=null; this.parentMenu=null;
this.addFormVisible = true; this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm); //this.addForm=Object.assign({}, this.editForm);
}, },
showSubAdd:function(row){
if(!this.roles.some(i=>i.roleid=='productAdmin') && !this.roles.some(i=>i.roleid=='productTeamAdmin')){
this.$notify({showClose: true, message: "只有产品经理、产品组长能够修改需求", type: 'error'});
return false;
}
showSubAdd:function(row){
this.editForm=row this.editForm=row
this.parentMenu=row this.parentMenu=row
this.addFormVisible=true this.addFormVisible=true
@ -533,15 +523,17 @@
showProdcutAdd:function(){ showProdcutAdd:function(){
this.$refs.xmProductMng.showAdd(); this.$refs.xmProductMng.showAdd();
}, },
afterAddSubmit(){
afterAddSubmit(row){
this.addFormVisible=false; this.addFormVisible=false;
this.pageInfo.count=true; this.pageInfo.count=true;
this.parentMenu=null; this.parentMenu=null;
this.getXmMenus(); this.getXmMenus();
treeTool.reloadChildren(this.$refs.table,this.maps,row.pmenuId,'pmenuId',this.loadXmMenusLazy)
}, },
afterEditSubmit(){
afterEditSubmit(row){
this.editFormVisible=false; this.editFormVisible=false;
this.getXmMenus();
this.getXmMenus();
treeTool.reloadChildren(this.$refs.table,this.maps,row.pmenuId,'pmenuId',this.loadXmMenusLazy)
}, },
//xmMenu //xmMenu
selsChange: function (sels) { selsChange: function (sels) {
@ -552,14 +544,11 @@
this.filters.parentMenu=null; this.filters.parentMenu=null;
this.filters.parentMenuList=[]; this.filters.parentMenuList=[];
this.productVisible=false; this.productVisible=false;
this.xmMenus=[]
this.getXmMenus() this.getXmMenus()
}, },
//xmMenu //xmMenu
handleDel: function (row,index) {
if(row.mmUserid!=this.userInfo.userid){
this.$notify({showClose: true, message: "只能操作你负责的需求", type: 'error'});
return false;
}
handleDel: function (row,index) {
this.$confirm('确认删除该记录吗?', '提示', { this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
@ -569,20 +558,18 @@
this.load.del=false; this.load.del=false;
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
this.pageInfo.count=true;
this.getXmMenus();
this.pageInfo.count=true;
debugger;
treeTool.reloadChildren(this.$refs.table,this.maps,row.pmenuId,'pmenuId',this.loadXmMenusLazy)
this.getXmMenus();
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.del=false ); }).catch( err => this.load.del=false );
}); });
}, },
//xmMenu //xmMenu
batchDel: function () {
var mmSels=this.sels.filter(i=>i.mmUserid!=this.userInfo.userid)
if(mmSels.length>0){
this.$notify({showClose: true, message: "只能操作你负责的需求", type: 'error'});
return false;
}
batchDel: function () {
this.$confirm('确认删除选中记录吗?', '提示', { this.$confirm('确认删除选中记录吗?', '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
@ -592,7 +579,8 @@
var tips=res.data.tips; var tips=res.data.tips;
if( tips.isOk ){ if( tips.isOk ){
this.pageInfo.count=true; this.pageInfo.count=true;
this.getXmMenus();
this.getXmMenus();
treeTool.reloadAllChildren(this.$refs.table,this.maps,this.sels,'pmenuId',this.loadXmMenusLazy)
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error'}); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error'});
}).catch( err => this.load.del=false ); }).catch( err => this.load.del=false );
@ -639,50 +627,7 @@
}) })
return dataList; return dataList;
}, },
/**begin 自定义函数请在下面加**/
translateDataToTree(data2) {
var data=JSON.parse(JSON.stringify(data2));
let parents = data.filter(value =>{
//
if(value.pmenuId == 'undefined' || value.pmenuId == null || value.pmenuId == ''){
return true;
//
}else if(data.some(i=>value.pmenuId==i.menuId)){
return false;
}else {
return true
}
})
let children = data.filter(value =>{
if(data.some(i=>value.pmenuId==i.menuId)){
return true;
}else{
return false;
}
})
let translator = (parents, children) => {
parents.forEach((parent) => {
children.forEach((current, index) => {
if (current.pmenuId === parent.menuId) {
let temp = JSON.parse(JSON.stringify(children))
temp.splice(index, 1)
translator([current], temp)
typeof parent.children !== 'undefined' ? parent.children.push(current) : parent.children = [current]
}
}
)
}
)
}
translator(parents, children)
return parents
},
/**begin 自定义函数请在下面加**/ /**begin 自定义函数请在下面加**/
selectedMenu:function(row){ selectedMenu:function(row){
this.$emit("selected",row) this.$emit("selected",row)
@ -755,6 +700,9 @@
var tips =res.data.tips var tips =res.data.tips
if(tips.isOk){ if(tips.isOk){
this.getXmMenus() this.getXmMenus()
if(this.parentMenu && this.parentMenu.menuId){
treeTool.reloadAllChildren(this.$refs.table,this.maps,this.parentMenu.menuId,'pmenuId',this.loadXmMenusLazy)
}
}else{ }else{
this.$notify({showClose: true, message: tips.msg, type: 'error' }); this.$notify({showClose: true, message: tips.msg, type: 'error' });
} }

52
src/views/xm/core/xmProjectPhase/XmProjectPhaseMng.vue

@ -506,20 +506,14 @@ import XmTaskList from '../xmTask/XmTaskList.vue';
}, },
afterAddSubmit(row){ afterAddSubmit(row){
this.addFormVisible=false; this.addFormVisible=false;
this.pageInfo.count=true;
if(!this.maps.get(row.parentPhaseId)){
this.searchXmProjectPhases()
}else{
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}
this.pageInfo.count=true;
this.searchXmProjectPhases()
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}, },
afterEditSubmit(row){ afterEditSubmit(row){
this.editFormVisible=false;
if(!this.maps.get(row.parentPhaseId)){
this.searchXmProjectPhases()
}else{
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}
this.editFormVisible=false;
this.searchXmProjectPhases()
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}, },
afterPhaseTemplateSelected(phaseTemplates){ afterPhaseTemplateSelected(phaseTemplates){
if(phaseTemplates==null || phaseTemplates.length==0){ if(phaseTemplates==null || phaseTemplates.length==0){
@ -600,10 +594,9 @@ import XmTaskList from '../xmTask/XmTaskList.vue';
this.load.add=false this.load.add=false
var tips =res.data.tips var tips =res.data.tips
if(tips.isOk){
if( (this.parentProjectPhase && !this.maps.get(this.parentProjectPhase.id))|| !this.parentProjectPhase){
this.searchXmProjectPhases()
}else{
if(tips.isOk){
this.searchXmProjectPhases()
if(this.parentProjectPhase&&this.this.parentProjectPhase.id){
treeTool.reloadChildren(this.$refs.table,this.maps,this.parentProjectPhase.id,'parentPhaseId',this.loadXmProjectPhaseLazy) treeTool.reloadChildren(this.$refs.table,this.maps,this.parentProjectPhase.id,'parentPhaseId',this.loadXmProjectPhaseLazy)
} }
}else{ }else{
@ -626,12 +619,9 @@ import XmTaskList from '../xmTask/XmTaskList.vue';
this.load.del=false; this.load.del=false;
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
this.pageInfo.count=true;
if( !this.maps.get(row.parentPhaseId)){
this.searchXmProjectPhases()
}else{
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}
this.pageInfo.count=true;
this.searchXmProjectPhases()
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.del=false ); }).catch( err => this.load.del=false );
@ -658,20 +648,10 @@ import XmTaskList from '../xmTask/XmTaskList.vue';
this.load.del=false; this.load.del=false;
var tips=res.data.tips; var tips=res.data.tips;
if( tips.isOk ){ if( tips.isOk ){
this.pageInfo.count=true;
var parents=phases.filter(i=>!phases.some(k=>k.id==i.parentPhaseId));
var isLoadAll=parents.some(i=>i.lvl<=1||!this.maps.get(i.parentPhaseId));
var needLoadChlidList=parents.filter(i=>i.lvl>1)
if(isLoadAll){
this.searchXmProjectPhases()
}
if(needLoadChlidList.length>0){
needLoadChlidList.forEach(i=>{
if( this.maps.get(i.parentPhaseId)){
treeTool.reloadChildren(this.$refs.table,this.maps,i.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}
})
}
this.pageInfo.count=true;
this.searchXmProjectPhases()
treeTool.reloadAllChildren(this.$refs.table,this.maps,phases,'parentPhaseId',this.loadXmProjectPhaseLazy)
} }
this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error'}); this.$notify({showClose: true, message: tips.msg, type: tips.isOk?'success':'error'});
}).catch( err => this.load.del=false ); }).catch( err => this.load.del=false );

32
src/views/xm/core/xmTask/XmTaskMng.vue

@ -143,7 +143,13 @@
icon="el-icon-search" icon="el-icon-search"
v-loading="load.list" v-loading="load.list"
></el-button> ></el-button>
<el-button type="danger"
v-if="isTaskCenter != '1' && isMy != '1'"
@click="batchDel"
v-loading="load.edit"
icon="el-icon-edit"
>删除</el-button
>
<el-popover <el-popover
placement="top-start" placement="top-start"
title="选择创建任务的方式" title="选择创建任务的方式"
@ -326,7 +332,7 @@
> >
</el-col> </el-col>
<el-col :span="24" style="padding-top: 5px"> <el-col :span="24" style="padding-top: 5px">
<el-button
<el-button type="danger"
v-if="isTaskCenter != '1' && isMy != '1'" v-if="isTaskCenter != '1' && isMy != '1'"
@click="batchDel" @click="batchDel"
v-loading="load.edit" v-loading="load.edit"
@ -459,7 +465,7 @@
show-overflow-tooltip show-overflow-tooltip
> >
<template slot-scope="scope"> <template slot-scope="scope">
<font v-if="scope.row.ntype!='1'">
<font>
<span <span
v-for="(item, index) in [formatExeUsernames(scope.row)]" v-for="(item, index) in [formatExeUsernames(scope.row)]"
:key="index" :key="index"
@ -502,7 +508,7 @@
> >
<template slot="header"> 需求 </template> <template slot="header"> 需求 </template>
<template slot-scope="scope"> <template slot-scope="scope">
<font v-if="scope.row.ntype!='1'">
<font>
<el-link @click.stop="toMenu(scope.row)">{{ <el-link @click.stop="toMenu(scope.row)">{{
scope.row.menuName ? scope.row.menuName : "去关联需求" scope.row.menuName ? scope.row.menuName : "去关联需求"
}}</el-link> }}</el-link>
@ -1668,14 +1674,7 @@ export default {
}); });
}, },
//xmTask //xmTask
batchDel: function () {
if (
!this.roles.some((i) => i.roleid == "projectAdmin") &&
!this.roles.some((i) => i.roleid == "teamAdmin")
) {
this.$notify.error("只有项目经理、小组长可以操作");
return;
}
batchDel: function () {
this.$confirm("确认删除选中记录吗?", "提示", { this.$confirm("确认删除选中记录吗?", "提示", {
type: "warning", type: "warning",
}).then(() => { }).then(() => {
@ -1688,12 +1687,8 @@ export default {
this.pageInfo.count = true; this.pageInfo.count = true;
var parents=this.sels.filter(i=>!this.sels.some(k=>k.id==i.parentTaskid)); var parents=this.sels.filter(i=>!this.sels.some(k=>k.id==i.parentTaskid));
var needLoadChlidList=parents.filter(i=>i.lvl>1) var needLoadChlidList=parents.filter(i=>i.lvl>1)
this.searchXmTasks()
if(needLoadChlidList.length>0){
needLoadChlidList.forEach(i=>{
treeTool.reloadChildren(this.$refs.table,this.maps,i.parentTaskid,'parentTaskid',this.loadXmTaskLazy)
})
}
this.searchXmTasks()
treeTool.reloadAllChildren(this.$refs.table,this.maps,this.sles,'parentTaskid',this.loadXmTaskLazy)
} }
this.$notify({ this.$notify({
showClose: true, showClose: true,
@ -2236,6 +2231,7 @@ export default {
this.searchXmTasks(); this.searchXmTasks();
}, },
formatExeUsernames(row) { formatExeUsernames(row) {
debugger;
var exeUsernames = row.exeUsernames; var exeUsernames = row.exeUsernames;
var respons = { var respons = {
type: "info", type: "info",

Loading…
Cancel
Save