123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- /**
- * Created by Mai on 2017/7/25.
- */
- let MainTreeCol = {
- getText: {
- subType: function (node) {
- if (node.sourceType === projectObj.project.Bills.getSourceType()) {
- return '';
- // CSL, 2017-11-29
- } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
- if (node.data.type == 1 || node.data.type == undefined) // 兼容旧定额
- return '定'
- else if (node.data.type == 2){ // 量价
- return volumePriceMaps[node.data.subType];
- }
- else if (node.data.type == 3){ // 工料机定额
- return '工料机'; // 这里明细值等张伟城确定
- }
- } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
- return '主';
- }
- },
- // CSL, 2017-11-28
- calcProgramName: function (node) {
- let programID = node.data.programID;
- if (!programID) return
- else return projectObj.project.calcProgram.compiledTemplateMaps[programID];
- }
- },
- readOnly: {
- subType: function (node){
- return (node.data.type != 2 && node.data.type != 3);
- },
- // CSL, 2017-11-28
- calcProgramName: function (node) {
- if (
- node.sourceType === projectObj.project.Ration.getSourceType() ||
- (node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children && node.source.children.length === 0 && projectObj.project.projSetting.billsCalcMode === billsPrice)
- ) return false
- else return true;
- },
- bills: function (node) {
- return node.sourceType === projectObj.project.Bills.getSourceType();
- },
- ration: function (node) {
- return node.sourceType === projectObj.project.Ration.getSourceType();
- },
- volumePrice: function (node) {
- return (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
- },
- non_bills: function (node) {
- return node.sourceType !== projectObj.project.Bills.getSourceType();
- },
- non_ration: function (node) {
- return node.sourceType !== projectObj.project.Ration.getSourceType();
- },
- non_volumePrice: function (node) {
- return !(node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
- },
- billsParent: function (node) {
- return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
- },
- leafBillsWithDetail: function (node) {
- return (!MainTreeCol.readOnly.billsParent(node)) && (node.children.length > 0);
- },
- forCalcBase: function (node) {
- // to do according to billsParentType
- return MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
- },
- forUnitFee: function (node) {
- return MainTreeCol.readOnly.ration(node) || MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.leafBillsWithDetail(node);
- },
- forTotalFee: function (node) {
- return MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.billsParent(node) || (MainTreeCol.readOnly.leafBillsWithDetail(node));
- },
- forQuantifyDetail:function (node) {
- return !(node.sourceType==ModuleNames.ration||!MainTreeCol.readOnly.billsParent(node));
- }
- },
- cellType: {
- unit: function () {
- let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
- combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
- '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
- return combo;
- },
- units: function () {
- this.unit;
- },
- feeRate: function () {
- return feeRateObject.getFeeRateEditCellType();
- },
- // CSL, 2017-11-28
- calcProgramName: function (node) {
- if (
- node.sourceType === projectObj.project.Ration.getSourceType() ||
- (node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children && node.source.children.length === 0 && projectObj.project.projSetting.billsCalcMode === billsPrice)
- ) {
- var names = new GC.Spread.Sheets.CellTypes.ComboBox();
- names.items(projectObj.project.calcProgram.compiledTemplateNames);
- return names;
- }
- },
- // CSL, 2017-11-28
- subType: function (node) {
- if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation){
- let VPType = new GC.Spread.Sheets.CellTypes.ComboBox();
- if (node.data.type == rationType.volumePrice)
- VPType.items(["人工","材料","机械","主材","设备"])
- else if (node.data.type == rationType.gljRation)
- VPType.items(["材料","主材","设备"]);
- return VPType;
- };
- },
- },
- getEvent: function (eventName) {
- let names = eventName.split('.');
- let event = this;
- for (let name of names) {
- if (event[name]) {
- event = event[name];
- } else {
- return null;
- }
- }
- if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
- return null;
- } else {
- return event;
- }
- },
- getNumberFormatter: function (digit) {
- switch (digit) {
- case 1:
- return '0.#';
- case 2:
- return '0.##';
- case 3:
- return '0.###';
- case 4:
- return '0.####';
- case 5:
- return '0.#####';
- case 6:
- return '0.######';
- default:
- return '0.##';
- }
- }
- };
- let colSettingObj = {
- settingSpread: null,
- checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
- loadSetting: function (sheet, setting) {
- sheet.setRowCount(setting.cols.length);
- sheet.setColumnCount(setting.headRows, GC.Spread.Sheets.SheetArea.rowHeader);
- sheet.setColumnCount(1);
- sheet.getRange(-1, 0, -1, 1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
- sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.colHeader).value('显示');
- sheet.setColumnWidth(0, 300);
- setting.cols.forEach(function (col, index) {
- let i, iCol = 0, cell;
- for (i = 0; i < col.head.spanCols.length; i++) {
- if (col.head.spanCols[i] !== 0) {
- cell = sheet.getCell(index, iCol, GC.Spread.Sheets.SheetArea.rowHeader);
- cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
- }
- if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
- sheet.addSpan(index, iCol, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.rowHeader);
- }
- iCol += col.head.spanRows[i];
- };
- let colWidth = sheet.getColumnWidth(index, GC.Spread.Sheets.SheetArea.rowHeader);
- colWidth = colWidth > col.width ? colWidth : col.width;
- sheet.setColumnWidth(index, colWidth, GC.Spread.Sheets.SheetArea.rowHeader);
- cell = sheet.getCell(index, 0).value(col.visible);
- sheet.autoFitRow(index);
- });
- },
- initSettingSpread: function () {
- this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
- this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.vertical;
- this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
- }
- };
- $('#column').on('shown.bs.modal', function () {
- if (!colSettingObj.settingSpread) {
- colSettingObj.initSettingSpread();
- }
- });
- $('#column').on('hide.bs.modal', function () {
- let sheet = colSettingObj.settingSpread.getActiveSheet();
- for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
- projectObj.project.projSetting.main_tree_col.cols[iRow].visible = sheet.getValue(iRow, 0);
- projectObj.project.projSetting.mainGridSetting.cols[iRow].visible = sheet.getValue(iRow, 0);
- }
- SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
- projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
- });
|