import { ref as B, computed as A, h as x, defineComponent as O, reactive as j, watch as D, onMounted as z, resolveComponent as p, openBlock as y, createElementBlock as C, createVNode as n, unref as m, withCtx as u, createElementVNode as g, createCommentVNode as G, Fragment as $, renderList as q, createBlock as H, createTextVNode as E, toDisplayString as J, pushScopeId as X, popScopeId as ee } from "vue";
import { Card as P, InputSearch as te, Tree as oe, message as T } from "ant-design-vue";
import { useRouter as ae } from "vue-router";
import { C as ne } from "./index.18983179.js";
import { d as h, n as re, W as ue, h as se, D as le, p as ie, k as ce, _ as de } from "./index.14fbe0a4.js";
import { W as pe } from "./WorkflowBackModal.d7a7566a.js";
import { W as me } from "./WorkflowFormRenderDrawer.92087c3d.js";
import { W as fe } from "./WorkflowTaskModal.f996c726.js";
import "axios";
import "./SanZhiFormRenderOA.6d13345d.js";
const I = B([]), N = B([]), f = B([]), R = A(() => f.value.map((r) => r.instanceId)), _e = A(() => f.value.map((r) => r.id));
function ye() {
  return new Promise((o, r) => {
    h("apis").getWorkflowCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((t) => {
      const { data: c } = t;
      I.value = c, c.length && N.value.push(c[0].id), o(t);
    }).catch((t) => {
      r(t);
    });
  });
}
function ge() {
  return new Promise((o, r) => {
    o([{
      tabName: "\u5DF2\u5B8C\u7ED3",
      tabParam: "1",
      tabTitle: "\u5DF2\u5B8C\u7ED3"
    }, {
      tabName: "\u5DF2\u5F52\u6863",
      tabParam: "3",
      tabTitle: "\u5DF2\u5F52\u6863"
    }]);
  });
}
function he(o) {
  const { archiveStatus: r, instanceRunStatus: t, instanceStatus: c } = o;
  return r ? { color: "success", text: "\u5DF2\u5F52\u6863" } : t === "END" ? { color: "default", text: "\u5DF2\u7EC8\u6B62" } : c ? { color: "processing", text: "\u5DF2\u5B8C\u7ED3" } : { color: "warning", text: "\u672A\u5B8C\u7ED3" };
}
function M(o = {}, r, t = {}) {
  let _ = {
    rowKey: "id",
    columns: [
      {
        title: "\u6807\u9898",
        dataIndex: "title",
        customRender: function({ record: l }) {
          const { flowId: d, instanceId: e, id: v, title: F } = l, w = { flowId: d, instanceId: e, taskId: v };
          return x("span", {
            class: "ant-btn-link pointer",
            onClick: function() {
              re({ params: w, router: r });
            }
          }, F);
        },
        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 d = he(l);
          return x(ue, {
            color: d.color,
            value: d.text
          });
        },
        width: 100
      },
      {
        title: "\u64CD\u4F5C",
        dataIndex: "actions",
        width: 80,
        fixed: "right",
        buttons: [
          {
            title: "\u6D41\u7A0B\u8F68\u8FF9",
            icon: "fund-outlined",
            props: {
              type: "primary"
            },
            key: "record",
            onClick: function(l) {
              o.modal.openModal({ data: l });
            }
          },
          {
            title: "\u5DE5\u4F5C\u4EFB\u52A1",
            icon: "control-outlined",
            props: {
              type: "primary"
            },
            key: "task",
            onClick: function(l) {
              o.taskModal.openModal({ data: l });
            }
          }
        ]
      }
    ],
    rowSelection: {
      onChange: (l, d) => {
        f.value = d;
      },
      selectedRowKeys: _e
    }
  };
  const { tableQuery: b = {} } = t;
  return b.status != "1" && delete _.rowSelection, _;
}
function W(o = {}) {
  const r = o.tableQuery && o.tableQuery.categoryId, t = 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: "startTime",
          endTime: "endTime"
        },
        component: "a-range-picker",
        componentProps: {
          style: {
            width: "100%"
          },
          valueFormat: "YYYY-MM-DD"
        }
      }, {
        field: "categoryId",
        label: "\u5DE5\u4F5C\u6D41\u7A0B",
        hide: !t.noTree,
        defaultValue: r || "",
        component: "a-tree-select",
        componentProps: {
          "tree-data": I,
          "field-names": {
            children: "children",
            value: "id",
            label: "name"
          },
          treeDefaultExpandAll: !0
        }
      }]
    }
  };
}
const be = (o) => (X("data-v-6446c322"), o = o(), ee(), o), ve = { class: "workflow-manage" }, Fe = {
  key: 0,
  class: "left"
}, we = { class: "input-box" }, ke = { class: "tree-box" }, De = { class: "right" }, Ce = /* @__PURE__ */ be(() => /* @__PURE__ */ g("p", null, "\u8BF7\u9009\u62E9\u5F52\u6863\u65F6\u95F4\uFF0C\u672A\u9009\u62E9\u65F6\u95F4\u5C06\u4F1A\u5F52\u6863\u5168\u90E8", -1)), Ee = /* @__PURE__ */ O({
  __name: "SanZhiWorkflowArchive",
  setup(o) {
    const r = ae(), t = {};
    function c(a) {
      t.table = a;
    }
    function _(a) {
      t.modal = a;
    }
    function b(a) {
      t.workflowForm = a;
    }
    function l(a) {
      t.backModal = a;
    }
    function d(a) {
      t.taskModal = a;
    }
    const e = j({
      locationQuery: se(),
      keyword: "",
      treeData: I,
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: N,
      formProps: W(),
      tableProps: {},
      tabsList: [],
      tableQuery: {
        status: "1"
      },
      tableData: {},
      loading: !1,
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: "",
      archiveTimeRange: []
    });
    e.tableProps = M(t, r, e);
    const v = A(() => !e.locationQuery.noTree);
    D(
      () => e.selectedKeys,
      (a, s) => {
        const k = a[0] || "";
        e.tableQuery.categoryId = k, t.table.reload();
      },
      { deep: !0 }
    ), D(
      () => e.tableQuery.categoryId,
      () => {
        f.value = [];
      }
    ), D(
      () => e.tableQuery.status,
      () => {
        e.tableProps = M(t, r, e), f.value = [];
      }
    );
    function F() {
      return h("apis").getWorkflowTaskInstancePageList;
    }
    async function w() {
      const a = R.value.length;
      if (!a) {
        T.info("\u8BF7\u9009\u62E9\u81F3\u5C11\u4E00\u6761\u6570\u636E");
        return;
      }
      try {
        await ce({
          content: `\u786E\u8BA4\u5F52\u6863\u9009\u4E2D\u7684\u6D41\u7A0B\u4E48\uFF0C\u5171\u9009\u4E2D${a}\u6761`
        });
      } catch {
        return;
      }
      h("apis").archiveByInstanceList({ body: R.value }).then(() => {
        T.success("\u5F52\u6863\u6210\u529F");
      });
    }
    async function S() {
      const a = e.archiveTimeRange[0], s = e.archiveTimeRange[1];
      h("apis").archiveByLaunchTime({ startTime: a, endTime: s }).then(() => {
        T.success("\u4E00\u952E\u5F52\u6863\u6210\u529F");
      });
    }
    return z(() => {
      ge().then((a) => {
        e.tabsList = a;
      }), ye().then(() => {
        e.formProps = W(e);
      });
    }), (a, s) => {
      const k = p("a-radio-button"), Q = p("a-radio-group"), K = p("a-range-picker"), L = p("a-menu-item"), Y = p("a-popconfirm"), V = p("a-menu"), U = p("a-dropdown-button");
      return y(), C("div", ve, [
        v.value ? (y(), C("div", Fe, [
          n(m(P), { size: "small" }, {
            default: u(() => [
              g("div", we, [
                n(m(te), {
                  value: e.keyword,
                  "onUpdate:value": s[0] || (s[0] = (i) => e.keyword = i),
                  placeholder: "\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9"
                }, null, 8, ["value"])
              ]),
              g("div", ke, [
                n(m(oe), {
                  "tree-data": e.treeData,
                  selectedKeys: e.selectedKeys,
                  "onUpdate:selectedKeys": s[1] || (s[1] = (i) => e.selectedKeys = i),
                  fieldNames: e.fieldNames
                }, null, 8, ["tree-data", "selectedKeys", "fieldNames"])
              ])
            ]),
            _: 1
          })
        ])) : G("", !0),
        g("div", De, [
          n(m(P), { size: "small" }, {
            default: u(() => [
              n(m(ne), {
                api: F(),
                autoGet: !1,
                extraParams: e.tableQuery,
                tableProps: e.tableProps,
                formProps: e.formProps,
                onRegister: c
              }, {
                middle: u(() => [
                  n(Q, {
                    value: e.tableQuery.status,
                    "onUpdate:value": s[2] || (s[2] = (i) => e.tableQuery.status = i),
                    onChange: t.table.reload
                  }, {
                    default: u(() => [
                      (y(!0), C($, null, q(e.tabsList, (i, Z) => (y(), H(k, {
                        value: i.tabParam,
                        key: Z
                      }, {
                        default: u(() => [
                          E(J(i.tabName), 1)
                        ]),
                        _: 2
                      }, 1032, ["value"]))), 128))
                    ]),
                    _: 1
                  }, 8, ["value", "onChange"])
                ]),
                formRight: u(() => [
                  n(U, {
                    type: "primary",
                    onClick: w
                  }, {
                    overlay: u(() => [
                      n(V, null, {
                        default: u(() => [
                          n(Y, {
                            placement: "bottom",
                            onConfirm: S
                          }, {
                            title: u(() => [
                              Ce,
                              n(K, {
                                value: e.archiveTimeRange,
                                "onUpdate:value": s[3] || (s[3] = (i) => e.archiveTimeRange = i),
                                valueFormat: "YYYY-MM-DD",
                                dropdownClassName: "ponconfim-class"
                              }, null, 8, ["value"])
                            ]),
                            default: u(() => [
                              n(L, { key: "1" }, {
                                default: u(() => [
                                  E("\u4E00\u952E\u5F52\u6863")
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      })
                    ]),
                    icon: u(() => [
                      n(m(le))
                    ]),
                    default: u(() => [
                      E(" \u5F52\u6863 ")
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }, 8, ["api", "extraParams", "tableProps", "formProps"])
            ]),
            _: 1
          })
        ]),
        n(ie, { onRegister: _ }),
        n(pe, { onRegister: l }),
        n(me, { onRegister: b }),
        n(fe, {
          hideActions: !0,
          onRegister: d
        })
      ]);
    };
  }
});
const Se = /* @__PURE__ */ de(Ee, [["__scopeId", "data-v-6446c322"]]);
export {
  Se as default
};
