main_tree_col.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. forName:function (node) {
  90. },
  91. forUnit:function (node) {
  92. if(MainTreeCol.readOnly.bills(node)&&(node.data.type==billType.DXFY||node.data.type==billType.FB)){//在大项费用、分部行,计量单位只读。
  93. return true;
  94. }else {
  95. return treeNodeTools.isRation(node);
  96. }
  97. },
  98. forContentCharacter: function (node) {
  99. return !MainTreeCol.readOnly.bills(node) || (node.data.type !== billType.BILL && node.data.type !== billType.FX);
  100. },
  101. forRuleText: function (node) {
  102. if(MainTreeCol.readOnly.bills(node)){
  103. if(node.data.type === billType.FX || (node.data.type === billType.BILL && node.source.children.length === 0)){
  104. return false;
  105. }
  106. }
  107. return true;
  108. }
  109. },
  110. cellType: {
  111. unit: function () {
  112. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  113. combo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
  114. '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
  115. return combo;
  116. },
  117. feeRate: function () {
  118. return feeRateObject.getFeeRateEditCellType();
  119. },
  120. quantity:function () {
  121. },
  122. calcBase: function () {
  123. return calcBaseView.getCalcBaseCellType();
  124. },
  125. calcProgramName: function (node) {
  126. },
  127. //类别
  128. subType: function (node) {
  129. },
  130. //是否分包
  131. isSubcontract: function (node) {
  132. },
  133. isEstimate:function (node) {
  134. },
  135. //综合合价
  136. commonTotalFee: function () {
  137. }
  138. },
  139. getEvent: function (eventName) {
  140. let names = eventName.split('.');
  141. let event = this;
  142. for (let name of names) {
  143. if (event[name]) {
  144. event = event[name];
  145. } else {
  146. return null;
  147. }
  148. }
  149. if (event && Object.prototype.toString.apply(event) !== "[object Function]") {
  150. return null;
  151. } else {
  152. return event;
  153. }
  154. },
  155. getNumberFormatter: function (digit) {
  156. switch (digit) {
  157. case 1:
  158. return '0.#';
  159. case 2:
  160. return '0.##';
  161. case 3:
  162. return '0.###';
  163. case 4:
  164. return '0.####';
  165. case 5:
  166. return '0.#####';
  167. case 6:
  168. return '0.######';
  169. default:
  170. return '0.##';
  171. }
  172. }
  173. };
  174. let colSettingObj = {
  175. settingSpread: null,
  176. checkBox: new GC.Spread.Sheets.CellTypes.CheckBox(),
  177. loadSetting: function (sheet, setting) {
  178. sheet.setColumnCount(setting.cols.length);
  179. sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
  180. sheet.setRowCount(1);
  181. sheet.getRange(0, -1, 1, -1).cellType(this.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  182. setting.headRowHeight.forEach(function (rowHeight, index) {
  183. sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
  184. });
  185. setting.cols.forEach(function (col, index) {
  186. let i, iRow = 0, cell;
  187. for (i = 0; i < col.head.spanCols.length; i++) {
  188. if (col.head.spanCols[i] !== 0) {
  189. cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
  190. cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]).wordWrap(true);
  191. }
  192. if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
  193. sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
  194. }
  195. iRow += col.head.spanRows[i];
  196. };
  197. sheet.setColumnWidth(index, col.width);
  198. cell = sheet.getCell(0, index).value(col.visible);
  199. });
  200. },
  201. initSettingSpread: function () {
  202. this.settingSpread = SheetDataHelper.createNewSpread($('#col_setting_spread')[0], {sheetCount: 1});
  203. this.settingSpread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.horizontal;
  204. this.loadSetting(this.settingSpread.getActiveSheet(), projectObj.project.projSetting.main_tree_col);
  205. }
  206. };
  207. $('#column').on('shown.bs.modal', function () {
  208. if (!colSettingObj.settingSpread) {
  209. colSettingObj.initSettingSpread();
  210. }
  211. });
  212. $('#column').on('hide.bs.modal', function () {
  213. let sheet = colSettingObj.settingSpread.getActiveSheet();
  214. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol ++) {
  215. projectObj.project.projSetting.main_tree_col.cols[iCol].visible = sheet.getValue(0, iCol);
  216. projectObj.project.projSetting.mainGridSetting.cols[iCol].visible = sheet.getValue(0, iCol);
  217. }
  218. SheetDataHelper.refreshColumnVisible(projectObj.project.projSetting.mainGridSetting, projectObj.mainSpread.getActiveSheet());
  219. projectObj.project.pushNow('editColSetting', projectObj.project.projSetting.moduleName, {projectID: projectObj.project.ID(), main_tree_col: projectObj.project.projSetting.main_tree_col});
  220. });