<template>
  <el-dialog
    :visible.sync="visible"
    v-bind="modalOptions"
    append-to-body
  >
    <el-form
      ref="formData"
      :model="formData"
      size="mini"
      label-position="left"
      label-suffix=":"
      label-width="200px"
    >
      <!-- 升级日志信息 -->
      <el-form-item label="ID" prop="relationshipLogId">
        {{ formData.relationshipLogId || '--' }}
      </el-form-item>
      <el-form-item label="用户ID" prop="buyerUserId">
        {{ formData.buyerUserId || '--' }}
      </el-form-item>
      <el-form-item label="会员手机号码" prop="phone">
        {{ formData.phone || '--' }}
      </el-form-item>
      <el-form-item label="会员身份" prop="identity">
        <span v-if="formData.identity === 1">会员</span>
        <span v-else-if="formData.identity === 2">团长</span>
        <span v-else-if="formData.identity === 3">合伙人</span>
        <span v-else>--</span>
      </el-form-item>
      <el-form-item label="操作类型" prop="operateType">
        <span v-if="formData.operateType === 1">扫码绑定</span>
        <span v-else-if="formData.operateType === 2">升级团长</span>
        <span v-else-if="formData.operateType === 3">升级合伙人</span>
        <span v-else>--</span>
      </el-form-item>
      <el-form-item label="绑定上级ID" prop="superiorUserId">
        {{ formData.superiorUserId || '--' }}
      </el-form-item>
      <el-form-item label="绑定上级手机号码" prop="superiorPhone">
        {{ formData.superiorPhone || '--' }}
      </el-form-item>
      <el-form-item label="绑定上级身份" prop="superiorIdentity">
        <span v-if="formData.superiorIdentity === 1">会员</span>
        <span v-else-if="formData.superiorIdentity === 2">团长</span>
        <span v-else-if="formData.superiorIdentity === 3">合伙人</span>
        <span v-else>--</span>
      </el-form-item>
      <el-form-item label="操作详情" prop="operateDetail">
        {{ formData.operateDetail || '--' }}
      </el-form-item>
      <el-form-item label="操作时间" prop="operateTime">
        {{ formData.operateTime || '--' }}
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>

export default {
  name: 'DetailModal',
  data() {
    return {
      modalOptions: {
        closeOnClickModal: false,
        width: '800px',
        title: '查看升级日志详情'
      },
      visible: false,
      formData: {
        relationshipLogId: '',
        buyerUserId: '',
        phone: '',
        identity: '',
        operateType: '',
        superiorUserId: '',
        superiorPhone: '',
        superiorIdentity: '',
        operateDetail: '',
        operateTime: ''
      }
    }
  },
  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>

