main_tree_col.js 8.3 KB

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