com-angel-authorization 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -616,7 +616,7 @@ function mapMenuResource(item) {
616
616
  );
617
617
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
618
618
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
619
- const rawParentId = row.parentId ?? row.parent_id;
619
+ const rawParentId = row.parentId ?? row.parent_id ?? (row.parent && typeof row.parent === "object" ? row.parent.resourceId ?? row.parent.resource_id ?? row.parent.id : void 0);
620
620
  const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
621
621
  const rawDepth = row.depth;
622
622
  const parsedDepth = Number(rawDepth);
@@ -773,7 +773,11 @@ function createMenuResourceApi(request) {
773
773
  url: `/authorization-resources/${encodeURIComponent(resourceId)}/sub-resources`,
774
774
  signal
775
775
  });
776
- return extractRecords(json).map(mapMenuResource).filter((item) => item !== null);
776
+ return extractRecords(json).map(mapMenuResource).filter((item) => item !== null).map((item) => ({
777
+ ...item,
778
+ // 子资源接口常不回 parentId,用请求路径上的父级补齐
779
+ parentId: item.parentId ?? resourceId
780
+ }));
777
781
  },
778
782
  listPermissionPoints(params, signal) {
779
783
  return permissionApi.list(params, signal);
@@ -1831,6 +1835,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1831
1835
  const saving = (0, import_vue4.ref)(false);
1832
1836
  const deletingRow = (0, import_vue4.ref)(null);
1833
1837
  const deleting = (0, import_vue4.ref)(false);
1838
+ const permissionKeyword = (0, import_vue4.ref)("");
1834
1839
  const permissionNameMap = (0, import_vue4.computed)(() => {
1835
1840
  const map = /* @__PURE__ */ new Map();
1836
1841
  permissionPoints.value.forEach(
@@ -1838,6 +1843,13 @@ var MenuManager = (0, import_vue4.defineComponent)({
1838
1843
  );
1839
1844
  return map;
1840
1845
  });
1846
+ const filteredPermissionPoints = (0, import_vue4.computed)(() => {
1847
+ const kw = permissionKeyword.value.trim().toLowerCase();
1848
+ if (!kw) return permissionPoints.value;
1849
+ return permissionPoints.value.filter(
1850
+ (p) => p.name.toLowerCase().includes(kw) || p.identification.toLowerCase().includes(kw)
1851
+ );
1852
+ });
1841
1853
  const allKnownMenus = (0, import_vue4.computed)(() => {
1842
1854
  const map = /* @__PURE__ */ new Map();
1843
1855
  records.value.forEach((row) => map.set(row.resourceId, row));
@@ -1846,12 +1858,31 @@ var MenuManager = (0, import_vue4.defineComponent)({
1846
1858
  });
1847
1859
  return Array.from(map.values());
1848
1860
  });
1849
- const parentOptions = (0, import_vue4.computed)(
1850
- () => allKnownMenus.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1861
+ function resolveRowParentId(row) {
1862
+ if (row.parentId) return row.parentId;
1863
+ for (const [parentId, children] of Object.entries(childrenMap.value)) {
1864
+ if (children.some((child) => child.resourceId === row.resourceId)) {
1865
+ return parentId;
1866
+ }
1867
+ }
1868
+ return null;
1869
+ }
1870
+ const parentOptions = (0, import_vue4.computed)(() => {
1871
+ const opts = allKnownMenus.value.filter((row) => !editing.value || row.resourceId !== editing.value.resourceId).map((row) => ({
1851
1872
  value: row.resourceId,
1852
1873
  label: `${row.name}\uFF08${MENU_TYPE_LABEL[row.type]}\uFF09`
1853
- }))
1854
- );
1874
+ }));
1875
+ if (form.parentId && !opts.some((opt) => opt.value === form.parentId)) {
1876
+ const parent = allKnownMenus.value.find(
1877
+ (row) => row.resourceId === form.parentId
1878
+ );
1879
+ opts.unshift({
1880
+ value: form.parentId,
1881
+ label: parent ? `${parent.name}\uFF08${MENU_TYPE_LABEL[parent.type]}\uFF09` : form.parentId
1882
+ });
1883
+ }
1884
+ return opts;
1885
+ });
1855
1886
  const flatRows = (0, import_vue4.computed)(() => {
1856
1887
  const rows = [];
1857
1888
  const walk = (list) => {
@@ -1924,6 +1955,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1924
1955
  }
1925
1956
  function openCreate(parent) {
1926
1957
  editing.value = null;
1958
+ permissionKeyword.value = "";
1927
1959
  if (parent) {
1928
1960
  Object.assign(form, {
1929
1961
  ...emptyForm2(),
@@ -1937,10 +1969,12 @@ var MenuManager = (0, import_vue4.defineComponent)({
1937
1969
  void loadPermissionPoints();
1938
1970
  }
1939
1971
  function openEdit(row) {
1972
+ const parentId = resolveRowParentId(row);
1940
1973
  editing.value = row;
1974
+ permissionKeyword.value = "";
1941
1975
  Object.assign(form, {
1942
- parentId: row.parentId ?? null,
1943
- depth: resolveMenuDepth(row.parentId ?? null, allKnownMenus.value),
1976
+ parentId,
1977
+ depth: row.depth > 0 ? row.depth : resolveMenuDepth(parentId, allKnownMenus.value),
1944
1978
  type: row.type,
1945
1979
  name: row.name,
1946
1980
  identification: row.identification,
@@ -1952,7 +1986,10 @@ var MenuManager = (0, import_vue4.defineComponent)({
1952
1986
  void loadPermissionPoints();
1953
1987
  }
1954
1988
  function closeDialog() {
1955
- if (!saving.value) dialogOpen.value = false;
1989
+ if (!saving.value) {
1990
+ dialogOpen.value = false;
1991
+ permissionKeyword.value = "";
1992
+ }
1956
1993
  }
1957
1994
  async function handleSubmit(event) {
1958
1995
  event.preventDefault();
@@ -2300,6 +2337,21 @@ var MenuManager = (0, import_vue4.defineComponent)({
2300
2337
  ]),
2301
2338
  (0, import_vue4.h)("fieldset", { style: s2.fieldset }, [
2302
2339
  (0, import_vue4.h)("legend", { style: s2.label }, "\u6743\u9650\u6807\u8BC6"),
2340
+ permissionPoints.value.length > 0 ? [
2341
+ (0, import_vue4.h)("input", {
2342
+ style: { ...s2.input, marginBottom: "8px" },
2343
+ value: permissionKeyword.value,
2344
+ placeholder: "\u641C\u7D22\u6743\u9650\u540D\u79F0 / \u6807\u8BC6",
2345
+ onInput: (e) => {
2346
+ permissionKeyword.value = e.target.value;
2347
+ }
2348
+ }),
2349
+ (0, import_vue4.h)(
2350
+ "div",
2351
+ { style: s2.hint },
2352
+ permissionKeyword.value.trim() ? `\u5DF2\u9009 ${form.permissionPointIds.length} \u9879 \xB7 \u5339\u914D ${filteredPermissionPoints.value.length} / ${permissionPoints.value.length}` : `\u5DF2\u9009 ${form.permissionPointIds.length} \u9879 \xB7 \u5171 ${permissionPoints.value.length} \u9879`
2353
+ )
2354
+ ] : null,
2303
2355
  (0, import_vue4.h)(
2304
2356
  "div",
2305
2357
  { style: s2.multiSelect },
@@ -2309,7 +2361,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
2309
2361
  { style: s2.hint },
2310
2362
  "\u6682\u65E0\u6743\u9650\u70B9\uFF0C\u8BF7\u5148\u5728\u6743\u9650\u70B9\u7BA1\u7406\u4E2D\u65B0\u589E"
2311
2363
  )
2312
- ] : permissionPoints.value.map(
2364
+ ] : filteredPermissionPoints.value.length === 0 ? [(0, import_vue4.h)("div", { style: s2.hint }, "\u65E0\u5339\u914D\u6743\u9650\u70B9")] : filteredPermissionPoints.value.map(
2313
2365
  (p) => (0, import_vue4.h)(
2314
2366
  "label",
2315
2367
  { key: p.resourceId, style: s2.checkItem },