main_tree_col_backup.js 9.0 KB

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