<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="signConfigId">
        {{ formData.signConfigId || '--' }}
      </el-form-item>
      <el-form-item label="每日签到金额" prop="signPrice">
        {{ formData.signPrice || '--' }}
      </el-form-item>
      <el-form-item label="连续签到天数设置" prop="signDay">
        {{ formData.signDay || '--' }}
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        {{ formData.createTime || '--' }}
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import { getByIdBeeSignConfig } from '@/api/signInManagement/transactionSignIn'

export default {
  name: 'DetailModal',
  data() {
    return {
      modalOptions: {
        closeOnClickModal: false,
        width: '800px',
        title: '查看消费金签到配置详情'
      },
      visible: false,
      formData: {
        signConfigId: '',
        signPrice: '',
        signDay: '',
        createTime: ''
      }
    }
  },
  methods: {
    handleClose() {
      this.visible = false
    },
    handleOpen(params = {}) {
      this.formData = Object.assign(this.$options.data().formData, params)
      if (params.signConfigId) {
        this.getInfo(params.signConfigId)
      }
      this.visible = true
    },
    async getInfo(id) {
      const loading = this.$loading({ text: '加载中' })
      try {
        const res = await getByIdBeeSignConfig({ id })
        this.formData = Object.assign(this.$options.data().formData, res.data, {
          signConfigId: res.data.signConfigId || '',
          signPrice: res.data.signPrice || '',
          signDay: res.data.signDay || '',
          createTime: res.data.createTime || ''
        })
      } finally {
        loading.close()
      }
    }
  }
}
</script>

