main_tree_col.js 7.4 KB

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