main_tree_col.js 9.3 KB

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