Browse Source

优化

master
陈裕财 4 years ago
parent
commit
ff6ac20dbb
  1. 17
      src/common/js/treeTool.js
  2. 6
      src/views/xm/core/xmProjectPhase/XmProjectPhaseAdd.vue
  3. 10
      src/views/xm/core/xmProjectPhase/XmProjectPhaseBatch.vue
  4. 6
      src/views/xm/core/xmProjectPhase/XmProjectPhaseEdit.vue
  5. 64
      src/views/xm/core/xmProjectPhase/XmProjectPhaseMng.vue

17
src/common/js/treeTool.js

@ -1,6 +1,19 @@
export default { export default {
reloadChildren: function(table,maps, parentId,parentIdName,loadChildren) {
var lazyTreeNodeMap=table.store.states.lazyTreeNodeMap
if (maps.get(parentId)) {
const { tree, treeNode, resolve } = maps.get(parentId)
if (tree) { // 重新执行父节点加载子级操作
loadChildren(tree, treeNode, resolve)
if (tree[parentIdName]) { // 若存在爷爷结点,则执行爷爷节点加载子级操作,防止最后一个子节点被删除后父节点不显示删除按钮
const a = maps.get(tree[parentIdName])
loadChildren(a.tree, a.treeNode, a.resolve)
}
}
}
},
/** /**
* 将类表数据转换为如下树状结构的数据 * 将类表数据转换为如下树状结构的数据
* { * {

6
src/views/xm/core/xmProjectPhase/XmProjectPhaseAdd.vue

@ -191,7 +191,7 @@
}, },
autoParams:function(autoParams){ autoParams:function(autoParams){
this.fillphaseBudgetHoursToField() this.fillphaseBudgetHoursToField()
this.fillphaseBudgetCostAtToField()
this.fillphaseBudgetAtToField()
} }
}, },
data() { data() {
@ -307,7 +307,7 @@
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
//this.$refs['addForm'].resetFields(); //this.$refs['addForm'].resetFields();
this.$emit('submit');// @submit="afteraddSubmit"
this.$emit('submit',res.data.data);// @submit="afteraddSubmit"
} }
this.$message({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$message({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.add=false); }).catch( err => this.load.add=false);
@ -355,7 +355,7 @@
this.addForm.phaseBudgetHours=this.toFixed(this.autoParams.phaseBudgetHours) this.addForm.phaseBudgetHours=this.toFixed(this.autoParams.phaseBudgetHours)
}, },
fillphaseBudgetCostAtToField:function(){
fillphaseBudgetAtToField:function(){
this.addForm.phaseBudgetNouserAt=this.toFixed(this.autoParams.phaseBudgetNouserAt) this.addForm.phaseBudgetNouserAt=this.toFixed(this.autoParams.phaseBudgetNouserAt)
this.addForm.phaseBudgetOutUserAt=this.toFixed(this.autoParams.phaseBudgetOutUserAt ) this.addForm.phaseBudgetOutUserAt=this.toFixed(this.autoParams.phaseBudgetOutUserAt )
this.addForm.phaseBudgetInnerUserAt=this.toFixed(this.autoParams.phaseBudgetInnerUserAt ) this.addForm.phaseBudgetInnerUserAt=this.toFixed(this.autoParams.phaseBudgetInnerUserAt )

10
src/views/xm/core/xmProjectPhase/XmProjectPhaseBatch.vue

@ -796,7 +796,7 @@ export default {
i.projectId = this.selProject.id; i.projectId = this.selProject.id;
i.projectName = this.selProject.name; i.projectName = this.selProject.name;
i.branchId = this.selProject.branchId; i.branchId = this.selProject.branchId;
i.phaseBudgetCostAt = 0;
i.phaseBudgetAt = 0;
i.phaseBudgetNouserAt = 0; i.phaseBudgetNouserAt = 0;
i.phaseBudgetInnerUserAt = 0; i.phaseBudgetInnerUserAt = 0;
i.phaseBudgetOutUserAt = 0; i.phaseBudgetOutUserAt = 0;
@ -979,7 +979,7 @@ export default {
let parents = data.filter((value) => { let parents = data.filter((value) => {
// //
var calcData = this.getRowSum(value); var calcData = this.getRowSum(value);
value.phaseBudgetCostAt = calcData.phaseBudgetCostAt;
value.phaseBudgetAt = calcData.phaseBudgetAt;
value.actCostAt = calcData.actCostAt; value.actCostAt = calcData.actCostAt;
if ( if (
value.parentPhaseId == "undefined" || value.parentPhaseId == "undefined" ||
@ -1107,7 +1107,7 @@ export default {
) { ) {
row.actOutUserAt = 0; row.actOutUserAt = 0;
} }
var phaseBudgetCostAt =
var phaseBudgetAt =
parseFloat(row.phaseBudgetNouserAt) + parseFloat(row.phaseBudgetNouserAt) +
parseFloat(row.phaseBudgetInnerUserAt) + parseFloat(row.phaseBudgetInnerUserAt) +
parseFloat(row.phaseBudgetOutUserAt); parseFloat(row.phaseBudgetOutUserAt);
@ -1116,7 +1116,7 @@ export default {
parseFloat(row.actInnerUserAt) + parseFloat(row.actInnerUserAt) +
parseFloat(row.actOutUserAt); parseFloat(row.actOutUserAt);
return { phaseBudgetCostAt: phaseBudgetCostAt, actCostAt: actCostAt };
return { phaseBudgetAt: phaseBudgetAt, actCostAt: actCostAt };
}, },
fieldChange: function (row, fieldName, nextReplace) { fieldChange: function (row, fieldName, nextReplace) {
if (nextReplace) { if (nextReplace) {
@ -1684,7 +1684,7 @@ export default {
subRow.projectId = this.selProject.id; subRow.projectId = this.selProject.id;
subRow.projectName = this.selProject.name; subRow.projectName = this.selProject.name;
subRow.branchId = this.selProject.branchId; subRow.branchId = this.selProject.branchId;
subRow.phaseBudgetCostAt = 0;
subRow.phaseBudgetAt = 0;
subRow.phaseBudgetNouserAt = 0; subRow.phaseBudgetNouserAt = 0;
subRow.phaseBudgetInnerUserAt = 0; subRow.phaseBudgetInnerUserAt = 0;
subRow.phaseBudgetOutUserAt = 0; subRow.phaseBudgetOutUserAt = 0;

6
src/views/xm/core/xmProjectPhase/XmProjectPhaseEdit.vue

@ -199,7 +199,7 @@
}, },
autoParams:function(autoParams){ autoParams:function(autoParams){
this.fillphaseBudgetHoursToField() this.fillphaseBudgetHoursToField()
this.fillphaseBudgetCostAtToField()
this.fillphaseBudgetAtToField()
} }
}, },
data() { data() {
@ -318,7 +318,7 @@
var tips=res.data.tips; var tips=res.data.tips;
if(tips.isOk){ if(tips.isOk){
//this.$refs['editForm'].resetFields(); //this.$refs['editForm'].resetFields();
this.$emit('submit');// @submit="aftereditSubmit"
this.$emit('submit',res.data.data);// @submit="aftereditSubmit"
} }
this.$message({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' }); this.$message({showClose: true, message: tips.msg, type: tips.isOk?'success':'error' });
}).catch( err => this.load.edit=false); }).catch( err => this.load.edit=false);
@ -366,7 +366,7 @@
this.editForm.phaseBudgetHours=this.toFixed(this.autoParams.phaseBudgetHours) this.editForm.phaseBudgetHours=this.toFixed(this.autoParams.phaseBudgetHours)
}, },
fillphaseBudgetCostAtToField:function(){
fillphaseBudgetAtToField:function(){
this.editForm.phaseBudgetNouserAt=this.toFixed(this.autoParams.phaseBudgetNouserAt) this.editForm.phaseBudgetNouserAt=this.toFixed(this.autoParams.phaseBudgetNouserAt)
this.editForm.phaseBudgetOutUserAt=this.toFixed(this.autoParams.phaseBudgetOutUserAt ) this.editForm.phaseBudgetOutUserAt=this.toFixed(this.autoParams.phaseBudgetOutUserAt )
this.editForm.phaseBudgetInnerUserAt=this.toFixed(this.autoParams.phaseBudgetInnerUserAt ) this.editForm.phaseBudgetInnerUserAt=this.toFixed(this.autoParams.phaseBudgetInnerUserAt )

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

@ -107,7 +107,7 @@
</el-table-column> </el-table-column>
<el-table-column label="成本(元)" width="100"> <el-table-column label="成本(元)" width="100">
<el-table-column prop="phaseBudgetCostAt" label="预计" width="100" >
<el-table-column prop="phaseBudgetAt" label="预计" width="100" >
</el-table-column> </el-table-column>
<el-table-column prop="actCostAt" label="实际" width="100" > <el-table-column prop="actCostAt" label="实际" width="100" >
</el-table-column> </el-table-column>
@ -206,6 +206,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 { listXmProjectPhase,calcKeyPaths, delXmProjectPhase, batchDelXmProjectPhase,batchImportFromTemplate,batchSaveBudget,loadTasksToXmProjectPhase,setPhaseMngUser } from '@/api/xm/core/xmProjectPhase'; import { listXmProjectPhase,calcKeyPaths, delXmProjectPhase, batchDelXmProjectPhase,batchImportFromTemplate,batchSaveBudget,loadTasksToXmProjectPhase,setPhaseMngUser } from '@/api/xm/core/xmProjectPhase';
@ -226,22 +227,9 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
...mapGetters([ ...mapGetters([
'userInfo','roles' 'userInfo','roles'
]), ]),
projectPhaseTreeData() {
let xmProjectPhases = JSON.parse(JSON.stringify(this.xmProjectPhases || []));
if (this.valueChangeRows && this.valueChangeRows.length) {
this.valueChangeRows.forEach(c => {
var index = xmProjectPhases.findIndex(i=>i.id==c.id);
const oldRow = JSON.parse(JSON.stringify(xmProjectPhases[index]));
xmProjectPhases.splice(index,1);
c.parentPhaseId = oldRow.parentPhaseId;
xmProjectPhases.push(c);
})
}
const projectPhaseTreeData = this.translateDataToTree(xmProjectPhases);
return projectPhaseTreeData;
},
projectPhaseTreeData() {
return treeTool.translateDataToTree(this.xmProjectPhases,"parentPhaseId","id");
},
phaseBudgetData(){ phaseBudgetData(){
if( this.xmIteration || this.xmProduct){ if( this.xmIteration || this.xmProduct){
return {} return {}
@ -396,6 +384,7 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
endDate: 'endDate', endDate: 'endDate',
}, },
maps:new Map(),
/**end 自定义属性请在上面加 请加备注**/ /**end 自定义属性请在上面加 请加备注**/
} }
},//end data },//end data
@ -460,11 +449,9 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
} }
return params; return params;
}, },
loadXmProjectPhaseLazy(row, treeNode, resolve) {
if(row.children&&row.children.length>0){
resolve(row.children)
}else{
var params={parentPhaseId:row.id}
loadXmProjectPhaseLazy(tree, treeNode, resolve) {
this.maps.set(tree.id, { tree, treeNode, resolve }) //
var params={parentPhaseId:tree.id}
params=this.getParams(params); params=this.getParams(params);
params.isTop="" params.isTop=""
this.load.list = true; this.load.list = true;
@ -477,10 +464,10 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
}else{ }else{
resolve([]) resolve([])
} }
}).catch( err => this.load.list = false );
}
}).catch( err => this.load.list = false );
}, },
// XmProjectPhase xm_project_phase // XmProjectPhase xm_project_phase
getXmProjectPhases() { getXmProjectPhases() {
this.valueChangeRows=[] this.valueChangeRows=[]
@ -521,7 +508,7 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
this.$message({showClose: true, message: "只有项目经理、小组组长可以操作计划", type: 'error' }); this.$message({showClose: true, message: "只有项目经理、小组组长可以操作计划", type: 'error' });
return; return;
} }
this.editForm = Object.assign({}, row);
this.editForm = row;
this.editFormVisible = true; this.editFormVisible = true;
}, },
// XmProjectPhase xm_project_phase // XmProjectPhase xm_project_phase
@ -551,13 +538,22 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
this.addFormVisible = true; this.addFormVisible = true;
//this.addForm=Object.assign({}, this.editForm); //this.addForm=Object.assign({}, this.editForm);
}, },
afterAddSubmit(){
afterAddSubmit(row){
this.addFormVisible=false; this.addFormVisible=false;
this.pageInfo.count=true; this.pageInfo.count=true;
this.getXmProjectPhases();
if(!this.maps.get(row.parentPhaseId)){
this.searchXmProjectPhases()
}else{
treeTool.reloadChildren(this.$refs.table,this.maps,row.parentPhaseId,'parentPhaseId',this.loadXmProjectPhaseLazy)
}
}, },
afterEditSubmit(){
this.editFormVisible=false;
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)
}
}, },
afterPhaseTemplateSelected(phaseTemplates){ afterPhaseTemplateSelected(phaseTemplates){
if(phaseTemplates==null || phaseTemplates.length==0){ if(phaseTemplates==null || phaseTemplates.length==0){
@ -612,7 +608,7 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
i.projectId=this.selProject.id i.projectId=this.selProject.id
i.projectName=this.selProject.name i.projectName=this.selProject.name
i.branchId=this.selProject.branchId i.branchId=this.selProject.branchId
i.phaseBudgetCostAt=0
i.phaseBudgetAt=0
i.phaseBudgetNouserAt=0 i.phaseBudgetNouserAt=0
i.phaseBudgetInnerUserAt=0 i.phaseBudgetInnerUserAt=0
i.phaseBudgetOutUserAt=0 i.phaseBudgetOutUserAt=0
@ -739,7 +735,7 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
let parents = data.filter(value =>{ let parents = data.filter(value =>{
// //
var calcData=this.getRowSum(value); var calcData=this.getRowSum(value);
value.phaseBudgetCostAt=calcData.phaseBudgetCostAt
value.phaseBudgetAt=calcData.phaseBudgetAt
value.actCostAt=calcData.actCostAt value.actCostAt=calcData.actCostAt
if(value.parentPhaseId == 'undefined' || value.parentPhaseId == null || value.parentPhaseId == ''){ if(value.parentPhaseId == 'undefined' || value.parentPhaseId == null || value.parentPhaseId == ''){
return true; return true;
@ -1001,10 +997,10 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
if(row.actOutUserAt==null || row.actOutUserAt=='' || row.actOutUserAt==undefined){ if(row.actOutUserAt==null || row.actOutUserAt=='' || row.actOutUserAt==undefined){
row.actOutUserAt=0; row.actOutUserAt=0;
} }
var phaseBudgetCostAt=parseFloat(row.phaseBudgetNouserAt)+parseFloat(row.phaseBudgetInnerUserAt)+parseFloat(row.phaseBudgetOutUserAt)
var phaseBudgetAt=parseFloat(row.phaseBudgetNouserAt)+parseFloat(row.phaseBudgetInnerUserAt)+parseFloat(row.phaseBudgetOutUserAt)
var actCostAt=parseFloat(row.actNouserAt)+parseFloat(row.actInnerUserAt)+parseFloat(row.actOutUserAt) var actCostAt=parseFloat(row.actNouserAt)+parseFloat(row.actInnerUserAt)+parseFloat(row.actOutUserAt)
return {phaseBudgetCostAt:phaseBudgetCostAt,actCostAt:actCostAt};
return {phaseBudgetAt:phaseBudgetAt,actCostAt:actCostAt};
}, },
fieldChange:function(row,fieldName, nextReplace){ fieldChange:function(row,fieldName, nextReplace){
if (nextReplace) { if (nextReplace) {
@ -1322,7 +1318,7 @@ import XmProjectGroupSelect from '../xmProjectGroup/XmProjectGroupSelect.vue';
subRow.projectId=this.selProject.id subRow.projectId=this.selProject.id
subRow.projectName=this.selProject.name subRow.projectName=this.selProject.name
subRow.branchId=this.selProject.branchId subRow.branchId=this.selProject.branchId
subRow.phaseBudgetCostAt=0
subRow.phaseBudgetAt=0
subRow.phaseBudgetNouserAt=0 subRow.phaseBudgetNouserAt=0
subRow.phaseBudgetInnerUserAt=0 subRow.phaseBudgetInnerUserAt=0
subRow.phaseBudgetOutUserAt=0 subRow.phaseBudgetOutUserAt=0

Loading…
Cancel
Save