|
@@ -176,7 +176,7 @@ const projTreeObj = {
|
|
|
onDragDropBlock : function (sender,args) {//拖动移动项目位置
|
|
|
let selected = projTreeObj.tree.selected;
|
|
|
let targetNode = projTreeObj.tree.items[args.toRow];
|
|
|
- let projectMap = {},feeRateMap={},unitPriceMap = {},parent=null,next = null;
|
|
|
+ let projectMap = {},feeRateMap={},unitPriceMap = {},parent=null,next = null,oldProject=null;
|
|
|
let rootProjectID = null;//记录建设项目ID
|
|
|
//let updateObj = {project:[],feeRateFile:[],unitPriceFile:[]};
|
|
|
args.cancel = true;//首先取消填充的动作
|
|
@@ -185,6 +185,7 @@ const projTreeObj = {
|
|
|
}
|
|
|
|
|
|
if(selected.data.projType=="Tender"){//移动单位工程
|
|
|
+ oldProject = selected.parent.parent;//记录原来的建设项目
|
|
|
if(targetNode.data.projType=="Tender"||targetNode.data.projType=="Engineering"){//只能移动到这两个地方
|
|
|
if(targetNode.data.projType=="Tender"){//移动到单位工程后面
|
|
|
[parent,next] = getMoveUpdateData(selected,targetNode,projectMap,true);
|
|
@@ -201,6 +202,7 @@ const projTreeObj = {
|
|
|
}
|
|
|
}
|
|
|
if(selected.data.projType=="Engineering"){//移动的是单项工程
|
|
|
+ oldProject = selected.parent;//记录原来的建设项目
|
|
|
if(targetNode.data.projType=="Engineering"||targetNode.data.projType=="Project"){//目标位置是单项工程和建设项目
|
|
|
if(targetNode.data.projType=="Engineering"){
|
|
|
[parent,next] = getMoveUpdateData(selected,targetNode,projectMap,true);
|
|
@@ -245,7 +247,7 @@ const projTreeObj = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- projTreeObj.moveTo(selected,targetNode,parent,next);
|
|
|
+ projTreeObj.moveTo(selected,targetNode,parent,next,oldProject);
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
function getMoveUpdateData(sel,target,projectMap,sameLevel) {
|
|
@@ -591,8 +593,8 @@ const projTreeObj = {
|
|
|
let dataCode = this.setting.header[col]['dataCode'];
|
|
|
let value = '';
|
|
|
if(dataCode === 'engineeringCost'){
|
|
|
- if(node.data.projType === projectType.tender){
|
|
|
- value = node.data.engineeringCost ? node.data.engineeringCost : 0;
|
|
|
+ if(node.data.projType !== projectType.folder){//显示除了文件夹节点的工程造价结果 -- vincent
|
|
|
+ value = node.data.engineeringCost ? node.data.engineeringCost : '0.00';
|
|
|
}
|
|
|
}
|
|
|
else if(dataCode === 'unitPriceFile'){
|
|
@@ -633,16 +635,67 @@ const projTreeObj = {
|
|
|
};
|
|
|
me.renderSheetFuc(sheet, fuc);
|
|
|
},
|
|
|
- refreshNodeData: function (node) {
|
|
|
+ refreshNodeData: function (nodes) {
|
|
|
let me = this;
|
|
|
let sheet = me.workBook.getActiveSheet();
|
|
|
let header = me.setting.header;
|
|
|
- let rIdx = me.tree.items.indexOf(node);
|
|
|
me.renderSheetFuc(sheet, function () {
|
|
|
- for(let i = 0; i < header.length; i++){
|
|
|
- me.setCellValue({row: rIdx, col: i}, node);
|
|
|
+
|
|
|
+ if(_.isArray(nodes)){
|
|
|
+ for(let t of nodes){
|
|
|
+ setSheetCellData(t);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ setSheetCellData(nodes);
|
|
|
}
|
|
|
});
|
|
|
+ function setSheetCellData(n) {
|
|
|
+ let rIdx = me.tree.items.indexOf(n);
|
|
|
+ for(let i = 0; i < header.length; i++){
|
|
|
+ me.setCellValue({row: rIdx, col: i}, n);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ sumEngineeringCost:function(){
|
|
|
+ let projectNodes = _.filter(projTreeObj.tree.items,function (item) {
|
|
|
+ return item.data.projType == projectType.project;
|
|
|
+ })
|
|
|
+ for(let p of projectNodes){
|
|
|
+ this.calEngineeringCost(p);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ calEngineeringCost:function (node) {
|
|
|
+ let projectNode = null;//建设项目节点
|
|
|
+ let refreshNodes = [];
|
|
|
+ if(node.data.projType == projectType.project){
|
|
|
+ projectNode = node;
|
|
|
+ }
|
|
|
+ if(node.data.projType == projectType.engineering){
|
|
|
+ projectNode = node.parent;
|
|
|
+ }
|
|
|
+ if(node.data.projType == projectType.tender){
|
|
|
+ projectNode = node.parent&&node.parent.parent?node.parent.parent:null;
|
|
|
+ }
|
|
|
+ if(projectNode){
|
|
|
+ calNode(projectNode);
|
|
|
+ }
|
|
|
+ let children = projectNode.children;
|
|
|
+ refreshNodes.push(projectNode);
|
|
|
+ return refreshNodes.concat(children);
|
|
|
+ function calNode(node) {
|
|
|
+ let tem_sum = 0;
|
|
|
+ if(node.data.projType == projectType.tender){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for(let t of node.children){
|
|
|
+ calNode(t);
|
|
|
+ let temP = scMathUtil.roundForObj(t.data.engineeringCost,2);
|
|
|
+ tem_sum = scMathUtil.roundForObj(temP+tem_sum,2);
|
|
|
+ }
|
|
|
+ node.data.engineeringCost = scMathUtil.roundToString(tem_sum,2);
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
insert: function (data, parent, next) {
|
|
|
let node = this.tree.addNodeData(data, parent, next);
|
|
@@ -682,29 +735,34 @@ const projTreeObj = {
|
|
|
this.workBook.getActiveSheet().deleteRows(orgRow, 1);
|
|
|
this.addRow(this.tree.items[newRow]);
|
|
|
},
|
|
|
- moveTo : function(select,target,parent,next){
|
|
|
+ moveTo : function(select,target,parent,next,oldProject){
|
|
|
let me = this;
|
|
|
let fromRow = select.serialNo();
|
|
|
let rCout = select.posterityCount() + 1;//删除的行数
|
|
|
- let toRow = target.serialNo();
|
|
|
let sheet = me.workBook.getActiveSheet();
|
|
|
+ let refreshNodes = [];
|
|
|
me.tree.removeNode(select);//删除旧节点
|
|
|
let newNode = addNewNodes(select, parent, next);
|
|
|
+ if(oldProject){
|
|
|
+ refreshNodes = refreshNodes.concat(me.calEngineeringCost(oldProject));
|
|
|
+ refreshNodes = refreshNodes.concat(me.calEngineeringCost(parent));
|
|
|
+ }
|
|
|
// projTreeObj.remove(sheet, fromRow, rCout);
|
|
|
|
|
|
me.renderSheetFuc(sheet, function () {
|
|
|
sheet.deleteRows(fromRow, rCout);
|
|
|
sheet.addRows(newNode.serialNo(),rCout);
|
|
|
let oldSelection = sheet.getSelections()[0];
|
|
|
- let newSelection = {row: newNode.serialNo(), rowCount: 1,col:oldSelection.col,colCount:oldSelection.colCount};
|
|
|
me.initSelection({row: newNode.serialNo(), rowCount: oldSelection.rowCount}, oldSelection);
|
|
|
sheet.setSelection(newNode.serialNo(),oldSelection.col,oldSelection.rowCount,oldSelection.colCount);
|
|
|
let children = newNode.getAllChildren();
|
|
|
children.push(newNode);
|
|
|
for(let c of children){
|
|
|
sheet.getCell(c.serialNo(), 0).cellType(me.getTreeNodeCell(me.tree));
|
|
|
- me.refreshNodeData(c);
|
|
|
+ // me.refreshNodeData(c);
|
|
|
}
|
|
|
+ refreshNodes = refreshNodes.concat(children);
|
|
|
+ me.refreshNodeData(refreshNodes);
|
|
|
});
|
|
|
|
|
|
function addNewNodes(node,parent,next) {
|
|
@@ -964,14 +1022,19 @@ $(document).ready(function() {
|
|
|
updateData = GetDeleteUpdateData(projTreeObj.tree.selected);
|
|
|
UpdateProjectData(updateData, function () {
|
|
|
dialog.modal('hide');
|
|
|
+ let selected = projTreeObj.tree.selected;
|
|
|
//删除行号
|
|
|
- let rIdx = projTreeObj.tree.items.indexOf(projTreeObj.tree.selected);
|
|
|
+ let rIdx = projTreeObj.tree.items.indexOf(selected);
|
|
|
//删除行数
|
|
|
- let rCout = projTreeObj.tree.selected.posterityCount() + 1;
|
|
|
- projTreeObj.tree.removeNode(projTreeObj.tree.selected);
|
|
|
+ let rCout = selected.posterityCount() + 1;
|
|
|
+ projTreeObj.tree.removeNode(selected);
|
|
|
+ let refreshNodes = projTreeObj.calEngineeringCost(selected);
|
|
|
//delete view
|
|
|
let sheet = projTreeObj.workBook.getActiveSheet();
|
|
|
projTreeObj.remove(sheet, rIdx, rCout);
|
|
|
+ if(selected.data.projType == projectType.tender||selected.data.projType == projectType.engineering){
|
|
|
+ projTreeObj.refreshNodeData(refreshNodes);//刷新工程造价信息
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -1011,71 +1074,6 @@ $(document).ready(function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // 移动到按钮点击
|
|
|
- $('#move-to-btn').click(function () {
|
|
|
- if (projTreeObj.tree && projTreeObj.tree.selected) {
|
|
|
- $('#move-to-dialog').modal('show');
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 移动到窗口内容重组
|
|
|
- $('#move-to-dialog').on('show.bs.modal', function () {
|
|
|
- movetoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo'), projTreeObj.tree.selected);
|
|
|
- });
|
|
|
-
|
|
|
- // 移动到操作
|
|
|
- $('#move-to-confirm').click(function () {
|
|
|
- let updateData = null;
|
|
|
- let dialog = $('#move-to-dialog');
|
|
|
- let target = GetTargetTreeNode($.fn.zTree.getZTreeObj('treeDemo'));
|
|
|
- let cur = projTreeObj.tree.selected;
|
|
|
-
|
|
|
- if (!target) {
|
|
|
- dialog.modal('hide');
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (target.data.projType !== projectType.engineering) {
|
|
|
- alert("请移动到单项工程中!");
|
|
|
- return false;
|
|
|
- }
|
|
|
- // 判断同级是否有同名
|
|
|
- if (target.children.length > 0) {
|
|
|
- for (let tmp in target.children) {
|
|
|
- if (tmp === 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (target.children[tmp].data.name === cur.data.name) {
|
|
|
- alert("对应单项工程中存在同名数据!");
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let parent = target;
|
|
|
- let next = target.firstChild();
|
|
|
- if (parent !== cur.parent || (next !== cur && next !== cur.nextSibling)){
|
|
|
- let typeInfo = {
|
|
|
- updateType: 'update',
|
|
|
- projectType: null
|
|
|
- };
|
|
|
- updateData = GetUpdateData(null, parent, next, '', null, projTreeObj.tree.selected.id(), typeInfo);
|
|
|
- //维护cur pre
|
|
|
- let curPre = cur.preSibling();
|
|
|
- if(curPre){
|
|
|
- updateData.push({updateType: 'update', updateData: {ID: curPre.id(), NextSiblingID: cur.nid()}});
|
|
|
- }
|
|
|
- UpdateProjectData(updateData, function (data) {
|
|
|
- dialog.modal('hide');
|
|
|
- let orgRow = projTreeObj.tree.items.indexOf(projTreeObj.tree.selected);
|
|
|
- projTreeObj.tree.move(projTreeObj.tree.selected, parent, next);
|
|
|
- let newRow = projTreeObj.tree.items.indexOf(projTreeObj.tree.selected);
|
|
|
- //view move
|
|
|
- projTreeObj.move(orgRow, newRow);
|
|
|
- });
|
|
|
- } else {
|
|
|
- dialog.modal('hide');
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
// 复制到按钮点击
|
|
|
$('#copy-to-btn').click(function () {
|
|
@@ -1215,6 +1213,7 @@ function init() {
|
|
|
projTreeObj.tree = pmTree.createNew(projTreeObj.setting, datas);
|
|
|
projTreeObj.tree.selected = projTreeObj.tree.items[0];
|
|
|
projTreeObj.buildSheet();
|
|
|
+ projTreeObj.sumEngineeringCost();
|
|
|
projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header);
|
|
|
//初始选择
|
|
|
let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
|