area_increase_fee_view.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * Created by zhang on 2020/1/10.
  3. */
  4. let areaIncreaseFeeObj = {
  5. setDefaultSetting:function () {
  6. if(!gljUtil.isDef(projectObj.project.property.areaSetting)){
  7. let data={
  8. labour:10,
  9. material:1.5,
  10. machine:0,
  11. };
  12. projectObj.project.updateProjectProperty(data,"areaSetting")
  13. }
  14. },
  15. casCadeUpdate:async function (node,newval,fieldName) {
  16. let datas = [];
  17. let data = {
  18. type:node.sourceType,
  19. data:{ID:node.data.ID}
  20. };
  21. setData(data.data,newval,fieldName);
  22. datas.push(data);
  23. setChildren(node,newval,datas);//同步设置所有子项
  24. this.updateAndRefresh(datas);
  25. function setChildren(pnode,newValue,datas) {//同步设置所有子项
  26. if(pnode.children.length > 0 && (pnode.children[0].sourceType == ModuleNames.bills || pnode.children[0].sourceType == ModuleNames.ration)){//设置子项
  27. for(let c of pnode.children){
  28. let data = {
  29. type:c.sourceType,
  30. data:{ID:c.data.ID}
  31. };
  32. if(c.data.calcBase&&c.data.calcBase!="") continue;
  33. setData(data.data,newval,fieldName);
  34. datas.push(data);
  35. setChildren(c,newValue,datas)
  36. }
  37. }
  38. }
  39. function setData(data,avalue,fieldName) {
  40. data[fieldName] = avalue;
  41. if(fieldName == "outPutMaxPrice") data.maxPrice = null;
  42. }
  43. },
  44. updateAndRefresh:async function(datas){
  45. let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
  46. projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
  47. await OVER_HEIGHT.reCalcOverHeightFee();
  48. await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
  49. });
  50. projectObj.project.projectGLJ.calcQuantity();
  51. gljOprObj.refreshView();
  52. },
  53. confirmAreaIncreaseFeeSetting:async function () {
  54. let labour = $("#areaIncreaseFee_labour").val();
  55. let material = $("#areaIncreaseFee_material").val();
  56. let machine = $("#areaIncreaseFee_machine").val();
  57. if(!settingNumCheck(labour,"人工")) return;
  58. if(!settingNumCheck(material,"材料")) return;
  59. if(!settingNumCheck(machine,"机械")) return;
  60. let areaSetting = {
  61. labour:scMathUtil.roundForObj(labour,2),
  62. material:scMathUtil.roundForObj(material,2),
  63. machine:scMathUtil.roundForObj(machine,2)
  64. };
  65. let tem ={
  66. type:'project',
  67. data:{ID:projectObj.project.ID(),"property.areaSetting":areaSetting}
  68. };
  69. $('#areaIncreaseFeeDiv').modal('hide');
  70. let needUpdate = false;
  71. for(let key in areaSetting){
  72. if(areaSetting[key] != projectObj.project.property.areaSetting[key]){
  73. needUpdate = true;
  74. break;
  75. }
  76. }
  77. if(needUpdate){
  78. let datas = this.getAreaIncreaseDatas();
  79. datas.push(tem);
  80. this.updateAndRefresh(datas);
  81. }
  82. function settingNumCheck(value,type) {
  83. if(!number_util.isNum(value)){
  84. alert("输入的"+type+"数据类型不对,请重新输入!");
  85. return false;
  86. }
  87. if(parseFloat(value) < -100){
  88. alert("输入的"+type+"不能小于负100,请重新输入!");
  89. return false
  90. }
  91. return true;
  92. }
  93. },
  94. getAreaIncreaseDatas:function (withBills = false) {
  95. let datas = [];
  96. let rations = projectObj.project.Ration.datas;
  97. for(let r of rations){
  98. if(r.areaIncreaseFee == true){
  99. datas.push({type:"ration",data:{ID:r.ID,areaIncreaseFee:true}})
  100. }
  101. }
  102. if(withBills == true){
  103. let bills = projectObj.project.Bills.datas;
  104. for(let b of bills){
  105. if(b.areaIncreaseFee == true){
  106. datas.push({type:"bills",data:{ID:b.ID,areaIncreaseFee:true}})
  107. }
  108. }
  109. }
  110. return datas;
  111. },
  112. cancelAreaIncreaseFee:async function () {
  113. let datas = this.getAreaIncreaseDatas(true);
  114. //将值设置为false
  115. for(let d of datas){
  116. d.data.areaIncreaseFee = false;
  117. }
  118. let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
  119. projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
  120. await OVER_HEIGHT.reCalcOverHeightFee();
  121. await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
  122. });
  123. }
  124. };
  125. $(function () {
  126. $("#areaIncreaseFeeConfirm").on("click",async function(e){
  127. areaIncreaseFeeObj.confirmAreaIncreaseFeeSetting();
  128. });
  129. $('#areaIncreaseFeeDiv').on('show.bs.modal', function (e) {
  130. let areaSetting = {
  131. labour:10,
  132. material:1.5,
  133. machine:0,
  134. };
  135. if(gljUtil.isDef(projectObj.project.property.areaSetting)) areaSetting = projectObj.project.property.areaSetting;
  136. $("#areaIncreaseFee_labour").val(areaSetting.labour);
  137. $("#areaIncreaseFee_material").val(areaSetting.material);
  138. $("#areaIncreaseFee_machine").val(areaSetting.machine);
  139. });
  140. });