_SubRulesGroup.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="sub-groups" v-if="data">
  3. <SubConditions
  4. v-for="(rules, i) in data"
  5. :key="i"
  6. ref="group"
  7. :groupData="rules"
  8. :isLast="data.length === 1"
  9. :ind="i"
  10. :showAdd="data.length < maxNum"
  11. :baseTypes="baseTypes"
  12. :firstPlace="firstPlace"
  13. :disabled="i === 0 && disable"
  14. @changeVal="handleInput"
  15. @addRule="addRule"
  16. @delRule="delRule"
  17. ></SubConditions>
  18. <div class="group-oper">
  19. <el-button size="small" @click="addGroup">+新增分组</el-button>
  20. <el-button
  21. :disabled="isLast"
  22. size="small"
  23. type="danger"
  24. plain
  25. @click="delGroup"
  26. >-删除分组</el-button
  27. >
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import SubConditions from "./_SubConditions.vue";
  33. export default {
  34. name: "SubRulesGroup",
  35. props: ["data", "inx", "isLast", "baseTypes", "maxNum", "firstPlace"],
  36. data() {
  37. return {};
  38. },
  39. computed: {
  40. disable: function () {
  41. return Object.keys(this.firstPlace || {}).length > 0;
  42. }
  43. },
  44. methods: {
  45. handleInput(val, i) {
  46. this.data[i] = val;
  47. },
  48. addRule() {
  49. let temp = {
  50. subDescription: "",
  51. subConceptId: "",
  52. subType: "",
  53. subLenName: "",
  54. subLenCode: "",
  55. subLibName: "",
  56. subMaxOperator: "",
  57. subMaxUnit: "",
  58. subMaxValue: "",
  59. subMinOperator: "",
  60. subMinUnit: "",
  61. subMinValue: "",
  62. subEqValue: "",
  63. dataType: ""
  64. };
  65. this.data.push(temp);
  66. },
  67. delRule(i) {
  68. if (i === 0 && this.data.length === 1) {
  69. this.$emit("delGroup", this.inx);
  70. return;
  71. }
  72. this.data.splice(i, 1);
  73. },
  74. addGroup() {
  75. this.$emit("addGroup");
  76. },
  77. delGroup() {
  78. this.$emit("delGroup", this.inx);
  79. },
  80. warning(msg, type) {
  81. this.$message({
  82. showClose: true,
  83. message: msg,
  84. type: type || "warning"
  85. });
  86. },
  87. showConfirmDialog(msg, resolve) {
  88. this.$alert(msg, "提示", {
  89. confirmButtonText: "确定",
  90. type: "warning"
  91. })
  92. .then(() => {
  93. resolve();
  94. })
  95. .catch(() => {
  96. this.warning("删除失败,请重试!");
  97. });
  98. }
  99. },
  100. components: {
  101. SubConditions
  102. }
  103. };
  104. </script>
  105. <style lang="less" scoped>
  106. .sub-groups {
  107. background: #f5f5f5;
  108. padding: 20px;
  109. }
  110. .group-oper {
  111. text-align: center;
  112. padding: 11px 0;
  113. border-top: 4px solid #f5f5f5;
  114. background: #fff;
  115. }
  116. .el-button--danger.is-plain:focus,
  117. .el-button--danger.is-plain:hover {
  118. color: #fbc4c4;
  119. border-color: #fbc4c4;
  120. }
  121. .el-button--danger.is-plain {
  122. background: none;
  123. &.is-disabled {
  124. color: #f9a7a7;
  125. background-color: #fef0f0;
  126. border-color: #fde2e2;
  127. }
  128. }
  129. </style>