commonFuncs.js 3.59 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
        this.$notify({
          title: "成功",
          message: "保存成功",
          type: "success",
        });
潘际乾 committed
14 15 16
        this.$store.dispatch("TagsView/delView", this.$route)
        this.$router.history.push("/taskList", () => {
          this.$store.commit("setTaskListTabVal", 'trnrel')
17 18
          //修改待复核界面刷新状态为需要刷新
          this.$store.commit("setLoadingFreshReview", true)
潘际乾 committed
19
        });
fukai committed
20 21 22 23 24 25 26 27 28 29 30 31 32
      }else  if(result.fieldErrors && Object.keys(result.fieldErrors).length > 0 ){
        const tab = this.showBackendErrors(result.fieldErrors)
        if (tab) {
          // tab切换之后,需出发tab-click的事件
          this.tabClick(tab);
        }
        this.$notify({
          title: "错误",
          message: "检核失败!",
          type: "error",
        });
      }
      else{
潘际乾 committed
33 34 35 36 37
        this.$notify({
          title: "失败",
          message: "保存失败",
          type: "error",
        });
fukai committed
38
       
潘际乾 committed
39 40 41 42
      }
    },
		// 表单暂存
    async handleStash() {
43 44 45 46 47 48 49 50 51 52 53 54
      // 汇入汇款交易必须输入收款人信息才能暂存
      if(this.trnName == 'cptadv'){
        let extkey = this.model.cpdgrp.pye.pts.extkey;
        if(extkey.replace(/(^\s*)|(\s*$)/g, '').length == 0){
        this.$notify({
          title: "失败",
          message: "必须输入收款人信息才能暂存",
          type: "error",
        });
        return;
        }
      }
潘际乾 committed
55 56 57 58 59 60 61
      let result = await this.pedding();
      if (result.respCode == SUCCESS) {
        this.$notify({
          title: "成功",
          message: "暂存成功",
          type: "success",
        });
潘际乾 committed
62 63 64
        this.$store.dispatch("TagsView/delView", this.$route)
        this.$router.history.push("/taskList", () => {
          this.$store.commit("setTaskListTabVal", 'sptbrk')
65 66
          //修改草稿箱界面刷新状态为需要刷新
          this.$store.commit("setLoadingFreshPending", true)
潘际乾 committed
67
        });
潘际乾 committed
68 69 70 71 72 73 74 75 76 77 78
      } else {
        this.$notify({
          title: "失败",
          message: "暂存失败",
          type: "error",
        });
      }
    },
		// 表单校验
    async handleCheck() {
      let result = await this.checkAll();
潘际乾 committed
79
      if (result.respCode == SUCCESS) {
潘际乾 committed
80 81
        const fieldErrors = result.fieldErrors;
        this.updateModel(result.data);
fukai committed
82
        if(fieldErrors && Object.keys(fieldErrors).length == 0){
83 84
            // 清除之前的校验状态
            this.getRoot().$refs.modelForm.clearValidate();
fukai committed
85 86 87 88 89
            this.$notify({
              title: "成功",
              message: "校验成功",
              type: "success",
            });
90
            return
fukai committed
91
        }
fukai committed
92
        const tab = this.showBackendErrors(fieldErrors)
潘际乾 committed
93 94
        if (tab) {
          // tab切换之后,需出发tab-click的事件
95 96 97 98
          if (tab.name !== this.tabVal) {
            this.isChecking = true
            this.myTabClick ? this.myTabClick(tab) : this.tabClick(tab);
          }
fukai committed
99 100 101 102 103 104
          this.$notify({
            title: "错误",
            message: "校核失败",
            type: "error",
          });
          return
潘际乾 committed
105
        }
106 107
      } else {
        this.$notify.error({ title: "错误", message: result.respMsg });
潘际乾 committed
108 109
      }
    },
wangguangchao committed
110
    async handlePass(data) {
wangguangchao committed
111
      this.$store.state.Transaction.operateFuns[data.operateId]["pass"]()
潘际乾 committed
112
    },
潘际乾 committed
113 114 115
    async handleRefuse(data) {
      this.$store.state.Transaction.operateFuns[data.operateId]["refuse"]()
    },
潘际乾 committed
116 117
  },
};