main_tree_col.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. forCode:function (node) {
  78. return MainTreeCol.readOnly.glj(node)|| (node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type===rationType.gljRation);
  79. }
  80. },
  81. cellType: {
  82. unit: function () {
  83. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  84. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  85. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  86. return combo;
  87. },
  88. feeRate: function () {
  89. return feeRateObject.getFeeRateEditCellType();
  90. },
  91. calcBase: function () {
  92. return calcBaseView.getCalcBaseCellType();
  93. }
  94. },
  95. getEvent: function (eventName) {
  96. let names = eventName.split('.');
  97. let event = this;
  98. for (let name of names) {
  99. if (event[name]) {
  100. event = event[name];
  101. } else {
  102. return null;
  103. }
  104. }
  105. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  106. return null;
  107. } else {
  108. return event;
  109. }
  110. },
  111. getNumberFormatter: function (digit) {
  112. switch (digit) {
  113. case 1:
  114. return '0.#';
  115. case 2:
  116. return '0.##';
  117. case 3:
  118. return '0.###';
  119. case 4:
  120. return '0.####';
  121. case 5:
  122. return '0.#####';
  123. case 6:
  124. return '0.######';
  125. default:
  126. return '0.##';
  127. }
  128. }
  129. };
  130. let colSettingObj = {
  131. settingSpread: null,
  132. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  133. loadSetting: function (sheet, setting) {
  134. sheet.setColumnCount(setting.cols.length);
  135. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  136. sheet.setRowCount(1);
  137. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  138. setting.headRowHeight.forEach(function (rowHeight, index) {
  139. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  140. });
  141. setting.cols.forEach(function (col, index) {
  142. let i, iRow = 0, cell;
  143. for (i = 0; i < col.head.spanCols.length; i++) {
  144. if (col.head.spanCols[i] !== 0) {
  145. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  146. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  147. }
  148. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  149. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  150. }
  151. iRow += col.head.spanRows[i];
  152. };
  153. sheet.setColumnWidth(index, col.width);
  154. cell = sheet.getCell(0, index).value(col.visible);
  155. });
  156. },
  157. initSettingSpread: function () {
  158. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  159. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  160. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  161. }
  162. };
  163. $('#column').on('shown.bs.modal', function () {
  164. if (!colSettingObj.settingSpread) {
  165. colSettingObj.initSettingSpread();
  166. }
  167. });
  168. $('#column').on('hide.bs.modal', function () {
  169. let sheet = colSettingObj.settingSpread.getActiveSheet();
  170. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  171. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  172. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  173. }
  174. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  175. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  176. });