main_tree_col.js 7.4 KB

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