|
@@ -50,10 +50,6 @@ let gatherFeesView = {
|
|
|
|
|
|
buildSheet: function (){
|
|
|
let me = this;
|
|
|
- let obj = projectObj.project.calcProgram.getGatherFeeData();
|
|
|
- me.datas = obj.calcPrograms;
|
|
|
- $('#lblGatherFee').text(`费用汇总 ${obj.totalFee}`);
|
|
|
-
|
|
|
if (me.mainSpread) {
|
|
|
me.mainSpread.destroy();
|
|
|
me.mainSpread = null;
|
|
@@ -62,31 +58,19 @@ let gatherFeesView = {
|
|
|
me.detailSpread.destroy();
|
|
|
me.detailSpread = null;
|
|
|
};
|
|
|
- me.mainSpread = sheetCommonObj.buildSheet($('#gfMainSpread')[0], me.mainSetting, me.datas.length);
|
|
|
+ // me.mainSpread = sheetCommonObj.buildSheet($('#gfMainSpread')[0], me.mainSetting, me.datas.length);
|
|
|
+ me.mainSpread = sheetCommonObj.buildSheet($('#gfMainSpread')[0], me.mainSetting, 1);
|
|
|
me.mainSheet = me.mainSpread.getSheet(0);
|
|
|
sheetCommonObj.spreadDefaultStyle(me.mainSpread);
|
|
|
- me.detailSpread = sheetCommonObj.buildSheet($('#gfDetailSpread')[0], me.detailSetting, me.datas[0].calcItems.length);
|
|
|
+ // me.detailSpread = sheetCommonObj.buildSheet($('#gfDetailSpread')[0], me.detailSetting, me.datas[0].calcItems.length);
|
|
|
+ me.detailSpread = sheetCommonObj.buildSheet($('#gfDetailSpread')[0], me.detailSetting, 1);
|
|
|
me.detailSheet = me.detailSpread.getSheet(0);
|
|
|
sheetCommonObj.spreadDefaultStyle(me.detailSpread);
|
|
|
- // let arr = projectObj.project.calcProgram.compiledFeeTypeNames.slice();
|
|
|
- // arr.delete('暂估费');
|
|
|
- // let fieldName = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
- // fieldName.items(arr);
|
|
|
- // me.detailSheet.getRange(-1, 4, -1, 1).cellType(fieldName);
|
|
|
-
|
|
|
me.mainSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onMainEnterCell);
|
|
|
me.detailSheet.bind(GC.Spread.Sheets.Events.ValueChanged, me.onDetailValueChanged);
|
|
|
me.detailSheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
|
|
|
me.detailSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onDetailEnterCell);
|
|
|
- me.detailSheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
- sheetCommonObj.showData(me.mainSheet, me.mainSetting, me.datas);
|
|
|
- me.mainSheet.setRowCount(me.datas.length);
|
|
|
-
|
|
|
me.detailSheet.name('gatherfee_detail');
|
|
|
- // feeRateObject.setFeeRateCellCol(me.detailSheet, _.findIndex(me.detailSetting.header,{'dataCode':'feeRate'}));
|
|
|
- sheetCommonObj.showData(me.detailSheet, me.detailSetting, me.datas[0].calcItems);
|
|
|
- me.getfeeRateColor(me.datas[0].calcItems);
|
|
|
- customRowHeader(me.detailSheet, me.datas[0].calcItems.length);
|
|
|
if(!projectReadOnly){
|
|
|
// me.loadMainContextMenu();
|
|
|
// me.loadDetailContextMenu();
|
|
@@ -101,23 +85,22 @@ let gatherFeesView = {
|
|
|
sheetCommonObj.disableSpread(me.mainSpread);
|
|
|
sheetCommonObj.disableSpread(me.detailSpread);
|
|
|
};
|
|
|
-
|
|
|
},
|
|
|
- getStdCalcProgramFiles: function(){
|
|
|
- function getStdCPFilesHtml(stdCPLibs) {
|
|
|
- let result = '<option value="">请选择计算程序标准库</option>';
|
|
|
- if (stdCPLibs.length <= 0) {
|
|
|
- return result;
|
|
|
- };
|
|
|
-
|
|
|
- for (let lib of stdCPLibs){
|
|
|
- result += '<option value='+ lib.id +'>'+ lib.name +'</option>';
|
|
|
- };
|
|
|
- return result;
|
|
|
- };
|
|
|
-
|
|
|
- let stdCPHtml = getStdCPFilesHtml(projectObj.project.projectInfo.engineeringInfo.program_lib);
|
|
|
- $("#calcProgramFileSelect").html(stdCPHtml);
|
|
|
+ showData: async function () {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ let me = this;
|
|
|
+ let obj = await projectObj.project.calcProgram.getGatherFeeData();
|
|
|
+ me.datas = obj.calcPrograms;
|
|
|
+ $('#lblGatherFee').text(`费用汇总 ${obj.totalFee}`);
|
|
|
+ sheetCommonObj.showData(me.mainSheet, me.mainSetting, me.datas);
|
|
|
+ me.mainSheet.setRowCount(me.datas.length);
|
|
|
+ sheetCommonObj.showData(me.detailSheet, me.detailSetting, me.datas[0].calcItems);
|
|
|
+ me.getfeeRateColor(me.datas[0].calcItems);
|
|
|
+ customRowHeader(me.detailSheet, me.datas[0].calcItems.length);
|
|
|
+
|
|
|
+ let count = gatherFeesView.datas[gatherFeesView.mainSheet.getActiveRowIndex()].calcItems.length;
|
|
|
+ gatherFeesView.detailSheet.setRowCount(count, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
},
|
|
|
onMainEnterCell: function(sender, args) {
|
|
|
var me = gatherFeesView;
|
|
@@ -247,274 +230,7 @@ let gatherFeesView = {
|
|
|
// let e = `ID:${c.ID} ${c.expression} ${c.dispExpr} ${c.dispExprUser} ${c.compiledExpr} ${c.custom}`;
|
|
|
// projectObj.testDisplay('', e);
|
|
|
},
|
|
|
- onClipboardPasting: function (sender, args) {
|
|
|
- args.cancel = true;
|
|
|
- },
|
|
|
- loadMainContextMenu: function () {
|
|
|
- $.contextMenu({
|
|
|
- selector: '#gfMainSpread',
|
|
|
- build: function ($trigger, e) {
|
|
|
- SheetDataHelper.safeRightClickSelection($trigger, e, gatherFeesView.mainSpread);
|
|
|
- },
|
|
|
- items: {
|
|
|
- "copyTemplate": {
|
|
|
- name: "另存为",
|
|
|
- icon: 'copy',
|
|
|
- callback: function (key, opt) {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let template = gatherFeesView.getSelectionInfo().template;
|
|
|
- let idx = gatherFeesView.mainSpread.getActiveSheet().getActiveRowIndex();
|
|
|
-
|
|
|
- let newTemplate = {};
|
|
|
- newTemplate.ID = analyzer.templateMaxID() + 1;
|
|
|
- newTemplate.name = analyzer.templateNewName(template.name);
|
|
|
- newTemplate.custom = true;
|
|
|
- newTemplate.calcItems = [];
|
|
|
- $.extend(true, newTemplate.calcItems, template.calcItems);
|
|
|
- // 清理掉费率ID关联
|
|
|
- for (let ci of newTemplate.calcItems){
|
|
|
- if (ci.feeRateID || ci.feeRateID == null)
|
|
|
- delete ci.feeRateID;
|
|
|
- };
|
|
|
-
|
|
|
- let data = {
|
|
|
- 'projectID': projectObj.project.ID(),
|
|
|
- 'ID': newTemplate.ID,
|
|
|
- 'name': newTemplate.name,
|
|
|
- 'custom': newTemplate.custom,
|
|
|
- 'calcItems': newTemplate.calcItems
|
|
|
- };
|
|
|
-
|
|
|
- gatherFeesView.addTemplate(data, function (rst) {
|
|
|
- if (rst){
|
|
|
- let ts = projectObj.project.calcProgram.templates;
|
|
|
- ts.push(newTemplate);
|
|
|
- projectObj.project.calcProgram.compileTemplateMaps();
|
|
|
- projectObj.project.calcProgram.compileTemplate(newTemplate);
|
|
|
- gatherFeesView.buildSheet();
|
|
|
- gatherFeesView.mainSheet.setSelection(ts.length - 1, 0, 1, 1);
|
|
|
- gatherFeesView.mainSheet.showRow(ts.length - 1, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
- gatherFeesView.refreshDetailSheet();
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- "reNameTemplate": {
|
|
|
- name: "重命名...",
|
|
|
- icon: 'edit',
|
|
|
- disabled: function () {
|
|
|
- let custom = gatherFeesView.getSelectionInfo().template.custom;
|
|
|
- let canReName = custom ? custom : false;
|
|
|
- return !canReName;
|
|
|
- },
|
|
|
- callback: function (key, opt) {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let template = gatherFeesView.getSelectionInfo().template;
|
|
|
- let idx = gatherFeesView.mainSpread.getActiveSheet().getActiveRowIndex();
|
|
|
-
|
|
|
- let newName = '';
|
|
|
- hintBox.valueBox('重命名', template.name, function () {
|
|
|
- newName = hintBox.value;
|
|
|
-
|
|
|
- if (!newName){
|
|
|
- hintBox.error(`名称不能为空!`);
|
|
|
- return false;
|
|
|
- };
|
|
|
-
|
|
|
- if (newName == template.name) {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (analyzer.templateNameIsExist(newName)){
|
|
|
- hintBox.error(`“${newName}” 已存在,请重新输入!`);
|
|
|
- return false;
|
|
|
- };
|
|
|
-
|
|
|
- template.name = newName;
|
|
|
- let data = {
|
|
|
- 'projectID': projectObj.project.ID(),
|
|
|
- 'ID': template.ID,
|
|
|
- 'name': template.name
|
|
|
- };
|
|
|
- gatherFeesView.updateTemplate(data, function (rst) {
|
|
|
- if (rst){
|
|
|
- projectObj.project.calcProgram.compileTemplateMaps();
|
|
|
- projectObj.mainController.refreshTreeNode(calcTools.getNodesByProgramID(template.ID));
|
|
|
- sheetCommonObj.showData(gatherFeesView.mainSpread.getSheet(0), gatherFeesView.mainSetting, gatherFeesView.datas);
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- "spr1": '--------',
|
|
|
- "deleteTemplate": {
|
|
|
- name: '删除',
|
|
|
- icon: 'fa-remove',
|
|
|
- disabled: function () {
|
|
|
- let custom = gatherFeesView.getSelectionInfo().template.custom;
|
|
|
- let canDelete = custom ? custom : false;
|
|
|
- return !canDelete;
|
|
|
- },
|
|
|
- callback: function () {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let template = gatherFeesView.getSelectionInfo().template;
|
|
|
- if (analyzer.templateIsUsed(template.ID)) {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- hintBox.infoBox('系统提示', `计算模板“${template.name}”已被使用,不允许删除!`, 1);
|
|
|
- return;
|
|
|
- };
|
|
|
- hintBox.infoBox('系统提示', `确定要删除计算模板“${template.name}”吗?`, 2, cbYes);
|
|
|
- function cbYes() {
|
|
|
- let data = {
|
|
|
- 'projectID': projectObj.project.ID(),
|
|
|
- 'ID': template.ID
|
|
|
- };
|
|
|
- gatherFeesView.deleteTemplate(data, function (rst) {
|
|
|
- if (rst){
|
|
|
- let idx = gatherFeesView.mainSheet.getActiveRowIndex();
|
|
|
- projectObj.project.calcProgram.templates.splice(idx, 1);
|
|
|
- projectObj.project.calcProgram.compileTemplateMaps();
|
|
|
- gatherFeesView.buildSheet();
|
|
|
- gatherFeesView.mainSheet.setSelection(idx - 1, 0, 1, 1);
|
|
|
- gatherFeesView.mainSheet.showRow(idx - 1, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
- gatherFeesView.refreshDetailSheet();
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- loadDetailContextMenu: function () {
|
|
|
- $.contextMenu({
|
|
|
- selector: '#gfDetailSpread',
|
|
|
- build: function ($triggerElement, event) {
|
|
|
- SheetDataHelper.safeRightClickSelection($triggerElement, event, gatherFeesView.detailSpread);
|
|
|
- },
|
|
|
- items: {
|
|
|
- "newCalcItem": {
|
|
|
- name: "插入行",
|
|
|
- icon: 'fa-sign-in',
|
|
|
- callback: function () {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let template = gatherFeesView.getSelectionInfo().template;
|
|
|
- let idx = gatherFeesView.detailSpread.getActiveSheet().getActiveRowIndex();
|
|
|
-
|
|
|
- let newItem = {};
|
|
|
- newItem.ID = analyzer.calcItemMaxID(template) + 1;
|
|
|
- // newItem.name = '新建';
|
|
|
- newItem.memo = '自定义';
|
|
|
- newItem.custom = true;
|
|
|
- newItem.expression = '0'; // 这里必须得有值,否则程序内部公式解析会出现诸多问题
|
|
|
- template.calcItems.splice(idx + 1, 0, newItem);
|
|
|
- let data = {
|
|
|
- 'projectID': projectObj.project.ID(),
|
|
|
- 'ID': template.ID,
|
|
|
- 'calcItems': template.calcItems
|
|
|
- };
|
|
|
- gatherFeesView.updateTemplate(data, function (rst) {
|
|
|
- if (rst){
|
|
|
- projectObj.project.calcProgram.compileTemplate(template);
|
|
|
- gatherFeesView.refreshDetailSheet();
|
|
|
- gatherFeesView.detailSpread.getActiveSheet().setSelection(idx + 1, 0, 1, 1);
|
|
|
- let relationNodes = calcTools.getNodesByProgramID(template.ID);
|
|
|
- projectObj.project.calcProgram.calcNodesAndSave(relationNodes);
|
|
|
- }
|
|
|
- });
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- },
|
|
|
- "spr1": '--------',
|
|
|
- "deleteCalcItem": {
|
|
|
- name: '删除行',
|
|
|
- icon: 'fa-remove',
|
|
|
- callback: function () {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let template = gatherFeesView.getSelectionInfo().template;
|
|
|
- let idx = gatherFeesView.detailSpread.getActiveSheet().getActiveRowIndex();
|
|
|
- let item = template.calcItems[idx];
|
|
|
-
|
|
|
- if (item.fieldName == 'common'){
|
|
|
- $.bootstrapLoading.end();
|
|
|
- hintBox.infoBox('系统提示', `费用类别为“工程造价”的行不允许删除!`, 1);
|
|
|
- return;
|
|
|
- };
|
|
|
|
|
|
- if (analyzer.calcItemIsUsed(template, item)){
|
|
|
- $.bootstrapLoading.end();
|
|
|
- let s = hintBox.font(item.tempUsed + 1);
|
|
|
- hintBox.infoBox('系统提示', `第 ${idx + 1} 行“${item.name}”已被第 ${s} 行引用,不允许删除!`, 1);
|
|
|
- delete item.tempUsed;
|
|
|
- return;
|
|
|
- };
|
|
|
-
|
|
|
- hintBox.infoBox('系统提示', `确定要删除计算规则“${item.name}”吗?`, 2, cbYes);
|
|
|
- function cbYes() {
|
|
|
- template.calcItems.splice(idx, 1);
|
|
|
- let data = {
|
|
|
- 'projectID': projectObj.project.ID(),
|
|
|
- 'ID': template.ID,
|
|
|
- 'calcItems': template.calcItems
|
|
|
- };
|
|
|
- gatherFeesView.updateTemplate(data, function (rst) {
|
|
|
- if (rst){
|
|
|
- projectObj.project.calcProgram.compileTemplate(template);
|
|
|
- gatherFeesView.refreshDetailSheet();
|
|
|
- let relationNodes = calcTools.getNodesByProgramID(template.ID);
|
|
|
- projectObj.project.calcProgram.calcNodesAndSave(relationNodes);
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- },
|
|
|
- saveCalcItem: function (data, callback) {//data
|
|
|
- CommonAjax.post('/calcProgram/saveCalcItem', data,
|
|
|
- function (result) {
|
|
|
- if(callback){
|
|
|
- callback(result);
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- updateTemplate: function (data, callback) {
|
|
|
- CommonAjax.post('/calcProgram/updateTemplate', data,
|
|
|
- function (result) {
|
|
|
- if(callback){
|
|
|
- callback(result);
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- addTemplate: function (data, callback) {
|
|
|
- CommonAjax.post('/calcProgram/addTemplate', data,
|
|
|
- function (result) {
|
|
|
- if(callback){
|
|
|
- callback(result);
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
- deleteTemplate: function (data, callback) {
|
|
|
- $.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/calcProgram/deleteTemplate', data,
|
|
|
- function (result) {
|
|
|
- if(callback){
|
|
|
- callback(result);
|
|
|
- }
|
|
|
- $.bootstrapLoading.end();
|
|
|
- }
|
|
|
- );
|
|
|
- },
|
|
|
getSelectionInfo:function () {
|
|
|
var templateIndex = this.mainSpread.getActiveSheet().getActiveRowIndex();
|
|
|
var dIndex = this.detailSpread.getActiveSheet().getActiveRowIndex();
|
|
@@ -552,40 +268,18 @@ $(document).ready(function(){
|
|
|
sessionStorage.setItem('mainTab', '#tab_gather_fees');
|
|
|
$(e.relatedTarget.hash).removeClass('active');
|
|
|
// 每次进来都要重新计算一次
|
|
|
- // if (!gatherFeesView.mainSpread)
|
|
|
+ if (!gatherFeesView.mainSpread)
|
|
|
gatherFeesView.buildSheet()
|
|
|
- // else
|
|
|
- // gatherFeesView.mainSpread.refresh();
|
|
|
+ else
|
|
|
+ gatherFeesView.mainSpread.refresh();
|
|
|
|
|
|
- let count = gatherFeesView.datas[gatherFeesView.mainSheet.getActiveRowIndex()].calcItems.length;
|
|
|
- gatherFeesView.detailSheet.setRowCount(count, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ gatherFeesView.showData();
|
|
|
});
|
|
|
|
|
|
- $("#calcProgramFileSelect").change(function() {
|
|
|
- // 取标准库数据过来显示。
|
|
|
- let libID = $(this).val();
|
|
|
- if (libID == ''){
|
|
|
- gatherFeesView.mainSpread.getSheet(0).setRowCount(0);
|
|
|
- gatherFeesView.detailSpread.getSheet(0).setRowCount(0);
|
|
|
- return false;
|
|
|
- };
|
|
|
-
|
|
|
- $.bootstrapLoading.start();
|
|
|
- libID = parseFloat(libID);
|
|
|
- let projectID = projectObj.project.ID();
|
|
|
- CommonAjax.post('/calcProgram/updateTemplateFile', {"projectID": projectID, "libID": libID}, function (data) {
|
|
|
- projectObj.project.calcProgram.datas.templates = data;
|
|
|
- projectObj.project.calcProgram.compileAllTemps();
|
|
|
- projectObj.project.calcProgram.calcAllNodesAndSave();
|
|
|
- gatherFeesView.buildSheet();
|
|
|
- $.bootstrapLoading.end();
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- $("#lblGatherFee").bind('click',function () {
|
|
|
- gatherFeesView.buildSheet();
|
|
|
- gatherFeesView.refreshDetailSheet();
|
|
|
- });
|
|
|
+ // $("#lblGatherFee").bind('click',function () {
|
|
|
+ // gatherFeesView.buildSheet();
|
|
|
+ // gatherFeesView.refreshDetailSheet();
|
|
|
+ // });
|
|
|
});
|
|
|
|
|
|
|