SubRulesGroup.vue 3.2 KB

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