main_tree_col.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /**
  2. * Created by Mai on 2017/7/25.
  3. */
  4. let MainTreeCol = {
  5. getText: {
  6. subType: function (node) {
  7. if (node.sourceType === projectObj.project.Bills.getSourceType()) {
  8. return '';
  9. // CSL, 2017-11-29
  10. } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
  11. if (node.data.type == 1 || node.data.type == undefined) // 兼容旧定额
  12. return '定'
  13. else if (node.data.type == 2){ // 量价
  14. return volumePriceMaps[node.data.subType];
  15. }
  16. else if (node.data.type == 3){ // 工料机定额
  17. return '工料机'; // 这里明细值等张伟城确定
  18. }
  19. } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
  20. return '主';
  21. }
  22. },
  23. // CSL, 2017-11-28
  24. calcProgramName: function (node) {
  25. let programID = node.data.programID;
  26. if (!programID) return
  27. else return projectObj.project.calcProgram.compiledTemplateMaps[programID];
  28. }
  29. },
  30. readOnly: {
  31. // CSL, 2017-11-28
  32. subType: function (node){
  33. return (node.data.type != 2 && node.data.type != 3);
  34. },
  35. calcProgramName: function (node) {
  36. if (
  37. node.sourceType === projectObj.project.Ration.getSourceType() ||
  38. (projectObj.project.calcProgram.isLeafBill(node) && projectObj.project.projSetting.billsCalcMode === leafBillGetFeeType.billsPrice)
  39. ) return false
  40. else return true;
  41. },
  42. commonUnitFee: function(node){
  43. return !projectObj.project.calcProgram.isNullBill(node);
  44. },
  45. bills: function (node) {
  46. return node.sourceType === projectObj.project.Bills.getSourceType();
  47. },
  48. ration: function (node) {
  49. return node.sourceType === projectObj.project.Ration.getSourceType();
  50. },
  51. volumePrice: function (node) {
  52. return (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
  53. },
  54. non_bills: function (node) {
  55. return node.sourceType !== projectObj.project.Bills.getSourceType();
  56. },
  57. non_ration: function (node) {
  58. return node.sourceType !== projectObj.project.Ration.getSourceType();
  59. },
  60. non_volumePrice: function (node) {
  61. return !(node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
  62. },
  63. billsParent: function (node) {
  64. return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
  65. },
  66. leafBillsWithDetail: function (node) {
  67. return (!MainTreeCol.readOnly.billsParent(node)) && (node.children.length > 0);
  68. },
  69. forCalcBase: function (node) {
  70. // to do according to billsParentType
  71. return MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
  72. },
  73. forUnitFee: function (node) {
  74. return MainTreeCol.readOnly.ration(node) || MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.leafBillsWithDetail(node);
  75. },
  76. forTotalFee: function (node) {
  77. return MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.billsParent(node) || (MainTreeCol.readOnly.leafBillsWithDetail(node));
  78. },
  79. forQuantifyDetail:function (node) {
  80. return !(node.sourceType==ModuleNames.ration||!MainTreeCol.readOnly.billsParent(node));
  81. }
  82. },
  83. cellType: {
  84. unit: function () {
  85. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  86. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  87. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  88. return combo;
  89. },
  90. units: function () {
  91. this.unit;
  92. },
  93. feeRate: function () {
  94. return feeRateObject.getFeeRateEditCellType();
  95. },
  96. // CSL, 2017-11-28
  97. calcProgramName: function (node) {
  98. if (
  99. node.sourceType === projectObj.project.Ration.getSourceType() ||
  100. (projectObj.project.calcProgram.isLeafBill(node) && projectObj.project.projSetting.billsCalcMode === leafBillGetFeeType.billsPrice)
  101. ) {
  102. var names = new GC.Spread.Sheets.CellTypes.ComboBox();
  103. names.items(projectObj.project.calcProgram.compiledTemplateNames);
  104. return names;
  105. }
  106. },
  107. // CSL, 2017-11-28
  108. subType: function (node) {
  109. if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation){
  110. let VPType = new GC.Spread.Sheets.CellTypes.ComboBox();
  111. if (node.data.type == rationType.volumePrice)
  112. VPType.items(["人工","材料","机械","主材","设备"])
  113. else if (node.data.type == rationType.gljRation)
  114. VPType.items(["材料","主材","设备"]);
  115. return VPType;
  116. };
  117. },
  118. },
  119. getEvent: function (eventName) {
  120. let names = eventName.split('.');
  121. let event = this;
  122. for (let name of names) {
  123. if (event[name]) {
  124. event = event[name];
  125. } else {
  126. return null;
  127. }
  128. }
  129. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  130. return null;
  131. } else {
  132. return event;
  133. }
  134. },
  135. getNumberFormatter: function (digit, align) { // CSL, 2017-11-30 扩展:小数点是否对齐。
  136. if (align) {
  137. switch (digit) {
  138. case 1:
  139. return '0.0';
  140. case 2:
  141. return '0.00';
  142. case 3:
  143. return '0.000';
  144. case 4:
  145. return '0.0000';
  146. case 5:
  147. return '0.00000';
  148. case 6:
  149. return '0.000000';
  150. default:
  151. return '0.00';
  152. };
  153. }
  154. else{
  155. switch (digit) {
  156. case 1:
  157. return '0.#';
  158. case 2:
  159. return '0.##';
  160. case 3:
  161. return '0.###';
  162. case 4:
  163. return '0.####';
  164. case 5:
  165. return '0.#####';
  166. case 6:
  167. return '0.######';
  168. default:
  169. return '0.##';
  170. };
  171. }
  172. }
  173. };
  174. let colSettingObj = {
  175. settingSpread: null,
  176. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  177. loadSetting: function (sheet, setting) {
  178. sheet.setRowCount(setting.cols.length);
  179. sheet.setColumnCount(setting.headRows, GC.Spread.Sheets.SheetArea.rowHeader);
  180. sheet.setColumnCount(1);
  181. sheet.getRange(-1, 0, -1, 1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  182. sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.colHeader).value('显示');
  183. sheet.setColumnWidth(0, 300);
  184. setting.cols.forEach(function (col, index) {
  185. let i, iCol = 0, cell;
  186. for (i = 0; i < col.head.spanCols.length; i++) {
  187. if (col.head.spanCols[i] !== 0) {
  188. cell = sheet.getCell(index, iCol, GC.Spread.Sheets.SheetArea.rowHeader);
  189. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
  190. }
  191. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  192. sheet.addSpan(index, iCol, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.rowHeader);
  193. }
  194. iCol += col.head.spanRows[i];
  195. };
  196. let colWidth = sheet.getColumnWidth(index, GC.Spread.Sheets.SheetArea.rowHeader);
  197. colWidth = colWidth > col.width ? colWidth : col.width;
  198. sheet.setColumnWidth(index, colWidth, GC.Spread.Sheets.SheetArea.rowHeader);
  199. cell = sheet.getCell(index, 0).value(col.visible);
  200. sheet.autoFitRow(index);
  201. });
  202. },
  203. initSettingSpread: function () {
  204. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  205. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.vertical;
  206. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  207. }
  208. };
  209. $('#column').on('shown.bs.modal', function () {
  210. if (!colSettingObj.settingSpread) {
  211. colSettingObj.initSettingSpread();
  212. }
  213. });
  214. $('#column').on('hide.bs.modal', function () {
  215. let sheet = colSettingObj.settingSpread.getActiveSheet();
  216. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  217. projectObj.project.projSetting.main_tree_col.cols[iRow].visible = sheet.getValue(iRow, 0);
  218. projectObj.project.projSetting.mainGridSetting.cols[iRow].visible = sheet.getValue(iRow, 0);
  219. }
  220. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  221. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  222. });