<template>
  <div class="cmain">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <div class="bos">
        <div class="lab">
          <div class="bsg"></div>
          <div class="tit">个人信息</div>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="form.name" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证" prop="idCard">
              <el-input v-model="form.idCard" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="手机号" prop="phone">
              <el-input v-model="form.phone" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="开户行" prop="bankName">
              <el-input v-model="form.bankName" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="银行卡号" prop="bankAccount">
              <el-input v-model="form.bankAccount" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="支付宝" prop="alipay">
              <el-input v-model="form.alipay" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="bos">
        <div class="lab">
          <div class="bsg"></div>
          <div class="tit">身份信息</div>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-input v-model="form.sex" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="nationality">
              <el-input v-model="form.nationality" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出生年月" prop="birth">
              <el-input v-model="form.birth" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" disabled />
        </el-form-item>
        <el-row>
          <el-col :span="8">
            <el-form-item label="身份证人面像">
              <el-image :fit="'contain'" class="sfz" :z-index="50000" :src="baseUrl + form.p1" :preview-src-list="[baseUrl + form.p1]"></el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证人徽面">
              <el-image :fit="'contain'" class="sfz" :z-index="50000" :src="baseUrl + form.p2" :preview-src-list="[baseUrl + form.p2]"></el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="有效期" prop="endDate">
              <el-input v-model="form.endDate" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
    <div class="mfooter" v-if="!param.detail">
      <el-button type="primary" @click="submitForm(1)">审核通过</el-button>
      <el-button type="danger" @click="submitForm(2)">审核不通过</el-button>
      <el-button @click="$layer.close(layerid)">取 消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {},
      rules: {}
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  mounted() {
    if (this.param.id) {
      this.ajax({ url: '/work/user/detail/' + this.param.id }).then((response) => {
        this.form = response.data;
      });
    }
  },
  methods: {
    submitForm(isAuthentication) {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.form.isAuthentication = isAuthentication;
          this.ajax({ method: 'post', url: '/work/user/edit', data: this.form }).then((response) => {
            this.$modal.msgSuccess('操作成功');
            this.$layer.close(this.layerid);
            this.$parent.getList();
          });
        }
      });
    }
  }
};
</script>
