project_property_indicativeInfo.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. * Created by Zhong on 2018/3/7.
  3. */
  4. let indicativeInfoObj = {
  5. feeType: {common: 'common', labour: 'labour', material: 'material', machine: 'machine', mainMaterial: 'mainMaterial', equipment: 'equipment',
  6. labourDiff: 'labourDiff', materialDiff: 'materialDiff', machineDiff: 'machineDiff', manage: 'manage', profit: 'profit'},
  7. workBook: null,
  8. setting:{
  9. header: [
  10. {name: '名称', dataCode: 'name', width: 200, vAlign: 'center', hAlign: 'left'},
  11. {name: '金额', dataCode: 'price', width: 120, vAlign: 'center', hAlign: 'right'},
  12. {name: '占造价比例(%)', dataCode: 'rate', width: 100, vAlign: 'center', hAlign: 'right'},
  13. {name: '单方造价', dataCode: 'perCentiare', width: 80, vAlign: 'center', hAlign: 'right'}
  14. ],
  15. options: {
  16. tabStripVisible: false,
  17. allowCopyPasteExcelStyle : false,
  18. allowExtendPasteRange: false,
  19. allowUserDragDrop : false,
  20. allowUserDragFill: false,
  21. scrollbarMaxAlign : true
  22. }
  23. },
  24. renderSheetFuc: function (sheet, fuc) {
  25. sheet.suspendPaint();
  26. sheet.suspendEvent();
  27. fuc();
  28. sheet.resumePaint();
  29. sheet.resumeEvent();
  30. },
  31. setOptions: function (workbook, opts) {
  32. for(let opt in opts){
  33. workbook.options[opt] = opts[opt];
  34. }
  35. },
  36. buildHeader: function (sheet, headers) {
  37. let me = projFeatureView;
  38. let fuc = function () {
  39. sheet.setColumnCount(headers.length);
  40. sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
  41. for(let i = 0, len = headers.length; i < len; i++){
  42. sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
  43. sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
  44. }
  45. };
  46. me.renderSheetFuc(sheet, fuc);
  47. },
  48. buildSheet: function () {
  49. if(!this.workBook){
  50. this.workBook = new GC.Spread.Sheets.Workbook($('#indicativeInfoSpread')[0], {sheetCount: 1});
  51. this.setOptions(this.workBook, this.setting.options);
  52. this.workBook.getSheet(0).options.isProtected = true;
  53. this.buildHeader(this.workBook.getActiveSheet(), this.setting.header);
  54. }
  55. },
  56. showData(datas){
  57. let sheet = this.workBook.getActiveSheet();
  58. let cols = this.setting.header;
  59. let fuc = function () {
  60. sheet.setRowCount(datas.length);
  61. for(let col = 0, cLen = cols.length; col < cLen; col++){
  62. sheet.getRange(-1, col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);
  63. sheet.getRange(-1, col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).vAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
  64. for(let row = 0, rLen = datas.length; row < rLen; row++){
  65. sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
  66. }
  67. }
  68. };
  69. this.renderSheetFuc(sheet, fuc);
  70. },
  71. //是清单
  72. isBills: function (node) {
  73. return node && node.sourceType === projectObj.project.Bills.getSourceType();
  74. },
  75. //是大项费用
  76. isDXFY: function (node) {
  77. return this.isBills(node) && node.data.type === billType.DXFY;
  78. },
  79. //是分部分项工程
  80. isFBFX: function (node) {
  81. return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.SUB_ENGINERRING;
  82. },
  83. //是措施项目
  84. isCSXM: function (node) {
  85. return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.MEASURE;
  86. },
  87. //是工程造价
  88. isEngieeringCost: function (node) {
  89. return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.ENGINEERINGCOST;
  90. },
  91. //存在某个费用
  92. fee: function (node, feeType) {
  93. return node && node.data.feesIndex && node.data.feesIndex[feeType] ? node.data.feesIndex[feeType].totalFee : 0;
  94. },
  95. //根据固定行ID获取固定行清单节点
  96. getFixedBill: function (flag) {
  97. for(let node of projectObj.project.mainTree.items){
  98. if(node && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === flag){
  99. return node;
  100. }
  101. }
  102. return null;
  103. },
  104. getDXFY: function (node) {
  105. if(!node) return null;
  106. let dxfy = Object.create(null);
  107. let engCostFee = this.fee(this.getFixedBill(fixedFlag.ENGINEERINGCOST), this.feeType.common);
  108. let commonFee = this.fee(node, this.feeType.common);
  109. let buildingArea = projFeatureView.getFeature('projFeature', 'buildingArea');
  110. let areaNum = !buildingArea.value || buildingArea.value == '' || isNaN(buildingArea.value) ? 0 : buildingArea.value;
  111. dxfy.name = node.data.name;
  112. dxfy.price = commonFee ? parseFloat(commonFee).toDecimal(decimalObj.bills.totalPrice) : 0;
  113. dxfy.rate = engCostFee == 0 || this.isEngieeringCost(node) ? '' : parseFloat(dxfy.price/engCostFee*100).toDecimal(2);
  114. dxfy.perCentiare = areaNum == 0 ? '' : parseFloat(dxfy.price/areaNum).toDecimal(decimalObj.bills.totalPrice);
  115. return dxfy;
  116. },
  117. getIndicativeInfo: function () {
  118. let rst = [];
  119. for(let node of projectObj.project.mainTree.items){
  120. if(this.isDXFY(node)){
  121. let dxfy = this.getDXFY(node);
  122. if(!dxfy) continue;
  123. if(this.isFBFX(node)){
  124. rst.push(dxfy);
  125. rst.push({name: '其中:', price: '', rate: '', perCentiare: ''});
  126. rst.push({name: ' 人工费', price: parseFloat(this.fee(node, this.feeType.labour)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  127. rst.push({name: ' 材料费', price: parseFloat(this.fee(node, this.feeType.material)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  128. rst.push({name: ' 机械费', price: parseFloat(this.fee(node, this.feeType.machine)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  129. rst.push({name: ' 主材费', price: parseFloat(this.fee(node, this.feeType.mainMaterial)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  130. rst.push({name: ' 设备费', price: parseFloat(this.fee(node, this.feeType.equipment)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  131. let labourDiff = this.fee(node, this.feeType.labourDiff),
  132. materialDiff = this.fee(node, this.feeType.materialDiff),
  133. machineDiff = this.fee(node, this.feeType.machineDiff),
  134. rcjDiff = labourDiff + materialDiff + machineDiff;
  135. rst.push({name: '人材机价差', price: parseFloat(rcjDiff).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  136. rst.push({name: '企业管理费', price: parseFloat(this.fee(node, this.feeType.manage)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  137. rst.push({name: '利润', price: parseFloat(this.fee(node, this.feeType.profit)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
  138. }
  139. else if(this.isCSXM(node)){
  140. rst.push(dxfy);
  141. rst.push({name: '其中:', price: '', rate: '', perCentiare: ''});
  142. let safeConst = this.getDXFY(this.getFixedBill(fixedFlag.SAFETY_CONSTRUCTION));
  143. if(safeConst){
  144. safeConst.name = ` ${safeConst.name}`;
  145. rst.push(safeConst);
  146. }
  147. }
  148. else{
  149. rst.push(dxfy);
  150. }
  151. }
  152. }
  153. return rst;
  154. }
  155. };
  156. $(document).ready(function () {
  157. $('#poj-set').on('shown.bs.modal', function () {
  158. indicativeInfoObj.buildSheet();
  159. indicativeInfoObj.showData(indicativeInfoObj.getIndicativeInfo());
  160. });
  161. $('#poj-set').on('hidden.bs.modal', function () {
  162. if(indicativeInfoObj.workBook){
  163. indicativeInfoObj.workBook.destroy();
  164. indicativeInfoObj.workBook = null;
  165. }
  166. });
  167. $('#tab_poj-settings-indicativeInfo').on('shown.bs.tab', function () {
  168. indicativeInfoObj.workBook.refresh();
  169. });
  170. });