import { defineComponent as B, ref as R, computed as E, nextTick as S, resolveComponent as D, openBlock as b, createBlock as P, withCtx as c, createVNode as i, reactive as v, watch as M, createElementVNode as y, onMounted as T, createElementBlock as x, unref as w, createTextVNode as j } from "vue";
import { Card as F, InputSearch as Z, Tree as Q, Button as z, message as g } from "ant-design-vue";
import { useRouter as q } from "vue-router";
import { e as W, _ as h, m as H, d as k, j as _, k as A } from "./index.14fbe0a4.js";
import L from "./SanZhiWorkflowVue3.e20042b8.js";
import { C as G } from "./index.18983179.js";
import "axios";
const J = B({
  name: "WorkflowNoticeModal",
  components: { ConfigForm: W },
  props: {
    formData: {
      type: [Object],
      default: () => ({})
    },
    open: {
      type: [Boolean],
      default: !1
    }
  },
  emits: ["update:open", "update:formData", "handleOk"],
  setup(o, { emit: n }) {
    const m = {
      layout: "horizontal",
      columns: [{
        label: "\u901A\u77E5\u5F00\u5173",
        field: "status",
        component: "a-switch",
        componentProps: {}
      }, {
        label: "\u901A\u77E5\u65E5\u671F",
        field: "remindDay",
        required: !0,
        component: "a-input-number",
        componentProps: {
          addonBefore: "\u81EA\u53D1\u8D77\u65E5",
          addonAfter: "\u5929\u540E\u901A\u77E5",
          min: 1
        }
      }, {
        label: "\u901A\u77E5\u5185\u5BB9",
        field: "content",
        required: !0,
        component: "a-textarea",
        componentProps: {
          placeholder: "\u8BF7\u8F93\u5165\u901A\u77E5\u5185\u5BB9-\u4F7F\u7528{}\u4F5C\u4E3A\u6A21\u677F\u8BED\u6CD5"
        }
      }, {
        label: "\u6392\u9664\u4EBA\u5458",
        field: "excludeUser",
        component: "input-user-select",
        componentProps: {}
      }, {
        label: "\u901A\u77E5\u4EBA\u5458",
        field: "remindUser",
        component: "input-user-select",
        componentProps: {}
      }]
    }, s = {};
    function r(p) {
      Object.assign(s, p);
    }
    const f = R(!1), e = E({
      get: () => (f.value = !1, o.open && S(() => {
        s.resetFields();
      }), o.open),
      set: (p) => {
        n("update:open", p);
      }
    }), d = E({
      get: () => o.formData,
      set: (p) => {
        n("update:formData", p);
      }
    });
    async function l() {
      try {
        await s.validateFields();
      } catch {
        return;
      }
      f.value = !0, n("handleOk", d.value);
    }
    return { formProps: m, open: e, formData: d, loading: f, registerForm: r, handleOk: l };
  }
});
function X(o, n, m, s, r, f) {
  const e = D("ConfigForm"), d = D("a-modal");
  return b(), P(d, {
    visible: o.open,
    "onUpdate:visible": n[1] || (n[1] = (l) => o.open = l),
    okButtonProps: { loading: o.loading },
    title: "\u901A\u77E5\u8BBE\u7F6E",
    onOk: o.handleOk
  }, {
    default: c(() => [
      i(e, {
        modelValue: o.formData,
        "onUpdate:modelValue": n[0] || (n[0] = (l) => o.formData = l),
        formProps: o.formProps,
        onRegister: o.registerForm
      }, null, 8, ["modelValue", "formProps", "onRegister"])
    ]),
    _: 1
  }, 8, ["visible", "okButtonProps", "onOk"]);
}
const Y = /* @__PURE__ */ h(J, [["render", X]]), ee = B({
  name: "WorkflowNoticeModal",
  components: { ConfigForm: W, SanZhiWorkflowVue3: L },
  props: {
    open: {
      type: [Boolean],
      default: !1
    },
    isEdit: {
      type: [Boolean],
      default: !1
    },
    workflowProps: {
      type: [Object],
      default: function() {
        return {};
      }
    },
    workflowData: {
      type: [Object],
      default: function() {
        return {};
      }
    }
  },
  emits: ["update:open"],
  setup(o, { emit: n }) {
    const m = E({
      get: () => o.open,
      set: (r) => {
        n("update:open", r);
      }
    }), s = v({
      workflowData: {}
    });
    return M(
      () => o.workflowData,
      (r) => {
        H(s.workflowData, r);
      },
      { immediate: !0 }
    ), { open: m, state: s };
  }
}), te = /* @__PURE__ */ y("div", { class: "actions-box" }, null, -1);
function oe(o, n, m, s, r, f) {
  const e = D("SanZhiWorkflowVue3"), d = D("a-drawer");
  return b(), P(d, {
    width: "100%",
    bodyStyle: { padding: "0" },
    visible: o.open,
    "onUpdate:visible": n[1] || (n[1] = (l) => o.open = l),
    title: o.isEdit ? "\u7F16\u8F91\u6D41\u7A0B" : "\u65B0\u589E\u6D41\u7A0B"
  }, {
    extra: c(() => [
      te
    ]),
    default: c(() => [
      i(e, {
        workflowProps: o.workflowProps,
        modelValue: o.state.workflowData,
        "onUpdate:modelValue": n[0] || (n[0] = (l) => o.state.workflowData = l)
      }, null, 8, ["workflowProps", "modelValue"])
    ]),
    _: 1
  }, 8, ["visible", "title"]);
}
const ne = /* @__PURE__ */ h(ee, [["render", oe]]), ae = { class: "workflow-manage" }, ue = { class: "left" }, re = { class: "input-box" }, le = { class: "tree-box" }, se = { class: "right" }, ie = /* @__PURE__ */ B({
  __name: "SanZhiWorkflowManage",
  setup(o) {
    const n = q(), s = {
      columns: [
        {
          title: "\u6D41\u7A0B\u540D\u79F0",
          dataIndex: "name"
        },
        {
          title: "\u6D41\u7A0B\u7B80\u79F0",
          dataIndex: "shortName"
        },
        {
          title: "\u6D41\u7A0Bid",
          dataIndex: "id"
        },
        {
          title: "\u64CD\u4F5C",
          dataIndex: "actions",
          width: 110,
          buttons: [
            {
              title: "\u7F16\u8F91",
              icon: "form-outlined",
              props: {
                type: "primary"
              },
              key: "edit"
            },
            {
              title: "\u53D1\u5E03",
              icon: "upload-outlined",
              props: {
                type: "success"
              },
              key: "publish"
            },
            {
              title: "\u901A\u77E5",
              icon: "notification-outlined",
              props: {},
              key: "notice"
            },
            {
              title: "\u5220\u9664",
              icon: "delete-outlined",
              props: {
                danger: !0
              },
              key: "delete"
            }
          ]
        }
      ]
    }, r = {};
    function f(u) {
      Object.assign(r, u);
    }
    const e = v({
      keyword: "",
      treeData: [],
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: [],
      tableQuery: {},
      tableData: {},
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: "",
      workflowProps: {}
    });
    M(
      () => e.selectedKeys,
      (u, t) => {
        const a = u[0];
        !a || (e.tableQuery.categoryId = a, r.reload());
      },
      { deep: !0 }
    );
    function d() {
      k("apis").getWorkflowCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((u) => {
        const { data: t } = u;
        e.treeData = t, t.length && e.selectedKeys.push(t[0].id);
      });
    }
    function l() {
      return k("apis").getWorkflowPageList;
    }
    function p({ item: u, record: t }) {
      const { key: a } = u;
      if (a === "edit") {
        const { id: V } = t;
        _({ params: { flowId: V }, router: n }).then(($) => {
          const { type: K } = $;
          K === "drawer" && (e.isEdit = !0, e.flowId = t.id, e.openEditModal = !0);
        });
      }
      a === "publish" && N(t), a === "notice" && (e.currentEdit = t, e.openNoticeModal = !0, I(t.id)), a === "delete" && C(t);
    }
    async function N(u) {
      try {
        await A({
          title: "\u63D0\u793A",
          content: "\u786E\u8BA4\u53D1\u5E03\u5F53\u524D\u6D41\u7A0B?"
        });
      } catch {
        return;
      }
      k("apis").publishWorkflowById({ id: u.id }).then(() => {
        g.success("\u53D1\u5E03\u6210\u529F");
      });
    }
    async function C(u) {
      try {
        await A({
          title: "\u63D0\u793A",
          content: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6D41\u7A0B?"
        });
      } catch {
        return;
      }
      k("apis").deleteWorkflowById({ id: u.id }).then(() => {
        g.success("\u5220\u9664\u6210\u529F"), r.reload();
      });
    }
    function I(u) {
      k("apis").getWorkflowRemind({ flowId: u }).then((t) => {
        e.notice = { ...t.data };
      });
    }
    function O() {
      k("apis").addOrUpdateWorkflowRemind({
        body: { ...e.notice, status: !!e.notice.status, id: e.currentEdit.id }
      }).then(() => {
        g.success("\u8BBE\u7F6E\u6210\u529F"), e.openNoticeModal = !1;
      });
    }
    function U() {
      _({
        params: { categoryId: e.tableQuery.categoryId },
        router: n
      }).then((u) => {
        const { type: t } = u;
        t === "drawer" && (e.isEdit = !1, e.workflowProps = {}, e.workflowData = { attr: { type: e.tableQuery.categoryId } }, e.openEditModal = !0);
      });
    }
    return T(() => {
      d();
    }), (u, t) => (b(), x("div", ae, [
      y("div", ue, [
        i(w(F), { size: "small" }, {
          default: c(() => [
            y("div", re, [
              i(w(Z), {
                value: e.keyword,
                "onUpdate:value": t[0] || (t[0] = (a) => e.keyword = a),
                placeholder: "\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9"
              }, null, 8, ["value"])
            ]),
            y("div", le, [
              i(w(Q), {
                "tree-data": e.treeData,
                selectedKeys: e.selectedKeys,
                "onUpdate:selectedKeys": t[1] || (t[1] = (a) => e.selectedKeys = a),
                fieldNames: e.fieldNames
              }, null, 8, ["tree-data", "selectedKeys", "fieldNames"])
            ])
          ]),
          _: 1
        })
      ]),
      y("div", se, [
        i(w(F), { size: "small" }, {
          default: c(() => [
            i(w(G), {
              api: l(),
              autoGet: !1,
              extraParams: e.tableQuery,
              tableProps: s,
              onHandleAction: p,
              onRegister: f
            }, {
              formRight: c(() => [
                i(w(z), {
                  type: "primary",
                  onClick: U
                }, {
                  default: c(() => [
                    j("\u65B0\u589E\u6D41\u7A0B")
                  ]),
                  _: 1
                })
              ]),
              _: 1
            }, 8, ["api", "extraParams"])
          ]),
          _: 1
        })
      ]),
      i(Y, {
        open: e.openNoticeModal,
        "onUpdate:open": t[2] || (t[2] = (a) => e.openNoticeModal = a),
        formData: e.notice,
        "onUpdate:formData": t[3] || (t[3] = (a) => e.notice = a),
        onHandleOk: O
      }, null, 8, ["open", "formData"]),
      i(ne, {
        open: e.openEditModal,
        "onUpdate:open": t[4] || (t[4] = (a) => e.openEditModal = a),
        isEdit: e.isEdit,
        workflowProps: e.workflowProps
      }, null, 8, ["open", "isEdit", "workflowProps"])
    ]));
  }
});
const ye = /* @__PURE__ */ h(ie, [["__scopeId", "data-v-61dba07e"]]);
export {
  ye as default
};
