ibiz-template-plugin.es.js 13.2 KB
Newer Older
lxm1993's avatar
lxm1993 committed
1 2
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;
lxm1993's avatar
lxm1993 committed
3 4 5 6 7
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";
lxm1993's avatar
lxm1993 committed
8
import { defineComponent as L, ref as f, getCurrentInstance as C, onMounted as I, h as t, watch as J, onUnmounted as H } from "vue";
lxm1993's avatar
lxm1993 committed
9 10
import { Tooltip as w, Button as A, Icon as F } from "view-design";
import { CounterService as K } from "@ibiz-template/service";
lxm1993's avatar
lxm1993 committed
11
const g = new U(import.meta.url);
lxm1993's avatar
lxm1993 committed
12 13
const Q = L({
  name: "AppPortalListPortlet",
chitanda's avatar
chitanda committed
14
  props: {
lxm1993's avatar
lxm1993 committed
15 16
    modelData: {
      type: z,
chitanda's avatar
chitanda committed
17 18
      required: !0
    },
lxm1993's avatar
lxm1993 committed
19 20
    controller: {
      type: D,
chitanda's avatar
chitanda committed
21 22 23
      required: !0
    }
  },
lxm1993's avatar
lxm1993 committed
24
  setup(s) {
lxm1993's avatar
lxm1993 committed
25
    const n = k("app-portal-list-portlet"), e = f([]), p = Array.from({
lxm1993's avatar
lxm1993 committed
26
      length: 3
lxm1993's avatar
lxm1993 committed
27
    }).map((c, i) => g.dir(`/assets/img/app-portal-list-${i}.svg`)), l = C();
lxm1993's avatar
lxm1993 committed
28 29 30 31 32 33 34
    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);
        });
chitanda's avatar
chitanda committed
35
      });
lxm1993's avatar
lxm1993 committed
36
    }
chitanda's avatar
chitanda committed
37
    return {
lxm1993's avatar
lxm1993 committed
38 39 40 41 42 43
      ns: n,
      appPortalList: e,
      appPortalImgList: p,
      openPage: (c) => {
        c && window.open(c);
      }
chitanda's avatar
chitanda committed
44 45 46
    };
  },
  render() {
lxm1993's avatar
lxm1993 committed
47 48 49 50 51
    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,
chitanda's avatar
chitanda committed
52
      on: {
lxm1993's avatar
lxm1993 committed
53
        click: () => this.openPage(s.url)
chitanda's avatar
chitanda committed
54
      }
lxm1993's avatar
lxm1993 committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68
    }, [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]
      }
    })])]))]);
chitanda's avatar
chitanda committed
69 70
  }
});
lxm1993's avatar
lxm1993 committed
71
class V {
lxm1993's avatar
lxm1993 committed
72
  constructor() {
lxm1993's avatar
lxm1993 committed
73
    y(this, "component", Q);
lxm1993's avatar
lxm1993 committed
74
  }
lxm1993's avatar
lxm1993 committed
75 76 77 78 79 80 81
  async createController(n, e, p) {
    const l = new D(
      n,
      e,
      p
    );
    return await l.init(), l;
lxm1993's avatar
lxm1993 committed
82 83
  }
}
lxm1993's avatar
lxm1993 committed
84 85
const T = L({
  name: "FuncDrawer",
chitanda's avatar
chitanda committed
86
  props: {
lxm1993's avatar
lxm1993 committed
87 88 89 90
    isShowDrawer: {
      type: Boolean,
      required: !0,
      default: !1
chitanda's avatar
chitanda committed
91 92
    }
  },
lxm1993's avatar
lxm1993 committed
93 94
  emits: {
    "on-close": () => !0
95
  },
lxm1993's avatar
lxm1993 committed
96 97 98 99
  setup(s, {
    emit: n
  }) {
    var S;
lxm1993's avatar
lxm1993 committed
100
    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 = () => {
lxm1993's avatar
lxm1993 committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
      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;
lxm1993's avatar
lxm1993 committed
116
          }), h.value = Object.keys(r).map((a) => ({
lxm1993's avatar
lxm1993 committed
117 118 119 120 121 122 123 124 125 126 127 128 129
            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) => {
lxm1993's avatar
lxm1993 committed
130
        o.ok && (m == null || m.$Notice.success({
lxm1993's avatar
lxm1993 committed
131 132 133 134 135 136 137 138 139 140 141 142
          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);
      });
lxm1993's avatar
lxm1993 committed
143
    }, v = (o, r) => {
lxm1993's avatar
lxm1993 committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
      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") {
lxm1993's avatar
lxm1993 committed
160
        const P = c.value.findIndex(($) => $.pssysappfuncid === r.pssysappfuncid);
lxm1993's avatar
lxm1993 committed
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
        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),
lxm1993's avatar
lxm1993 committed
191
        dragstart: (a) => v(a, r),
lxm1993's avatar
lxm1993 committed
192 193 194
        dragover: q,
        drop: (a) => _(a, r)
      },
chitanda's avatar
chitanda committed
195
      attrs: {
lxm1993's avatar
lxm1993 committed
196
        draggable: i.value
chitanda's avatar
chitanda committed
197
      }
lxm1993's avatar
lxm1993 committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211
    }, [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: {
lxm1993's avatar
lxm1993 committed
212
        src: o.icon ? g.dir(`/assets/img/${o.icon}`) : p,
lxm1993's avatar
lxm1993 committed
213 214 215 216 217 218 219 220 221
        draggable: !1
      }
    })]), t(w, {
      attrs: {
        content: o.tip,
        disabled: !o.tip
      }
    }, [t("div", {
      class: e.be("group-item", "text")
lxm1993's avatar
lxm1993 committed
222
    }, [o.pssysappfuncname])])]))])]), h.value.map((o, r) => t("div", {
lxm1993's avatar
lxm1993 committed
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
      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: {
lxm1993's avatar
lxm1993 committed
249
        src: a.icon ? g.dir(`/assets/img/${a.icon}`) : p,
lxm1993's avatar
lxm1993 committed
250 251 252 253 254 255 256 257 258 259
        draggable: !1
      }
    })]), t(w, {
      attrs: {
        content: a.tip,
        disabled: !a.tip
      }
    }, [t("div", {
      class: e.be("group-item", "text")
    }, [a.pssysappfuncname])])]))])]))])]);
260
  }
lxm1993's avatar
lxm1993 committed
261 262 263 264 265
}), W = L({
  name: "FuncPortalListPortlet",
  components: {
    FuncDrawer: T
  },
chitanda's avatar
chitanda committed
266
  props: {
lxm1993's avatar
lxm1993 committed
267 268
    modelData: {
      type: z,
chitanda's avatar
chitanda committed
269 270
      required: !0
    },
lxm1993's avatar
lxm1993 committed
271 272
    controller: {
      type: D,
chitanda's avatar
chitanda committed
273 274 275
      required: !0
    }
  },
lxm1993's avatar
lxm1993 committed
276
  setup(s) {
lxm1993's avatar
lxm1993 committed
277
    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();
lxm1993's avatar
lxm1993 committed
278 279 280 281 282
    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();
lxm1993's avatar
lxm1993 committed
283
          h.value = d;
lxm1993's avatar
lxm1993 committed
284
        }
chitanda's avatar
chitanda committed
285
      });
lxm1993's avatar
lxm1993 committed
286
    }));
lxm1993's avatar
lxm1993 committed
287
    const m = (d) => {
lxm1993's avatar
lxm1993 committed
288 289
      d && ibiz.net.get(`/appfuncs/${d}/getfuncurl`).then((v) => {
        v.ok && v.data && v.data.url && window.open(v.data.url);
lxm1993's avatar
lxm1993 committed
290
      });
lxm1993's avatar
lxm1993 committed
291
    }, b = f(!1);
chitanda's avatar
chitanda committed
292
    return {
lxm1993's avatar
lxm1993 committed
293 294 295 296
      ns: n,
      quickEntryImg: e,
      editorImg: p,
      placeholderImg: l,
lxm1993's avatar
lxm1993 committed
297 298
      funcPortalList: h,
      openPage: m,
lxm1993's avatar
lxm1993 committed
299 300 301 302
      isShowDrawer: b,
      isShowDrawerChange: async () => {
        if (b.value = !1, i) {
          const d = await i.load();
lxm1993's avatar
lxm1993 committed
303
          h.value = d;
lxm1993's avatar
lxm1993 committed
304 305
        }
      }
chitanda's avatar
chitanda committed
306 307 308
    };
  },
  render() {
lxm1993's avatar
lxm1993 committed
309
    return t("div", {
chitanda's avatar
chitanda committed
310
      class: this.ns.b()
lxm1993's avatar
lxm1993 committed
311 312 313 314 315 316 317
    }, [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", {
chitanda's avatar
chitanda committed
318
      attrs: {
lxm1993's avatar
lxm1993 committed
319 320 321 322 323 324 325 326 327
        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;
328
        }
chitanda's avatar
chitanda committed
329
      }
lxm1993's avatar
lxm1993 committed
330 331 332
    }, [t("div", {
      class: this.ns.be("header-right", "icon")
    }, [t("img", {
chitanda's avatar
chitanda committed
333
      attrs: {
lxm1993's avatar
lxm1993 committed
334 335 336 337 338 339 340 341 342 343 344
        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,
chitanda's avatar
chitanda committed
345
      on: {
lxm1993's avatar
lxm1993 committed
346
        click: () => this.openPage(s.pssysappfuncid)
chitanda's avatar
chitanda committed
347
      }
lxm1993's avatar
lxm1993 committed
348 349 350
    }, [t("div", {
      class: this.ns.be("item", "icon")
    }, [t("img", {
351
      attrs: {
lxm1993's avatar
lxm1993 committed
352
        src: s.icon ? g.dir(`/assets/img/${s.icon}`) : this.placeholderImg
353
      }
lxm1993's avatar
lxm1993 committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
    })]), 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
      }
    })]);
chitanda's avatar
chitanda committed
369 370
  }
});
lxm1993's avatar
lxm1993 committed
371
class X {
lxm1993's avatar
lxm1993 committed
372
  constructor() {
lxm1993's avatar
lxm1993 committed
373 374 375 376 377 378 379 380 381
    y(this, "component", W);
  }
  async createController(n, e, p) {
    const l = new D(
      n,
      e,
      p
    );
    return await l.init(), l;
lxm1993's avatar
lxm1993 committed
382 383
  }
}
lxm1993's avatar
lxm1993 committed
384 385
const Y = L({
  name: "TodoAppMenuPortlet",
chitanda's avatar
chitanda committed
386
  props: {
lxm1993's avatar
lxm1993 committed
387 388
    modelData: {
      type: B,
chitanda's avatar
chitanda committed
389
      required: !0
390
    },
lxm1993's avatar
lxm1993 committed
391 392 393
    controller: {
      type: E,
      required: !0
chitanda's avatar
chitanda committed
394 395
    }
  },
lxm1993's avatar
lxm1993 committed
396 397 398
  setup(s) {
    const n = k("todo-app-menu-portlet"), e = Array.from({
      length: 5
lxm1993's avatar
lxm1993 committed
399
    }).map((c, i) => g.dir(`/assets/img/todo-app-menu-${i}.svg`));
lxm1993's avatar
lxm1993 committed
400
    let p = null;
lxm1993's avatar
lxm1993 committed
401
    const l = f({});
lxm1993's avatar
lxm1993 committed
402 403 404
    if (s.modelData.appMenu) {
      const i = s.modelData.appMenu.source.getPSAppCounterRef();
      i && (I(async () => {
lxm1993's avatar
lxm1993 committed
405 406
        p = await K.getCounterByRef(i), p.onChange((m) => {
          l.value = m;
lxm1993's avatar
lxm1993 committed
407 408 409 410 411
        });
      }), H(() => {
        p == null || p.destroy();
      }));
    }
chitanda's avatar
chitanda committed
412
    return {
lxm1993's avatar
lxm1993 committed
413 414 415 416 417 418 419 420 421 422 423
      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");
      }
chitanda's avatar
chitanda committed
424 425
    };
  },
lxm1993's avatar
lxm1993 committed
426 427 428 429 430 431 432
  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,
chitanda's avatar
chitanda committed
433
      on: {
lxm1993's avatar
lxm1993 committed
434
        click: () => this.onClickMenuItem(n)
chitanda's avatar
chitanda committed
435
      }
lxm1993's avatar
lxm1993 committed
436 437 438 439 440
    }, [t("div", {
      class: this.ns.b("item-left")
    }, [t("div", {
      class: this.ns.be("item-left", "icon")
    }, [t("img", {
chitanda's avatar
chitanda committed
441
      attrs: {
lxm1993's avatar
lxm1993 committed
442
        src: this.todoImgList[e]
chitanda's avatar
chitanda committed
443
      }
lxm1993's avatar
lxm1993 committed
444 445 446 447 448 449 450
    })])]), 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, {
chitanda's avatar
chitanda committed
451
      attrs: {
lxm1993's avatar
lxm1993 committed
452 453
        content: n.source.tooltip,
        disabled: !n.source.tooltip
chitanda's avatar
chitanda committed
454
      }
lxm1993's avatar
lxm1993 committed
455 456 457
    }, [t("div", {
      class: this.ns.be("item-right", "text")
    }, [n.label])])])]))]);
chitanda's avatar
chitanda committed
458 459
  }
});
lxm1993's avatar
lxm1993 committed
460
class Z {
461
  constructor() {
lxm1993's avatar
lxm1993 committed
462 463 464 465 466 467 468 469 470
    y(this, "component", Y);
  }
  async createController(n, e, p) {
    const l = new E(
      n,
      e,
      p
    );
    return await l.init(), l;
471 472
  }
}
lxm1993's avatar
lxm1993 committed
473
const ct = {
chitanda's avatar
chitanda committed
474
  mateUrl: import.meta.url,
lxm1993's avatar
lxm1993 committed
475 476 477 478 479 480 481 482 483 484
  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()
485 486 487 488
    );
  }
};
export {
lxm1993's avatar
lxm1993 committed
489
  ct as default
490
};