index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="bf-rolelist">
  3. <!-- 角色列表 -->
  4. <div class="cont">
  5. <div v-if="title" class="paren_header">
  6. <p>{{ title }}</p>
  7. </div>
  8. <template v-if="dataList.length">
  9. <div :class="active ? 'bgActive' : 'bgActivecheckbox'" class="paren_content">
  10. <el-scrollbar style="height: 100%">
  11. <template v-if="!type">
  12. <el-row :gutter="16">
  13. <el-checkbox-group @change="checkChange" v-model="checkList">
  14. <el-col :span="number" v-for="(item, index) in dataList" :key="index">
  15. <div @click="handleBg(item, index)" :class="active && msg === index ? 'bgColor' : ''" class="cide">
  16. <div class="cide_header">
  17. <p :title="item.name">{{ item.name }}</p>
  18. <el-checkbox :label="index"></el-checkbox>
  19. </div>
  20. </div>
  21. </el-col>
  22. </el-checkbox-group>
  23. </el-row>
  24. </template>
  25. <template v-else>
  26. <el-row :gutter="16">
  27. <el-radio-group style="display: block;" @change="radioChange" v-model="radio">
  28. <el-col :span="number" v-for="(item, index) in dataList" :key="index">
  29. <div @click.stop="handleBg(index)" :class="active && msg === index ? 'bgColor' : ''" class="cide">
  30. <div class="cide_header">
  31. <p>{{ item.name }}</p>
  32. <el-radio :label="index"></el-radio>
  33. </div>
  34. </div>
  35. </el-col>
  36. </el-radio-group>
  37. </el-row>
  38. </template>
  39. </el-scrollbar>
  40. </div>
  41. </template>
  42. <template v-else>
  43. <el-empty description="暂无数据"></el-empty>
  44. </template>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import "./rolelist.scss";
  50. export default {
  51. props: {
  52. title: {
  53. type: String,
  54. default: "",
  55. },
  56. type: {
  57. type: Boolean,
  58. default: false,
  59. },
  60. number: {
  61. type: Number,
  62. default: 3,
  63. },
  64. active: {
  65. type: Boolean,
  66. default: false,
  67. },
  68. dataList: {
  69. type: Array,
  70. default: () => [],
  71. },
  72. checkBoxList: {
  73. type: Array,
  74. default: () => [],
  75. },
  76. radioCheck: {
  77. type: Number,
  78. default: 0,
  79. }
  80. },
  81. data () {
  82. return {
  83. radio: null,
  84. checkList: [],
  85. msg: null,
  86. };
  87. },
  88. watch: {
  89. checkBoxList: {
  90. handler (arr) {
  91. this.checkList = arr;
  92. },
  93. deep: true,
  94. },
  95. radioCheck: {
  96. handler (num) {
  97. this.radio = num;
  98. },
  99. deep: true,
  100. },
  101. },
  102. methods: {
  103. // 选中
  104. handleBg (item, i) {
  105. this.msg = i;
  106. this.$emit("checkClick", item);
  107. },
  108. //多选框
  109. checkChange (arr) {
  110. this.$emit("checkChange", arr);
  111. },
  112. //单选框
  113. radioChange (val) {
  114. this.$emit("radioChange", val);
  115. },
  116. },
  117. };
  118. </script>
  119. <style lang="scss" scoped>
  120. .paren_content {
  121. ::v-deep .el-radio__label {
  122. display: none;
  123. }
  124. ::v-deep .el-checkbox__label {
  125. display: none;
  126. }
  127. }
  128. </style>