<!-- 用户编辑弹窗 -->
<template>
  <ele-modal
    width="800px"
    :visible="visible"
    :append-to-body="true"
    :close-on-click-modal="true"
    custom-class="ele-dialog-form"
    title="适用门店"
    @update:visible="updateVisible"
  >
    <el-card shadow="never">
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :columns="columns"
        :datasource="allBiz"
        cache-key="pingProductCouponBizList"
        :need-page="false"
        :loading="loading"
      >
        <!-- 表头工具栏 -->
        <template v-slot:toolbar> </template>
      </ele-pro-table>
    </el-card>
  </ele-modal>
</template>

<script>
  import { getCouponBizList } from '@/api/car/product';
  export default {
    components: {},
    props: {
      // 弹窗是否打开
      visible: Boolean,
      couponId: String
    },
    data() {
      return {
        where: {
          couponId: ''
        },
        editVersion: false,
        loading: false,
        // 是否是修改
        isUpdate: false,
        columns: [
          {
            prop: 'biz_name',
            label: '门店',
            align: 'center',
            minWidth: 100
          },
          {
            prop: 'province_name',
            label: '省份',
            align: 'center'
          },
          {
            prop: 'city_name',
            label: '市',
            align: 'center'
          },
          {
            prop: 'address',
            label: '详细地址',
            align: 'center'
          }
        ],
        allBiz: []
      };
    },
    computed: {
      // 是否开启响应式布局
      styleResponsive() {
        return this.$store.state.theme.styleResponsive;
      }
    },
    created() {},
    methods: {
      loadBiz() {
        getCouponBizList({ couponId: this.couponId })
          .then((data) => {
            this.allBiz = data.list;
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      },
      /* 更新visible */
      updateVisible(value) {
        this.$emit('update:visible', value);
      }
    },
    watch: {
      visible(visible) {
        if (visible) {
          this.loadBiz();
        } else {
          this.allBiz = [];
        }
      }
    }
  };
</script>
<style>
  .ele-image-upload-list .ele-image-upload-item {
    margin-top: 2px;
    margin-bottom: 2px;
  }
</style>
