<!--
 * @Descripttion: (领券记录/tb_customer_coupon 详情弹窗)
 * @version: (1.0)
 * @Author: (lwh)
 * @Date: (2023-07-31)
 * @LastEditors: (lwh)
 * @LastEditTime: (2023-07-31)
-->
<template>
  <el-dialog v-model="props.modelValue" title="领券记录信息详情" width="900px" @closed="closeDialog" @open="openDialog">
    <el-form ref="formRef" :model="formData" :disabled="true">

      <el-row :gutter="20">


        <el-col :lg="12">
          <el-form-item :label-width="labelWidth" label="优惠券" prop="couponGuid">
            <el-input v-model='formData.couponName' disabled type="text">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :lg="12">
          <el-form-item :label-width="labelWidth" label="客户" prop="customerGuid">
            <el-input v-model='formData.customerName' disabled type="text">
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :lg="12">
          <el-form-item :label-width="labelWidth" label="是否过期">
            <el-select v-model="formData.customerCouponIsExpired">
              <el-option v-for="item in  is_expired " :key="item.dictValue" :label="item.dictLabel"
                :value="parseInt(item.dictValue)"></el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :lg="12">
          <el-form-item :label-width="labelWidth" label="是否已使用">
            <el-select v-model="formData.customerCouponIsUsed">
              <el-option v-for="item in  is_used " :key="item.dictValue" :label="item.dictLabel"
                :value="parseInt(item.dictValue)"></el-option>
            </el-select>
          </el-form-item>
        </el-col>






      </el-row>
    </el-form>
  </el-dialog>
</template>

<script setup>
import { ElMessage } from 'element-plus'
import { reactive, ref, watch } from "vue";


// 打开弹窗时回调
const openDialog = async () => {
  await getis_expired()
  await getis_used()

}

const formData = ref({
  ...props.data,
});
watch(props, async (v) => {
  formData.value = v.data;
});

// -业务参数
// 是否过期字典选项列表
const is_expired = ref([]);
// 是否已使用字典选项列表
const is_used = ref([]);

// -业务方法
// 字典获取
async function getis_expired() {
  await proxy.getDicts('is_expired').then((res) => {
    is_expired.value = res.data
  })
}
// 字典获取
async function getis_used() {
  await proxy.getDicts('is_used').then((res) => {
    is_used.value = res.data
  })
}



// 基础参数
const formRef = ref();
const labelWidth = 100;
const { proxy } = getCurrentInstance()
const props = defineProps({
  modelValue: Boolean,
  data: Object,
  done: Function,
});
const emits = defineEmits(["update:modelValue"]);


// -基础方法
const closeDialog = () => {
  emits("update:modelValue", false);
};

</script>
