<template>
  <el-dialog
    :title="title"
    :center="true"
    align="left"
    top="22vh"
    width="600px"
    :close-on-click-modal="false"
    :visible.sync="showModelThis"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
    @close="showModelThis = false"
  >
    <el-card style="margin-top: -20px" v-loading="loading">
      <add-edit-form
        v-if="showModel"
        :id="id"
        :sitem="{}"
        :show-model="showModel"
        :is-detail="isDetail"
        @closeModel="handClick"
        @refresh="refresh"
      />
    </el-card>
  </el-dialog>
</template>
<script>
import addEditForm from "./addEditForm.vue";
export default {
  name: "handover",
  props: ["showModel", "id", "isDetail"],
  components: {
    addEditForm,
  },
  data() {
    return {
      title: "",
      showModelThis: this.showModel,
    };
  },
  watch: {
    showModel: function (val) {
      this.showModelThis = val;
      if (val) {
        this.initForm();
      }
    },
    showModelThis(val) {
      if (!val) {
        this.$emit("cancel");
      }
    },
  },
  methods: {
    
    async initForm() {
      this.loading = true;
      if (this.id === "add") {
        this.title = "添加离职交接";
        this.rulesThis = this.rules;
        // await this.resetForm();
      } else {
        if (this.isDetail) {
          // this.title = "离职交接详情";
          this.rulesThis = {};
        } else {
          this.rulesThis = this.rules;
        }
        // await this.resetForm();
        // await this.initData();
      }
      this.loading = false;
    },
    handClick(e) {
      this.showModelThis = e;
    },
    refresh(e) {
      this.showModelThis = e;
      this.$emit("refresh", true);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
