|
@@ -55,8 +55,10 @@ const projTreeObj = {
|
|
|
tree: null,
|
|
|
workBook: null,
|
|
|
copyToWorkBook:null,
|
|
|
+ replaceWorkBook:null,
|
|
|
copySelected:null,
|
|
|
preSelection: null,
|
|
|
+ changeInfo:null,
|
|
|
setting: {
|
|
|
tree: {
|
|
|
id: 'ID',
|
|
@@ -116,7 +118,28 @@ const projTreeObj = {
|
|
|
allowUserDragFill: false,
|
|
|
scrollbarMaxAlign : true,
|
|
|
showDragDropTip:false
|
|
|
- }},
|
|
|
+ }
|
|
|
+ },
|
|
|
+ replaceSetting:{
|
|
|
+ header: [
|
|
|
+ {name: '工程列表', dataCode: 'name', width: 250, vAlign: 'center', hAlign: 'left'},
|
|
|
+ {name: '选择', dataCode: 'selected', width: 50, vAlign: 'center', cellType:'checkBox'}
|
|
|
+ ],
|
|
|
+ //选中行颜色
|
|
|
+ style: {
|
|
|
+ defalutBackColor: 'White',
|
|
|
+ selectedColor: '#BBFFFF'
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ tabStripVisible: false,
|
|
|
+ allowCopyPasteExcelStyle : false,
|
|
|
+ allowExtendPasteRange: false,
|
|
|
+ allowUserDragDrop : false,
|
|
|
+ allowUserDragFill: false,
|
|
|
+ scrollbarMaxAlign : true,
|
|
|
+ showDragDropTip:false
|
|
|
+ }
|
|
|
+ },
|
|
|
renderSheetFuc: function (sheet, fuc) {
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
@@ -137,6 +160,7 @@ const projTreeObj = {
|
|
|
sheet.bind(_events.EditStarting, this.onCellEditing);
|
|
|
sheet.bind(_events.ClipboardPasting,this.onCellEditing);
|
|
|
workBook.bind(_events.DragDropBlock, this.onDragDropBlock);
|
|
|
+ workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, this.changeFileClick)
|
|
|
},
|
|
|
buildHeader: function (sheet, headers) {
|
|
|
let me = this;
|
|
@@ -472,6 +496,14 @@ const projTreeObj = {
|
|
|
let me = projTreeObj;
|
|
|
me.initSelection(args.newSelections[0], args.oldSelections[0],args.sheet);
|
|
|
},
|
|
|
+ changeFileClick:async function (sender,args) {
|
|
|
+ if(args.sheet.name() == "projectSheet"){
|
|
|
+ await projTreeObj.initFileChangePage(projTreeObj.setting.header[args.col].dataCode);
|
|
|
+ $("#mr_from").val(projTreeObj.setting.header[args.col].dataCode);
|
|
|
+ $("#project_name").text(projTreeObj.tree.selected.data.name);
|
|
|
+ $('#m_replace_file').modal('show');
|
|
|
+ }
|
|
|
+ },
|
|
|
onDragDropBlock : function (sender,args) {//拖动移动项目位置
|
|
|
let selected = projTreeObj.tree.selected;
|
|
|
let targetNode = projTreeObj.tree.items[args.toRow];
|
|
@@ -837,7 +869,7 @@ const projTreeObj = {
|
|
|
function withingClickArea(){
|
|
|
return hitinfo.x > centerX + halfBoxLength && hitinfo.x < centerX + halfBoxLength + imgWidth + indent/2+3 + textLength;
|
|
|
}
|
|
|
- if(hitinfo.sheet.name() != "copyToSheet"){//如果是复制到sheet,不用执行
|
|
|
+ if(hitinfo.sheet.name() === "projectSheet"){//只有项目管理界面才执行
|
|
|
//单项文件,进入造价书界面
|
|
|
if(node.data.projType === projectType.tender && withingClickArea()){
|
|
|
let timeoutTime = 200;
|
|
@@ -909,10 +941,11 @@ const projTreeObj = {
|
|
|
}
|
|
|
return new TreeNodeCellType();
|
|
|
},
|
|
|
- setCellValue: function (cell, node,sheet) {
|
|
|
+ setCellValue: function (cell, node,sheet,setting) {
|
|
|
//const sheet = this.workBook.getActiveSheet();
|
|
|
+ if(!setting) setting = this.setting;
|
|
|
const {row, col} = cell;
|
|
|
- let dataCode = this.setting.header[col]['dataCode'];
|
|
|
+ let dataCode = setting.header[col]['dataCode'];
|
|
|
let value = '';
|
|
|
if(dataCode === 'unitPriceFile'){
|
|
|
if(node.data.projType === projectType.tender){
|
|
@@ -932,9 +965,10 @@ const projTreeObj = {
|
|
|
}
|
|
|
sheet.setValue(row, col, value);
|
|
|
},
|
|
|
- showTreeData: function (nodes, headers,sheet) {
|
|
|
+ showTreeData: function (nodes, setting,sheet) {
|
|
|
+ let headers = setting.header;
|
|
|
let me = this;
|
|
|
- let tree = sheet.name() == "copyToSheet"?me.copyTree:me.tree;
|
|
|
+ let tree = nodes.length>0?nodes[0].tree:me.tree;//sheet.name() == "copyToSheet"?me.copyTree:me.tree;
|
|
|
let fuc = function(){
|
|
|
sheet.setRowCount(0);
|
|
|
sheet.setRowCount(nodes.length);
|
|
@@ -944,8 +978,16 @@ const projTreeObj = {
|
|
|
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).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
|
|
|
- me.setCellValue({row: i, col: j}, nodes[i],sheet);
|
|
|
+ if(headers[j].cellType == "checkBox"){
|
|
|
+ sheet.setCellType(i, j,new GC.Spread.Sheets.CellTypes.CheckBox(),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.getCell(i, j).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
+ }
|
|
|
+ me.setCellValue({row: i, col: j}, nodes[i],sheet,setting);
|
|
|
let dataCode = headers[j].dataCode;
|
|
|
+ if(nodes[i].data.projType == "Tender" && (dataCode=="feeRateFile" || dataCode == "unitPriceFile")) {
|
|
|
+ sheet.setCellType(i, j,sheetCommonObj.getSelectButton(headers[j].width),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.getCell(i, j,GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
+ }
|
|
|
//sheet.setValue(i, j, nodes[i]['data'][dataCode]);
|
|
|
}
|
|
|
sheet.getCell(i, 1,GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
@@ -1018,6 +1060,95 @@ const projTreeObj = {
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ initFileChangePage:async function (from) {
|
|
|
+ let title = from == "unitPriceFile" ?"批量替换单价文件":"批量替换费率文件";
|
|
|
+ $("#mr_title").text(title);
|
|
|
+ this.initHtmlByFromRadio();
|
|
|
+ let result = from == "unitPriceFile"?await this.setUnitFileChangeFileData():await this.setFeeRateChangeFileData();
|
|
|
+ console.log(result);
|
|
|
+ this.changeInfo = result;
|
|
|
+ this.loadFileOptions(this.changeInfo,from);
|
|
|
+
|
|
|
+ },
|
|
|
+ setFeeRateChangeFileData:async function(){
|
|
|
+ //userID
|
|
|
+ let node = projTreeObj.tree.selected;
|
|
|
+ let data={"user_id":userID, "projectID":node.data.ID, "rootProjectID":node.data.property.rootProjectID};
|
|
|
+ let result = await ajaxPost("/feeRates/getChangeInfo",data);
|
|
|
+ this.getFileListWithPath(result.others);
|
|
|
+ return result;
|
|
|
+
|
|
|
+ },
|
|
|
+ setUnitFileChangeFileData:async function(){
|
|
|
+ let node = projTreeObj.tree.selected;
|
|
|
+ let data ={"project_id":node.data.ID,"rootProjectID":node.data.property.rootProjectID};
|
|
|
+ let result = await ajaxPost("/glj/get-project-info",data);
|
|
|
+ this.getFileListWithPath(result.other);
|
|
|
+ console.log(result);
|
|
|
+ //数据结构不一样,这里做一下转换
|
|
|
+ let t_result = {
|
|
|
+ currentProject:{
|
|
|
+ ID:node.data.ID,
|
|
|
+ currentOptions:result.self,
|
|
|
+ },
|
|
|
+ others:result.other
|
|
|
+ }
|
|
|
+ return t_result;
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ getFileListWithPath:function (list) {
|
|
|
+ for(let n of list){
|
|
|
+ let node = projTreeObj.tree.findNode(n.ID);
|
|
|
+ if(node) n.name = getPathName(node);
|
|
|
+ }
|
|
|
+
|
|
|
+ function getPathName(node) {
|
|
|
+ if(node.parent && node.parent.data){
|
|
|
+ return getPathName(node.parent)+"\\"+node.data.name
|
|
|
+ }else {
|
|
|
+ return node.data?node.data.name:"";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ loadFileOptions:function (data,from) {
|
|
|
+ let idField = "ID",optionField ="optionList";
|
|
|
+ if(from == "unitPriceFile"){
|
|
|
+ idField = 'id';
|
|
|
+ optionField = 'unitPriceList'
|
|
|
+ }
|
|
|
+ $('#currentOptions').empty();
|
|
|
+ for(let c of data.currentProject.currentOptions){
|
|
|
+ var option = $("<option>").val(c[idField]).text(c.name);
|
|
|
+ $('#currentOptions').append(option);
|
|
|
+ }
|
|
|
+ $('#otherProject').empty();
|
|
|
+ for(let p of data.others){
|
|
|
+ var option = $("<option>").val(p.ID).text(p.name);
|
|
|
+ $('#otherProject').append(option);
|
|
|
+ }
|
|
|
+ $('#otherFileOptions').empty();
|
|
|
+ if(data.others.length>0){
|
|
|
+ for(let f of data.others[0][optionField]){
|
|
|
+ var option = $("<option>").val(f[idField]).text(f.name);
|
|
|
+ $('#otherFileOptions').append(option);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initHtmlByFromRadio:function () {
|
|
|
+ var radioV= $("input[name='select_from']:checked").val();
|
|
|
+ if(radioV == "0"){
|
|
|
+ $("#fromProject").show();
|
|
|
+ $("#fromOther").hide();
|
|
|
+ } else {
|
|
|
+ $("#fromProject").hide();
|
|
|
+ $("#fromOther").show();
|
|
|
+ }
|
|
|
+ },
|
|
|
initCopyToSpread:function () {
|
|
|
let me = this;
|
|
|
me.copyToWorkBook = projTreeObj.buildSheet(me.copyToWorkBook,'copyToSpread',me.copyToSetting);
|
|
@@ -1029,11 +1160,27 @@ const projTreeObj = {
|
|
|
datas.push(i.data);
|
|
|
}
|
|
|
me.copyTree = pmTree.createNew(projTreeObj.setting, datas);
|
|
|
- me.showTreeData(me.copyTree.items, me.copyToSetting.header, sheet);
|
|
|
+ me.showTreeData(me.copyTree.items, me.copyToSetting, sheet);
|
|
|
me.copySelected = null;
|
|
|
let initSel = sheet.getSelections()[0] ? sheet.getSelections()[0] : {row: 0, rowCount: 1};
|
|
|
projTreeObj.initSelection(initSel,null,sheet);
|
|
|
},
|
|
|
+ initReplaceSpread:function () {
|
|
|
+ let me = this;
|
|
|
+ me.replaceWorkBook = projTreeObj.buildSheet(me.replaceWorkBook,'replaceSpread',me.replaceSetting);
|
|
|
+ let sheet = me.replaceWorkBook.getActiveSheet();
|
|
|
+ sheet.options.isProtected = true;
|
|
|
+ sheet.name('replaceSheet');
|
|
|
+ let datas = [];
|
|
|
+ for(let i of me.tree.items){
|
|
|
+ datas.push(i.data);
|
|
|
+ }
|
|
|
+ me.replaceTree = pmTree.createNew(projTreeObj.setting, datas);
|
|
|
+ me.showTreeData(me.replaceTree.items, me.replaceSetting, sheet);
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
insert: function (data, parent, next) {
|
|
|
let preNode = this.tree.items[this.preSelection.row];
|
|
|
let node = this.tree.addNodeData(data, parent, next);
|
|
@@ -1547,11 +1694,19 @@ $(document).ready(function() {
|
|
|
});*/
|
|
|
|
|
|
$('#copy-to-dialog').on('shown.bs.modal', function () {
|
|
|
- console.log('shown copy to ');
|
|
|
projTreeObj.initCopyToSpread();
|
|
|
// copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
|
|
|
});
|
|
|
|
|
|
+ $('#m_replace_file').on('shown.bs.modal', function () {
|
|
|
+ // projTreeObj.tree.selected
|
|
|
+ projTreeObj.initReplaceSpread();
|
|
|
+ });
|
|
|
+ $("input[name='select_from']").each(function(){
|
|
|
+ $(this).click(function(){
|
|
|
+ projTreeObj.initHtmlByFromRadio();
|
|
|
+ });
|
|
|
+ });
|
|
|
// 复制到操作
|
|
|
$("#copy-to-confirm").click(function() {
|
|
|
let originalNode = projTreeObj.tree.selected;
|
|
@@ -1654,7 +1809,6 @@ $(document).ready(function() {
|
|
|
}else {
|
|
|
$('#taxType_div').show();
|
|
|
}
|
|
|
- console.log(taxTypeArray);
|
|
|
}
|
|
|
|
|
|
function getStdCalcProgramFiles(){
|
|
@@ -1733,9 +1887,10 @@ function initProjects(callback) {
|
|
|
projTreeObj.tree.selected = projTreeObj.tree.items[0];
|
|
|
projTreeObj.workBook = projTreeObj.buildSheet(projTreeObj.workBook,'projSpread',projTreeObj.setting);
|
|
|
projTreeObj.workBook.getSheet(0).frozenColumnCount(2);
|
|
|
+ projTreeObj.workBook.getSheet(0).name('projectSheet');
|
|
|
sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
|
|
|
projTreeObj.sumEngineeringCost();
|
|
|
- projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header, projTreeObj.workBook.getActiveSheet());
|
|
|
+ projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting, projTreeObj.workBook.getActiveSheet());
|
|
|
//初始选择
|
|
|
let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
|
|
|
projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
|
|
@@ -3483,6 +3638,25 @@ $('#allowCopy').change(function () {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+//批量替换文件,切换建设项目
|
|
|
+$('#otherProject').change(function(){
|
|
|
+ let optionList = [],idField = 'ID';
|
|
|
+ var newVal = $(this).val();
|
|
|
+ var projects = projTreeObj.changeInfo.others;
|
|
|
+ var selected = _.find(projects,{ID:parseInt(newVal)});
|
|
|
+ if($("#mr_from").val() =="unitPriceFile"){
|
|
|
+ idField = 'id';
|
|
|
+ optionList = selected.unitPriceList;
|
|
|
+ }else {
|
|
|
+ optionList = selected.optionList;
|
|
|
+ }
|
|
|
+ $('#otherFileOptions').empty();
|
|
|
+ for(let f of optionList){
|
|
|
+ let option = $("<option>").val(f[idField]).text(f.name);
|
|
|
+ $('#otherFileOptions').append(option);
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
//分享给...界面确认
|
|
|
$('#shareToConfirm').click(function () {
|
|
|
let selected = projTreeObj.tree.selected;
|