BusinessButton.vue 3.73 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
<template>
  <div class="bus-button">
    <c-button type="primary" v-on:click="save">{{
      $t("buttons.submit")
    }}</c-button>
    <c-button type="primary" v-on:click="pedding">{{
      $t("buttons.stash")
    }}</c-button>
    <c-button type="primary" v-on:click="check">{{
      $t("buttons.check")
    }}</c-button>
    <c-button v-on:click="exit">{{ $t("buttons.quit") }}</c-button>
  </div>
</template>
<script>
import commonApi from "~/mixin/commonApi";
import Utils from "~/utils";

export default {
  props: ["$pntvm"],
  data() {
    return {};
  },
  methods: {
    async save() {
      console.log(123);
      let vm = this.getVM();
      let result = await vm.save();
      console.log(result);
      // if (result.respCode == SUCCESS) {
      //     this.$notify({
      //         title: '成功',
      //         message: '保存成功',
      //         type: 'success'
      //     });
      //     this.$router.history.push("/business/trnrel")
      // } else {

      // }

      if (
        result.respCode == SUCCESS &&
        Object.keys(result.fieldErrors).length == 0
      ) {
        this.$notify({
          title: "成功",
          message: "保存成功",
          type: "success",
        });
        this.$store.dispatch("TagsView/delView", this.$route);
        this.$router.history.push("/taskList", () => {
          this.$store.commit("setTaskListTabVal", "trnrel");
        });
      } else if (
        result.fieldErrors &&
        Object.keys(result.fieldErrors).length > 0
      ) {
        let errorMsg = "";

        let errorMsgkey = "";
        let errorMsgVal = "";
        for (const key in result.fieldErrors) {
          errorMsgkey = key;
          errorMsgVal = result.fieldErrors[key];
          errorMsg = errorMsg + errorMsgkey + ":" + errorMsgVal + ";";
        }
        this.$notify.error({
          title: "失败",
          message: "保存失败!错误信息[" + errorMsg + "]",
        });
      } else {
        this.$notify({
          title: "失败",
          message: "保存失败",
          type: "error",
        });
      }
    },
    async pedding() {
      let result = await this.getVM().pedding();
      console.log(result);
      if (result.respCode == SUCCESS) {
        this.$notify({
          title: "成功",
          message: "暂存成功",
          type: "success",
        });
        this.$router.history.push("/business/sptsel");
      } else {
        this.$notify({
          title: "失败",
          message: "暂存失败",
          type: "error",
        });
      }
    },
    async check() {
      let result = await this.getVM().checkAll();
      if (result.respCode != SUCCESS) {
        this.$notify.error({ title: "错误", message: result.respMsg });
      } else {
        // 清除之前的校验状态
        this.getVM().$refs.modelForm.clearValidate();
        const fields = this.getVM().$refs.modelForm.fields;
        const fieldErrors = result.fieldErrors;
        this.getVM().updateModel(result.data);
        Utils.positioningErrorMsg(fieldErrors, fields);
        const tab = Utils.positioningErrorMsg(fieldErrors, fields);
        if (tab) {
          if (tab.name !== this.getVM().tabVal) {
            // tab切换之后,需出发tab-click的事件
            this.getVM().tabClick();
          }
        }
      }
    },
    exit() {
      this.$confirm("您有未保存的数据,确定退出吗, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$router.history.push("/home");
      });
    },
    getVM() {
      return this.$pntvm;
    },
  },
};
</script>
<style>
.bus-button {
  margin-bottom: 10px;
}

.bus-button :first-child {
  margin-left: 0;
}
</style>