submitAction.js 3.61 KB
Newer Older
1
import errorMessageUtil from "./util/errorMessageUtil";
2
import {minusIndex} from '../query-actions/util/queryTag.js';
wangcong committed
3 4
export default {
  execute: function (bill, param) {
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
    if (param && param.param && param.param.budgetcontrol) {
      let res = this.getBudgetControl(bill, true, param);
      res.then((data) => {
        if (data.code == 0) {
          let result = this.getBudgetControl(bill, false, param);
          result.then((data1) => {
            if (data1.code == 0) {
              this.submitExecute(bill, param);
            } else if (data1.code == 1) {
              GAMS.Common.messagePrompt(data1.msg);
            }
          });
        } else if (data.code == 1) {
          setTimeout(() => {
            GAMS.Common.messagePrompt(data.msg);
          }, 500);
        } else if (data.code == 2) {
          setTimeout(() => {
            this.getModal(bill, param, data);
          }, 500);
        }
      });
    } else {
      this.submitExecute(bill, param);
    }
  },
  getModal(bill, param, data) {
    GMS.$hideContainer.$Modal.confirm({
      title: "信息提示",
      content: data.msg,
      onOk: () => {
        let result = this.getBudgetControl(bill, false, param);
        result.then((data1) => {
          if (data1.code == 0) {
            this.submitExecute(bill, param);
          } else if (data1.code == 1) {
            GAMS.Common.messagePrompt(data1.msg);
          }
        });
      },
      onCancel: () => {
        GMS.$hideContainer.$Message["error"]({
          content: "已取消",
        });
      },
    });
  },
  getBudgetControl(bill, check, param) {
    let postData = {
      data: bill.getBuillData(),
    };
    let url = `/v1/budget/control/${param.define}/${check}`;
    return new Promise((resolve, reject) => {
      GMS.$http
        .post(url, postData, {
          headers: {
            post: {
              "Content-Type": "application/json",
            },
          },
        })
        .then((res) => {
          resolve(res.data);
        });
    });
  },
  submitExecute(bill, param){
wangcong committed
72 73
    if (bill) {
      bill.setControlsSate(param["_control_name_"], 'enable', false)
74 75 76 77 78 79 80 81 82 83
      let postData = {
        data: bill.getBuillData(),
      };
      let url = `/rbc/bill/workflowAction/executed/${param.define}/workflow.submitToFlow?transmission=total`;
      window.GMS.$http.post(url, JSON.stringify(postData)).then((response) => {
        const data = response.data
        let code = 200
        if (data.code != 0) {
          code = 201
        }
wangcong committed
84 85
        bill.setControlsSate(param["_control_name_"], 'enable', true)
        if (code === 200) {
86
          const id = data.content.billData.id;
87
          minusIndex();//上张下张用
wangcong committed
88
          GMS.$hideContainer.$Message.success('提交成功');
qiaoyanqi committed
89 90
          let curTagId = window.nros.context.getCurrTag();
          GMS.vbus.$emit("workflow-state-change", 90,curTagId);
wangcong committed
91
        } else if (code === 201) {
92 93 94 95 96
          GMS.$hideContainer.$Spin.hide()
          data.message && GMS.$hideContainer.$Message.error({
            content: errorMessageUtil.submitAction.getErrorMessage(data.message),
            duration: 3
          });
wangcong committed
97 98 99 100
        } else if (code === 202) {
          GMS.$hideContainer.$Spin.hide();
          GMS.$hideContainer.$Message.error("暂存单据异常请联系管理员");
        }
101 102 103 104
      }).catch((err) => {
        GMS.$hideContainer.$Message.error('工作流配置错误,请联系管理员');
        bill.setControlsSate(param["_control_name_"], "enable", true)
        bill.setControlsSate(param["_control_name_"],"loading",false)
105
      })
wangcong committed
106 107 108 109 110 111
    } else {
      GMS.$hideContainer.$Spin.hide();
      alert('缺少参数');
    }
  }
}