<template>
  <el-dialog
    v-loading="loading"
    :title="title"
    :center="true"
    align="left"
    top="8vh"
    width="1024px"
    :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="closeModel"
  >
    <el-card style="height: 700px; margin-top: -25px">
      <addview
        :id="id"
        :newTime="newTime"
        :show-model="showModel"
        :is-detail="isDetail"
        :invNo="invNo"
        :status="status"
        @refreshAll="refreshAll"
      ></addview>
    </el-card>
  </el-dialog>
</template>
<script>
import addview from "./addview";

export default {
  name: "invoiceApply",
  props: ["showModel", "id", "isDetail","status", "invNo"],
  components: {
    addview,
  },
  data() {
    return {
      loading: false,
      newTime: 0,
      showModelThis: this.showModel,
    };
  },
  watch: {
    showModel: function (val) {
      this.showModelThis = val;
      if (val) {
        this.initForm();
      }
    },
    showModelThis(val) {
      if (!val) {
        this.$emit("cancel");
      }
    },
  },
  methods: {
    closeModel() {
      console.log("closeModel!!");
    },
    async initForm() {
      this.newTime = 0;
      this.loading = true;
      if (this.isDetail === "003") {
        this.title = "添加发票申请";
      } else if (this.isDetail === "005") {
        this.title = "修改发票申请";
      } else if (this.isDetail === "007") {
        this.title = "发票申请详情";
      }
      this.changea();
      this.loading = false;
    },
    refreshAll() {
      this.showModelThis = false;
      this.$emit("refresh");
    },
    changea() {
      this.newTime = new Date().valueOf();
    },
  },
};
</script>

   <style lang="scss" scoped>
.invoiceApply {
}
</style>
