{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js??ref--0-0!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-fvue\\src\\components\\flow\\start.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\src\\components\\flow\\start.vue","mtime":1667327529419},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\babel.config.js","mtime":1667327525434},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/es6.regexp.replace\";\nimport _typeof from \"D:/jenkins/workspace/xq-web-fvue/node_modules/@babel/runtime/helpers/esm/typeof.js\";\nimport _defineProperty from \"D:/jenkins/workspace/xq-web-fvue/node_modules/@babel/runtime/helpers/esm/defineProperty.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\nimport req from \"@/request.js\";\nimport { mapState } from \"vuex\";\nimport FormContent from \"@/components/flow/formContent.vue\";\nimport TaskSelectDestination from \"@/components/flow/task/taskSelectDestination.vue\";\nimport utils from \"@/utils.js\";\nimport { Base64 } from \"js-base64\";\nexport default {\n  name: \"start\",\n  components: {\n    FormContent: FormContent,\n    TaskSelectDestination: TaskSelectDestination\n  },\n  props: [\"defId\", \"instId\", \"leaderId\", \"copyInstId\"],\n  data: function data() {\n    var _ref;\n\n    return _ref = {\n      tableData: [],\n      dialogVisible: false,\n      disabled: true,\n      nodeDef: {},\n      flowId: \"\",\n      isShowStartBtn: true,\n      isMyRequest: false,\n      defName: \"\",\n      initFillData: false,\n      reloadForm: false\n    }, _defineProperty(_ref, \"defName\", \"\"), _defineProperty(_ref, \"btnAlias\", \"\"), _defineProperty(_ref, \"data\", null), _defineProperty(_ref, \"show\", false), _defineProperty(_ref, \"localInstId\", this.instId), _ref;\n  },\n  computed: mapState({\n    curOrgPost: function curOrgPost(state) {\n      return state.user.postCharge;\n    }\n  }),\n  beforeRouteEnter: function beforeRouteEnter(to, from, next) {\n    next(function (vm) {\n      //判断用户是否具有流程启动权限\n      var userId = vm.$store.state.login.currentUser.userId,\n          instId = to.params.instId,\n          defId = to.params.defId,\n          leadId = to.params.leaderId;\n      var url = \"\".concat(window.context.bpmModel, \"/flow/defAuthorize/v1/startRight?userId=\").concat(userId, \"&defId=\").concat(defId, \"&leadId=\").concat(leadId); // 发起的是流程草稿时\n\n      if (instId) {\n        url = \"\".concat(url, \"&instId=\").concat(instId);\n      }\n\n      req.get(url).then(function (resp) {\n        if (!resp.data || !resp.data.state || !resp.data.value) {\n          vm.$alert('您没有该流程的启动权限', '无权限', {\n            confirmButtonText: \"返回主页\",\n            callback: function callback(action) {\n              vm.$router.push(\"/home\");\n            }\n          });\n        } else {\n          vm.show = true;\n        }\n      });\n    });\n  },\n  mounted: function mounted() {\n    var _this = this; //如果该字段的校验受另一个字段影响。则监听另一个字段控件发布的值改变事件\n\n\n    this.$root.$on(\"startFlowBtnChange\", function (value) {\n      _this.isShowStartBtn = value;\n    }); //监听表单加载完成发布事件\n\n    this.$root.$on(\"formLoading\", function (value) {\n      _this.disabled = value;\n    });\n  },\n  methods: {\n    //处理任务\n    handleTask: function handleTask(row) {\n      this.$router.push(\"/task/\" + row.id + \"/0\");\n    },\n    // 准备数据\n    handleData: function handleData(formDataStr) {\n      var data = {\n        defId: this.defId\n      };\n\n      if (formDataStr) {\n        // URL表单\n        if (formDataStr.constructor == Object) {\n          data.formType = \"frame\";\n\n          if (formDataStr.businessKey) {\n            data.businessKey = formDataStr.businessKey;\n          }\n\n          if (formDataStr.sysCode) {\n            data.sysCode = formDataStr.sysCode;\n          }\n\n          if (formDataStr.vars) {\n            data.vars = formDataStr.vars;\n          }\n        } else if (formDataStr.constructor == String) {\n          data.data = Base64.encode(formDataStr);\n          data.formType = \"inner\";\n        }\n      }\n\n      data.supportMobile = 0;\n\n      if (this.instId) {\n        data.proInstId = this.instId;\n      }\n\n      if (this.curOrgPost && this.curOrgPost.org) {\n        data.startOrgId = this.curOrgPost.org.id;\n      }\n\n      if (window.urgentStateValue) {\n        data.urgentStateValue = window.urgentStateValue;\n      }\n\n      if (this.leaderId && this.leaderId != 0) {\n        data.agentLeaderId = this.leaderId;\n      }\n\n      return data;\n    },\n    //启动\n    start: function start() {\n      var _this2 = this;\n\n      this.btnAlias = \"startFlow\";\n\n      var _this = this; //获取VUE表单实例(判断是否是在线表单)\n\n\n      if (document.getElementsByName(\"online-form\")[0]) {\n        var tables = document.getElementsByName(\"online-form\")[0].__vue__.permission.table; //获取子表权限\n\n\n        var boData = document.getElementsByName(\"online-form\")[0].__vue__.data; //获取表单bo对象\n\n\n        var zData = {};\n\n        for (var k in boData) {\n          zData = boData[k];\n        }\n\n        for (var key in tables) {\n          //如果有导入属性，则表明不是子表而是数据报表，不做必填校验\n          if (tables[key] && tables[key].hasOwnProperty(\"export\")) {\n            continue;\n          }\n\n          if ((tables[key].required == true || tables[key].required == \"true\") && zData[\"sub_\" + key] && zData[\"sub_\" + key].length == 0) {\n            this.$message({\n              message: \"子表必填一条记录\",\n              type: \"warning\"\n            });\n            return;\n          }\n        }\n      }\n\n      utils.getOnlineFormData(true).then(function (formDataStr) {\n        //执行按钮前置脚本\n        if (_typeof(formDataStr) === \"object\" && (formDataStr.hasOwnProperty('businessKey') || formDataStr.hasOwnProperty('sysCode'))) {\n          _this2.data = formDataStr;\n        } else {\n          _this2.data = JSON.parse(formDataStr);\n        }\n\n        var scriptResult = _this2.runBeforeScript();\n\n        if (scriptResult === false) return;\n\n        if (scriptResult.then && typeof scriptResult.then == \"function\") {\n          scriptResult.then(function () {\n            //接口返回成功则正常执行按钮操作\n            _this.startNext();\n          }, function (fail) {\n            //接口返回失败则终止按钮操作，并给与提示\n            _this.$message.warning(fail);\n\n            return;\n          });\n        } else {\n          //执行前置脚本返回true时正常执行按钮操作\n          _this.startNext();\n        }\n      }).catch(function (reason) {\n        return utils.handleGetFormDataReject(reason, true).then(function () {\n          return _this2.processStart();\n        });\n      });\n    },\n    //执行前置脚本\n    runBeforeScript: function runBeforeScript() {\n      var _this = this;\n\n      var item = utils.indexOfList(_this.$refs.formContent.buttons, \"alias\", _this.btnAlias);\n      return _this.tempScript(item.beforeScript);\n    },\n    //执行前置脚本\n    tempScript: function tempScript(script) {\n      var _this = this.$refs.formContent;\n      var _req = req;\n      var boData = this.$refs.formContent.data;\n      var tempScript = \"var tempFunction = function(_req,data,_this){ \" + script + \"};\";\n      var result = eval(tempScript + \"tempFunction(_req,boData,_this);\");\n\n      if (result && result.then && typeof result.then == \"function\") {\n        return result;\n      }\n\n      if (result === false) return false;\n      return true;\n    },\n    startNext: function startNext() {\n      var _this3 = this;\n\n      utils.getOnlineFormData(false).then(function (formDataStr) {\n        utils.closeAllNotification();\n\n        if (!_this3.nodeDef.localProperties.jumpType && !_this3.nodeDef.localProperties.choiceExcutor) {\n          _this3.processStart(formDataStr);\n        } else {\n          _this3.$store.dispatch(\"storeProcess/getAfterJumpNodes\", {\n            taskId: \"\",\n            data: Base64.encode(formDataStr),\n            defId: _this3.defId || \"\",\n            instId: _this3.instId || \"\"\n          }).then(function (data) {\n            if (data.afterNodes.length == 0 || data.afterNodes.length == 1 && data.afterNodes[0].excutorList != undefined && data.afterNodes[0].excutorList.length == 1) {\n              _this3.processStart(formDataStr);\n            } else {\n              var formData = {};\n\n              if (formDataStr.constructor == Object) {\n                formData = formDataStr;\n                formData.data = \"\";\n              } else if (formDataStr.constructor == String) {\n                formData.data = Base64.encode(formDataStr);\n              }\n\n              _this3.$refs.taskSelectDestination.showDialog(formData, \"\", \"\"); //父组件调用子组件方法\n\n            }\n          });\n        }\n      });\n    },\n    //流程发起\n    processStart: function processStart(formDataStr) {\n      var _this4 = this;\n\n      var formKey = this.$refs.formContent.formKey;\n      var data = this.handleData(formDataStr);\n\n      if (sessionStorage.getItem(\"formImportTempJson\")) {\n        data.updateSubTableJson = sessionStorage.getItem(\"formImportTempJson\");\n      }\n\n      this.disabled = true;\n      this.$store.dispatch(\"storeProcess/start\", data).then(function (row) {\n        if (row.curBoPkVal) {\n          sessionStorage.setItem(\"formImportTempRefId\", row.curBoPkVal);\n        }\n\n        sessionStorage.removeItem(\"formImportTempJson\");\n\n        if (row.tasks && row.tasks.length > 0) {\n          if (row.tasks.length == 1) {\n            _this4.$router.push(\"/task/\" + row.tasks[0].id + \"/0\");\n          } else {\n            //弹出窗口让用户自己选择去哪个待办\n            _this4.tableData = row.tasks;\n            _this4.dialogVisible = true;\n          }\n        } else {\n          if (row.inst.status != \"end\") {\n            _this4.$router.push(\"/inst/\" + row.instId + \"/request\");\n          } else {\n            _this4.$router.push(\"/instRead/\" + row.instId + \"/myRequest\");\n          }\n        } // this.$store\n        //   .dispatch(\"storeProcess/getInstanceByInstId\", row.instId)\n        //   .then((insts) => {\n        //     if (insts.status != \"end\") {\n        //       this.$router.push(\"/inst/\" + row.instId + \"/request\");\n        //     } else {\n        //       this.$router.push(\"/instRead/\" + row.instId + \"/myRequest\");\n        //     }\n        //   });\n\n      }).finally(function () {\n        _this4.disabled = false;\n      });\n    },\n    //保存\n    saveDraft: function saveDraft() {\n      var _this5 = this;\n\n      this.btnAlias = \"saveDraft\";\n      var scriptResult = this.runBeforeScript();\n      var formKey = this.$refs.formContent.formKey;\n      this.disabled = true;\n      var this_ = this;\n      utils.getOnlineFormData(false).then(function (formDataStr) {\n        utils.closeAllNotification();\n        var data = this_.handleData(formDataStr);\n        data.formKey = formKey;\n\n        if (sessionStorage.getItem(\"formImportTempJson\")) {\n          data.updateSubTableJson = sessionStorage.getItem(\"formImportTempJson\");\n        }\n\n        this_.$store.dispatch(\"storeProcess/saveDraft\", data).then(function (row) {\n          if (row.curBoPkVal) {\n            sessionStorage.setItem(\"formImportTempRefId\", row.curBoPkVal);\n          }\n\n          sessionStorage.removeItem(\"formImportTempJson\");\n          this_.isMyRequest = true;\n          this_.localInstId = row.instId;\n          this_.$router.replace(\"/start/\" + this_.defId + \"/\" + row.instId);\n        }).finally(function () {\n          //保存完成后,需要重新加载bo数据,不然第二次保存的时候会因为版本号不同而导致保存失败\n          _this5.$refs.formContent.init(true);\n        });\n      }).catch(function (reason) {\n        _this5.disabled = false;\n        utils.handleGetFormDataReject(reason);\n      });\n    },\n    //返回\n    back: function back() {\n      utils.closeAllNotification();\n\n      if (this.instId) {\n        this.$router.push(\"/v-flow/v-request\");\n      } else {\n        if (JSON.stringify(this.$route.query) == \"{}\") {\n          // this.$router.push(\"/v-flow/v-flowList\");\n          this.$router.go(-1);\n        } else {\n          this.$router.go(-1);\n        }\n      }\n    },\n    toMyTodo: function toMyTodo() {\n      this.$router.push(\"/v-flow/v-todo\");\n    }\n  },\n  created: function created() {\n    var _this6 = this;\n\n    //监听表单数据请求完成\n    var _this = this; //取发起节点的属性用于判断是否可以选择路径跳转\n\n\n    window.agentLeaderId = this.leaderId;\n    this.$store.dispatch(\"storeProcess/getCurNodeProperties\", {\n      defId: this.defId || \"\",\n      instId: this.instId || \"\",\n      taskId: \"\"\n    }).then(function (NodeDef) {\n      _this6.nodeDef = NodeDef;\n\n      if (NodeDef.nodeProperties && NodeDef.nodeProperties.length > 0 && NodeDef.nodeProperties[0].initFillData) {\n        _this.initFillData = NodeDef.nodeProperties[0].initFillData;\n\n        _this.$refs[\"formContent\"].setInitFillData(_this.initFillData);\n      }\n    }); //获取流程信息\n\n    req.get(window.context.bpmModel + \"/flow/def/v1/defGet?defId=\" + this.defId).then(function (res) {\n      _this6.defName = res.data.name;\n    });\n  }\n};",null]}