nongcun_2020.js 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // 农村公路养护2020
  2. // 覆盖标准清单添加逻辑(实质上是覆盖获取对比节点片段方法)
  3. (() => {
  4. const functionMap = {
  5. /**
  6. * 获取操作<<农村公路养护预算费用库>>时的节点片段
  7. * 片段为主树根节点(与其他费用定额的添加逻辑一致)
  8. */
  9. budeget() {
  10. return { parent: null, mainTreeFragment: projectObj.project.Bills.tree.roots };
  11. },
  12. /**
  13. * 获取操作<<农村公路小修工程量清单库>>时的节点片段
  14. * 1.主树焦点行必须在固定清单“小修费”的子节点xx项目清单范围内,范围内指清单本身及其所有后代节点
  15. * 小修费下某清单为xx项目清单的判定规则:小修费下名称不为“道路”、“桥梁”、“隧道”的清单
  16. * 2.若焦点行在无效范围中,插入时弹出提示
  17. */
  18. minorRepair() {
  19. const selected = projectObj.project.mainTree.selected;
  20. // 获取焦点所属的小修费下的xx项目(同时不为“道路”、“桥梁”、“隧道”)
  21. const targetNode = getTargetNode(selected);
  22. if (!targetNode) {
  23. return { errMsg: '当前位置不可添加小修工程量清单,请选中小修费下的项目名称,再添加工程量清单。' };
  24. }
  25. return { parent: targetNode, mainTreeFragment: targetNode.children || [] };
  26. function getTargetNode(node) {
  27. const exclusion = ['道路', '桥梁', '隧道'];
  28. while (node) {
  29. const isTheNode = node.parent && node.parent.getFlag() === fixedFlag.MINOR_REPAIR_FEE && !exclusion.includes(node.data.name);
  30. if (isTheNode) {
  31. return node;
  32. }
  33. node = node.parent;
  34. }
  35. return null;
  36. }
  37. },
  38. /**
  39. * 获取操作<<农村公路养护工程工程量清单>>的节点片段
  40. * 1.主树焦点行必须在固定清单“预防养护费”或者“修复养护费”下的建筑安装工程费清单范围内(多少层都可以,子代、孙子代...),范围内指清单本身及其所有后代节点
  41. * 2.若焦点行在无效范围中,插入时弹出提示
  42. */
  43. maintain() {
  44. const selected = projectObj.project.mainTree.selected;
  45. const targetNode = getTargetNode(selected);
  46. if (!targetNode) {
  47. return { errMsg: '当前位置不可添加养护工程量清单,请选择中建筑安装工程费,再添加工程量清单。' };
  48. }
  49. return { parent: targetNode, mainTreeFragment: targetNode.children || [] };
  50. function getTargetNode(node) {
  51. const targetName = '建筑安装工程费';
  52. while (node) {
  53. const isTheNode = node.data.name === targetName && node.isBelongToFlags([fixedFlag.PREVENTIVE_MAINTENANCE_FEE, REPAIR_MAINTENANCE_FEE]);
  54. if (isTheNode) {
  55. return node;
  56. }
  57. node = node.parent;
  58. }
  59. return null;
  60. }
  61. }
  62. };
  63. // 获取当前操作的清单库的方法
  64. function getFragmentFunction() {
  65. const selLibText = $('#stdBillsGuidanceLibSelect').text();
  66. if (/农村公路养护预算费用/.test(selLibText)) {
  67. return functionMap.budeget;
  68. } else if (/农村公路小修工程量清单/.test(selLibText)) {
  69. return functionMap.minorRepair;
  70. } else if (/农村公路养护工程工程量清单/.test(selLibText)) {
  71. return functionMap.maintain;
  72. } else {
  73. return null;
  74. }
  75. }
  76. // 获取对比的主树节点片段
  77. function overwrite() {
  78. if (typeof billsGuidance !== 'undefined') {
  79. // 不同的清单库插入获取片段都不同,先获取是哪个库进行操作
  80. const func = getFragmentFunction();
  81. if (func) {
  82. billsGuidance.overwrite.getFragment = func;
  83. }
  84. }
  85. }
  86. overwrite();
  87. })();