GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
@中文描述:优化批量处理完成后的任务刷新逻辑
@升级登记:1 @同步后端:0 @同步数据库:0 @同步配置:0 @向下兼容:1
master
1 parent
ca3544d
commit
7b3c2cdb54bb0e3a1e035232ca220b72e554a525
ganyi
authored
20 days ago
Showing
1 changed file
project/hivuiMain/views/taskCenter.vue
Ignore Space
Show notes
View
project/hivuiMain/views/taskCenter.vue
<template> <div class="taskCenter"> <template v-if="batchIframeUrl"> <hi-taskcenter ref="hiTask" @openfunc="openfunc" @openmonitor="openmonitorFn" :batchProcessFn="batchProcessFn" :batchProcessFunc="batchProcessFuncFn" :syncBatch="syncBatch" style=" background-color: #fff; padding-top: 10px; box-sizing: border-box; " > </hi-taskcenter> </template> <template v-else> <hi-taskcenter ref="hiTask" @openfunc="openfunc" @openmonitor="openmonitorFn" :batchProcessFunc="batchProcessFuncFn" :syncBatch="syncBatch" style=" background-color: #fff; padding-top: 10px; box-sizing: border-box; " > </hi-taskcenter> </template> </div> </template> <script> import "hi-taskcenter/hi-taskcenter.css"; import HiTaskcenter from "hi-taskcenter"; import { getToken } from "@main/utils/auth"; export default { components: { HiTaskcenter, }, data() { return { // 同步请求批处理 syncBatch: HIVUI_SETTING.syncBatch, // 保存打开的批处理窗口对象 batchWindow: null, batchTitle: "", batchIframeUrl: "", // 缓存批处理参数 batchParams: { method: "", batchData: [], }, }; }, computed: { batchTitleDialog() { return "任务批处理" + this.batchTitle; }, }, mounted() { let me = this; let electron = top.window.electron; if (top.window.customSysCofig.batchIframeUrl && electron) { me.batchIframeUrl = top.window.customSysCofig.batchIframeUrl; } document.addEventListener("iframeActiving", function (e) { //console.log(e.detail); if (top.window.__refreshTaskcenter) { top.window.__refreshTaskcenter = false; me.$refs.hiTask.taskschemeItemClick({ value: "untreated", label: me.$t("hivuiMain_taskcenter_untreated"), sel: true, }); } }); window.addEventListener("message", this.handleIframeMsg); }, beforeDestroy() { window.removeEventListener("message", this.handleIframeMsg); // 销毁时关闭批处理窗口 if (this.batchWindow && !this.batchWindow.closed) { this.batchWindow.close(); } }, methods: { openfunc(__data1, __data2, __data3) { if (__data2.furl) { if ( top.window.customSysCofig.taskcenterCustomeropen && typeof top.window.customSysCofig.taskcenterCustomeropen == "function" ) { top.window.customSysCofig.taskcenterCustomeropen.call(this, __data2); } else { top.window.open(__data2.furl); } } else { top.window.SysPage.newPage( __data2.fpdisplayname, location.origin + (window._global ? "" : window.HIVUI_SETTING.serverName) + "/" + __data2.fmodelpath, { fmodelpath: __data2.fmodelpath, version: __data2.fversion, ftaskguid: __data2.ftaskguid, flowstate: __data2.flowstate, forderguid: __data2.forderguid, fnumber: __data2.fordernumber, fbzid: __data2.fbzid, pn: window.HIVUI_SETTING.projectName, } ); } }, openmonitorFn(_this, __data2) { //流程监控 if (__data2 && __data2.furl) { if ( top.window.customSysCofig.taskcenterCustomeropenmonitor && typeof top.window.customSysCofig.taskcenterCustomeropenmonitor == "function" ) { top.window.customSysCofig.taskcenterCustomeropenmonitor.call( this, _this, __data2 ); } } }, // 批处理 batchProcessFuncFn(config) { if (config.row && config.row.furl) { if ( top.window.customSysCofig.taskcenterbatchProcess && typeof top.window.customSysCofig.taskcenterbatchProcess == "function" ) { return top.window.customSysCofig.taskcenterbatchProcess.call( this, this.$refs.hiTask, config ); } } else { return this.$refs.hiTask.processFlow(config); } }, // 接收子页面回调 handleIframeMsg(e) { console.log("接收子页面回调", e); const data = e.data; // 子页面加载完成就绪,发送批量数据 if (data.type === "childReady") { this.sendDataToBatchWindow(); return; } const hiTask = this.$refs.hiTask; if (data.type === "batchFinish" && hiTask) { // 刷新任务列表 hiTask.taskschemeItemClick({ value: "untreated", label: this.$t("hivuiMain_taskcenter_untreated"), sel: true, }); this.clearAllSelect(); } }, clearAllSelect() { const hiTask = this.$refs.hiTask; if (hiTask) { hiTask.setCheckAll(false); } }, // 批处理入口:window.open打开新窗口 batchProcessFn(method, batchData) { console.log("打开新窗口", method, batchData); // this.clearAllSelect(); this.batchTitle = method == "flowOut" ? "(流转)" : "(回退)"; this.batchParams = { method, batchData, }; // 如果已有窗口且未关闭,聚焦窗口;否则打开新窗口 if (this.batchWindow && !this.batchWindow.closed) { this.batchWindow.focus(); } else { // 打开批处理页面 this.batchWindow = window.open( this.batchIframeUrl, "taskBatchProcess", "width=900,height=600,scrollbars=yes" ); } }, // 向批处理窗口发送数据 sendDataToBatchWindow() { console.log("向批处理窗口发送数据"); if (!this.batchWindow || this.batchWindow.closed) return; this.batchWindow.postMessage( { type: "refreshTable", serverUrl: window.HIVUI_SETTING.serverUrl, pn: window.HIVUI_SETTING.projectName, method: this.batchParams.method, list: this.batchParams.batchData, token: getToken(), }, "*" ); }, }, }; </script> <style scoped> .taskCenter { height: 100%; } </style>
<template> <div class="taskCenter"> <template v-if="batchIframeUrl"> <hi-taskcenter ref="hiTask" @openfunc="openfunc" @openmonitor="openmonitorFn" :batchProcessFn="batchProcessFn" :batchProcessFunc="batchProcessFuncFn" :syncBatch="syncBatch" style=" background-color: #fff; padding-top: 10px; box-sizing: border-box; " > </hi-taskcenter> </template> <template v-else> <hi-taskcenter ref="hiTask" @openfunc="openfunc" @openmonitor="openmonitorFn" :batchProcessFunc="batchProcessFuncFn" :syncBatch="syncBatch" style=" background-color: #fff; padding-top: 10px; box-sizing: border-box; " > </hi-taskcenter> </template> </div> </template> <script> import "hi-taskcenter/hi-taskcenter.css"; import HiTaskcenter from "hi-taskcenter"; import { getToken } from "@main/utils/auth"; export default { components: { HiTaskcenter, }, data() { return { // 同步请求批处理 syncBatch: HIVUI_SETTING.syncBatch, // 保存打开的批处理窗口对象 batchWindow: null, batchTitle: "", batchIframeUrl: "", // 缓存批处理参数 batchParams: { method: "", batchData: [], }, }; }, computed: { batchTitleDialog() { return "任务批处理" + this.batchTitle; }, }, mounted() { let me = this; let electron = top.window.electron; if (top.window.customSysCofig.batchIframeUrl && electron) { me.batchIframeUrl = top.window.customSysCofig.batchIframeUrl; } document.addEventListener("iframeActiving", function (e) { //console.log(e.detail); if (top.window.__refreshTaskcenter) { top.window.__refreshTaskcenter = false; me.$refs.hiTask.taskschemeItemClick({ value: "untreated", label: me.$t("hivuiMain_taskcenter_untreated"), sel: true, }); } }); window.addEventListener("message", this.handleIframeMsg); }, beforeDestroy() { window.removeEventListener("message", this.handleIframeMsg); // 销毁时关闭批处理窗口 if (this.batchWindow && !this.batchWindow.closed) { this.batchWindow.close(); } }, methods: { openfunc(__data1, __data2, __data3) { if (__data2.furl) { if ( top.window.customSysCofig.taskcenterCustomeropen && typeof top.window.customSysCofig.taskcenterCustomeropen == "function" ) { top.window.customSysCofig.taskcenterCustomeropen.call(this, __data2); } else { top.window.open(__data2.furl); } } else { top.window.SysPage.newPage( __data2.fpdisplayname, location.origin + (window._global ? "" : window.HIVUI_SETTING.serverName) + "/" + __data2.fmodelpath, { fmodelpath: __data2.fmodelpath, version: __data2.fversion, ftaskguid: __data2.ftaskguid, flowstate: __data2.flowstate, forderguid: __data2.forderguid, fnumber: __data2.fordernumber, fbzid: __data2.fbzid, pn: window.HIVUI_SETTING.projectName, } ); } }, openmonitorFn(_this, __data2) { //流程监控 if (__data2 && __data2.furl) { if ( top.window.customSysCofig.taskcenterCustomeropenmonitor && typeof top.window.customSysCofig.taskcenterCustomeropenmonitor == "function" ) { top.window.customSysCofig.taskcenterCustomeropenmonitor.call( this, _this, __data2 ); } } }, // 批处理 batchProcessFuncFn(config) { if (config.row && config.row.furl) { if ( top.window.customSysCofig.taskcenterbatchProcess && typeof top.window.customSysCofig.taskcenterbatchProcess == "function" ) { return top.window.customSysCofig.taskcenterbatchProcess.call( this, this.$refs.hiTask, config ); } } else { return this.$refs.hiTask.processFlow(config); } }, // 接收子页面回调 handleIframeMsg(e) { console.log("接收子页面回调", e); const data = e.data; // 子页面加载完成就绪,发送批量数据 if (data.type === "childReady") { this.sendDataToBatchWindow(); return; } if (data.type === "batchFinish") { // 刷新任务列表 this.$refs.hiTask.taskschemeItemClick({ value: "untreated", label: this.$t("hivuiMain_taskcenter_untreated"), sel: true, }); } }, // 批处理入口:window.open打开新窗口 batchProcessFn(method, batchData) { console.log(method, batchData); this.batchTitle = method == "flowOut" ? "(流转)" : "(回退)"; this.batchParams = { method, batchData, }; // 如果已有窗口且未关闭,聚焦窗口;否则打开新窗口 if (this.batchWindow && !this.batchWindow.closed) { this.batchWindow.focus(); } else { // 打开批处理页面 this.batchWindow = window.open( this.batchIframeUrl, "taskBatchProcess", "width=900,height=600,scrollbars=yes" ); } }, // 向批处理窗口发送数据 sendDataToBatchWindow() { console.log("向批处理窗口发送数据"); if (!this.batchWindow || this.batchWindow.closed) return; this.batchWindow.postMessage( { type: "refreshTable", serverUrl: window.HIVUI_SETTING.serverUrl, pn: window.HIVUI_SETTING.projectName, method: this.batchParams.method, list: this.batchParams.batchData, token: getToken(), }, "*" ); }, }, }; </script> <style scoped> .taskCenter { height: 100%; } </style>
Show line notes below