import { defineComponent as h, shallowRef as C, ref as E, computed as F, nextTick as M, resolveComponent as y, openBlock as D, createBlock as v, withCtx as g, createVNode as p, reactive as I, watch as O, onMounted as N, createElementBlock as A, createElementVNode as P, unref as k, createTextVNode as W } from "vue";
import { InputNumber as x, Card as R, Button as T, message as b } from "ant-design-vue";
import { useRouter as U } from "vue-router";
import { e as V, _, d as m, k as $ } from "./index.14fbe0a4.js";
import { C as K } from "./index.18983179.js";
import "axios";
const j = h({
  name: "WorkflowNoticeModal",
  components: { ConfigForm: V },
  props: {
    formData: {
      type: [Object],
      default: () => ({})
    },
    open: {
      type: [Boolean],
      default: !1
    }
  },
  emits: ["update:open", "update:formData", "handleOk"],
  setup(t, { emit: n }) {
    const c = {
      layout: "horizontal",
      labelCol: { span: 4 },
      columns: [
        {
          label: "\u6309\u94AE\u540D\u79F0",
          field: "name"
        },
        {
          label: "\u56FE\u6807",
          field: "ico"
        },
        {
          label: "\u5B57\u6BB5\u540D",
          field: "script"
        },
        {
          label: "\u63CF\u8FF0",
          field: "note"
        },
        {
          label: "\u6392\u5E8F",
          field: "sort",
          component: C(x)
        }
      ]
    }, r = {};
    function f(u) {
      Object.assign(r, u);
    }
    const e = E(!1), d = F({
      get: () => (e.value = !1, t.open && M(() => {
        r.resetFields();
      }), t.open),
      set: (u) => {
        n("update:open", u);
      }
    }), s = F({
      get: () => t.formData,
      set: (u) => {
        n("update:formData", u);
      }
    });
    async function i() {
      try {
        await r.validateFields();
      } catch {
        return;
      }
      e.value = !0, n("handleOk", s.value);
    }
    return { formProps: c, open: d, formData: s, loading: e, registerForm: f, handleOk: i };
  }
});
function Q(t, n, c, r, f, e) {
  const d = y("ConfigForm"), s = y("a-modal");
  return D(), v(s, {
    visible: t.open,
    "onUpdate:visible": n[1] || (n[1] = (i) => t.open = i),
    okButtonProps: { loading: t.loading },
    title: "\u6D41\u7A0B\u6309\u94AE",
    onOk: t.handleOk
  }, {
    default: g(() => [
      p(d, {
        modelValue: t.formData,
        "onUpdate:modelValue": n[0] || (n[0] = (i) => t.formData = i),
        formProps: t.formProps,
        onRegister: t.registerForm
      }, null, 8, ["modelValue", "formProps", "onRegister"])
    ]),
    _: 1
  }, 8, ["visible", "okButtonProps", "onOk"]);
}
const S = /* @__PURE__ */ _(j, [["render", Q]]), Z = { class: "workflow-manage" }, z = { class: "right" }, H = /* @__PURE__ */ h({
  __name: "SanZhiWorkFlowButtonManage",
  setup(t) {
    U();
    const c = {
      columns: [
        {
          title: "\u6309\u94AE\u540D\u79F0",
          dataIndex: "name"
        },
        {
          title: "\u56FE\u6807",
          dataIndex: "ico"
        },
        {
          title: "\u5B57\u6BB5\u540D",
          dataIndex: "script"
        },
        {
          title: "\u63CF\u8FF0",
          dataIndex: "note"
        },
        {
          title: "\u6392\u5E8F",
          dataIndex: "sort"
        },
        {
          title: "\u64CD\u4F5C",
          dataIndex: "actions",
          width: 110,
          buttons: [
            {
              title: "\u7F16\u8F91",
              icon: "form-outlined",
              props: {
                type: "primary"
              },
              key: "edit"
            },
            {
              title: "\u5220\u9664",
              icon: "delete-outlined",
              props: {
                danger: !0
              },
              key: "delete"
            }
          ]
        }
      ]
    }, r = {};
    function f(o) {
      Object.assign(r, o);
    }
    const e = I({
      keyword: "",
      treeData: [],
      fieldNames: {
        children: "children",
        title: "name",
        key: "id"
      },
      selectedKeys: [],
      tableQuery: {},
      tableData: {},
      currentEdit: {},
      openNoticeModal: !1,
      notice: {},
      openEditModal: !1,
      isEdit: !1,
      flowId: "",
      workflowProps: {}
    });
    O(
      () => e.selectedKeys,
      (o, a) => {
        const l = o[0];
        !l || (e.tableQuery.categoryId = l, r.reload());
      },
      { deep: !0 }
    );
    function d() {
      m("apis").getWorkflowCategoryTree({ type: "WORKFLOW", parentId: 0 }).then((o) => {
        const { data: a } = o;
        e.treeData = a, a.length && e.selectedKeys.push(a[0].id);
      });
    }
    function s() {
      return m("apis").getWorkflowButtonPageList;
    }
    function i({ item: o, record: a }) {
      const { key: l } = o;
      l === "edit" && (e.notice = { ...a }, e.openNoticeModal = !0), l === "delete" && u(a);
    }
    async function u(o) {
      try {
        await $({
          title: "\u63D0\u793A",
          content: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6309\u94AE?"
        });
      } catch {
        return;
      }
      m("apis").deleteWorkflowButtonById({ id: o.id }).then(() => {
        b.success("\u5220\u9664\u6210\u529F"), r.reload();
      });
    }
    function B(o) {
      m("apis").addOrUpdateWorkflowButton({
        body: { ...o }
      }).then(() => {
        b.success("\u64CD\u4F5C\u6210\u529F"), r.reload(), e.openNoticeModal = !1;
      });
    }
    function w() {
      e.openNoticeModal = !0;
    }
    return N(() => {
      d();
    }), (o, a) => (D(), A("div", Z, [
      P("div", z, [
        p(k(R), { size: "small" }, {
          default: g(() => [
            p(k(K), {
              api: s(),
              autoGet: !1,
              extraParams: e.tableQuery,
              tableProps: c,
              onHandleAction: i,
              onRegister: f
            }, {
              formRight: g(() => [
                p(k(T), {
                  type: "primary",
                  onClick: w
                }, {
                  default: g(() => [
                    W("\u65B0\u589E\u6309\u94AE")
                  ]),
                  _: 1
                })
              ]),
              _: 1
            }, 8, ["api", "extraParams"])
          ]),
          _: 1
        })
      ]),
      p(S, {
        open: e.openNoticeModal,
        "onUpdate:open": a[0] || (a[0] = (l) => e.openNoticeModal = l),
        formData: e.notice,
        "onUpdate:formData": a[1] || (a[1] = (l) => e.notice = l),
        onHandleOk: B
      }, null, 8, ["open", "formData"])
    ]));
  }
});
const ee = /* @__PURE__ */ _(H, [["__scopeId", "data-v-4db8f574"]]);
export {
  ee as default
};
