<template>
  <div>
    <obj-modal
      ref="modal"
      labelWidth="150px"
      :modalConfig="modalConfig"
      :modalData="modalData"
      :modalHandles="modalHandles"
    >
      <div slot="dialog__content">
        <el-form
          :model="ruleForm"
          ref="ruleForm"
          label-width="150px"
          class="demo-ruleForm"
        >
          <el-row>
            <el-col :span="8">
              <el-form-item label="优惠卷名称：">
                <span>{{ ruleForm.name }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="优惠卷类别：">
                <span>{{ getCategory(ruleForm.category) }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="优惠金额：">
                <span>{{ ruleForm.money }}</span>
              </el-form-item></el-col
            >
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="最低消费：">
                <span>{{ ruleForm.minPrice }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="领取限量：">
                <span>{{ ruleForm.limitedNum }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="发放总数：">
                <span>{{ ruleForm.total }}</span>
              </el-form-item></el-col
            >
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="剩余数量：">
                <span>{{ ruleForm.lastTotal }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="可领取开始时间：">
                <span>{{ ruleForm.receiveStartTime }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="可领取结束时间：">
                <span>{{ ruleForm.receiveEndTime }}</span>
              </el-form-item></el-col
            >
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="使用时间范围开始时间：">
                <span>{{ ruleForm.useStartTime }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="可使用时间范围结束时间：">
                <span>{{ ruleForm.useEndTime }}</span>
              </el-form-item></el-col
            >
            <el-col :span="8">
              <el-form-item label="状态：">
                <span>{{ ruleForm.status == 1 ? "开启" : "结束" }}</span>
              </el-form-item></el-col
            >
          </el-row>
        </el-form>
      </div>
      <!-- 选择商品 -->
    </obj-modal>
  </div>
</template>
<script>
import { debounce, cloneDeep } from "lodash";
export default {
  components: {},
  props: {},
  data() {
    return {
      isAdd: true,
      //表格属性
      modalConfig: {
        title: "优惠卷详情",
        show: false,
        width: "1200px",
        fullscreen: true,
      },
      modalData: {},
      ruleForm: {},
      tableData: [],
    };
  },
  watch: {
    // "modalConfig.show"(newVal) {
    //   if (newVal) {
    //     //关闭弹窗清空校验
    //     setTimeout(() => {
    //       this.$refs.ruleForm.resetFields();
    //     });
    //   }
    // },
  },
  methods: {
    queryTableData(pageNo, pageSize) {},
    toggle(e) {
      if (this.modalConfig.show == false) {
        this.modalConfig.show = true;
      } else {
        this.modalConfig.show = false;
      }
      if (e) {
        this.init(cloneDeep(e));
      }
      return {
        add: () => {
          this.modalConfig.title = "订单详情";
          this.isAdd = true;
        },
        update: () => {
          this.modalConfig.title = "优惠卷详情";
          this.isAdd = false;
        },
      };
    },
    init(row) {
      console.log(row);
      this.ruleForm = JSON.parse(JSON.stringify(row));
      console.log(this.ruleForm);
    },
    handleSelectionChange(e) {
      console.log(e);
    },
    getCategory(val) {
      if (val == "NO_THRESHOLD") {
        return "无门槛优惠券"
      } else if (val == "MAX_OUT") {
        return "满减优惠券"
      } else if (val == "FIRST_ATTENTION") {
        return "首次关注优惠券"
      } else if (val == "BIRTHDAY") {
        return "生日券"
      } else if (val == "PLATFORM") {
        return "平台优惠券"
      }
    },
  },
  computed: {
    modalHandles() {
      return [
        {
          label: "关闭",
          handle: () => {
            this.toggle();
          },
        },
        // {
        //   label: "确认",
        //   type: "primary",
        //   // submit: true,
        //   handle: () => {
        //   },
        // },
      ];
    },
  },
  asyncComputed: {},
};
</script>
<style lang="scss" scoped>
</style>