08335 / hivui-platform-template
hivui平台项目模板
Newer
Older
hivui-platform-template / 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: [],
      },

      testData: [
        {
          forderguid: "438862b5e0f54cdfa81994d283983d91",
          fwithdraw: false,
          flowstate: "tsProcessing",
          fusername: "张景茂",
          fbzid: "00274",
          ftaskurgentlevel: "一般",
          fcreatorid: "20355",
          fsummaryinfo:
            "20355/吴海文/AF.80 申请事假0.125天,从2026-01-27 14:13:00到2026-01-27 17:14:00止",
          fversion: "1.0.0",
          fmodelpath:
            "fdszh/BanGongGuanLi/QingJiaShenQing/flow/QingJiaShenQingXinZeng.flow",
          fisphone: 2,
          ftime: "2026-01-27 11:14:06",
          fcreatorname: "吴海文",
          fpdisplayname: "请假申请",
          fdisplayname: "直属上级审批",
          fordernumber: "QZHR-260127-1003",
          forderstate: 0,
          freadstate: 0,
          fuserid: "00274",
          ftaskname: "TaskUnit_nG5ifZUs",
          fcreatorbz: "20355",
          ftaskguid: "61633b650c8f428684d335ea168d954c",
          fstate: "tsTask",
          FGUID: "1ad3a3fc-d485-46b7-8aa1-934cb1408f1d",
          fbatch: true,
        },
        {
          forderguid: "3ee43c420ec0422280b4a75e02a1f281",
          fwithdraw: false,
          flowstate: "tsProcessing",
          fusername: "张景茂",
          fbzid: "00274",
          ftaskurgentlevel: "一般",
          fcreatorid: "20355",
          fsummaryinfo:
            "20355/吴海文/AF.80 申请事假0.125天,从2026-01-27 11:13:41到2026-01-27 12:13:00止",
          fversion: "1.0.0",
          fmodelpath:
            "fdszh/BanGongGuanLi/QingJiaShenQing/flow/QingJiaShenQingXinZeng.flow",
          fisphone: 2,
          ftime: "2026-01-27 11:13:47",
          fcreatorname: "吴海文",
          fpdisplayname: "请假申请",
          fdisplayname: "直属上级审批",
          fordernumber: "QZHR-260127-1002",
          forderstate: 0,
          freadstate: 0,
          fuserid: "00274",
          ftaskname: "TaskUnit_nG5ifZUs",
          fcreatorbz: "20355",
          ftaskguid: "5eea811916e84b6cb6451309d711857c",
          fstate: "tsTask",
          FGUID: "a86e5413-ae70-45d5-a8c5-eb3b7f70f757",
          fbatch: true,
        },
        {
          FDATE: "更早",
          FNOW: "2026-06-25T17:06:29.193+0000",
          FGUID: "16dc6ebb-497a-4508-a717-097634c96e76",
          FPARENTID: "16dc6ebb-497a-4508-a717-097634c96e76",
          FSTATE: "tsStarted",
          FGRADE: 3,
          FPROCURL: "/eap/cwgl/fygl/fyft/fyftd",
          FCREATETIME: "2026-03-26T04:00:43.130+0000",
          FFINISHTIME: null,
          FLIMITTIME: "2026-03-26T04:00:43.130+0000",
          FRECEIVETIME: "2026-03-26T04:00:43.130+0000",
          FOVERTIME: null,
          FSTARTTIME: "2026-03-26T04:00:43.130+0000",
          FKIND: "ftkActivity",
          FPROCUNITID: "ProcActivity17",
          FSOGNID: "",
          FSOGNNAME: "",
          FSDEPTID: "AJ.04.18.01",
          FSDEPTNAME: "AJ.04.18.01",
          FSPOSITIONID: "HQRY",
          FSPOSITIONNAME: "备货专员",
          FSPERSONID: "03870/苏娟",
          FSPERSONNAME: "苏娟",
          FPRIORITY: "tpNormal",
          FFUNCURL: null,
          FEXECUTEMODE: "emSimultaneous",
          FPREEMPTMODE: "omFirstOpen",
          FVALUE: 1,
          FAUTOTYPE: 0,
          FC1: null,
          FC2: null,
          FC3: null,
          FRECEIVEDEPTID: "AF",
          FRECEIVEDEPTNAME: "计算机部",
          FRECEIVEPERSONID: "00274",
          FRECEIVEPERSONNAME: "张景茂",
          FRECEIVEPOSITIONID: "GJJL",
          FRECEIVEPOSITIONNAME: "技术计算机",
          FRECEIVEURL:
            "ORG:\\ORGANIZE.OGNROOT\\FD.OGN\\AF.DPT\\GJJL.PTM\\00274.PSM",
          FEXECUTESTATE: "esUnknown",
          FRECEIVEORGID: "00274",
          FRECEIVEORGNAME: "张景茂",
          FDESCRIPTION: null,
          FADJUNCT: null,
          FFLOWGUID: "601f99f0-8bf7-431f-88c5-38a03fbd211f",
          FAUDITPOINT: null,
          FPROCNAME: "费用分摊单审批",
          FSENDERURL:
            "ORG:\\ORGANIZE.OGNROOT\\FD.OGN\\AJ.DPT\\AJ.04.DPT\\AJ.04.18.DPT\\AJ.04.18.01.DPT\\HQRY.PTM\\03870.PSM",
          FSENDERORGID: "03870",
          FSENDERORGNAME: "苏娟",
          FPREVGUID: "d1541459-d6a3-4423-9508-3da5e725bd4a",
          FNEXTGUID: "-1",
          FMOBILE: null,
          FSUBJECT: "费用分摊单审批:费用分摊单[FTFM-260326-1003]",
          FBIZKIND: null,
          FEXECUTEMODE2: null,
          FFGUID: "601f99f0-8bf7-431f-88c5-38a03fbd211f",
          FVERSION: "1.1",
          FFlowName: "费用分摊单",
          FDESCRIPTION2: "03870/苏娟/AJ.04.18.01费用报销¥1,100.00元",
          FKEYVALUE: "FTFM-260326-1003",
          RID: 42,
          FCOLLECTTIME: "26-03-26",
          furl: "http://smart.fdauto.com:2222/smart/eap/cwgl/fygl/fyft/fyftd.work?__TASKGUID=16dc6ebb-497a-4508-a717-097634c96e76&__PARENTGUID=16dc6ebb-497a-4508-a717-097634c96e76&__FLOWGUID=601f99f0-8bf7-431f-88c5-38a03fbd211f&__PROCUNITID=ProcActivity17&__workVersion=1.1&__type=需处理&__orgId=00274",
          ftaskguid: "16dc6ebb-497a-4508-a717-097634c96e76",
          fbatch: 1,
          fcreatorname: "苏娟",
          fsummaryinfo: "费用分摊单审批:费用分摊单[FTFM-260326-1003]",
          fusername: "苏娟",
          fuserid: "03870",
          ftime: "2026-03-26 12:00:43",
          fordernumber: "FTFM-260326-1003",
          fpdisplayname: "费用分摊单",
          fdisplayname: "费用分摊单审批",
        },
      ],
    };
  },
  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 === "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"
        );
      }

      // 等待窗口加载完成后发送数据
      const timer = setInterval(() => {
        if (this.batchWindow && !this.batchWindow.closed) {
          clearInterval(timer);
          this.sendDataToBatchWindow();
        }
      }, 100);
    },
    // 向批处理窗口发送数据
    sendDataToBatchWindow() {
      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.testData,
          token: getToken(),
        },
        "*"
      );
    },
  },
};
</script>

<style scoped>
.taskCenter {
  height: 100%;
}
</style>