<template>
  <div class="app-container">
    <el-card class="card-layout">
      <div class="detail-title">
        <div>状态: <dict-tag style="display: inline-block;" :options="dict.type.examine_status" :value="detail.examineStatus" /></div>
        <div style="margin-left: 120px;">审核时间: {{ detail.examineTime }}</div>
      </div>
    </el-card>

    <el-card class="card-layout" style="margin-top: 20px;">
      <div class="detail-info">
        <el-row>
          <el-col :span="12">优惠券标题：{{ detail.couponTitle }}</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">优惠券分类：{{ detail.categoryName }}</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">优惠券类型：<dict-tag style="display: inline-block;" :options="dict.type.coupon_type" :value="detail.couponType" /></el-col>
        </el-row>
        <el-row>
          <el-col :span="12">有效期：{{detail.validityType === '1' ? `${detail.validityStartDate} ~ ${detail.validityEndDate}` : `领取后${detail.validityNum}天内`}}</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">库存：{{ detail.issued }}</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="detail-label">领券限制：</div>
            <div class="detail-value">
              <div>每人总共可领取 {{detail.receiveTotal === -1 ? '不限制' : `${detail.receiveTotal}张`}} </div>
              <div>每人每日可领取 {{detail.receiveDay === -1 ? '不限制' : `${detail.receiveDay}张`}} </div>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">适用门店：{{ detail.storeName }}</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">优惠券照片：<ImagePreview :src="detail.url || ''" :src-list="[detail.url]" /></el-col>
        </el-row>
        <el-row>
          <el-col :span="12">使用须知：{{ detail.remarks }}</el-col>
        </el-row>
        <el-row v-if="detail.couponType === 'team'">
          <el-col :span="12">套餐名称：{{ detail.mealTitle }}</el-col>
        </el-row>
        <el-row v-if="detail.couponType === 'team'">
          <el-col :span="12">套餐原价：{{ detail.originalPrice }}元</el-col>
        </el-row>
        <el-row v-if="detail.couponType === 'team'">
          <el-col :span="12">折扣价：{{ detail.presentPrice }}元</el-col>
        </el-row>
        <el-row v-if="detail.couponType === 'team'">
          <el-col :span="12">备注：{{ detail.mealRemarks }}</el-col>
        </el-row>
        <template v-if="detail.couponType === 'team'">
          <el-row v-for="(item, index) in detail.couponDetailList" :key="index">
            <el-col :span="12">
              <div style="width: 100%;">
                <div>{{item.category}}</div>
                <el-table :data="item.list" style="width: 100%;" size="small">
                  <el-table-column label="菜品" prop="foodName">
                  </el-table-column>
                  <el-table-column label="份数" prop="foodNum">
                  </el-table-column>
                  <el-table-column label="价格" prop="foodPrice">
                  </el-table-column>
                </el-table>
              </div>

            </el-col>
          </el-row>
        </template>

        <el-row>
          <el-col :span="12">每日发放限制：{{ detail.grant === -1 ? '不限制' : `${detail.grant}张` }}</el-col>
        </el-row>

        <!-- <el-row>
          <el-col :span="12">
            <div class="detail-label">默认决策：</div>
            <div class="detail-value">
              <div v-for="(item, index) in detail.defaultPolicy" :key="index">
                {{ item.groupName }}
                {{ item.fieldZhName }}
                等于
                {{ item.fieldValue }}
              </div>
            </div>
          </el-col>
          <el-col :span="12">创建人：{{ detail.createBy }}</el-col>
        </el-row> -->
      </div>
    </el-card>

  </div>
</template>

<script>
import { auditDetail } from '@/api/coupon/audit.js'

export default {
  name: 'CouponAuditDetail',
  dicts: ['coupon_type', 'examine_status'],
  data() {
    return {
      detail: {}
    }
  },
  mounted() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      auditDetail(this.$route.params.id).then(res => {
        this.detail = res.data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.detail-info {
  width: 90%;
  margin-top: 26px;
  font-size: 14px;
  line-height: 3;

  &:first-child {
    margin-top: 0;
  }

  .el-col {
    display: flex;
  }
}
</style>
