<style scoped>
.user-panel {
  margin: 10px auto;
}
</style>
<template>
  <el-dialog
    :visible.sync="showDialog"
    :title="modalTitle"
    :modal-append-to-body="false"
    style="text-align:left;"
    @close="closeDialog"
    :close-on-click-modal="false"
    width="600px"
  >
    <div class="user-panel" v-loading="loading">
        <el-form ref="form" :model="formModel" :label-width="'100px'">
            <el-form-item label="应聘人" prop="realName">
            <el-input v-model="formModel.realName" placeholder="请输入应聘人" disabled="disabled" style="width:400px"></el-input>
            </el-form-item>
            <el-form-item label="身份证号" prop="idCard">
            <el-input v-model="formModel.idCard" placeholder="请输入身份证号" disabled="disabled" style="width:400px"></el-input>
            </el-form-item>
            <el-form-item label="拒绝原因" prop="remark">
                <el-input type="textarea" :rows="4" v-model="formModel.remark" placeholder="请输入备注" style="width:400px"></el-input>
            </el-form-item>

        </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 resumeDeliverApi from "@/api/job/resumeDeliver";

export default {
  props: ["businessKey", "title"],
  data() {
    return {
      formModel: {
        id: "",
        idCard:"",
        companyPhone:"",
        chatDate:"",
        chatTime:"",
        chatType:"",
        remark:"",
      },
      dataDictionaryList: [],
      showDialog: true,
      loading: false,
      submitting: false
    };
  },
  methods: {
    closeDialog() {
      this.$emit("close", false);
    },
    handleSubmit() {
      var self = this;
      this.$refs["form"].validate(valid => {
        if (valid) {
          (function() {
            var id = self.formModel.id;

            self.formModel.chatType = "6";

            return resumeDeliverApi.add(self.formModel);

          })().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);
            }
          });
        }
      });
    },
  },
  async mounted() {
    var self = this;
    self.loading = true;

    (function() {
      if (self.businessKey.length == 0) {
        return resumeDeliverApi.create();
      } else {
        return resumeDeliverApi.edit3(self.businessKey);
      }
    })()
      .then(response => {
        var jsonData = response.data;
        self.loading = false;

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