<template>
  <el-dialog
    :visible.sync="visible"
    v-bind="modalOptions"
  >
    <el-form
      ref="formData"
      :model="formData"
      size="mini"
      label-position="left"
      label-suffix=":"
      label-width="200px"
    >
      <!-- 代金券出账信息 -->
      <el-form-item label="ID" prop="id">
        {{ formData.id || '--' }}
      </el-form-item>
      <el-form-item label="平台代金券ID" prop="platformVoucherId">
        {{ formData.platformVoucherId || '--' }}
      </el-form-item>
      <el-form-item label="出账商家ID" prop="shopId">
        {{ formData.shopId || '--' }}
      </el-form-item>
      <el-form-item label="兑换订单编号" prop="orderFormid">
        {{ formData.orderFormid || '--' }}
      </el-form-item>
      <el-form-item label="出账数量" prop="number">
        {{ formData.number || '--' }}
      </el-form-item>
      <el-form-item label="出账类型" prop="waterType">
        <span v-if="formData.waterType === 1">专区兑换</span>
        <span v-else-if="formData.waterType === 2">社区兑换</span>
        <span v-else-if="formData.waterType === 3">转出</span>
        <span v-else>--</span>
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        {{ formData.createTime || '--' }}
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>

export default {
  name: 'DetailModal',
  data() {
    return {
      modalOptions: {
        closeOnClickModal: false,
        width: '800px',
        title: '查看代金券出账详情'
      },
      visible: false,
      formData: {
        id: '',
        platformVoucherId: '',
        shopId: '',
        orderFormid: '',
        number: '',
        waterType: '',
        createTime: ''
      }
    }
  },
  methods: {
    handleClose() {
      this.visible = false
    },
    handleOpen(params = {}) {
      this.formData = Object.assign(this.$options.data().formData, params)
      if (params.id) {
        // this.getInfo(params.id)
      }
      this.visible = true
    },
    async getInfo(id) {
      const loading = this.$loading({ text: '加载中' })
      try {
        const res = await xxx({ id })
        this.formData = Object.assign(this.$options.data().formData, res.data, {
          id: res.data.id || ''
        })
      } finally {
        loading.close()
      }
    }
  }
}
</script>

