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

export default {
  methods: {
		// 表单提交
6
    async handleSubmit(rulePath) {
7 8 9 10 11 12 13 14 15 16 17 18
      let result;
      if(rulePath){
        result = await this.executeRule(rulePath);

        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", () => {
19 20 21 22 23 24
            if(rulePath == 'bopbut.sav'){
              this.$store.commit("setTaskListTabVal", 'bopsel')
            }
            else if(rulePath == 'cfabut.sav'){
              this.$store.commit("setTaskListTabVal", 'cfasel')
            }
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
            //修改待复核界面刷新状态为需要刷新
            this.$store.commit("setLoadingFreshReview", true)
          });
        }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{
          this.$notify({
            title: "失败",
            message: "保存失败",
            type: "error",
          });
         
        }
      }else{
        result = await this.save();
        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')
            //修改待复核界面刷新状态为需要刷新
            this.$store.commit("setLoadingFreshReview", true)
          });
        }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{
          this.$notify({
            title: "失败",
            message: "保存失败",
            type: "error",
          });
         
fukai committed
81
        }
潘际乾 committed
82
      }
83
      
潘际乾 committed
84
    },
jianglong committed
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

    async handleConfirm() {
      let result = await this.confirm();
      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", 'sptrel')
          //修改待复核界面刷新状态为需要刷新
          this.$store.commit("setLoadingFreshReview", true)
        });
      }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{
        this.$notify({
          title: "失败",
          message: "确认失败",
          type: "error",
        });
       
      }
    },

潘际乾 committed
122 123
		// 表单暂存
    async handleStash() {
124 125 126 127 128 129 130 131 132 133 134 135
      // 汇入汇款交易必须输入收款人信息才能暂存
      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
136 137 138 139 140 141 142
      let result = await this.pedding();
      if (result.respCode == SUCCESS) {
        this.$notify({
          title: "成功",
          message: "暂存成功",
          type: "success",
        });
潘际乾 committed
143 144 145
        this.$store.dispatch("TagsView/delView", this.$route)
        this.$router.history.push("/taskList", () => {
          this.$store.commit("setTaskListTabVal", 'sptbrk')
146 147
          //修改草稿箱界面刷新状态为需要刷新
          this.$store.commit("setLoadingFreshPending", true)
潘际乾 committed
148
        });
潘际乾 committed
149 150 151 152 153 154 155 156 157
      } else {
        this.$notify({
          title: "失败",
          message: "暂存失败",
          type: "error",
        });
      }
    },
		// 表单校验
158
    async handleCheck(rulePath) {
159 160 161
      // this.$refs['modelForm'].validate((valid) => {
      //   console.log('valid', valid)
      // })
162 163 164 165 166 167 168 169
      let result;
      if(rulePath){
        result = await this.executeRule(rulePath);
      }else{
        result = await this.checkAll();
        
      }
      //  let result = await this.checkAll();
潘际乾 committed
170
      if (result.respCode == SUCCESS) {
潘际乾 committed
171 172
        const fieldErrors = result.fieldErrors;
        this.updateModel(result.data);
fukai committed
173
        if(fieldErrors && Object.keys(fieldErrors).length == 0){
174 175
            // 清除之前的校验状态
            this.getRoot().$refs.modelForm.clearValidate();
fukai committed
176 177 178 179 180
            this.$notify({
              title: "成功",
              message: "校验成功",
              type: "success",
            });
181
            return
fukai committed
182
        }
fukai committed
183
        const tab = this.showBackendErrors(fieldErrors)
潘际乾 committed
184 185
        if (tab) {
          // tab切换之后,需出发tab-click的事件
186 187 188 189
          if (tab.name !== this.tabVal) {
            this.isChecking = true
            this.myTabClick ? this.myTabClick(tab) : this.tabClick(tab);
          }
fukai committed
190 191 192 193 194 195
          this.$notify({
            title: "错误",
            message: "校核失败",
            type: "error",
          });
          return
潘际乾 committed
196
        }
197 198
      } else {
        this.$notify.error({ title: "错误", message: result.respMsg });
潘际乾 committed
199 200
      }
    },
wangguangchao committed
201
    async handlePass(data) {
wangguangchao committed
202
      this.$store.state.Transaction.operateFuns[data.operateId]["pass"]()
潘际乾 committed
203
    },
潘际乾 committed
204 205 206
    async handleRefuse(data) {
      this.$store.state.Transaction.operateFuns[data.operateId]["refuse"]()
    },
潘际乾 committed
207 208
  },
};