main_tree_col.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. forContentCharacter: function (node) {
  95. return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);
  96. },
  97. forRuleText: function (node) {
  98. if(MainTreeCol.readOnly.bills(node)){
  99. if(node.data.type === billType.FX || (node.data.type === billType.BILL && node.source.children.length === 0)){
  100. return false;
  101. }
  102. }
  103. return true;
  104. }
  105. },
  106. cellType: {
  107. unit: function () {
  108. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  109. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  110. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  111. return combo;
  112. },
  113. feeRate: function () {
  114. return feeRateObject.getFeeRateEditCellType();
  115. },
  116. calcBase: function () {
  117. return calcBaseView.getCalcBaseCellType();
  118. },
  119. calcProgramName: function (node) {
  120. },
  121. //类别
  122. subType: function (node) {
  123. },
  124. //是否分包
  125. isSubcontract: function (node) {
  126. },
  127. isEstimate:function (node) {
  128. }
  129. },
  130. getEvent: function (eventName) {
  131. let names = eventName.split('.');
  132. let event = this;
  133. for (let name of names) {
  134. if (event[name]) {
  135. event = event[name];
  136. } else {
  137. return null;
  138. }
  139. }
  140. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  141. return null;
  142. } else {
  143. return event;
  144. }
  145. },
  146. getNumberFormatter: function (digit) {
  147. switch (digit) {
  148. case 1:
  149. return '0.#';
  150. case 2:
  151. return '0.##';
  152. case 3:
  153. return '0.###';
  154. case 4:
  155. return '0.####';
  156. case 5:
  157. return '0.#####';
  158. case 6:
  159. return '0.######';
  160. default:
  161. return '0.##';
  162. }
  163. }
  164. };
  165. let colSettingObj = {
  166. settingSpread: null,
  167. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  168. loadSetting: function (sheet, setting) {
  169. sheet.setColumnCount(setting.cols.length);
  170. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  171. sheet.setRowCount(1);
  172. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  173. setting.headRowHeight.forEach(function (rowHeight, index) {
  174. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  175. });
  176. setting.cols.forEach(function (col, index) {
  177. let i, iRow = 0, cell;
  178. for (i = 0; i < col.head.spanCols.length; i++) {
  179. if (col.head.spanCols[i] !== 0) {
  180. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  181. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  182. }
  183. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  184. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  185. }
  186. iRow += col.head.spanRows[i];
  187. };
  188. sheet.setColumnWidth(index, col.width);
  189. cell = sheet.getCell(0, index).value(col.visible);
  190. });
  191. },
  192. initSettingSpread: function () {
  193. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  194. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  195. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  196. }
  197. };
  198. $('#column').on('shown.bs.modal', function () {
  199. if (!colSettingObj.settingSpread) {
  200. colSettingObj.initSettingSpread();
  201. }
  202. });
  203. $('#column').on('hide.bs.modal', function () {
  204. let sheet = colSettingObj.settingSpread.getActiveSheet();
  205. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  206. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  207. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  208. }
  209. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  210. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  211. });