commonFuncs.js 1.99 KB
Newer Older
潘际乾 committed
1 2 3 4 5 6 7
import Utils from "~/utils";

export default {
  methods: {
		// 表单提交
    async handleSubmit() {
      let result = await this.save();
hulei committed
8
      if (result.respCode == SUCCESS && Object.keys(result.fieldErrors).length == 0) {
潘际乾 committed
9 10 11 12 13 14
        this.$notify({
          title: "成功",
          message: "保存成功",
          type: "success",
        });
        this.$router.history.push("/business/trnrel");
15
      } else{
潘际乾 committed
16 17 18 19 20
        this.$notify({
          title: "失败",
          message: "保存失败",
          type: "error",
        });
21 22 23
        if(Object.keys(result.fieldErrors).length > 0 ){
          this.$notify.error({ title: "错误", message: result.respMsg });
        }
潘际乾 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
      }
    },
		// 表单暂存
    async handleStash() {
      let result = await this.pedding();
      if (result.respCode == SUCCESS) {
        this.$notify({
          title: "成功",
          message: "暂存成功",
          type: "success",
        });
        this.$router.history.push("/business/sptsel");
      } else {
        this.$notify({
          title: "失败",
          message: "暂存失败",
          type: "error",
        });
      }
    },
		// 表单校验
    async handleCheck() {
      let result = await this.checkAll();
47
      if (result.respCode == SUCCESS && Object.keys(result.fieldErrors).length == 0) {
潘际乾 committed
48 49 50 51 52 53 54 55 56 57 58
        // 清除之前的校验状态
        this.$refs.modelForm.clearValidate();
        const fields = this.$refs.modelForm.fields;
        const fieldErrors = result.fieldErrors;
        this.updateModel(result.data);
        Utils.positioningErrorMsg(fieldErrors, fields);
        const tab = Utils.positioningErrorMsg(fieldErrors, fields);
        if (tab) {
          // tab切换之后,需出发tab-click的事件
          this.tabClick(tab);
        }
hulei committed
59 60 61 62 63
        this.$notify({
          title: "成功",
          message: "校核成功",
          type: "success",
        });
64 65
      } else {
        this.$notify.error({ title: "错误", message: result.respMsg });
潘际乾 committed
66 67 68 69
      }
    },
  },
};