main_tree_col.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**
  2. * Created by Mai on 2017/7/25.
  3. */
  4. let MainTreeCol = {
  5. getText: {
  6. type: function (node) {
  7. if (node.sourceType === projectObj.project.Bills.getSourceType()) {
  8. return '';
  9. } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
  10. return '定';
  11. } else if (node.sourceType === projectObj.project.VolumePrice.getSourceType()) {
  12. return '量';
  13. } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
  14. return '主';
  15. }
  16. },
  17. quantity:function (node) {
  18. if(node.sourceType === projectObj.project.ration_glj.getSourceType()){
  19. return gljOprObj.getTotalQuantity(node.data);
  20. }else {
  21. return node.data["quantity"];
  22. }
  23. }
  24. },
  25. readOnly: {
  26. bills: function (node) {
  27. return node.sourceType === projectObj.project.Bills.getSourceType();
  28. },
  29. ration: function (node) {
  30. return node.sourceType === projectObj.project.Ration.getSourceType();
  31. },
  32. glj: function (node) {
  33. return node.sourceType == projectObj.project.ration_glj.getSourceType();
  34. },
  35. volumePrice: function (node) {
  36. return node.sourceType === projectObj.project.VolumePrice.getSourceType();
  37. },
  38. non_bills: function (node) {
  39. return node.sourceType !== projectObj.project.Bills.getSourceType();
  40. },
  41. non_ration: function (node) {
  42. return node.sourceType !== projectObj.project.Ration.getSourceType();
  43. },
  44. non_volumePrice: function (node) {
  45. return node.sourceType !== projectObj.project.Ration.getSourceType();
  46. },
  47. billsParent: function (node) {
  48. return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
  49. },
  50. leafBillsWithDetail: function (node) {
  51. return (!MainTreeCol.readOnly.billsParent(node)) && (node.children.length > 0);
  52. },
  53. forCalcBase: function (node) {
  54. // to do according to billsParentType
  55. return MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
  56. },
  57. forUnitFee: function (node) {
  58. return MainTreeCol.readOnly.ration(node) || MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.leafBillsWithDetail(node);
  59. },
  60. forTotalFee: function (node) {
  61. return MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.billsParent(node) || (MainTreeCol.readOnly.leafBillsWithDetail(node));
  62. },
  63. forFeeRate:function (node) {
  64. return MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.billsParent(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
  65. },
  66. forQuantity:function (node) {
  67. return MainTreeCol.readOnly.glj(node)||MainTreeCol.readOnly.billsParent(node)
  68. },
  69. forMarketPrice:function (node) {
  70. return MainTreeCol.readOnly.non_volumePrice(node);
  71. }
  72. },
  73. cellType: {
  74. unit: function () {
  75. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  76. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  77. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  78. return combo;
  79. },
  80. feeRate: function () {
  81. return feeRateObject.getFeeRateEditCellType();
  82. },
  83. calcBase: function () {
  84. return calcBaseView.getCalcBaseCellType();
  85. }
  86. },
  87. getEvent: function (eventName) {
  88. let names = eventName.split('.');
  89. let event = this;
  90. for (let name of names) {
  91. if (event[name]) {
  92. event = event[name];
  93. } else {
  94. return null;
  95. }
  96. }
  97. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  98. return null;
  99. } else {
  100. return event;
  101. }
  102. },
  103. getNumberFormatter: function (digit) {
  104. switch (digit) {
  105. case 1:
  106. return '0.#';
  107. case 2:
  108. return '0.##';
  109. case 3:
  110. return '0.###';
  111. case 4:
  112. return '0.####';
  113. case 5:
  114. return '0.#####';
  115. case 6:
  116. return '0.######';
  117. default:
  118. return '0.##';
  119. }
  120. }
  121. };
  122. let colSettingObj = {
  123. settingSpread: null,
  124. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  125. loadSetting: function (sheet, setting) {
  126. sheet.setColumnCount(setting.cols.length);
  127. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  128. sheet.setRowCount(1);
  129. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  130. setting.headRowHeight.forEach(function (rowHeight, index) {
  131. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  132. });
  133. setting.cols.forEach(function (col, index) {
  134. let i, iRow = 0, cell;
  135. for (i = 0; i < col.head.spanCols.length; i++) {
  136. if (col.head.spanCols[i] !== 0) {
  137. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  138. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  139. }
  140. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  141. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  142. }
  143. iRow += col.head.spanRows[i];
  144. };
  145. sheet.setColumnWidth(index, col.width);
  146. cell = sheet.getCell(0, index).value(col.visible);
  147. });
  148. },
  149. initSettingSpread: function () {
  150. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  151. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  152. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  153. }
  154. };
  155. $('#column').on('shown.bs.modal', function () {
  156. if (!colSettingObj.settingSpread) {
  157. colSettingObj.initSettingSpread();
  158. }
  159. });
  160. $('#column').on('hide.bs.modal', function () {
  161. let sheet = colSettingObj.settingSpread.getActiveSheet();
  162. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  163. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  164. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  165. }
  166. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  167. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  168. });