|
@@ -27,6 +27,8 @@ let fileType = {
|
|
const projTreeObj = {
|
|
const projTreeObj = {
|
|
tree: null,
|
|
tree: null,
|
|
workBook: null,
|
|
workBook: null,
|
|
|
|
+ copyToWorkBook:null,
|
|
|
|
+ copySelected:null,
|
|
preSelection: null,
|
|
preSelection: null,
|
|
setting: {
|
|
setting: {
|
|
tree: {
|
|
tree: {
|
|
@@ -58,6 +60,24 @@ const projTreeObj = {
|
|
showDragDropTip:false
|
|
showDragDropTip:false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ copyToSetting:{
|
|
|
|
+ header: [
|
|
|
|
+ {name: '工程列表', dataCode: 'name', width: 550, vAlign: 'center', hAlign: 'left'}
|
|
|
|
+ ],
|
|
|
|
+ //选中行颜色
|
|
|
|
+ style: {
|
|
|
|
+ defalutBackColor: 'White',
|
|
|
|
+ selectedColor: '#BBFFFF'
|
|
|
|
+ },
|
|
|
|
+ options: {
|
|
|
|
+ tabStripVisible: false,
|
|
|
|
+ allowCopyPasteExcelStyle : false,
|
|
|
|
+ allowExtendPasteRange: false,
|
|
|
|
+ allowUserDragDrop : false,
|
|
|
|
+ allowUserDragFill: false,
|
|
|
|
+ scrollbarMaxAlign : true,
|
|
|
|
+ showDragDropTip:false
|
|
|
|
+ }},
|
|
renderSheetFuc: function (sheet, fuc) {
|
|
renderSheetFuc: function (sheet, fuc) {
|
|
sheet.suspendPaint();
|
|
sheet.suspendPaint();
|
|
sheet.suspendEvent();
|
|
sheet.suspendEvent();
|
|
@@ -96,13 +116,15 @@ const projTreeObj = {
|
|
};
|
|
};
|
|
me.renderSheetFuc(sheet, fuc);
|
|
me.renderSheetFuc(sheet, fuc);
|
|
},
|
|
},
|
|
- buildSheet: function () {
|
|
|
|
- if(!this.workBook){
|
|
|
|
- this.workBook = new GC.Spread.Sheets.Workbook($('#projSpread')[0], {sheetCount: 1});
|
|
|
|
- this.setOptions(this.workBook, this.setting.options);
|
|
|
|
- this.buildHeader(this.workBook.getActiveSheet(), this.setting.header);
|
|
|
|
- this.bindEvent(this.workBook);
|
|
|
|
- }
|
|
|
|
|
|
+ buildSheet: function (workBook,spreadID,setting) {//改成和复制项目spread共用
|
|
|
|
+ let newWorkBook = workBook;
|
|
|
|
+ if(!workBook){
|
|
|
|
+ newWorkBook = new GC.Spread.Sheets.Workbook($('#'+spreadID)[0], {sheetCount: 1});
|
|
|
|
+ this.setOptions(newWorkBook, setting.options);
|
|
|
|
+ this.buildHeader(newWorkBook.getActiveSheet(), setting.header);
|
|
|
|
+ this.bindEvent(newWorkBook);
|
|
|
|
+ }
|
|
|
|
+ return newWorkBook;
|
|
},
|
|
},
|
|
getSelStyle: function (backColor) {
|
|
getSelStyle: function (backColor) {
|
|
let style = new GC.Spread.Sheets.Style();
|
|
let style = new GC.Spread.Sheets.Style();
|
|
@@ -114,9 +136,9 @@ const projTreeObj = {
|
|
return style;
|
|
return style;
|
|
},
|
|
},
|
|
//设置选中行底色
|
|
//设置选中行底色
|
|
- setSelStyle: function (sel, backColor) {
|
|
|
|
|
|
+ setSelStyle: function (sel, backColor,sheet) {
|
|
let me = this;
|
|
let me = this;
|
|
- let sheet = me.workBook.getSheet(0);
|
|
|
|
|
|
+ //let sheet = me.workBook.getSheet(0);
|
|
me.renderSheetFuc(sheet, function () {
|
|
me.renderSheetFuc(sheet, function () {
|
|
let style = me.getSelStyle(backColor);
|
|
let style = me.getSelStyle(backColor);
|
|
/*sel.row = sel.row === -1 ? 0 : sel.row;*/
|
|
/*sel.row = sel.row === -1 ? 0 : sel.row;*/
|
|
@@ -126,19 +148,30 @@ const projTreeObj = {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- initSelection: function (newSel, oldSel = null) {
|
|
|
|
|
|
+ initSelection: function (newSel, oldSel = null,sheet) {
|
|
let me = this;
|
|
let me = this;
|
|
let node = me.tree.items[newSel.row];
|
|
let node = me.tree.items[newSel.row];
|
|
//恢复底色
|
|
//恢复底色
|
|
if(oldSel){
|
|
if(oldSel){
|
|
- me.setSelStyle(oldSel, me.setting.style.defalutBackColor);
|
|
|
|
|
|
+ me.setSelStyle(oldSel, me.setting.style.defalutBackColor,sheet);
|
|
}
|
|
}
|
|
//设置选中行底色
|
|
//设置选中行底色
|
|
if(newSel){
|
|
if(newSel){
|
|
- me.setSelStyle(newSel, me.setting.style.selectedColor);
|
|
|
|
|
|
+ me.setSelStyle(newSel, me.setting.style.selectedColor,sheet);
|
|
|
|
+ }
|
|
|
|
+ if(sheet.name()=="copyToSheet"){ //复制到
|
|
|
|
+ me.copySelected = node;
|
|
|
|
+ let canCopy = false;
|
|
|
|
+ if(node){
|
|
|
|
+ canCopy = node.data.projType == projectType.tender|| node.data.projType == projectType.engineering;
|
|
|
|
+ }
|
|
|
|
+ canCopy == true?$("#copy-to-confirm").removeClass("disabled"):$("#copy-to-confirm").addClass("disabled");
|
|
|
|
+ return;//如果是复制到表,不用做后面的操作
|
|
}
|
|
}
|
|
me.tree.selected = node;
|
|
me.tree.selected = node;
|
|
me.preSelection = newSel;
|
|
me.preSelection = newSel;
|
|
|
|
+ console.log("set main tree selected");
|
|
|
|
+ console.log(me.tree.selected);
|
|
$(".tools-btn > a").not(".disabled").addClass("disabled");
|
|
$(".tools-btn > a").not(".disabled").addClass("disabled");
|
|
$("#add-engineering-btn").addClass("disabled");
|
|
$("#add-engineering-btn").addClass("disabled");
|
|
$('#add-tender-btn').removeClass('disabled');
|
|
$('#add-tender-btn').removeClass('disabled');
|
|
@@ -171,7 +204,7 @@ const projTreeObj = {
|
|
},
|
|
},
|
|
onSelectionChanging: function (sender, args) {
|
|
onSelectionChanging: function (sender, args) {
|
|
let me = projTreeObj;
|
|
let me = projTreeObj;
|
|
- me.initSelection(args.newSelections[0], args.oldSelections[0]);
|
|
|
|
|
|
+ me.initSelection(args.newSelections[0], args.oldSelections[0],args.sheet);
|
|
},
|
|
},
|
|
onDragDropBlock : function (sender,args) {//拖动移动项目位置
|
|
onDragDropBlock : function (sender,args) {//拖动移动项目位置
|
|
let selected = projTreeObj.tree.selected;
|
|
let selected = projTreeObj.tree.selected;
|
|
@@ -180,6 +213,9 @@ const projTreeObj = {
|
|
let rootProjectID = null;//记录建设项目ID
|
|
let rootProjectID = null;//记录建设项目ID
|
|
//let updateObj = {project:[],feeRateFile:[],unitPriceFile:[]};
|
|
//let updateObj = {project:[],feeRateFile:[],unitPriceFile:[]};
|
|
args.cancel = true;//首先取消填充的动作
|
|
args.cancel = true;//首先取消填充的动作
|
|
|
|
+ if(args.sheet.name()=="copyToSheet"){ //如果是复制到表,不用做后面的操作
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if(selected.preSibling()!=null&&selected.preSibling() == targetNode){
|
|
if(selected.preSibling()!=null&&selected.preSibling() == targetNode){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -507,7 +543,6 @@ const projTreeObj = {
|
|
TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
let offset = -1;
|
|
let offset = -1;
|
|
let node = tree.items[hitinfo.row];
|
|
let node = tree.items[hitinfo.row];
|
|
- tree.selected = node;
|
|
|
|
let centerX = hitinfo.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
|
|
let centerX = hitinfo.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
|
|
let centerY = (hitinfo.cellRect.y + offset + (hitinfo.cellRect.y + offset + hitinfo.cellRect.height)) / 2;
|
|
let centerY = (hitinfo.cellRect.y + offset + (hitinfo.cellRect.y + offset + hitinfo.cellRect.height)) / 2;
|
|
let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
|
|
let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
|
|
@@ -519,40 +554,41 @@ const projTreeObj = {
|
|
function withingClickArea(){
|
|
function withingClickArea(){
|
|
return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
|
|
return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
|
|
}
|
|
}
|
|
- //建设项目,侧滑汇总
|
|
|
|
- if(node.data.projType === projectType.project && withingClickArea()){
|
|
|
|
- setDataToSideBar();
|
|
|
|
- $(".slide-sidebar").animate({width:"800"}).addClass("open");
|
|
|
|
- $('body').unbind('click');
|
|
|
|
- setTimeout(function () {
|
|
|
|
- $("body").bind('click', function (event) {
|
|
|
|
- var e = event || window.event; //浏览器兼容性
|
|
|
|
- if (!$(event.target).is('a')) {
|
|
|
|
- var elem = event.target || e.srcElement;
|
|
|
|
- while (elem) { //循环判断至跟节点,防止点击的是div子元素
|
|
|
|
- if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
|
|
|
|
- return false;
|
|
|
|
|
|
+ if(hitinfo.sheet.name() != "copyToSheet"){//如果是复制到sheet,不用执行
|
|
|
|
+ //建设项目,侧滑汇总
|
|
|
|
+ if(node.data.projType === projectType.project && withingClickArea()){
|
|
|
|
+ setDataToSideBar();
|
|
|
|
+ $(".slide-sidebar").animate({width:"800"}).addClass("open");
|
|
|
|
+ $('body').unbind('click');
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ $("body").bind('click', function (event) {
|
|
|
|
+ var e = event || window.event; //浏览器兼容性
|
|
|
|
+ if (!$(event.target).is('a')) {
|
|
|
|
+ var elem = event.target || e.srcElement;
|
|
|
|
+ while (elem) { //循环判断至跟节点,防止点击的是div子元素
|
|
|
|
+ if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ elem = elem.parentNode;
|
|
}
|
|
}
|
|
- elem = elem.parentNode;
|
|
|
|
|
|
+ $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
|
|
}
|
|
}
|
|
- $(".slide-sidebar").animate({width: "0"}).removeClass("open")// 关闭处理
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }, 500);
|
|
|
|
- }
|
|
|
|
- //单项文件,进入造价书界面
|
|
|
|
- else if(node.data.projType === projectType.tender && withingClickArea()){
|
|
|
|
- let newTab = window.open('about:blank');
|
|
|
|
- BeforeOpenProject(node.data.ID, {'fullFolder': GetFullFolder(node.parent)}, function () {
|
|
|
|
- let mainUrl = `/main?project=${node.data.ID}`;
|
|
|
|
- CommonAjax.get(mainUrl, [], function () {
|
|
|
|
- newTab.location.href = mainUrl;
|
|
|
|
|
|
+ });
|
|
|
|
+ }, 500);
|
|
|
|
+ }
|
|
|
|
+ //单项文件,进入造价书界面
|
|
|
|
+ else if(node.data.projType === projectType.tender && withingClickArea()){
|
|
|
|
+ let newTab = window.open('about:blank');
|
|
|
|
+ BeforeOpenProject(node.data.ID, {'fullFolder': GetFullFolder(node.parent)}, function () {
|
|
|
|
+ let mainUrl = `/main?project=${node.data.ID}`;
|
|
|
|
+ CommonAjax.get(mainUrl, [], function () {
|
|
|
|
+ newTab.location.href = mainUrl;
|
|
|
|
+ });
|
|
});
|
|
});
|
|
- });
|
|
|
|
- return;
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!node || node.children.length === 0) { return; }
|
|
}
|
|
}
|
|
- if (!node || node.children.length === 0) { return; }
|
|
|
|
-
|
|
|
|
if (hitinfo.x > centerX - halfBoxLength && hitinfo.x < centerX + halfBoxLength && hitinfo.y > centerY - halfBoxLength && hitinfo.y < centerY + halfBoxLength) {
|
|
if (hitinfo.x > centerX - halfBoxLength && hitinfo.x < centerX + halfBoxLength && hitinfo.y > centerY - halfBoxLength && hitinfo.y < centerY + halfBoxLength) {
|
|
node.setExpanded(!node.expanded);
|
|
node.setExpanded(!node.expanded);
|
|
TREE_SHEET_HELPER.massOperationSheet(hitinfo.sheet, function () {
|
|
TREE_SHEET_HELPER.massOperationSheet(hitinfo.sheet, function () {
|
|
@@ -582,8 +618,8 @@ const projTreeObj = {
|
|
};
|
|
};
|
|
return new TreeNodeCellType();
|
|
return new TreeNodeCellType();
|
|
},
|
|
},
|
|
- setCellValue: function (cell, node) {
|
|
|
|
- const sheet = this.workBook.getActiveSheet();
|
|
|
|
|
|
+ setCellValue: function (cell, node,sheet) {
|
|
|
|
+ //const sheet = this.workBook.getActiveSheet();
|
|
const {row, col} = cell;
|
|
const {row, col} = cell;
|
|
let dataCode = this.setting.header[col]['dataCode'];
|
|
let dataCode = this.setting.header[col]['dataCode'];
|
|
let value = '';
|
|
let value = '';
|
|
@@ -610,10 +646,11 @@ const projTreeObj = {
|
|
}
|
|
}
|
|
sheet.setValue(row, col, value);
|
|
sheet.setValue(row, col, value);
|
|
},
|
|
},
|
|
- showTreeData: function (nodes, headers) {
|
|
|
|
|
|
+ showTreeData: function (nodes, headers,sheet) {
|
|
let me = this;
|
|
let me = this;
|
|
- let sheet = me.workBook.getActiveSheet();
|
|
|
|
|
|
+ // let sheet = me.workBook.getActiveSheet(); 为了共用
|
|
let fuc = function(){
|
|
let fuc = function(){
|
|
|
|
+ sheet.setRowCount(0);
|
|
sheet.setRowCount(nodes.length);
|
|
sheet.setRowCount(nodes.length);
|
|
for(let i = 0; i < nodes.length; i++){
|
|
for(let i = 0; i < nodes.length; i++){
|
|
let treeNodeCell = me.getTreeNodeCell(me.tree);
|
|
let treeNodeCell = me.getTreeNodeCell(me.tree);
|
|
@@ -621,7 +658,7 @@ const projTreeObj = {
|
|
for(let j = 0; j < headers.length; j++){
|
|
for(let j = 0; j < headers.length; j++){
|
|
sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
|
|
sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
|
|
sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
|
|
sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
|
|
- me.setCellValue({row: i, col: j}, nodes[i]);
|
|
|
|
|
|
+ me.setCellValue({row: i, col: j}, nodes[i],sheet);
|
|
let dataCode = headers[j].dataCode;
|
|
let dataCode = headers[j].dataCode;
|
|
//sheet.setValue(i, j, nodes[i]['data'][dataCode]);
|
|
//sheet.setValue(i, j, nodes[i]['data'][dataCode]);
|
|
}
|
|
}
|
|
@@ -638,16 +675,16 @@ const projTreeObj = {
|
|
|
|
|
|
if(_.isArray(nodes)){
|
|
if(_.isArray(nodes)){
|
|
for(let t of nodes){
|
|
for(let t of nodes){
|
|
- setSheetCellData(t);
|
|
|
|
|
|
+ setSheetCellData(t,sheet);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
- setSheetCellData(nodes);
|
|
|
|
|
|
+ setSheetCellData(nodes,sheet);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- function setSheetCellData(n) {
|
|
|
|
|
|
+ function setSheetCellData(n,sheet) {
|
|
let rIdx = me.tree.items.indexOf(n);
|
|
let rIdx = me.tree.items.indexOf(n);
|
|
for(let i = 0; i < header.length; i++){
|
|
for(let i = 0; i < header.length; i++){
|
|
- me.setCellValue({row: rIdx, col: i}, n);
|
|
|
|
|
|
+ me.setCellValue({row: rIdx, col: i}, n,sheet);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -692,11 +729,22 @@ const projTreeObj = {
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
},
|
|
|
|
+ initCopyToSpread:function () {
|
|
|
|
+ let me = this;
|
|
|
|
+ me.copyToWorkBook = projTreeObj.buildSheet(me.copyToWorkBook,'copyToSpread',me.copyToSetting);
|
|
|
|
+ let sheet = me.copyToWorkBook.getActiveSheet();
|
|
|
|
+ sheet.options.isProtected = true;
|
|
|
|
+ sheet.name('copyToSheet');
|
|
|
|
+ me.showTreeData(me.tree.items, me.copyToSetting.header, sheet);
|
|
|
|
+ me.copySelected = null;
|
|
|
|
+ let initSel = sheet.getSelections()[0] ? sheet.getSelections()[0] : {row: 0, rowCount: 1};
|
|
|
|
+ projTreeObj.initSelection(initSel,null,sheet);
|
|
|
|
+ },
|
|
insert: function (data, parent, next) {
|
|
insert: function (data, parent, next) {
|
|
let node = this.tree.addNodeData(data, parent, next);
|
|
let node = this.tree.addNodeData(data, parent, next);
|
|
this.addRow(node);
|
|
this.addRow(node);
|
|
let newSel = this.workBook.getSheet(0).getSelections()[0];
|
|
let newSel = this.workBook.getSheet(0).getSelections()[0];
|
|
- this.initSelection(newSel, this.preSelection);
|
|
|
|
|
|
+ this.initSelection(newSel, this.preSelection,this.workBook.getActiveSheet());
|
|
return node;
|
|
return node;
|
|
},
|
|
},
|
|
addRow: function (node) {
|
|
addRow: function (node) {
|
|
@@ -723,7 +771,7 @@ const projTreeObj = {
|
|
me.renderSheetFuc(sheet, function () {
|
|
me.renderSheetFuc(sheet, function () {
|
|
sheet.deleteRows(rIdx, count);
|
|
sheet.deleteRows(rIdx, count);
|
|
sheet.setRowCount(me.tree.items.length);
|
|
sheet.setRowCount(me.tree.items.length);
|
|
- me.initSelection({row: sheet.getActiveRowIndex(), rowCount: 1});
|
|
|
|
|
|
+ me.initSelection({row: sheet.getActiveRowIndex(), rowCount: 1},null,sheet);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
move: function (orgRow, newRow) {
|
|
move: function (orgRow, newRow) {
|
|
@@ -748,7 +796,7 @@ const projTreeObj = {
|
|
sheet.deleteRows(fromRow, rCout);
|
|
sheet.deleteRows(fromRow, rCout);
|
|
sheet.addRows(newNode.serialNo(),rCout);
|
|
sheet.addRows(newNode.serialNo(),rCout);
|
|
let oldSelection = sheet.getSelections()[0];
|
|
let oldSelection = sheet.getSelections()[0];
|
|
- me.initSelection({row: newNode.serialNo(), rowCount: oldSelection.rowCount}, oldSelection);
|
|
|
|
|
|
+ me.initSelection({row: newNode.serialNo(), rowCount: oldSelection.rowCount}, oldSelection,sheet);
|
|
sheet.setSelection(newNode.serialNo(),oldSelection.col,oldSelection.rowCount,oldSelection.colCount);
|
|
sheet.setSelection(newNode.serialNo(),oldSelection.col,oldSelection.rowCount,oldSelection.colCount);
|
|
let children = newNode.getAllChildren();
|
|
let children = newNode.getAllChildren();
|
|
children.push(newNode);
|
|
children.push(newNode);
|
|
@@ -1086,84 +1134,113 @@ $(document).ready(function() {
|
|
$('#copy-to-dialog').modal('show');
|
|
$('#copy-to-dialog').modal('show');
|
|
});
|
|
});
|
|
// 复制到弹层替换
|
|
// 复制到弹层替换
|
|
- $('#copy-to-dialog').on('show.bs.modal', function () {
|
|
|
|
|
|
+ /* $('#copy-to-dialog').on('show.bs.modal', function () {
|
|
copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
|
|
copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
|
|
|
|
+ });*/
|
|
|
|
+
|
|
|
|
+ $('#copy-to-dialog').on('shown.bs.modal', function () {
|
|
|
|
+ console.log('shown copy to ');
|
|
|
|
+ projTreeObj.initCopyToSpread();
|
|
|
|
+ // copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
|
|
});
|
|
});
|
|
|
|
|
|
// 复制到操作
|
|
// 复制到操作
|
|
$("#copy-to-confirm").click(function() {
|
|
$("#copy-to-confirm").click(function() {
|
|
- let dialog = $('#copy-to-dialog');
|
|
|
|
- let target = GetTargetTreeNode($.fn.zTree.getZTreeObj('treeDemo2'));
|
|
|
|
- let parent = null;
|
|
|
|
- let next = null;
|
|
|
|
- let pre = null;
|
|
|
|
- let cur = projTreeObj.tree.selected;
|
|
|
|
- if (!target) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (target.data.projType !== projectType.engineering) {
|
|
|
|
- alert("请移动到单项工程中!");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (target.data.projType !== projectType.tender && target.children.length !== 0 &&
|
|
|
|
- target.firstChild().data.projType !== projectType.tender) {
|
|
|
|
- dialog.modal('hide');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 判断同级是否有同名
|
|
|
|
- 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 originalNode = projTreeObj.tree.selected;
|
|
|
|
+ let toNode = projTreeObj.copySelected;
|
|
|
|
+ let parent = null,next = null;
|
|
|
|
+ if(toNode.data.projType == projectType.engineering){//复制为目标的子节点
|
|
|
|
+ parent = toNode;
|
|
|
|
+ next = toNode.nextSibling;
|
|
|
|
+ }else if(toNode.data.projType == projectType.tender){//复制为目标的后兄弟
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+/* tem_parent = target;
|
|
|
|
+ tem_next = target.firstChild();
|
|
|
|
+ tem_parent = target.parent;
|
|
|
|
+ tem_next = target.nextSibling;*/
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ console.log(originalNode);
|
|
|
|
+ console.log(toNode);
|
|
|
|
+ CommonAjax.post('/pm/api/copyProjects',{ID:'test',user_id: userID},function () {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ /* let dialog = $('#copy-to-dialog');
|
|
|
|
+ let target = GetTargetTreeNode($.fn.zTree.getZTreeObj('treeDemo2'));
|
|
|
|
+ let parent = null;
|
|
|
|
+ let next = null;
|
|
|
|
+ let pre = null;
|
|
|
|
+ let cur = projTreeObj.tree.selected;
|
|
|
|
+ if (!target) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (target.data.projType !== projectType.engineering) {
|
|
|
|
+ alert("请移动到单项工程中!");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (target.data.projType !== projectType.tender && target.children.length !== 0 &&
|
|
|
|
+ target.firstChild().data.projType !== projectType.tender) {
|
|
|
|
+ dialog.modal('hide');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断同级是否有同名
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (target.data.projType === projectType.tender) {
|
|
|
|
+ parent = target.parent;
|
|
|
|
+ next = target.nextSibling;
|
|
|
|
+ } else {
|
|
|
|
+ parent = target;
|
|
|
|
+ next = target.firstChild();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (parent !== cur.parent || (next !== cur && next !== cur.nextSibling)){
|
|
|
|
+ CommonAjax.post('/pm/api/getNewProjectID', {count: 1, user_id: userID}, function (IDs) {
|
|
|
|
+ let typeInfo = {
|
|
|
|
+ updateType: 'copy',
|
|
|
|
+ projType: cur.data.projectType
|
|
|
|
+ };
|
|
|
|
+ let updateData = GetUpdateData(null, parent, next, cur.data.name, cur.data.property, IDs.lowID, typeInfo);
|
|
|
|
+ updateData.forEach(function (data) {
|
|
|
|
+ if (data.updateType === 'copy') {
|
|
|
|
+ data['srcProjectId'] = cur.id();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ pre = GetNeedUpdatePreNode(parent, next);
|
|
|
|
+ if (pre) {
|
|
|
|
+ updateData = {};
|
|
|
|
+ updateData['updateType'] = 'update';
|
|
|
|
+ updateData['updateData'] = {};
|
|
|
|
+ updateData['updateData'][projTreeObj.tree.setting.tree.id] = pre.id();
|
|
|
|
+ updateData['updateData'][projTreeObj.tree.setting.tree.nid] = projTreeObj.tree.maxNodeId() + 1;
|
|
|
|
+ }
|
|
|
|
+ projTreeObj.tree.maxNodeId(IDs.lowID - 1);
|
|
|
|
+ CommonAjax.post('/pm/api/copyProjects', {updateData: updateData, user_id: userID}, function (data) {
|
|
|
|
+ dialog.modal('hide');
|
|
|
|
+ data.forEach(function (nodeData) {
|
|
|
|
+ if (nodeData.updateType === 'copy') {
|
|
|
|
+ projTreeObj.insert(nodeData.updateData, parent, next);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }, function () {
|
|
|
|
+ dialog.modal('hide');
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }*/
|
|
|
|
|
|
- if (target.data.projType === projectType.tender) {
|
|
|
|
- parent = target.parent;
|
|
|
|
- next = target.nextSibling;
|
|
|
|
- } else {
|
|
|
|
- parent = target;
|
|
|
|
- next = target.firstChild();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (parent !== cur.parent || (next !== cur && next !== cur.nextSibling)){
|
|
|
|
- CommonAjax.post('/pm/api/getNewProjectID', {count: 1, user_id: userID}, function (IDs) {
|
|
|
|
- let typeInfo = {
|
|
|
|
- updateType: 'copy',
|
|
|
|
- projType: cur.data.projectType
|
|
|
|
- };
|
|
|
|
- let updateData = GetUpdateData(null, parent, next, cur.data.name, cur.data.property, IDs.lowID, typeInfo);
|
|
|
|
- updateData.forEach(function (data) {
|
|
|
|
- if (data.updateType === 'copy') {
|
|
|
|
- data['srcProjectId'] = cur.id();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- pre = GetNeedUpdatePreNode(parent, next);
|
|
|
|
- if (pre) {
|
|
|
|
- updateData = {};
|
|
|
|
- updateData['updateType'] = 'update';
|
|
|
|
- updateData['updateData'] = {};
|
|
|
|
- updateData['updateData'][projTreeObj.tree.setting.tree.id] = pre.id();
|
|
|
|
- updateData['updateData'][projTreeObj.tree.setting.tree.nid] = projTreeObj.tree.maxNodeId() + 1;
|
|
|
|
- }
|
|
|
|
- projTreeObj.tree.maxNodeId(IDs.lowID - 1);
|
|
|
|
- CommonAjax.post('/pm/api/copyProjects', {updateData: updateData, user_id: userID}, function (data) {
|
|
|
|
- dialog.modal('hide');
|
|
|
|
- data.forEach(function (nodeData) {
|
|
|
|
- if (nodeData.updateType === 'copy') {
|
|
|
|
- projTreeObj.insert(nodeData.updateData, parent, next);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }, function () {
|
|
|
|
- dialog.modal('hide');
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
});
|
|
});
|
|
|
|
|
|
// 选择工程专业后动态更改费率文件等数据
|
|
// 选择工程专业后动态更改费率文件等数据
|
|
@@ -1207,12 +1284,12 @@ function init() {
|
|
// projTreeObj.getShowData(datas);
|
|
// projTreeObj.getShowData(datas);
|
|
projTreeObj.tree = pmTree.createNew(projTreeObj.setting, datas);
|
|
projTreeObj.tree = pmTree.createNew(projTreeObj.setting, datas);
|
|
projTreeObj.tree.selected = projTreeObj.tree.items[0];
|
|
projTreeObj.tree.selected = projTreeObj.tree.items[0];
|
|
- projTreeObj.buildSheet();
|
|
|
|
|
|
+ projTreeObj.workBook = projTreeObj.buildSheet(projTreeObj.workBook,'projSpread',projTreeObj.setting);
|
|
projTreeObj.sumEngineeringCost();
|
|
projTreeObj.sumEngineeringCost();
|
|
- projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header);
|
|
|
|
|
|
+ projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header, projTreeObj.workBook.getActiveSheet());
|
|
//初始选择
|
|
//初始选择
|
|
let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
|
|
let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
|
|
- projTreeObj.initSelection(initSel);
|
|
|
|
|
|
+ projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
|
|
$.bootstrapLoading.end();
|
|
$.bootstrapLoading.end();
|
|
});
|
|
});
|
|
engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
|
|
engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
|