main_tree_col.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. feeRate:function (node) {
  34. }
  35. },
  36. readOnly: {
  37. subType:function (node) {
  38. },
  39. calcProgramName:function (node) {
  40. },
  41. non_editSubType:function (node) {
  42. },
  43. commonUnitFee:function (node) {
  44. },
  45. commonTotalFee:function (node) {
  46. },
  47. bills: function (node) {
  48. return node.sourceType === projectObj.project.Bills.getSourceType();
  49. },
  50. ration: function (node) {
  51. return node.sourceType === projectObj.project.Ration.getSourceType();
  52. },
  53. glj: function (node) {
  54. return node.sourceType == projectObj.project.ration_glj.getSourceType();
  55. },
  56. volumePrice: function (node) {
  57. return node.sourceType === projectObj.project.VolumePrice.getSourceType();
  58. },
  59. non_bills: function (node) {
  60. return node.sourceType !== projectObj.project.Bills.getSourceType();
  61. },
  62. non_ration: function (node) {
  63. return node.sourceType !== projectObj.project.Ration.getSourceType();
  64. },
  65. non_volumePrice: function (node) {
  66. return node.sourceType !== projectObj.project.Ration.getSourceType();
  67. },
  68. billsParent: function (node) {
  69. return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
  70. },
  71. leafBillsWithDetail: function (node) {
  72. return (!MainTreeCol.readOnly.billsParent(node)) && (node.children.length > 0);
  73. },
  74. forCalcBase: function (node) {
  75. // to do according to billsParentType
  76. return MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
  77. },
  78. forUnitFee: function (node) {
  79. return MainTreeCol.readOnly.ration(node) || MainTreeCol.readOnly.billsParent(node) || MainTreeCol.readOnly.leafBillsWithDetail(node);
  80. },
  81. forTotalFee: function (node) {
  82. return MainTreeCol.readOnly.non_bills(node) || MainTreeCol.readOnly.billsParent(node) || (MainTreeCol.readOnly.leafBillsWithDetail(node));
  83. },
  84. forFeeRate:function (node) {
  85. return MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.billsParent(node)||MainTreeCol.readOnly.leafBillsWithDetail(node);
  86. },
  87. forQuantity:function (node) {
  88. return MainTreeCol.readOnly.glj(node)||MainTreeCol.readOnly.billsParent(node)
  89. },
  90. forMarketPrice:function (node) {
  91. return MainTreeCol.readOnly.non_volumePrice(node);
  92. },
  93. forContain:function (node) {
  94. return MainTreeCol.readOnly.non_ration(node)&&!MainTreeCol.readOnly.glj(node);
  95. },
  96. forCode:function (node) {
  97. return MainTreeCol.readOnly.glj(node)|| (node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type===rationType.gljRation);
  98. },
  99. forName:function (node) {
  100. },
  101. forUnit:function (node) {
  102. if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
  103. return true;
  104. }else {
  105. return treeNodeTools.isRation(node);
  106. }
  107. },
  108. forContentCharacter: function (node) {
  109. return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);
  110. },
  111. forRuleText: function (node) {
  112. if(MainTreeCol.readOnly.bills(node)){
  113. if(node.data.type === billType.FX || (node.data.type === billType.BILL && node.source.children.length === 0)){
  114. return false;
  115. }
  116. }
  117. return true;
  118. },
  119. // 超高降效
  120. forOverHeight: function () {}
  121. },
  122. cellType: {
  123. unit: function () {
  124. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  125. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  126. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  127. return combo;
  128. },
  129. // 工作内容
  130. jobContent: function () {
  131. },
  132. feeRate: function () {
  133. return feeRateObject.getFeeRateEditCellType();
  134. },
  135. quantity:function () {
  136. },
  137. calcBase: function () {
  138. return calcBaseView.getCalcBaseCellType();
  139. },
  140. calcProgramName: function (node) {
  141. },
  142. //类别
  143. subType: function (node) {
  144. },
  145. //是否分包
  146. isSubcontract: function (node) {
  147. },
  148. isEstimate:function (node) {
  149. },
  150. //综合合价
  151. commonTotalFee: function () {
  152. },
  153. // 超高降效
  154. overHeight: function () {}
  155. },
  156. getEvent: function (eventName) {
  157. let names = eventName.split('.');
  158. let event = this;
  159. for (let name of names) {
  160. if (event[name]) {
  161. event = event[name];
  162. } else {
  163. return null;
  164. }
  165. }
  166. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  167. return null;
  168. } else {
  169. return event;
  170. }
  171. },
  172. getNumberFormatter: function (digit) {
  173. switch (digit) {
  174. case 1:
  175. return '0.#';
  176. case 2:
  177. return '0.##';
  178. case 3:
  179. return '0.###';
  180. case 4:
  181. return '0.####';
  182. case 5:
  183. return '0.#####';
  184. case 6:
  185. return '0.######';
  186. default:
  187. return '0.##';
  188. }
  189. }
  190. };
  191. let colSettingObj = {
  192. settingSpread: null,
  193. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  194. loadSetting: function (sheet, setting) {
  195. sheet.setColumnCount(setting.cols.length);
  196. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  197. sheet.setRowCount(1);
  198. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  199. setting.headRowHeight.forEach(function (rowHeight, index) {
  200. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  201. });
  202. setting.cols.forEach(function (col, index) {
  203. let i, iRow = 0, cell;
  204. for (i = 0; i < col.head.spanCols.length; i++) {
  205. if (col.head.spanCols[i] !== 0) {
  206. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  207. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  208. }
  209. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  210. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  211. }
  212. iRow += col.head.spanRows[i];
  213. };
  214. sheet.setColumnWidth(index, col.width);
  215. cell = sheet.getCell(0, index).value(col.visible);
  216. });
  217. },
  218. initSettingSpread: function () {
  219. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  220. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  221. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  222. }
  223. };
  224. $('#column').on('shown.bs.modal', function () {
  225. if (!colSettingObj.settingSpread) {
  226. colSettingObj.initSettingSpread();
  227. }
  228. });
  229. $('#column').on('hide.bs.modal', function () {
  230. let sheet = colSettingObj.settingSpread.getActiveSheet();
  231. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  232. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  233. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  234. }
  235. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  236. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  237. });