var R = Object.defineProperty; var N = (s, n, e) => n in s ? R(s, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[n] = e; var y = (s, n, e) => (N(s, typeof n != "symbol" ? n + "" : n, e), e); import { PluginStaticResource as U, AppFuncCommand as j } from "@ibiz-template/runtime"; import { ListPortletController as D, AppMenuPortletController as E } from "@ibiz-template/controller"; import { ListPortletModel as z, AppMenuPortletModel as B, DefectModelError as G } from "@ibiz-template/model"; import { useNamespace as k, useListController as O } from "@ibiz-template/vue-util"; import { defineComponent as L, ref as f, getCurrentInstance as C, onMounted as I, h as t, watch as J, onUnmounted as H } from "vue"; import { Tooltip as w, Button as A, Icon as F } from "view-design"; import { CounterService as K } from "@ibiz-template/service"; const g = new U(import.meta.url); const Q = L({ name: "AppPortalListPortlet", props: { modelData: { type: z, required: !0 }, controller: { type: D, required: !0 } }, setup(s) { const n = k("app-portal-list-portlet"), e = f([]), p = Array.from({ length: 3 }).map((c, i) => g.dir(`/assets/img/app-portal-list-${i}.svg`)), l = C(); if (l && s.modelData.list) { const c = O(l.proxy, s.modelData.list, s.controller.context); I(() => { c.nerve.self.evt.on("mounted", async () => { const i = await c.load(); e.value = i.slice(0, 3); }); }); } return { ns: n, appPortalList: e, appPortalImgList: p, openPage: (c) => { c && window.open(c); } }; }, render() { return t("div", { class: this.ns.b() }, [this.appPortalList.map((s, n) => t("div", { class: [this.ns.b("item"), s.url ? "" : this.ns.bm("item", "disabled")], key: s.srfkey, on: { click: () => this.openPage(s.url) } }, [t(w, { attrs: { content: s.tip, disabled: !s.tip } }, [t("div", { class: this.ns.be("item", "text") }, [s.srfmajortext])]), t("div", { class: this.ns.be("item", "icon") }, [t("img", { attrs: { src: this.appPortalImgList[n] } })])]))]); } }); class V { constructor() { y(this, "component", Q); } async createController(n, e, p) { const l = new D( n, e, p ); return await l.init(), l; } } const T = L({ name: "FuncDrawer", props: { isShowDrawer: { type: Boolean, required: !0, default: !1 } }, emits: { "on-close": () => !0 }, setup(s, { emit: n }) { var S; const e = k("func-drawer"), p = g.dir("/assets/img/placeholder.svg"), l = "\u672A\u5206\u7C7B", h = f([]), c = f([]), i = f(!1), m = (S = C()) == null ? void 0 : S.proxy, b = () => { ibiz.net.post("/appfuncs/fetchpersonfuncsetting", { page: 0, size: 1e3, sort: "showorder,asc" }).then((o) => { if (o.ok && o.data && o.data.length) { const r = {}; c.value = o.data.filter((a) => { if (a.ispersonal || (a.ispersonal = 0), !a.pssystemappid) r[l] ? r[l].push(a) : r[l] = [a]; else { const u = a.pssystemappname; r[u] ? r[u].push(a) : r[u] = [a]; } return a.ispersonal; }), h.value = Object.keys(r).map((a) => ({ name: a, items: r[a] })); } }); }, x = () => { i.value && (c.value.forEach((o, r) => { o.showorder = r; }), ibiz.net.post("/appfuncs/setfuncsetting", { setting: JSON.stringify({ list: c.value }) }).then((o) => { o.ok && (m == null || m.$Notice.success({ title: "\u6210\u529F", desc: "\u4FDD\u5B58\u6210\u529F" }), b()); })), i.value = !i.value; }; J(() => s.isShowDrawer, (o) => { o && b(); }); const d = (o) => { o && ibiz.net.get(`/appfuncs/${o}/getfuncurl`).then((r) => { r.ok && r.data && r.data.url && window.open(r.data.url); }); }, v = (o, r) => { var a; i.value && ((a = o.dataTransfer) == null || a.setData("originIndex", r.toString())); }, q = (o) => { o.preventDefault(); }, _ = (o, r) => { if (o.preventDefault(), i.value && o.dataTransfer) { const a = Number(o.dataTransfer.getData("originIndex")); if (a !== r) { const u = c.value[a], P = c.value[r]; c.value.splice(a, 1, P), c.value.splice(r, 1, u); } } }, M = (o, r, a, u) => { if (o.stopPropagation(), r.ispersonal = Number(!r.ispersonal), u === "remove") c.value.splice(a, 1); else if (u === "change") { const P = c.value.findIndex(($) => $.pssysappfuncid === r.pssysappfuncid); P === -1 ? c.value.push(r) : c.value.splice(P, 1); } }; return () => t("div", { class: [e.b(), s.isShowDrawer ? e.m("show") : ""] }, [t("div", { class: e.b("content") }, [t("div", { class: e.b("group") }, [t("header", { class: e.b("group-header") }, [t("div", { class: e.b("group-header-left") }, ["\u5E38\u7528\u5E94\u7528"]), t("div", { class: e.b("group-header-right") }, [t(A, { on: { click: x } }, [i.value ? "\u4FDD\u5B58" : "\u914D\u7F6E"]), t(A, { on: { click: () => n("on-close") } }, ["\u8FD4\u56DE"])])]), t("main", { class: e.b("group-content") }, [c.value.map((o, r) => t("div", { class: [e.b("group-item"), o.pssysappfuncid ? "" : e.bm("group-item", "disabled")], key: o.pssysappfuncid, on: { click: () => d(o.pssysappfuncid), dragstart: (a) => v(a, r), dragover: q, drop: (a) => _(a, r) }, attrs: { draggable: i.value } }, [t("div", { class: [e.be("group-item", "checkbox"), e.bem("group-item", "checkbox", "remove"), i.value ? e.bem("group-item", "checkbox", "show") : ""], on: { click: (a) => M(a, o, r, "remove") } }, [t(F, { attrs: { type: "md-remove", size: 16 } })]), t("div", { class: e.be("group-item", "icon") }, [t("img", { attrs: { src: o.icon ? g.dir(`/assets/img/${o.icon}`) : p, draggable: !1 } })]), t(w, { attrs: { content: o.tip, disabled: !o.tip } }, [t("div", { class: e.be("group-item", "text") }, [o.pssysappfuncname])])]))])]), h.value.map((o, r) => t("div", { class: e.b("group"), key: r }, [t("header", { class: e.b("group-header") }, [o.name]), t("main", { class: e.b("group-content") }, [o.items.map((a) => t("div", { class: [e.b("group-item"), a.pssysappfuncid ? "" : e.bm("group-item", "disabled")], key: a.pssysappfuncid, on: { click: () => d(a.pssysappfuncid) } }, [t("div", { class: [e.be("group-item", "checkbox"), a.ispersonal ? e.bem("group-item", "checkbox", "selected") : "", i.value ? e.bem("group-item", "checkbox", "show") : ""], on: { click: (u) => M(u, a, r, "change") } }, [a.ispersonal ? t(F, { attrs: { type: "md-checkmark", size: 16 } }) : null]), t("div", { class: e.be("group-item", "icon") }, [t("img", { attrs: { src: a.icon ? g.dir(`/assets/img/${a.icon}`) : p, draggable: !1 } })]), t(w, { attrs: { content: a.tip, disabled: !a.tip } }, [t("div", { class: e.be("group-item", "text") }, [a.pssysappfuncname])])]))])]))])]); } }), W = L({ name: "FuncPortalListPortlet", components: { FuncDrawer: T }, props: { modelData: { type: z, required: !0 }, controller: { type: D, required: !0 } }, setup(s) { const n = k("func-portal-list-portlet"), e = g.dir("/assets/img/quick-entry.svg"), p = g.dir("/assets/img/editor.svg"), l = g.dir("/assets/img/placeholder.svg"), h = f([]), c = C(); let i = null; c && s.modelData.list && (i = O(c.proxy, s.modelData.list, s.controller.context), I(() => { i == null || i.nerve.self.evt.on("mounted", async () => { if (i) { const d = await i.load(); h.value = d; } }); })); const m = (d) => { d && ibiz.net.get(`/appfuncs/${d}/getfuncurl`).then((v) => { v.ok && v.data && v.data.url && window.open(v.data.url); }); }, b = f(!1); return { ns: n, quickEntryImg: e, editorImg: p, placeholderImg: l, funcPortalList: h, openPage: m, isShowDrawer: b, isShowDrawerChange: async () => { if (b.value = !1, i) { const d = await i.load(); h.value = d; } } }; }, render() { return t("div", { class: this.ns.b() }, [t("header", { class: this.ns.b("header") }, [t("div", { class: this.ns.b("header-left") }, [t("div", { class: this.ns.be("header-left", "icon") }, [t("img", { attrs: { src: this.quickEntryImg } })]), t("div", { class: this.ns.be("header-left", "text") }, ["\u5FEB\u901F\u5165\u53E3"])]), t("div", { class: this.ns.b("header-right"), on: { click: () => { this.isShowDrawer = !0; } } }, [t("div", { class: this.ns.be("header-right", "icon") }, [t("img", { attrs: { src: this.editorImg } })]), t("div", { class: this.ns.be("header-right", "text") }, ["\u66F4\u591A"])])]), t("div", { class: this.ns.e("divider") }), t("main", { class: this.ns.b("content") }, [this.funcPortalList.map((s) => t("div", { class: [this.ns.b("item"), s.pssysappfuncid ? "" : this.ns.bm("item", "disabled")], key: s.pssysappfuncid, on: { click: () => this.openPage(s.pssysappfuncid) } }, [t("div", { class: this.ns.be("item", "icon") }, [t("img", { attrs: { src: s.icon ? g.dir(`/assets/img/${s.icon}`) : this.placeholderImg } })]), t(w, { attrs: { content: s.tip, disabled: !s.tip } }, [t("div", { class: this.ns.be("item", "text") }, [s.pssysappfuncname])])]))]), t(T, { attrs: { isShowDrawer: this.isShowDrawer }, on: { "on-close": this.isShowDrawerChange } })]); } }); class X { constructor() { y(this, "component", W); } async createController(n, e, p) { const l = new D( n, e, p ); return await l.init(), l; } } const Y = L({ name: "TodoAppMenuPortlet", props: { modelData: { type: B, required: !0 }, controller: { type: E, required: !0 } }, setup(s) { const n = k("todo-app-menu-portlet"), e = Array.from({ length: 5 }).map((c, i) => g.dir(`/assets/img/todo-app-menu-${i}.svg`)); let p = null; const l = f({}); if (s.modelData.appMenu) { const i = s.modelData.appMenu.source.getPSAppCounterRef(); i && (I(async () => { p = await K.getCounterByRef(i), p.onChange((m) => { l.value = m; }); }), H(() => { p == null || p.destroy(); })); } return { ns: n, todoImgList: e, counter: p, counterData: l, onClickMenuItem: async (c) => { const i = c.source.getPSAppFunc(); if (i) await ibiz.commands.execute(j.TAG, i); else if (s.modelData.appMenu) throw new G(s.modelData.appMenu.source, "\u672A\u914D\u7F6E\u754C\u9762\u884C\u4E3A"); } }; }, render() { var s; return t("div", { class: this.ns.b() }, [(s = this.modelData.appMenu) == null ? void 0 : s.items.map((n, e) => t("div", { class: [this.ns.b("item"), n.source.getPSAppFunc() ? "" : this.ns.bm("item", "disabled")], key: n.id, on: { click: () => this.onClickMenuItem(n) } }, [t("div", { class: this.ns.b("item-left") }, [t("div", { class: this.ns.be("item-left", "icon") }, [t("img", { attrs: { src: this.todoImgList[e] } })])]), t("div", { class: this.ns.b("item-right") }, [t("div", { class: this.ns.be("item-right", "count") }, [t("span", { class: [(this.counterData[n.counterId] || 0) > 99 ? this.ns.be("item-right", "add") : ""] }, [(this.counterData[n.counterId] || 0) > 99 ? 99 : this.counterData[n.counterId] || 0]), t("span", ["\u4EF6"])]), t(w, { attrs: { content: n.source.tooltip, disabled: !n.source.tooltip } }, [t("div", { class: this.ns.be("item-right", "text") }, [n.label])])])]))]); } }); class Z { constructor() { y(this, "component", Y); } async createController(n, e, p) { const l = new E( n, e, p ); return await l.init(), l; } } const ct = { mateUrl: import.meta.url, install(s) { ibiz.register.portletPart.register( "PORTLET_CUSTOM_AppPortalList", new V() ), ibiz.register.portletPart.register( "PORTLET_CUSTOM_FuncPortalList", new X() ), ibiz.register.portletPart.register( "PORTLET_CUSTOM_TodoAppMenu", new Z() ); } }; export { ct as default };