123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- /**
- * Created by Mai on 2017/7/25.
- */
- let MainTreeCol = {
- getText: {
- type: function (node) {
- if (node.sourceType === projectObj.project.Bills.getSourceType()) {
- return '';
- } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
- return '定';
- } else if (node.sourceType === projectObj.project.VolumePrice.getSourceType()) {
- return '量';
- } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
- return '主';
- }
- }
- },
- readOnly: {
- 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.sourceType === projectObj.project.VolumePrice.getSourceType();
- },
- 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.sourceType !== projectObj.project.Ration.getSourceType();
- },
- 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));
- }
- },
- cellType: {
- unit: function () {
- let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
- combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
- '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
- return combo;
- },
- feeRate: function () {
- return feeRateObject.getFeeRateEditCellType();
- }
- },
- 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.setColumnCount(setting.cols.length);
- sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
- sheet.setRowCount(1);
- sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
- setting.headRowHeight.forEach(function (rowHeight, index) {
- sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
- });
- setting.cols.forEach(function (col, index) {
- let i, iRow = 0, cell;
- for (i = 0; i < col.head.spanCols.length; i++) {
- if (col.head.spanCols[i] !== 0) {
- cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
- cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
- }
- if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
- sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
- }
- iRow += col.head.spanRows[i];
- };
- sheet.setColumnWidth(index, col.width);
- cell = sheet.getCell(0, index).value(col.visible);
- });
- },
- initSettingSpread: function () {
- this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
- this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
- 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 iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
- projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
- projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
- }
- 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});
- });
|