element ui 复选框,点击特定值时候,其他不能点击(disabled)

拼搏现实的明天。 2022-09-06 00:20 210阅读 0赞
  1. <template>
  2. <div class="home">
  3. <p v-for="(item, index) in moniObj" :keys="index">
  4. <span class="fl-left font-size mar-l10 mar-top-10"
  5. >{
  6. { item.WiringTypeName }}:</span
  7. >
  8. <el-col :span="24">
  9. <span>
  10. <el-checkbox-group
  11. v-model="item.checkList"
  12. class="mar-top-10 fl-left mar-l10"
  13. @change="e => changeCheckbox(e, item)"
  14. >
  15. <el-checkbox
  16. :label="child.DictKey"
  17. v-for="(child, indexchild) in item.Items"
  18. :key="indexchild"
  19. :value="child.DictKey"
  20. :disabled="item.checkList.includes(item.Items[item.Items.length - 1].DictKey) && child.DictKey !== item.Items[item.Items.length - 1].DictKey"
  21. >
  22. {
  23. { child.DictValue }}
  24. </el-checkbox>
  25. </el-checkbox-group>
  26. </span>
  27. </el-col>
  28. <span class="fl-left mar-top-20 font-size mar-l10">
  29. {
  30. { item.DescriptionName }}:</span
  31. >
  32. <el-col :span="24" class="width-80 mar-top-10 ml-2">
  33. <el-input v-model="item.Description" type="textarea" row="1" />
  34. </el-col>
  35. </p>
  36. </div>
  37. </template>
  38. <script>
  39. import HelloWorld from "@/components/HelloWorld.vue";
  40. export default {
  41. name: "Home",
  42. components: {
  43. HelloWorld,
  44. },
  45. computed: {},
  46. data() {
  47. return {
  48. moniObj: [
  49. {
  50. WiringTypeName: "垂直",
  51. checkList: [],
  52. Items: [
  53. {
  54. DictValue: "测试11",
  55. DictKey: 1
  56. },
  57. {
  58. DictValue: "测试22",
  59. DictKey: 2
  60. },
  61. {
  62. DictValue: "测试332",
  63. DictKey: 3
  64. },
  65. {
  66. DictValue: "不涉及",
  67. DictKey: 4
  68. }
  69. ]
  70. },
  71. {
  72. WiringTypeName: "水平",
  73. checkList: [],
  74. Items: [
  75. {
  76. DictValue: "测试66",
  77. DictKey: 1
  78. },
  79. {
  80. DictValue: "测试44",
  81. DictKey: 2
  82. },
  83. {
  84. DictValue: "测试555",
  85. DictKey: 3
  86. },
  87. {
  88. DictValue: "不涉及",
  89. DictKey: 4
  90. }
  91. ]
  92. }
  93. ]
  94. };
  95. },
  96. methods: {
  97. changeCheckbox(e, item) {
  98. const val = item.Items[item.Items.length - 1].DictKey
  99. if (e[e.length-1] === val) {
  100. e.splice(0, e.length - 1)
  101. }
  102. }
  103. },
  104. };
  105. </script>

发表评论

表情:
评论列表 (有 0 条评论,210人围观)

还没有评论,来说两句吧...

相关阅读