SubRulesGroup.vue 3.5 KB

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