import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                      */
/* empty css                                                                     */
/* empty css                                                                        */
/* empty css                                                                       */
/* empty css                                                                            */
/* empty css                                                                     */
import { ref, watch, nextTick, resolveComponent, createElementBlock, openBlock, createVNode, withCtx, Fragment, renderList, unref, createBlock, createElementVNode, createCommentVNode, toDisplayString, createTextVNode, isRef } from "vue";
import api from "./api/index.mjs";
import { getCurrentVueInstance } from "../../../utils/getInstance.mjs";
import ApproveIdea from "./ApproveIdea.vue.mjs";
/* empty css               */
import { ElScrollbar } from "../../../../../../node_modules/element-plus/es/components/scrollbar/index.mjs";
import { ElTimeline, ElTimelineItem } from "../../../../../../node_modules/element-plus/es/components/timeline/index.mjs";
import { ElButton } from "../../../../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElDrawer } from "../../../../../../node_modules/element-plus/es/components/drawer/index.mjs";
const _hoisted_1 = { class: "header" };
const _hoisted_2 = { class: "app nodeName" };
const _hoisted_3 = { class: "createTime" };
const _hoisted_4 = {
  key: 0,
  class: "appContent"
};
const _hoisted_5 = { class: "openTask" };
const _hoisted_6 = { style: { "font-weight": "bold" } };
const _hoisted_7 = {
  key: 0,
  class: "appAssignee"
};
const _hoisted_8 = {
  key: 1,
  class: "apping"
};
const _hoisted_9 = {
  key: 2,
  class: "apping"
};
const _hoisted_10 = { class: "duration" };
const _hoisted_11 = {
  key: 1,
  class: "appContent"
};
const _hoisted_12 = { class: "openTask sign" };
const _hoisted_13 = { style: { "font-weight": "bold" } };
const _hoisted_14 = { class: "appAssignee" };
const _hoisted_15 = { key: 0 };
const _hoisted_16 = {
  key: 1,
  style: { "color": "#999" }
};
const _hoisted_17 = { class: "duration" };
const _hoisted_18 = { class: "header" };
const _hoisted_19 = { class: "nodeName" };
const _hoisted_20 = { class: "createTime" };
const _hoisted_21 = {
  key: 0,
  class: "content"
};
const _hoisted_22 = { class: "app-header" };
const _hoisted_23 = { class: "approveType" };
const _hoisted_24 = { class: "duration" };
const _hoisted_25 = { class: "app-footer" };
const _hoisted_26 = { class: "endTime" };
const _hoisted_27 = {
  key: 0,
  class: "assignee"
};
const _hoisted_28 = { class: "assignee-name" };
const _hoisted_29 = {
  key: 1,
  class: "assignee"
};
const _hoisted_30 = {
  key: 1,
  class: "signContent"
};
const _hoisted_31 = { class: "content" };
const _hoisted_32 = { class: "app-header" };
const _hoisted_33 = { class: "approveType" };
const _hoisted_34 = { class: "duration" };
const _hoisted_35 = { class: "app-footer" };
const _hoisted_36 = { class: "endTime" };
const _hoisted_37 = { class: "assignee" };
const _hoisted_38 = { class: "assignee-name" };
const _hoisted_39 = {
  key: 1,
  class: "content"
};
const _sfc_main = /* @__PURE__ */ Object.assign({
  name: "FecTimeLine"
}, {
  __name: "timeLine",
  props: {
    traceNo: {
      type: String,
      default: ""
    },
    type: {
      //主子流程类型
      type: String,
      default: "app"
    },
    taskDefinitionKey: {
      type: String,
      default: ""
    }
  },
  emits: ["loaded"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const flowTimelineRef = ref();
    const ctx = getCurrentVueInstance();
    const emit = __emit;
    const hisTaskList = ref([]);
    const taskList = ref([]);
    watch(
      () => props.traceNo,
      (traceNo) => {
        if (traceNo) {
          api.findTimeLineByTraceNo(
            ctx.$http,
            traceNo,
            props.type,
            props.taskDefinitionKey
          ).then((data) => {
            if (data) {
              hisTaskList.value = data.hisTask;
              taskList.value = data.task;
              nextTick(() => {
                emit("loaded", flowTimelineRef.value);
              });
            }
          });
        }
      },
      {
        immediate: true
      }
    );
    function getAssigneeName(assignee) {
      let assigneeName = "";
      for (let i in assignee) {
        assigneeName += assignee[i].opName;
        if (i < assignee.length - 1) {
          assigneeName += ",";
        }
      }
      return assigneeName;
    }
    function isBackToBack(assigneeList) {
      var _a;
      const assignee = assigneeList[0];
      if (assignee.opNo == ((_a = ctx.$store) == null ? void 0 : _a.getters.user.opNo)) {
        return true;
      } else {
        return false;
      }
    }
    const timeLineShow = ref(false);
    const childProcessInstanceId = ref();
    const childTaskDefinitionKey = ref();
    function queryChildProcess(item) {
      childProcessInstanceId.value = item.processInstanceId;
      childTaskDefinitionKey.value = item.taskDefinitionKey;
      timeLineShow.value = true;
    }
    function closeChildTimeLine() {
      timeLineShow.value = false;
    }
    __expose({
      closeChildTimeLine
    });
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_timeline_item = ElTimelineItem;
      const _component_el_timeline = ElTimeline;
      const _component_el_scrollbar = ElScrollbar;
      const _component_FecTimeLine = resolveComponent("FecTimeLine");
      const _component_el_drawer = ElDrawer;
      return openBlock(), createElementBlock("div", {
        class: "flowTimeline",
        ref_key: "flowTimelineRef",
        ref: flowTimelineRef
      }, [
        createVNode(_component_el_scrollbar, null, {
          default: withCtx(() => [
            createVNode(_component_el_timeline, null, {
              default: withCtx(() => [
                (openBlock(true), createElementBlock(Fragment, null, renderList(unref(taskList), (node) => {
                  return openBlock(), createBlock(_component_el_timeline_item, {
                    "hide-timestamp": true,
                    color: "var(--el-color-primary)",
                    size: "large"
                  }, {
                    default: withCtx(() => [
                      createElementVNode("div", _hoisted_1, [
                        createElementVNode("span", _hoisted_2, toDisplayString(node.name), 1),
                        createElementVNode("span", _hoisted_3, toDisplayString(node.createTime), 1)
                      ]),
                      node.taskType == "task" || node.taskType == "callActivity" || node.taskType == "bizTask" ? (openBlock(), createElementBlock("div", _hoisted_4, [
                        createElementVNode("div", _hoisted_5, [
                          createElementVNode("span", _hoisted_6, [
                            node.assignee ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(getAssigneeName(node.assignee)), 1)) : createCommentVNode("", true),
                            node.taskType == "bizTask" || node.taskType == "callActivity" ? (openBlock(), createElementBlock("span", _hoisted_8, " 办理中... ")) : (openBlock(), createElementBlock("span", _hoisted_9, " 审批中... "))
                          ]),
                          createElementVNode("span", _hoisted_10, "已送达：" + toDisplayString(node.duration), 1),
                          node.taskType == "callActivity" ? (openBlock(), createBlock(_component_el_button, {
                            key: 0,
                            type: "primary",
                            link: "",
                            class: "queryChildProcBtn",
                            onClick: ($event) => queryChildProcess(node)
                          }, {
                            default: withCtx(() => _cache[1] || (_cache[1] = [
                              createTextVNode("查看详情 ")
                            ])),
                            _: 2
                          }, 1032, ["onClick"])) : createCommentVNode("", true)
                        ])
                      ])) : createCommentVNode("", true),
                      node.taskType == "signTask" ? (openBlock(), createElementBlock("div", _hoisted_11, [
                        (openBlock(true), createElementBlock(Fragment, null, renderList(node.signTaskList, (sign) => {
                          return openBlock(), createElementBlock("div", _hoisted_12, [
                            createElementVNode("span", _hoisted_13, [
                              createElementVNode("span", _hoisted_14, [
                                isBackToBack(sign.assignee) ? (openBlock(), createElementBlock("span", _hoisted_15, toDisplayString(getAssigneeName(sign.assignee)), 1)) : (openBlock(), createElementBlock("span", _hoisted_16, "其他处理人"))
                              ]),
                              _cache[2] || (_cache[2] = createElementVNode("span", { class: "apping" }, " 审批中... ", -1))
                            ]),
                            createElementVNode("span", _hoisted_17, "已送达：" + toDisplayString(sign.duration), 1)
                          ]);
                        }), 256))
                      ])) : createCommentVNode("", true)
                    ]),
                    _: 2
                  }, 1024);
                }), 256)),
                (openBlock(true), createElementBlock(Fragment, null, renderList(unref(hisTaskList), (node) => {
                  return openBlock(), createBlock(_component_el_timeline_item, { "hide-timestamp": true }, {
                    default: withCtx(() => [
                      createElementVNode("div", _hoisted_18, [
                        createElementVNode("span", _hoisted_19, toDisplayString(node.name), 1),
                        createElementVNode("span", _hoisted_20, toDisplayString(node.createTime), 1)
                      ]),
                      node.taskType == "task" || node.taskType == "callActivity" ? (openBlock(), createElementBlock("div", _hoisted_21, [
                        createElementVNode("div", _hoisted_22, [
                          createElementVNode("span", _hoisted_23, toDisplayString(node.approveName || "办理完成"), 1),
                          createElementVNode("span", _hoisted_24, "耗时：" + toDisplayString(node.duration), 1)
                        ]),
                        createVNode(ApproveIdea, {
                          approveDesc: node.approveDesc
                        }, null, 8, ["approveDesc"]),
                        createElementVNode("div", _hoisted_25, [
                          createElementVNode("span", _hoisted_26, [
                            _cache[3] || (_cache[3] = createElementVNode("i", { class: "el-icon-time" }, null, -1)),
                            createTextVNode(toDisplayString(node.endTime), 1)
                          ]),
                          node.taskType == "task" ? (openBlock(), createElementBlock("span", _hoisted_27, [
                            _cache[4] || (_cache[4] = createTextVNode("处理人：")),
                            createElementVNode("span", _hoisted_28, toDisplayString(node.assigneeName), 1)
                          ])) : createCommentVNode("", true),
                          node.taskType == "callActivity" ? (openBlock(), createElementBlock("span", _hoisted_29, [
                            createVNode(_component_el_button, {
                              type: "primary",
                              link: "",
                              style: { "height": "25px" },
                              onClick: ($event) => queryChildProcess(node)
                            }, {
                              default: withCtx(() => _cache[5] || (_cache[5] = [
                                createTextVNode("查看详情")
                              ])),
                              _: 2
                            }, 1032, ["onClick"])
                          ])) : createCommentVNode("", true),
                          _cache[6] || (_cache[6] = createElementVNode("div", { class: "addNodeList" }, null, -1))
                        ])
                      ])) : createCommentVNode("", true),
                      node.taskType == "signTask" ? (openBlock(), createElementBlock("div", _hoisted_30, [
                        node.signTaskList && node.signTaskList.length > 0 ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(node.signTaskList, (sign) => {
                          return openBlock(), createElementBlock("div", _hoisted_31, [
                            createElementVNode("div", _hoisted_32, [
                              createElementVNode("span", _hoisted_33, toDisplayString(sign.approveName || "办理完成"), 1),
                              createElementVNode("span", _hoisted_34, "耗时：" + toDisplayString(sign.duration), 1)
                            ]),
                            createVNode(ApproveIdea, {
                              approveDesc: sign.approveDesc
                            }, null, 8, ["approveDesc"]),
                            createElementVNode("div", _hoisted_35, [
                              createElementVNode("span", _hoisted_36, [
                                _cache[7] || (_cache[7] = createElementVNode("i", { class: "el-icon-time" }, null, -1)),
                                createTextVNode(toDisplayString(sign.endTime), 1)
                              ]),
                              createElementVNode("span", _hoisted_37, [
                                _cache[8] || (_cache[8] = createTextVNode("处理人：")),
                                createElementVNode("span", _hoisted_38, toDisplayString(sign.assigneeName), 1)
                              ]),
                              _cache[9] || (_cache[9] = createElementVNode("div", { class: "addNodeList" }, null, -1))
                            ])
                          ]);
                        }), 256)) : (openBlock(), createElementBlock("div", _hoisted_39, _cache[10] || (_cache[10] = [
                          createElementVNode("div", { class: "approve" }, [
                            createElementVNode("span", { class: "point" }),
                            createElementVNode("span", { class: "iconfont icon-flow-default approveIcon approve_color_11" }),
                            createElementVNode("span", { class: "approveName approve_color_11" }, "没有查看权限")
                          ], -1)
                        ])))
                      ])) : createCommentVNode("", true)
                    ]),
                    _: 2
                  }, 1024);
                }), 256))
              ]),
              _: 1
            })
          ]),
          _: 1
        }),
        createVNode(_component_el_drawer, {
          modelValue: unref(timeLineShow),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(timeLineShow) ? timeLineShow.value = $event : null),
          direction: "rtl",
          "custom-class": "childTimelineDrawer",
          "modal-class": "childTimelineDrawerModal",
          "with-header": false
        }, {
          default: withCtx(() => [
            createVNode(_component_FecTimeLine, {
              processInstanceId: unref(childProcessInstanceId),
              taskDefinitionKey: unref(childTaskDefinitionKey)
            }, null, 8, ["processInstanceId", "taskDefinitionKey"])
          ]),
          _: 1
        }, 8, ["modelValue"])
      ], 512);
    };
  }
});
export {
  _sfc_main as default
};
