<template>
  <div class="couponModalSeletor">
    <Select v-model="modalId" filterable clearable multiple>
        <Option v-for="item in list" :value="item.appConfigPushNo" :key="item.appConfigPushNo">{{ `id ${item.id} - ${item.name}` }}</Option>
    </Select>
    <!-- <Button type="primary" @click="save">保存</Button> -->
  </div>
</template>
<script>
import operationApi from '@api/operation.api';
export default {
  props: {
    value: {
      type: Array,
      default: []
    }
  },
  watch: {
    value(val) {
      this.modalId = val;
    },
    modalId(val) {
      this.$emit('input', val);
    }
  },
  components: {
  },
  data() {
    return {
      list: [],
      modalId: []
    }
  },
  created() {
    this.modalId = this.value;
    this.getCouponModalList();
  },
  methods: {
    async getCouponModalList() {
      const res = await operationApi.getCouponModalList({
        elementType: 4, // 4为优惠券弹窗类型
        enable: 'VALID'
      });
      const list = res.list.map(item => {
        let obj = {};
        obj.id = item.id.toString();
        obj.appConfigPushNo = item.appConfigPushNo.toString();
        obj.name = item.componentName;
        return obj;
      })
      // console.log(list)
      this.list = list;
    }
  }
}
</script>
<style scoped lang="less">
</style>
