
<style scoped>
.user-panel {
  margin: 10px auto;
}
</style>
<template>
  <el-dialog
    :visible.sync="showDialog"
    :title="title"
    :modal-append-to-body="false"
    style="text-align: left"
    @close="closeDialog"
    :close-on-click-modal="false"
  >
    <div class="user-panel" v-loading="loading">
      <el-form
        ref="form"
        :model="formModel"
        :label-width="'100px'"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="企业名称：" prop="name">
              {{formModel.name}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="法人代表：" prop="legalPerson">
              {{formModel.legalPerson}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="信用代码：" prop="creditCode">
              {{formModel.creditCode}}
            </el-form-item>
          </el-col>
          <!-- <el-col :span="8">
            <el-form-item label="企业类型：" prop="type">
              {{formModel.type}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="企业规模：" prop="scale">
              {{formModel.scale}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属行业：" prop="industry">
              {{formModel.industry}}
            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="联系人：" prop="contactPerson">
              {{formModel.contactPerson}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系电话：" prop="tel">
              {{formModel.tel}}
            </el-form-item>
          </el-col>
          <!-- <el-col :span="24">
            <el-form-item label="企业地址：" prop="address">
              {{formModel.address}}
            </el-form-item>
          </el-col> -->
          <el-col :span="24">
            <el-image style="width: 100%;" :src="formModel.businessLicenseUrl" fit="contain">
              <div slot="error" class="image-slot">
                <i class="el-icon-picture-outline"></i>
              </div>
            </el-image>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="handleSubmit" :loading="submitting">通 过</el-button>
    </span>
  </el-dialog>
</template>
<script>
import Constant from "@/constant";
import userAuthenticationApproveApi from "@/api/base/userAuthenticationApprove";
import companyApi from "@/api/base/company";

export default {
  props: ["businessKey", "companyKey", "title"],
  data() {
    return {
      formModel: {},
      showDialog: true,
      loading: false,
      submitting: false,
    };
  },
  methods: {
    closeDialog() {
      this.$emit("close", false);
    },
    handleSubmit() {
      var self = this;

      (function () {
        var formData = new FormData();
        formData.append("id", self.companyKey);

        return companyApi.checked(formData);
      })().then(function (response) {
        var jsonData = response.data;

        if (jsonData.result) {
          self.$message({
            message: "保存成功!",
            type: "success",
          });

          self.$emit("close", true);
        } else {
          self.$message({
            message: jsonData.message + "",
            type: "warning",
          });

          self.$emit("close", false);
        }
      });
    },
  },
  mounted: function () {
    var self = this;

    (function () {
        return companyApi.editChecked(self.companyKey);
    })()
    .then((response) => {
      var jsonData = response.data;
      self.loading = false;

      if (jsonData.result) {
        self.formModel = jsonData.data;
        console.log(self.formModel);
      } else {
        self.$message.error(jsonData.message + "");
      }
    })
    .catch((error) => {
      self.$message.error(error + "");
    });
  },
};
</script>