import { ref as v, computed as A, h as I, defineComponent as Y, reactive as O, watch as C, onMounted as Z, resolveComponent as f, openBlock as E, createElementBlock as D, createVNode as o, unref as m, withCtx as r, createElementVNode as F, createCommentVNode as j, Fragment as z, renderList as G, createBlock as $, createTextVNode as y, toDisplayString as q } from "vue";
import { Card as T, InputSearch as H, Tree as J, Button as X, message as g } from "ant-design-vue";
import { useRouter as ee } from "vue-router";
import { C as te } from "./index.18983179.js";
import { d as p, n as ae, W as oe, h as ue, D as ne, p as re, k, _ as le } from "./index.14fbe0a4.js";
import { W as se } from "./WorkflowBackModal.d7a7566a.js";
import { W as ie } from "./WorkflowFormRenderDrawer.92087c3d.js";
import "axios";
import "./SanZhiFormRenderOA.6d13345d.js";
const P = v([]), W = v([]), b = v([]), N = A(() => b.value.map((n) => n.instanceId)), ce = A(() => b.value.map((n) => n.id));
function de() {
  return new Promise((u, n) => {
    p("apis").getWorkflowCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((a) => {
      const { data: l } = a;
      P.value = l, l.length && W.value.push(l[0].id), u(a);
    }).catch((a) => {
      n(a);
    });
  });
}
function me() {
  return new Promise((u, n) => {
    u([{
      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(u) {
  const { archiveStatus: n, instanceRunStatus: a, instanceStatus: l } = u;
  return n ? { color: "success", text: "\u5DF2\u5F52\u6863" } : a === "END" ? { color: "default", text: "\u5DF2\u7EC8\u6B62" } : l ? { color: "processing", text: "\u5DF2\u5B8C\u7ED3" } : { color: "warning", text: "\u672A\u5B8C\u7ED3" };
}
function fe(u = {}, n) {
  return {
    rowKey: "id",
    columns: [
      {
        title: "\u6807\u9898",
        dataIndex: "title",
        customRender: function({ record: s }) {
          const { flowId: i, instanceId: _, id: e, title: h } = s, w = { flowId: i, instanceId: _, taskId: e };
          return I("span", {
            class: "ant-btn-link pointer",
            onClick: function() {
              ae({ params: w, router: n });
            }
          }, 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: s }) {
          const i = pe(s);
          return I(oe, {
            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(s) {
              u.modal.openModal({ data: s });
            }
          }
        ]
      }
    ],
    rowSelection: {
      onChange: (s, i) => {
        b.value = i;
      },
      selectedRowKeys: ce
    }
  };
}
function M(u = {}) {
  const n = u.tableQuery && u.tableQuery.categoryId, a = u.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: n || "",
        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__ */ Y({
  __name: "SanZhiWorkflowMine",
  setup(u) {
    const n = ee(), a = {};
    function l(t) {
      a.table = t;
    }
    function s(t) {
      a.modal = t;
    }
    function i(t) {
      a.workflowForm = t;
    }
    function _(t) {
      a.backModal = t;
    }
    const e = O({
      locationQuery: ue(),
      keyword: "",
      treeData: P,
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: W,
      formProps: M(),
      tableProps: fe(a, n),
      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,
      () => {
        b.value = [];
      }
    ), C(
      () => e.tableQuery.status,
      () => {
        b.value = [];
      }
    );
    function w() {
      return p("apis").getWorkflowTaskInstanceLaunchPageList;
    }
    function R() {
      const t = a.table.getParams();
      e.loading = !0, p("apis.export").getWorkflowTaskInstanceLaunchExportExcel({ ...t }).then((c) => {
      }).finally(() => {
        e.loading = !1;
      });
    }
    async function L() {
      const t = N.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: N.value }).then(() => {
        g.success("\u50AC\u529E\u6210\u529F");
      });
    }
    async function Q({ 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 Z(() => {
      me().then((t) => {
        e.tabsList = t;
      }), de().then(() => {
        e.formProps = M(e);
      });
    }), (t, c) => {
      const B = f("a-radio-button"), S = f("a-radio-group"), x = f("a-menu-item"), K = f("a-menu"), U = f("a-dropdown-button");
      return E(), D("div", ye, [
        h.value ? (E(), D("div", be, [
          o(m(T), { size: "small" }, {
            default: r(() => [
              F("div", Ee, [
                o(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, [
                o(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
          })
        ])) : j("", !0),
        F("div", _e, [
          o(m(T), { size: "small" }, {
            default: r(() => [
              o(m(te), {
                api: w(),
                autoGet: !1,
                extraParams: e.tableQuery,
                tableProps: e.tableProps,
                formProps: e.formProps,
                onRegister: l
              }, {
                middle: r(() => [
                  o(S, {
                    value: e.tableQuery.status,
                    "onUpdate:value": c[2] || (c[2] = (d) => e.tableQuery.status = d),
                    onChange: a.table.reload
                  }, {
                    default: r(() => [
                      (E(!0), D(z, null, G(e.tabsList, (d, V) => (E(), $(B, {
                        value: d.tabParam,
                        key: V
                      }, {
                        default: r(() => [
                          y(q(d.tabName), 1)
                        ]),
                        _: 2
                      }, 1032, ["value"]))), 128))
                    ]),
                    _: 1
                  }, 8, ["value", "onChange"])
                ]),
                formRight: r(() => [
                  o(m(X), {
                    type: "primary",
                    onClick: R,
                    loading: e.loading
                  }, {
                    default: r(() => [
                      y(" \u5BFC\u51FA ")
                    ]),
                    _: 1
                  }, 8, ["loading"]),
                  o(U, {
                    type: "danger",
                    onClick: L
                  }, {
                    overlay: r(() => [
                      o(K, { onClick: Q }, {
                        default: r(() => [
                          o(x, { key: "1" }, {
                            default: r(() => [
                              y("\u4E00\u952E\u50AC\u529E")
                            ]),
                            _: 1
                          }),
                          o(x, { key: "2" }, {
                            default: r(() => [
                              y("\u4E00\u952E\u50AC\u529E\u4E0B\u4E00\u6B65")
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      })
                    ]),
                    icon: r(() => [
                      o(m(ne))
                    ]),
                    default: r(() => [
                      y(" \u50AC\u529E ")
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }, 8, ["api", "extraParams", "tableProps", "formProps"])
            ]),
            _: 1
          })
        ]),
        o(re, { onRegister: s }),
        o(se, { onRegister: _ }),
        o(ie, { onRegister: i })
      ]);
    };
  }
});
const xe = /* @__PURE__ */ le(he, [["__scopeId", "data-v-6a306fc3"]]);
export {
  xe as default
};
