rejectAction.js 2.93 KB
Newer Older
wangcong 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
import { getUUID } from "../query-actions/util/lib";
export default {
  execute: function (bill, param) {
      if(bill){
          if(param.param.isNeedSave){
              let saveParam = {
                  actions: "bill.Basic.save",
                  afterAction: "",
                  confirmTitle: "",
                  customSaveAction: "",
                  noCheckCardDepressPeriod: true,
                  noCheckSubTable: true,
                  viewName: ""
              }
              bill.executeServerAction(saveParam,function(code,data){
                  if(code===200){
                      this.approval(bill, param);
                      bill.setControlsSate(param["_control_name_"],"loading",false)
                  }else{
                      bill.setControlsSate(param["_control_name_"],"loading",false)
                      GMS.$hideContainer.$message.error("操作异常请联系管理员");
                  }
              }.bind(this));
          } else {
              this.approval(bill, param);
          }
      }else{
          alert('缺少参数');
      }
  },
  approval: function(bill, param){
      let billId = bill.getMasterData().getValue('id');
      let taskId = bill.getGlobalParam('reviewParam').taskId;
      let comments = bill.getGlobalParam('reviewParam').suggestions ? bill.getGlobalParam('reviewParam').suggestions:"";
      GMS.$http.post('/gms/workflow/task/completed/' + taskId + '?result=3&comments='+comments).then(
          function(response) {
              if (response.status == 200 || response.statusText == 'OK') {
                  // console.log('驳回成功');
                  bill.setControlsSate(param["_control_name_"],"loading",false)
                  GMS.$hideContainer.$Message.success('驳回成功!')
                  if (
                    window.osConfig.appOpenMode &&
                    window.osConfig.appOpenMode == "apploader"
                  ) {
                    GMS.$hideContainer.$portalAPI.emit('nros-tag-close')
                    GMS.$hideContainer.$portalAPI.emit(
                      "open-new-page", //打开一个新的页签
                      getUUID(),
                      "runner-bill-form",
                      {
                        templateName: param.param.viewName,
                        id: billId,
                        state:'readOnly'
                      },
                      {
                        openWay: "FUNCTAB",
                        title: "单据详情",
                      }
                    );
                  }
                  else {
                    GMS.$hideContainer.$router.push({
                      path: "/showInnerBillForm/" + param.param.viewName + "/" + billId
                    })
                  }
              }
          }.bind(this)
      )
      .catch(
          function(error) {
              bill.setControlsSate(param["_control_name_"],"loading",false)
          }.bind(this)
      );
  }
}