main_tree_col.js 9.0 KB

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