import { ref as v, computed as A, h as x, defineComponent as V, reactive as Y, watch as C, onMounted as O, resolveComponent as f, openBlock as E, createElementBlock as D, unref as m, createVNode as n, withCtx as r, createElementVNode as F, createCommentVNode as Z, Fragment as j, renderList as G, createBlock as $, createTextVNode as b, toDisplayString as q } from "vue";
import { Card as z, InputSearch as H, Tree as J, Button as X, message as g } from "ant-design-vue";
import { useRouter as ee } from "vue-router";
import { g as p, o as te, a as ae, C as oe, D as ue, W as ne, d as k, b as re } from "./index.e7201430.js";
import { W as se, a as le, b as ie } from "./WorkflowBackModal.6c390a74.js";
import "sanzhi-form-design-vue3";
import "axios";
const P = v([]), M = v([]), y = v([]), T = A(() => y.value.map((u) => u.instanceId)), ce = A(() => y.value.map((u) => u.id));
function de() {
  return new Promise((o, u) => {
    p("apis").getCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((a) => {
      const { data: s } = a;
      P.value = s, s.length && M.value.push(s[0].id), o(a);
    }).catch((a) => {
      u(a);
    });
  });
}
function me() {
  return new Promise((o, u) => {
    o([{
      tabName: "\u5168\u90E8",
      tabParam: "",
      tabTitle: "\u5168\u90E8"
    }, {
      tabName: "\u5DF2\u5B8C\u7ED3",
      tabParam: "1",
      tabTitle: "\u5DF2\u5B8C\u7ED3"
    }, {
      tabName: "\u672A\u5B8C\u7ED3",
      tabParam: "0",
      tabTitle: "\u672A\u5B8C\u7ED3"
    }, {
      tabName: "\u5DF2\u7EC8\u6B62",
      tabParam: "2",
      tabTitle: "\u5168\u90E8\u72B6\u6001"
    }, {
      tabName: "\u5DF2\u5F52\u6863",
      tabParam: "3",
      tabTitle: "\u5DF2\u5F52\u6863"
    }]);
  });
}
function pe(o) {
  const { archiveStatus: u, instanceRunStatus: a, instanceStatus: s } = o;
  return u ? { color: "success", text: "\u5DF2\u5F52\u6863" } : a === "END" ? { color: "default", text: "\u5DF2\u7EC8\u6B62" } : s ? { color: "processing", text: "\u5DF2\u5B8C\u7ED3" } : { color: "warning", text: "\u672A\u5B8C\u7ED3" };
}
function fe(o = {}, u) {
  return {
    rowKey: "id",
    columns: [
      {
        title: "\u6807\u9898",
        dataIndex: "title",
        customRender: function({ record: l }) {
          const { flowId: i, instanceId: _, id: e, title: h } = l, w = { flowId: i, instanceId: _, taskId: e };
          return x("span", {
            class: "ant-btn-link pointer",
            onClick: function() {
              te({ params: w, router: u });
            }
          }, h);
        },
        width: 350
      },
      {
        title: "\u6D41\u7A0B",
        dataIndex: "flowName",
        width: 150,
        ellipsis: !0
      },
      {
        title: "\u5F53\u524D\u6B65\u9AA4",
        dataIndex: "stepName",
        width: 100,
        ellipsis: !0
      },
      {
        title: "\u5904\u7406\u4EBA",
        dataIndex: "receiverName",
        width: 100,
        ellipsis: !0
      },
      {
        title: "\u53D1\u8D77\u65E5\u671F",
        dataIndex: "receiveTime",
        width: 190
      },
      {
        title: "\u6D41\u7A0B\u72B6\u6001",
        dataIndex: "instanceStatus",
        customRender: function({ record: l }) {
          const i = pe(l);
          return x(se, {
            color: i.color,
            value: i.text
          });
        },
        width: 100
      },
      {
        title: "\u64CD\u4F5C",
        dataIndex: "actions",
        width: 60,
        fixed: "right",
        buttons: [
          {
            title: "\u6D41\u7A0B\u8F68\u8FF9",
            icon: "fund-outlined",
            props: {
              type: "primary"
            },
            key: "record",
            onClick: function(l) {
              o.modal.openModal({ data: l });
            }
          }
        ]
      }
    ],
    rowSelection: {
      onChange: (l, i) => {
        y.value = i;
      },
      selectedRowKeys: ce
    }
  };
}
function N(o = {}) {
  const u = o.tableQuery && o.tableQuery.categoryId, a = o.locationQuery || {};
  return {
    formProps: {
      layout: "inline",
      columns: [{
        field: "title",
        label: "\u6807\u9898"
      }, {
        field: "sender",
        label: "\u53D1\u8D77\u4EBA"
      }, {
        field: "timeRange",
        label: "\u65F6\u95F4",
        colAttr: {
          span: 6
        },
        timeRangeFieldNames: {
          startTime: "completedStartTime",
          endTime: "completedEndTime"
        },
        component: "a-range-picker",
        componentProps: {
          style: {
            width: "100%"
          },
          valueFormat: "YYYY-MM-DD"
        }
      }, {
        field: "categoryId",
        label: "\u5DE5\u4F5C\u6D41\u7A0B",
        hide: !a.noTree,
        defaultValue: u || "",
        component: "a-tree-select",
        componentProps: {
          "tree-data": P,
          "field-names": {
            children: "children",
            value: "id",
            label: "name"
          },
          treeDefaultExpandAll: !0
        }
      }]
    }
  };
}
const ye = { class: "workflow-manage" }, be = {
  key: 0,
  class: "left"
}, Ee = { class: "input-box" }, ge = { class: "tree-box" }, _e = { class: "right" }, he = /* @__PURE__ */ b(" \u5BFC\u51FA "), we = /* @__PURE__ */ b("\u4E00\u952E\u50AC\u529E"), Be = /* @__PURE__ */ b("\u4E00\u952E\u50AC\u529E\u4E0B\u4E00\u6B65"), Ce = /* @__PURE__ */ b(" \u50AC\u529E "), De = /* @__PURE__ */ V({
  __name: "SanZhiWorkflowMine",
  setup(o) {
    const u = ee(), a = {};
    function s(t) {
      a.table = t;
    }
    function l(t) {
      a.modal = t;
    }
    function i(t) {
      a.workflowForm = t;
    }
    function _(t) {
      a.backModal = t;
    }
    const e = Y({
      locationQuery: ae(),
      keyword: "",
      treeData: P,
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: M,
      formProps: N(),
      tableProps: fe(a, u),
      tabsList: [],
      tableQuery: {
        status: ""
      },
      tableData: {},
      loading: !1,
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: ""
    }), h = A(() => !e.locationQuery.noTree);
    C(
      () => e.selectedKeys,
      (t, c) => {
        const B = t[0] || "";
        e.tableQuery.categoryId = B, a.table.reload();
      },
      { deep: !0 }
    ), C(
      () => e.tableQuery.categoryId,
      () => {
        y.value = [];
      }
    ), C(
      () => e.tableQuery.status,
      () => {
        y.value = [];
      }
    );
    function w() {
      return p("apis").getWorkflowTaskInstanceLaunchPageList;
    }
    function R() {
      const t = a.table.getParams();
      e.loading = !0, p("apis").getWorkflowTaskInstanceLaunchExportExcel({ ...t }).then((c) => {
      }).finally(() => {
        e.loading = !1;
      });
    }
    async function W() {
      const t = T.value.length;
      if (!t) {
        g.info("\u8BF7\u9009\u62E9\u81F3\u5C11\u4E00\u6761\u6570\u636E");
        return;
      }
      try {
        await k({
          content: `\u786E\u8BA4\u50AC\u529E\u9009\u4E2D\u7684\u6D41\u7A0B\u4E48\uFF0C\u5171\u9009\u4E2D${t}\u6761`
        });
      } catch {
        return;
      }
      p("apis").remindMyLaunchByInstanceList({ body: T.value }).then(() => {
        g.success("\u50AC\u529E\u6210\u529F");
      });
    }
    async function L({ key: t }) {
      if (t === "1") {
        try {
          await k({
            content: "\u786E\u8BA4\u4E00\u952E\u50AC\u529E\u4E48"
          });
        } catch {
          return;
        }
        p("apis").remindMyLaunchByInstanceList({ body: null }).then(() => {
          g.success("\u4E00\u952E\u50AC\u529E\u6210\u529F");
        });
        return;
      }
      try {
        await k({
          content: "\u786E\u8BA4\u4E00\u952E\u50AC\u529E\u4E0B\u4E00\u6B65\u4E48"
        });
      } catch {
        return;
      }
      p("apis").remindMyLaunchWaitByInstanceList({ body: null }).then(() => {
        g.success("\u4E00\u952E\u50AC\u529E\u4E0B\u4E00\u6B65\u6210\u529F");
      });
    }
    return O(() => {
      me().then((t) => {
        e.tabsList = t;
      }), de().then(() => {
        e.formProps = N(e);
      });
    }), (t, c) => {
      const B = f("a-radio-button"), Q = f("a-radio-group"), I = f("a-menu-item"), S = f("a-menu"), K = f("a-dropdown-button");
      return E(), D("div", ye, [
        m(h) ? (E(), D("div", be, [
          n(m(z), null, {
            default: r(() => [
              F("div", Ee, [
                n(m(H), {
                  value: e.keyword,
                  "onUpdate:value": c[0] || (c[0] = (d) => e.keyword = d),
                  placeholder: "\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9"
                }, null, 8, ["value"])
              ]),
              F("div", ge, [
                n(m(J), {
                  "tree-data": e.treeData,
                  selectedKeys: e.selectedKeys,
                  "onUpdate:selectedKeys": c[1] || (c[1] = (d) => e.selectedKeys = d),
                  fieldNames: e.fieldNames
                }, null, 8, ["tree-data", "selectedKeys", "fieldNames"])
              ])
            ]),
            _: 1
          })
        ])) : Z("", !0),
        F("div", _e, [
          n(m(oe), {
            api: w(),
            autoGet: !1,
            extraParams: e.tableQuery,
            tableProps: e.tableProps,
            formProps: e.formProps,
            onRegister: s
          }, {
            middle: r(() => [
              n(Q, {
                value: e.tableQuery.status,
                "onUpdate:value": c[2] || (c[2] = (d) => e.tableQuery.status = d),
                onChange: a.table.reload
              }, {
                default: r(() => [
                  (E(!0), D(j, null, G(e.tabsList, (d, U) => (E(), $(B, {
                    value: d.tabParam,
                    key: U
                  }, {
                    default: r(() => [
                      b(q(d.tabName), 1)
                    ]),
                    _: 2
                  }, 1032, ["value"]))), 128))
                ]),
                _: 1
              }, 8, ["value", "onChange"])
            ]),
            formRight: r(() => [
              n(m(X), {
                type: "primary",
                onClick: R,
                loading: e.loading
              }, {
                default: r(() => [
                  he
                ]),
                _: 1
              }, 8, ["loading"]),
              n(K, {
                type: "danger",
                onClick: W
              }, {
                overlay: r(() => [
                  n(S, { onClick: L }, {
                    default: r(() => [
                      n(I, { key: "1" }, {
                        default: r(() => [
                          we
                        ]),
                        _: 1
                      }),
                      n(I, { key: "2" }, {
                        default: r(() => [
                          Be
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                icon: r(() => [
                  n(m(ue))
                ]),
                default: r(() => [
                  Ce
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["api", "extraParams", "tableProps", "formProps"])
        ]),
        n(le, { onRegister: l }),
        n(ie, { onRegister: _ }),
        n(ne, { onRegister: i })
      ]);
    };
  }
});
const Te = /* @__PURE__ */ re(De, [["__scopeId", "data-v-4c975686"]]);
export {
  Te as default
};
