main_tree_col.js 8.3 KB

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