Browse Source

优化

master
陈裕财 4 years ago
parent
commit
e5f4cd0ec1
  1. 65
      src/common/js/treeTool.js
  2. 59
      src/views/xm/core/xmProjectGroup/XmProjectGroupMng.vue

65
src/common/js/treeTool.js

@ -0,0 +1,65 @@
export default {
/**
* 将类表数据转换为如下树状结构的数据
* {
* xxx:'',
* xxx2:'',
* children:[
* xxx:'',
* xxx2:'',
* ]
* }
* @param {*} data2 将要转换的数据
* @param {*} pidName 上级字段名称 pmenId
* @param {*} idName 本条数据主键字段名称 menuId
* @param {*} rowCallBack(data),如果需要对部分字段进行转换可以传入这个回调函数比如需要将 name:'陈天财' => label:'陈天财'
* @returns
*/
translateDataToTree: function(data2,pidName,idName,rowCallBack) {
var data=JSON.parse(JSON.stringify(data2));
let parents = data.filter(value =>{
//如果我的上级为空,则我是最上级
if(value[pidName] == 'undefined' || value[pidName] == null || value[pidName] == ''|| value[pidName] == '0'){
return true;
//如果我的上级不在列表中,我作为最上级
}else if(data.some(i=>value[pidName]==i[idName])){
return false;
}else {
return true
}
})
let children = data.filter(value =>{
if(data.some(i=>value[pidName]==i[idName])){
return true;
}else{
return false;
}
})
let translator = (parents, children) => {
parents.forEach((parent) => {
if(rowCallBack){
rowCallBack(parent)
}
children.forEach((current, index) => {
if (current[pidName] === parent[idName]) {
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
},
}

59
src/views/xm/core/xmProjectGroup/XmProjectGroupMng.vue

@ -1,18 +1,14 @@
<template> <template>
<section class="page-container border padding">
<section class="page-container border padding" >
<el-row v-if="!isSelectSingleUser && !isSelectMultiUser"> <el-row v-if="!isSelectSingleUser && !isSelectMultiUser">
<el-button type="primary" v-if="!xmProjectGroups||xmProjectGroups.length==0" @click="showAdd" icon="el-icon-plus">导入项目组</el-button>
<el-button type="plain" @click="showGroupState" icon="el-icon-s-data">小组进度</el-button> <el-button type="plain" @click="showGroupState" icon="el-icon-s-data">小组进度</el-button>
<el-button type="plain" @click="xmRecordVisible=true" icon="el-icon-document">变化日志</el-button> <el-button type="plain" @click="xmRecordVisible=true" icon="el-icon-document">变化日志</el-button>
<el-button type="plain" @click="doSearchImGroupsByProjectId" icon="el-icon-document">绑定即聊情况</el-button> <el-button type="plain" @click="doSearchImGroupsByProjectId" icon="el-icon-document">绑定即聊情况</el-button>
<el-button @click="groupRoleDescVisible=true" icon="el-icon-document">角色说明</el-button> <el-button @click="groupRoleDescVisible=true" icon="el-icon-document">角色说明</el-button>
<font color="red">注意点击架构图进行操作</font> <font color="red">注意点击架构图进行操作</font>
</el-row> </el-row>
<el-row v-else>
<el-button type="primary" @click="userConfirm" icon="el-icon-finished">确认选择用户</el-button>
</el-row>
<el-row>
<vue-okr-tree :data="okrTreeData"
<el-row >
<vue-okr-tree :data="okrTreeData" v-loading="load.list"
show-collapsable show-collapsable
default-expand-all default-expand-all
node-key="id" node-key="id"
@ -24,12 +20,12 @@
</el-row> </el-row>
<el-row> <el-row>
<!--编辑 XmProjectGroup xm_project_group界面--> <!--编辑 XmProjectGroup xm_project_group界面-->
<el-drawer title="编辑xm_project_group" :visible.sync="editFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<el-drawer title="编辑小组信息" :visible.sync="editFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-project-group-edit op-type="edit" :xm-project-group="editForm" :visible="editFormVisible" @cancel="editFormVisible=false" @submit="afterEditSubmit"></xm-project-group-edit> <xm-project-group-edit op-type="edit" :xm-project-group="editForm" :visible="editFormVisible" @cancel="editFormVisible=false" @submit="afterEditSubmit"></xm-project-group-edit>
</el-drawer> </el-drawer>
<!--新增 XmProjectGroup xm_project_group界面--> <!--新增 XmProjectGroup xm_project_group界面-->
<el-drawer title="新增xm_project_group" :visible.sync="addFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<el-drawer title="新增小组信息" :visible.sync="addFormVisible" size="60%" append-to-body :close-on-click-modal="false">
<xm-project-group-edit op-type="add" :xm-project-group="addForm" :visible="addFormVisible" @cancel="addFormVisible=false" @submit="afterAddSubmit"></xm-project-group-edit> <xm-project-group-edit op-type="add" :xm-project-group="addForm" :visible="addFormVisible" @cancel="addFormVisible=false" @submit="afterAddSubmit"></xm-project-group-edit>
</el-drawer> </el-drawer>
@ -157,6 +153,7 @@
<script> <script>
import util from '@/common/js/util';// import util from '@/common/js/util';//
import treeTool from '@/common/js/treeTool';//
import config from '@/common/config';// import config from '@/common/config';//
import { getDicts,initSimpleDicts,initComplexDicts } from '@/api/mdp/meta/item';// import { getDicts,initSimpleDicts,initComplexDicts } from '@/api/mdp/meta/item';//
import { listXmProjectGroup, delXmProjectGroup, batchDelXmProjectGroup,getGroups } from '@/api/xm/core/xmProjectGroup'; import { listXmProjectGroup, delXmProjectGroup, batchDelXmProjectGroup,getGroups } from '@/api/xm/core/xmProjectGroup';
@ -196,6 +193,7 @@
i.children=groupUsers i.children=groupUsers
} }
}) })
var groupsTree=treeTool.translateDataToTree(groups,'pgroupId','id')
var topLabel="组织架构" var topLabel="组织架构"
var currNodeType='' var currNodeType=''
var topdata={} var topdata={}
@ -212,7 +210,7 @@
...topdata, ...topdata,
label:topLabel, label:topLabel,
currNodeType:currNodeType, currNodeType:currNodeType,
children:groups
children:groupsTree
} }
] ]
return data; return data;
@ -359,34 +357,43 @@
// XmProjectGroup xm_project_group // XmProjectGroup xm_project_group
showAdd: function () { showAdd: function () {
if(this.xmProduct && this.xmProduct.id){ if(this.xmProduct && this.xmProduct.id){
this.addForm.pgroupId=null
this.addForm.pgroupName=null
this.addForm.productId=this.xmProduct.id this.addForm.productId=this.xmProduct.id
this.addForm.pgClass="1" this.addForm.pgClass="1"
this.addForm.projectId=null this.addForm.projectId=null
}else{
this.addFormVisible = true;
}else if(this.selProject && this.selProject.id){
this.addForm.pgroupId=null
this.addForm.pgroupName=null
this.addForm.productId=null this.addForm.productId=null
this.addForm.pgClass="0" this.addForm.pgClass="0"
this.addForm.projectId=this.selProject.id this.addForm.projectId=this.selProject.id
this.addFormVisible = true;
}else{
return;
} }
this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm); //this.addForm=Object.assign({}, this.editForm);
}, },
// XmProjectGroup xm_project_group // XmProjectGroup xm_project_group
showAddSub: function (row) { showAddSub: function (row) {
if(this.xmProduct && this.xmProduct.id){
this.addForm.productId=this.xmProduct.id
if(!row){
return;
}
if("1"==row.pgClass){
this.addForm.productId=row.productId
this.addForm.pgClass="1" this.addForm.pgClass="1"
this.addForm.projectId=null this.addForm.projectId=null
}else{ }else{
this.addForm.productId=null this.addForm.productId=null
this.addForm.pgClass="0" this.addForm.pgClass="0"
this.addForm.projectId=this.selProject.id
}
if(row){
this.addForm.pgroupId=row.id
this.addForm.pgroupName=row.groupName
this.addForm.groupName=row.groupName+"-"+"下级小组xx"
this.addForm.id=null
}
this.addForm.projectId=row.projectId
}
this.addForm.pgroupId=row.id
this.addForm.pgroupName=row.groupName
this.addForm.groupName=row.groupName+"-"+"下级小组xx"
this.addForm.id=null
this.addFormVisible = true; this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm); //this.addForm=Object.assign({}, this.editForm);
}, },
@ -518,10 +525,10 @@
} }
if(this.editForm.pgClass=='1'){ if(this.editForm.pgClass=='1'){
u.projectId=null u.projectId=null
u.productId=this.xmProduct.id
u.productId=this.editForm.productId
u.pgClass=this.editForm.pgClass u.pgClass=this.editForm.pgClass
}else{ }else{
u.projectId=this.selProject.id
u.projectId=this.editForm.projectId
u.productId=null u.productId=null
u.pgClass=this.editForm.pgClass u.pgClass=this.editForm.pgClass
} }
@ -538,9 +545,7 @@
this.$message({ showClose:true, message: tips.msg, type: tips.isOk?'success':'error'}); this.$message({ showClose:true, message: tips.msg, type: tips.isOk?'success':'error'});
}) })
},
delGroupUser(index,vindex) {
},
},
rowClick: function(row, event, column){ rowClick: function(row, event, column){
if(event.label!='操作' && event.type!='selection'){ if(event.label!='操作' && event.type!='selection'){
this.showEdit(row) this.showEdit(row)

Loading…
Cancel
Save