import { ref as D, h as k, defineComponent as E, reactive as I, computed as P, watch as x, onMounted as W, openBlock as _, createElementBlock as F, createVNode as l, unref as d, withCtx as f, createElementVNode as w, createCommentVNode as v, createTextVNode as A } from "vue";
import { message as R, Card as b, InputSearch as N, Tree as M, Button as S } from "ant-design-vue";
import { useRouter as K } from "vue-router";
import { C as Q } from "./index.18983179.js";
import { d as m, n as U, q as V, W as L, h as O, p as Y, _ as Z } from "./index.14fbe0a4.js";
import { W as z } from "./WorkflowBackModal.d7a7566a.js";
import { W as q } from "./WorkflowFormRenderDrawer.92087c3d.js";
import "axios";
import "./SanZhiFormRenderOA.6d13345d.js";
const h = D([]), T = D([]);
function G() {
  return new Promise((r, s) => {
    m("apis").getWorkflowCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((t) => {
      const { data: i } = t;
      h.value = i, i.length && T.value.push(i[0].id), r(t);
    }).catch((t) => {
      s(t);
    });
  });
}
function $(r = {}, s) {
  return {
    columns: [
      {
        title: "\u6807\u9898",
        dataIndex: "title",
        customRender: function({ record: o }) {
          const { flowId: n, instanceId: c, id: e, title: g } = o, y = { flowId: n, instanceId: c, taskId: e };
          return k("span", {
            class: "ant-btn-link pointer",
            onClick: function() {
              U({ params: y, router: s });
            }
          }, g);
        },
        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: "\u63A5\u6536\u65E5\u671F",
        dataIndex: "receiveTime",
        width: 190
      },
      {
        title: "\u505C\u7559\u65F6\u95F4",
        dataIndex: "stepName",
        customRender: function({ record: o }) {
          const { receiveTime: n } = o;
          return V()(n).fromNow();
        },
        width: 100
      },
      {
        title: "\u72B6\u6001",
        dataIndex: "status",
        customRender: function({ record: o }) {
          return k(L, {
            dict: "WORKFLOW_TASK_STATUS",
            value: o.status
          });
        },
        width: 100
      },
      {
        title: "\u64CD\u4F5C",
        dataIndex: "actions",
        width: 120,
        fixed: "right",
        buttons: [
          {
            title: "\u6D41\u7A0B\u8F68\u8FF9",
            icon: "fund-outlined",
            props: {
              type: "primary"
            },
            key: "record",
            onClick: function(o) {
              r.modal.openModal({ data: o });
            }
          },
          {
            title: "\u7EC8\u6B62\u5B9E\u4F8B",
            icon: "close-circle-outlined",
            props: {
              type: "primary",
              danger: !0
            },
            key: "end",
            popconfirm: {
              title: "\u786E\u8BA4\u7EC8\u6B62\u5F53\u524D\u5B9E\u4F8B\u4E48\uFF1F",
              confirm: function(o) {
                const { instanceId: n, title: c } = o;
                !n || m("apis").endFlowByInstanceId({ id: n }).then((e) => {
                  R.success(`\u7EC8\u6B62\u5B9E\u4F8B${c}\u6210\u529F`), r.table.reload();
                });
              }
            }
          },
          {
            title: "\u67E5\u770B\u9000\u56DE\u539F\u56E0",
            icon: "warning-outlined",
            hide: function(o) {
              const { type: n } = o;
              return n != "BACK";
            },
            props: {
              type: "default"
            },
            key: "view_return",
            onClick: function(o) {
              r.backModal.openModal({ data: o });
            }
          }
        ]
      }
    ]
  };
}
function B(r = {}) {
  const s = r.tableQuery && r.tableQuery.categoryId, t = r.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: "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: s || "",
        component: "a-tree-select",
        componentProps: {
          "tree-data": h,
          "field-names": {
            children: "children",
            value: "id",
            label: "name"
          },
          treeDefaultExpandAll: !0
        }
      }, {
        field: "readStatus",
        label: "\u8BFB\u53D6\u72B6\u6001",
        component: "dict-select",
        componentProps: {
          dict: "TASK_READ_STATUS",
          selectProps: {
            allowClear: !0
          }
        }
      }]
    }
  };
}
const j = { class: "workflow-manage" }, H = {
  key: 0,
  class: "left"
}, J = { class: "input-box" }, X = { class: "tree-box" }, ee = { class: "right" }, te = /* @__PURE__ */ E({
  __name: "SanZhiWorkflowWait",
  setup(r) {
    const s = K(), t = {};
    function i(a) {
      t.table = a;
    }
    function o(a) {
      t.modal = a;
    }
    function n(a) {
      t.workflowForm = a;
    }
    function c(a) {
      t.backModal = a;
    }
    const e = I({
      locationQuery: O(),
      keyword: "",
      treeData: h,
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: T,
      formProps: B(),
      tableProps: $(t, s),
      tableQuery: {
        status: 0,
        instanceStatus: ""
      },
      tableData: {},
      loading: !1,
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: ""
    }), g = P(() => !e.locationQuery.noTree);
    x(
      () => e.selectedKeys,
      (a, u) => {
        const p = a[0] || "";
        e.tableQuery.categoryId = p, t.table.reload();
      },
      { deep: !0 }
    );
    function y() {
      return m("apis").getWorkflowTaskPageList;
    }
    function C() {
      const a = t.table.getParams();
      e.loading = !0, m("apis.export").getWorkflowTaskExcel({ ...a }).then((u) => {
      }).finally(() => {
        e.loading = !1;
      });
    }
    return W(() => {
      G().then(() => {
        e.formProps = B(e);
      });
    }), (a, u) => (_(), F("div", j, [
      g.value ? (_(), F("div", H, [
        l(d(b), { size: "small" }, {
          default: f(() => [
            w("div", J, [
              l(d(N), {
                value: e.keyword,
                "onUpdate:value": u[0] || (u[0] = (p) => e.keyword = p),
                placeholder: "\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9"
              }, null, 8, ["value"])
            ]),
            w("div", X, [
              l(d(M), {
                "tree-data": e.treeData,
                selectedKeys: e.selectedKeys,
                "onUpdate:selectedKeys": u[1] || (u[1] = (p) => e.selectedKeys = p),
                fieldNames: e.fieldNames
              }, null, 8, ["tree-data", "selectedKeys", "fieldNames"])
            ])
          ]),
          _: 1
        })
      ])) : v("", !0),
      w("div", ee, [
        l(d(b), { size: "small" }, {
          default: f(() => [
            l(d(Q), {
              api: y(),
              autoGet: !1,
              extraParams: e.tableQuery,
              tableProps: e.tableProps,
              formProps: e.formProps,
              onRegister: i
            }, {
              formRight: f(() => [
                l(d(S), {
                  type: "primary",
                  onClick: C,
                  loading: e.loading
                }, {
                  default: f(() => [
                    A("\u5BFC\u51FA")
                  ]),
                  _: 1
                }, 8, ["loading"])
              ]),
              _: 1
            }, 8, ["api", "extraParams", "tableProps", "formProps"])
          ]),
          _: 1
        })
      ]),
      l(Y, { onRegister: o }),
      l(z, { onRegister: c }),
      l(q, { onRegister: n })
    ]));
  }
});
const ce = /* @__PURE__ */ Z(te, [["__scopeId", "data-v-963e26fa"]]);
export {
  ce as default
};
