main_tree_col.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. cellType: {
  121. unit: function () {
  122. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  123. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  124. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  125. return combo;
  126. },
  127. // 工作内容
  128. jobContent: function () {
  129. },
  130. feeRate: function () {
  131. return feeRateObject.getFeeRateEditCellType();
  132. },
  133. quantity:function () {
  134. },
  135. calcBase: function () {
  136. return calcBaseView.getCalcBaseCellType();
  137. },
  138. calcProgramName: function (node) {
  139. },
  140. //类别
  141. subType: function (node) {
  142. },
  143. //是否分包
  144. isSubcontract: function (node) {
  145. },
  146. isEstimate:function (node) {
  147. },
  148. //综合合价
  149. commonTotalFee: function () {
  150. }
  151. },
  152. getEvent: function (eventName) {
  153. let names = eventName.split('.');
  154. let event = this;
  155. for (let name of names) {
  156. if (event[name]) {
  157. event = event[name];
  158. } else {
  159. return null;
  160. }
  161. }
  162. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  163. return null;
  164. } else {
  165. return event;
  166. }
  167. },
  168. getNumberFormatter: function (digit) {
  169. switch (digit) {
  170. case 1:
  171. return '0.#';
  172. case 2:
  173. return '0.##';
  174. case 3:
  175. return '0.###';
  176. case 4:
  177. return '0.####';
  178. case 5:
  179. return '0.#####';
  180. case 6:
  181. return '0.######';
  182. default:
  183. return '0.##';
  184. }
  185. }
  186. };
  187. let colSettingObj = {
  188. settingSpread: null,
  189. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  190. loadSetting: function (sheet, setting) {
  191. sheet.setColumnCount(setting.cols.length);
  192. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  193. sheet.setRowCount(1);
  194. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  195. setting.headRowHeight.forEach(function (rowHeight, index) {
  196. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  197. });
  198. setting.cols.forEach(function (col, index) {
  199. let i, iRow = 0, cell;
  200. for (i = 0; i < col.head.spanCols.length; i++) {
  201. if (col.head.spanCols[i] !== 0) {
  202. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  203. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  204. }
  205. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  206. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  207. }
  208. iRow += col.head.spanRows[i];
  209. };
  210. sheet.setColumnWidth(index, col.width);
  211. cell = sheet.getCell(0, index).value(col.visible);
  212. });
  213. },
  214. initSettingSpread: function () {
  215. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  216. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  217. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  218. }
  219. };
  220. $('#column').on('shown.bs.modal', function () {
  221. if (!colSettingObj.settingSpread) {
  222. colSettingObj.initSettingSpread();
  223. }
  224. });
  225. $('#column').on('hide.bs.modal', function () {
  226. let sheet = colSettingObj.settingSpread.getActiveSheet();
  227. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  228. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  229. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  230. }
  231. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  232. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  233. });