import { ref as C, h as F, defineComponent as I, reactive as N, computed as A, watch as R, onMounted as W, resolveComponent as k, openBlock as p, createElementBlock as h, unref as c, createVNode as u, withCtx as m, createElementVNode as _, createCommentVNode as M, Fragment as Q, renderList as S, createBlock as K, createTextVNode as x, toDisplayString as L } from "vue";
import { Card as V, InputSearch as Y, Tree as U, Button as Z } from "ant-design-vue";
import { useRouter as j } from "vue-router";
import { g as w, o as H, a as O, C as G, W as q, b as z } from "./index.e7201430.js";
import { W as J, a as X, b as $ } from "./WorkflowBackModal.6c390a74.js";
import "sanzhi-form-design-vue3";
import "axios";
const D = C([]), B = C([]);
function ee() {
  return new Promise((o, r) => {
    w("apis").getCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((t) => {
      const { data: n } = t;
      D.value = n, n.length && B.value.push(n[0].id), o(t);
    }).catch((t) => {
      r(t);
    });
  });
}
function te() {
  return new Promise((o, r) => {
    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 ae(o) {
  const { archiveStatus: r, instanceRunStatus: t, instanceStatus: n } = o;
  return r ? { color: "success", text: "\u5DF2\u5F52\u6863" } : t === "END" ? { color: "default", text: "\u5DF2\u7EC8\u6B62" } : n ? { color: "processing", text: "\u5DF2\u5B8C\u7ED3" } : { color: "warning", text: "\u672A\u5B8C\u7ED3" };
}
function oe(o = {}, r) {
  return {
    columns: [
      {
        title: "\u6807\u9898",
        dataIndex: "title",
        customRender: function({ record: i }) {
          const { flowId: d, instanceId: f, id: e, title: b } = i, g = { flowId: d, instanceId: f, taskId: e };
          return F("span", {
            class: "ant-btn-link pointer",
            onClick: function() {
              H({ params: g, router: r });
            }
          }, b);
        },
        width: 350
      },
      {
        title: "\u6D41\u7A0B",
        dataIndex: "flowName",
        width: 150,
        ellipsis: !0
      },
      {
        title: "\u5F53\u524D\u6B65\u9AA4",
        dataIndex: "stepName",
        width: 100,
        ellipsis: !0
      },
      {
        title: "\u53D1\u8D77\u4EBA",
        dataIndex: "senderName",
        width: 100,
        ellipsis: !0
      },
      {
        title: "\u5904\u7406\u4EBA",
        dataIndex: "receiverName",
        width: 100,
        ellipsis: !0
      },
      {
        title: "\u63A5\u6536\u65E5\u671F",
        dataIndex: "receiveTime",
        width: 190
      },
      {
        title: "\u5904\u7406\u65E5\u671F",
        dataIndex: "completedTime",
        width: 190
      },
      {
        title: "\u6D41\u7A0B\u72B6\u6001",
        dataIndex: "instanceStatus",
        customRender: function({ record: i }) {
          const d = ae(i);
          return F(J, {
            color: d.color,
            value: d.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(i) {
              o.modal.openModal({ data: i });
            }
          }
        ]
      }
    ]
  };
}
function P(o = {}) {
  const r = o.tableQuery && o.tableQuery.categoryId, t = o.locationQuery || {};
  return {
    formProps: {
      baseColAttr: {
        span: 4
      },
      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: !t.noTree,
        defaultValue: r || "",
        component: "a-tree-select",
        componentProps: {
          "tree-data": D,
          "field-names": {
            children: "children",
            value: "id",
            label: "name"
          },
          treeDefaultExpandAll: !0
        }
      }]
    }
  };
}
const re = { class: "workflow-manage" }, ne = {
  key: 0,
  class: "left"
}, ue = { class: "input-box" }, le = { class: "tree-box" }, se = { class: "right" }, ie = /* @__PURE__ */ x("\u5BFC\u51FA"), de = /* @__PURE__ */ I({
  __name: "SanZhiWorkflowPass",
  setup(o) {
    const r = j(), t = {};
    function n(a) {
      t.table = a;
    }
    function i(a) {
      t.modal = a;
    }
    function d(a) {
      t.workflowForm = a;
    }
    function f(a) {
      t.backModal = a;
    }
    const e = N({
      locationQuery: O(),
      keyword: "",
      treeData: D,
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: B,
      formProps: P(),
      tableProps: oe(t, r),
      tabsList: [],
      tableQuery: {
        status: ""
      },
      tableData: {},
      loading: !1,
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: ""
    }), b = A(() => !e.locationQuery.noTree);
    R(
      () => e.selectedKeys,
      (a, l) => {
        const y = a[0] || "";
        e.tableQuery.categoryId = y, t.table.reload();
      },
      { deep: !0 }
    );
    function g() {
      return w("apis").getWorkflowTaskInstanceHandlePageList;
    }
    function E() {
      const a = t.table.getParams();
      e.loading = !0, w("apis").getWorkflowTaskInstanceHandleExportExcel({ ...a }).then((l) => {
      }).finally(() => {
        e.loading = !1;
      });
    }
    return W(() => {
      te().then((a) => {
        e.tabsList = a;
      }), ee().then(() => {
        e.formProps = P(e);
      });
    }), (a, l) => {
      const y = k("a-radio-button"), v = k("a-radio-group");
      return p(), h("div", re, [
        c(b) ? (p(), h("div", ne, [
          u(c(V), null, {
            default: m(() => [
              _("div", ue, [
                u(c(Y), {
                  value: e.keyword,
                  "onUpdate:value": l[0] || (l[0] = (s) => e.keyword = s),
                  placeholder: "\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9"
                }, null, 8, ["value"])
              ]),
              _("div", le, [
                u(c(U), {
                  "tree-data": e.treeData,
                  selectedKeys: e.selectedKeys,
                  "onUpdate:selectedKeys": l[1] || (l[1] = (s) => e.selectedKeys = s),
                  fieldNames: e.fieldNames
                }, null, 8, ["tree-data", "selectedKeys", "fieldNames"])
              ])
            ]),
            _: 1
          })
        ])) : M("", !0),
        _("div", se, [
          u(c(G), {
            api: g(),
            autoGet: !1,
            extraParams: e.tableQuery,
            tableProps: e.tableProps,
            formProps: e.formProps,
            onRegister: n
          }, {
            middle: m(() => [
              u(v, {
                value: e.tableQuery.status,
                "onUpdate:value": l[2] || (l[2] = (s) => e.tableQuery.status = s),
                onChange: t.table.reload
              }, {
                default: m(() => [
                  (p(!0), h(Q, null, S(e.tabsList, (s, T) => (p(), K(y, {
                    value: s.tabParam,
                    key: T
                  }, {
                    default: m(() => [
                      x(L(s.tabName), 1)
                    ]),
                    _: 2
                  }, 1032, ["value"]))), 128))
                ]),
                _: 1
              }, 8, ["value", "onChange"])
            ]),
            formRight: m(() => [
              u(c(Z), {
                type: "primary",
                onClick: E,
                loading: e.loading
              }, {
                default: m(() => [
                  ie
                ]),
                _: 1
              }, 8, ["loading"])
            ]),
            _: 1
          }, 8, ["api", "extraParams", "tableProps", "formProps"])
        ]),
        u(X, { onRegister: i }),
        u($, { onRegister: f }),
        u(q, { onRegister: d })
      ]);
    };
  }
});
const he = /* @__PURE__ */ z(de, [["__scopeId", "data-v-e3f5dba9"]]);
export {
  he as default
};
