OwnCusCom.vue 2.02 KB
<!-- 所属客户群体 - 组件 -->
<template>
  <div class="flex">
    <el-select
      v-model="form[targetItem.firstVal]"
      :placeholder="'请选择'"
      @change="handleFirstChange('')"
    >
      <el-option
        v-for="subItem in optionList"
        :key="subItem[targetItem.optionId]"
        :label="subItem[targetItem.optionLabel]"
        :value="subItem[targetItem.optionId]"
      ></el-option>
    </el-select>
    <!-- <el-input
      v-show="[3].includes(form[targetItem.firstVal])"
      v-model="subVal.input"
      placeholder="请输入商户/门店ID"
      @change="handleFirstChange"
    ></el-input> -->
    <el-select
      v-show="[1, 2, 4].includes(form[targetItem.firstVal])"
      v-model="form[targetItem.secondVal]"
      :multiple="targetItem.multiple || false"
      @change="handleFirstChange"
    >
      <el-option
        v-for="subItem in baseData[attrToList[form[targetItem.firstVal]]]"
        :key="subItem.dictValue"
        :label="subItem.dictLabel"
        :value="subItem.dictValue"
      ></el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  name: 'OwnCusCom',
  data() {
    return {
      // subVal: {
      // input: '',
      // mutiSelect: []
      // },
      // 下拉框对应List
      attrToList: {
        '1': 'accounTypetList',
        '2': 'accountLevelList',
        '4': 'accountRoleList'
      }
    }
  },

  props: {
    targetItem: {
      type: Object,
      default: () => { }
    },
    form: {
      type: Object,
      default: () => { }
    },
    optionList: {
      type: Array,
      default: () => []
    },
    baseData: {
      type: Object,
      default: () => { }
    }
  },

  mounted() {
    // console.log(this.targetItem)
  },

  methods: {
    handleFirstChange(val) {
      // if (!val) {
      //   this.subVal = {
      //     input: '',
      //     mutiSelect: []
      //   }
      // }
      this.$emit('changeSecond', { val: val, targetItem: this.targetItem })
    }
  }
}

</script>
<style scoped>
.flex {
  display: flex;
}
</style>