check-select-group.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="radio-slect-group">
  3. <template v-for="(item, i) in list">
  4. <view class="radio-slect-item" :key="i">
  5. <view class="p-view" @click="changeOpenKey(i)">
  6. <image class="icon" :src="`/static/${isOpen(i) ? 'up-icon' : 'down-icon'}.png`"></image>
  7. <text>{{ item[setting.pName] }}</text>
  8. </view>
  9. <template v-if="isOpen(i)">
  10. <view class="child-radio-group">
  11. <child-radio-group :pIndex="i" :list="item[setting.child] || []" :defaultValue="defaultValue"
  12. :label="label" :setting="setting" @change="toggleSelect" />
  13. </view>
  14. </template>
  15. </view>
  16. </template>
  17. </view>
  18. </template>
  19. <script>
  20. /**
  21. * 下拉式单选列表组合
  22. * 芦荟
  23. * 2021.2.3
  24. * props:属性说明看tm-radio-gruop.vue
  25. */
  26. import childRadioGroup from './check-group.vue'
  27. export default {
  28. props: ['list', 'defaultValue', 'label', 'setting', 'openkeys'],
  29. created() {},
  30. methods: {
  31. /**
  32. * 选中变化调用
  33. * @param {Object} selectData 当前选中的对象
  34. * @param {Object} index 当前选中下标
  35. */
  36. toggleSelect(data) {
  37. this.$emit('change',{
  38. ...data,
  39. parent:(pIndex || pIndex == 0) ? this.list[pIndex] : {}
  40. });
  41. },
  42. changeOpenKey(key) {
  43. let openKey = this.openkeys.find(openKey => openKey === key);
  44. this.$emit('changeOpenPKey', (openKey || openKey === 0 ? 'close' : 'open'), key)
  45. },
  46. isOpen(key) {
  47. let openKey = this.openkeys.find(openKey => openKey === key);
  48. return openKey || openKey === 0
  49. }
  50. },
  51. components: {
  52. childRadioGroup
  53. }
  54. }
  55. </script>
  56. <style lang="less">
  57. .radio-slect-group {
  58. background: #ffffff;
  59. .radio-slect-item {
  60. .p-view {
  61. display: flex;
  62. align-items: center;
  63. height: 75rpx;
  64. padding-left: 25rpx;
  65. .icon {
  66. margin-right: 15rpx;
  67. width: 21.25rpx;
  68. height: 12.5rpx;
  69. }
  70. >text {
  71. font-size: 22.5rpx;
  72. color: #292C33;
  73. }
  74. }
  75. }
  76. .child-radio-group {
  77. padding-left: 62.5rpx;
  78. }
  79. }
  80. </style>