zzz-pc-view 0.0.52 → 0.0.54

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zzz-pc-view",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "main": "src/index.umd.js",
5
5
  "module": "src/index.es.js",
6
6
  "types": "src/index.d.ts",
@@ -183,6 +183,13 @@ export declare class CurdApi<T extends object = object, P extends PaginationResp
183
183
  * @returns {Promise<any>} - 返回一个包含导出结果的Promise。
184
184
  */
185
185
  export(query?: T | Reactive<T>): httpRequest.HttpRequestPromise<void>;
186
+ /**
187
+ * 生成 API 请求的完整路径。
188
+ * 该方法会将基础路径和可选的子路径拼接起来,形成一个完整的 API 请求路径。
189
+ * @param {string} [subpath=''] - 可选的子路径,默认为空字符串。
190
+ * @returns {string} - 返回拼接后的完整 API 请求路径。
191
+ */
192
+ protected getApiPath(subpath?: string): string;
186
193
  /**
187
194
  * 获取数据对象的ID。
188
195
  * @param {T} data - 包含ID的数据对象。
package/src/index.es.js CHANGED
@@ -2389,7 +2389,30 @@ const setRoutes = (option) => {
2389
2389
  });
2390
2390
  };
2391
2391
  const navTreeRef = shallowRef(list$1);
2392
- const navChildrenMapRef = shallowRef(object);
2392
+ const navWithoutButtonsComputed = computed(() => toFlat(navTreeRef.value, "children"));
2393
+ const navWithoutButtonsMapComputed = computed(
2394
+ () => toKeyValue(navWithoutButtonsComputed.value, "id")
2395
+ );
2396
+ const navFoldersComputed = computed(
2397
+ () => navWithoutButtonsComputed.value.filter(
2398
+ (nav) => nav.type === 1
2399
+ /* FOLDER */
2400
+ )
2401
+ );
2402
+ const navMenusComputed = computed(
2403
+ () => navWithoutButtonsComputed.value.filter(
2404
+ (nav) => nav.type === 2
2405
+ /* MENU */
2406
+ )
2407
+ );
2408
+ const navButtonsRef = shallowRef([]);
2409
+ const navMenuButtonMapComputed = computed(() => toKeyValues(navButtonsRef.value, "parentId"));
2410
+ const navsComputed = computed(() => [...navWithoutButtonsComputed.value, ...navButtonsRef.value]);
2411
+ const navMapComputed = computed(() => toKeyValue(navsComputed.value, "id"));
2412
+ const setMenuButtons = (navButtons) => {
2413
+ const navWithoutButtonsMap = navWithoutButtonsMapComputed.value;
2414
+ navButtonsRef.value = navButtons.filter((navButton) => navWithoutButtonsMap[navButton.parentId]);
2415
+ };
2393
2416
  const setNavTree = (navFolders, navMenus, navLinks) => {
2394
2417
  const buildList = navMenus.filter((navMenu) => !navMenu.isHide);
2395
2418
  buildList.push(...navLinks);
@@ -2417,23 +2440,6 @@ const setNavTree = (navFolders, navMenus, navLinks) => {
2417
2440
  childrenMap[key2] = sort(childrenMap[key2], "orderNo");
2418
2441
  }
2419
2442
  navTreeRef.value = sort(roots, "orderNo");
2420
- navChildrenMapRef.value = childrenMap;
2421
- };
2422
- const menuButtonMapRef = shallowRef({});
2423
- const setMenuButtonMap = (navButtons) => {
2424
- menuButtonMapRef.value = toKeyValues(navButtons, "parentId");
2425
- };
2426
- const navsRef = shallowRef(list$1);
2427
- const navMapComputed = computed(() => toKeyValue(navsRef.value, "id"));
2428
- const navFoldersRef = shallowRef(list$1);
2429
- const navMenusRef = shallowRef(list$1);
2430
- const navButtonsRef = shallowRef(list$1);
2431
- const setNavsCategory = (navsCategory) => {
2432
- const { navFolders, navMenus, navLinks, navButtons } = navsCategory;
2433
- navsRef.value = [...navFolders, ...navMenus, ...navLinks, ...navButtons];
2434
- navFoldersRef.value = navFolders;
2435
- navMenusRef.value = [...navMenus, ...navLinks];
2436
- navButtonsRef.value = navButtons;
2437
2443
  };
2438
2444
  const setNavs = (option) => {
2439
2445
  const pageViewMap = getComponentViewMap(option.pageViewMap);
@@ -2441,33 +2447,25 @@ const setNavs = (option) => {
2441
2447
  const { navMenus, navButtons } = navsCategory;
2442
2448
  setRoutes({
2443
2449
  RootPageView: option.RootPageView,
2444
- // 根页面视图
2445
2450
  navMenus,
2446
- // 导航菜单
2447
2451
  pageViewMap,
2448
- // 页面视图映射
2449
2452
  navButtons,
2450
- // 导航按钮
2451
2453
  NotFoundPageView: option.NotFoundPageView
2452
- // 404页面视图
2453
2454
  });
2454
2455
  setNavTree(navsCategory.navFolders, navsCategory.navMenus, navsCategory.navLinks);
2455
- setMenuButtonMap(navButtons);
2456
- setNavsCategory(navsCategory);
2456
+ setMenuButtons(navButtons);
2457
2457
  };
2458
2458
  const clear = (option) => {
2459
2459
  navTreeRef.value = list$1;
2460
- navsRef.value = list$1;
2461
- navFoldersRef.value = list$1;
2462
- navMenusRef.value = list$1;
2463
2460
  navButtonsRef.value = list$1;
2464
- menuButtonMapRef.value = object;
2465
- navChildrenMapRef.value = object;
2466
2461
  if (option) {
2467
2462
  const { path } = option;
2468
2463
  router.addRoute({
2464
+ // 根路由的名称
2469
2465
  name: ROOT_ROUTE_NAME,
2466
+ // 根路由的路径
2470
2467
  path,
2468
+ // 根路由对应的组件
2471
2469
  component: option.PageView
2472
2470
  });
2473
2471
  router.replace(path).then(() => {
@@ -2536,61 +2534,52 @@ const response = {
2536
2534
  return navTreeRef.value;
2537
2535
  },
2538
2536
  /**
2539
- * 获取所有导航项的 getter 方法。
2540
- * 返回一个包含所有导航项的数组,这些导航项存储在 navsRef 引用中。
2541
- * @returns {ZNav[]} - 所有导航项的数组
2537
+ * 获取包含所有导航项的数组的 getter 方法。
2538
+ * 该方法返回 `navsComputed` 计算属性的值,包含所有的导航项,方便统一处理导航项。
2539
+ * @returns {ZNav[]} - 包含所有导航项的数组。
2542
2540
  */
2543
2541
  get navs() {
2544
- return navsRef.value;
2542
+ return navsComputed.value;
2545
2543
  },
2546
2544
  /**
2547
2545
  * 获取导航项 ID 到导航项对象的映射的 getter 方法。
2548
- * 该方法返回 `navMapComputed` 计算属性的值,此值是一个映射,
2549
- * 可以通过导航项的 ID 快速查找对应的导航项对象。
2550
- * @returns {Record<ZNav['id'], ZNav>} - 导航项 ID 到导航项对象的映射
2546
+ * 该方法返回 `navMapComputed` 计算属性的值,键为导航项的 ID,值为对应的导航项对象,方便通过 ID 快速查找导航项。
2547
+ * @returns {Record<ZNav['id'], ZNav>} - 导航项 ID 到导航项对象的映射。
2551
2548
  */
2552
2549
  get navMap() {
2553
2550
  return navMapComputed.value;
2554
2551
  },
2555
2552
  /**
2556
- * 获取导航目录项的 getter 方法。
2557
- * 返回一个包含所有导航目录项的数组,这些导航目录项存储在 navFoldersRef 引用中。
2558
- * @returns {ZNavFolder[]} - 导航目录项的数组
2553
+ * 获取导航目录项数组的 getter 方法。
2554
+ * 该方法返回 `navFoldersComputed` 计算属性的值,包含所有的导航目录项。
2555
+ * @returns {ZNavFolder[]} - 导航目录项数组。
2559
2556
  */
2560
2557
  get navFolders() {
2561
- return navFoldersRef.value;
2558
+ return navFoldersComputed.value;
2562
2559
  },
2563
2560
  /**
2564
- * 获取导航菜单和导航链接项的 getter 方法。
2565
- * 返回一个包含所有导航菜单和导航链接项的数组,这些项存储在 navMenusRef 引用中。
2566
- * @returns {(ZNavMenu | ZNavLink)[]} - 导航菜单和导航链接项的数组
2561
+ * 获取导航菜单项数组的 getter 方法。
2562
+ * 该方法返回 `navMenusComputed` 计算属性的值,包含所有的导航菜单项。
2563
+ * @returns {ZNavMenu[]} - 导航菜单项数组。
2567
2564
  */
2568
2565
  get navMenus() {
2569
- return navMenusRef.value;
2566
+ return navMenusComputed.value;
2570
2567
  },
2571
2568
  /**
2572
- * 获取导航按钮项的 getter 方法。
2573
- * 返回一个包含所有导航按钮项的数组,这些导航按钮项存储在 navButtonsRef 引用中。
2574
- * @returns {ZNavButton[]} - 导航按钮项的数组
2569
+ * 获取导航按钮项数组的 getter 方法。
2570
+ * 该方法返回 `navButtonsRef` 浅引用的值,包含所有的导航按钮项。
2571
+ * @returns {ZNavButton[]} - 导航按钮项数组。
2575
2572
  */
2576
2573
  get navButtons() {
2577
2574
  return navButtonsRef.value;
2578
2575
  },
2579
2576
  /**
2580
- * 获取菜单按钮映射的 getter 方法。
2581
- * 返回一个包含所有菜单按钮的映射对象,其中键为父级导航项的 ID,值为该父级导航项下的按钮数组。
2582
- * @returns {Record<ZBaseNav['id'], ZNavButton[]>} - 菜单按钮映射对象
2577
+ * 获取父级导航项 ID 到导航按钮项数组的映射的 getter 方法。
2578
+ * 该方法返回 `navMenuButtonMapComputed` 计算属性的值,键为父级导航项的 ID,值为该父级导航项下的导航按钮项数组,方便通过父级导航项 ID 快速查找对应的导航按钮项。
2579
+ * @returns {Record<ZNavButton['parentId'], ZNavButton[]>} - 父级导航项 ID 到导航按钮项数组的映射。
2583
2580
  */
2584
- get menuButtonMap() {
2585
- return menuButtonMapRef.value;
2586
- },
2587
- /**
2588
- * 获取导航目录的子导航项映射的 getter 方法。
2589
- * @type {Function}
2590
- * @returns {Record<ZNavFolder['id'], ZNavWithoutButton[]>} - 导航目录的子导航项映射。
2591
- */
2592
- get navChildrenMap() {
2593
- return navChildrenMapRef.value;
2581
+ get navMenuButtonMap() {
2582
+ return navMenuButtonMapComputed.value;
2594
2583
  },
2595
2584
  /**
2596
2585
  * 获取当前路由对应的根导航目录的 getter 方法。
@@ -3553,7 +3542,7 @@ class CurdApi {
3553
3542
  // 发起GET请求,获取列表数据
3554
3543
  api({
3555
3544
  // 构建请求URL,包括基础路径和查询参数
3556
- url: `${this.basePath}/list${stringify(query)}`,
3545
+ url: `${this.getApiPath("/list")}${stringify(query)}`,
3557
3546
  // 设置请求方法为GET
3558
3547
  method: "GET"
3559
3548
  }),
@@ -3588,7 +3577,7 @@ class CurdApi {
3588
3577
  return bindThenAjaxSource(
3589
3578
  api({
3590
3579
  // 构造请求 URL,包含基础路径
3591
- url: `${this.basePath}/page`,
3580
+ url: this.getApiPath("/page"),
3592
3581
  // 设置请求方法为 POST
3593
3582
  method: "POST",
3594
3583
  // 合并分页参数和查询参数
@@ -3608,7 +3597,7 @@ class CurdApi {
3608
3597
  return bindThenAjaxSource(
3609
3598
  // 使用 api 函数创建一个API请求配置对象,设置请求的URL和方法
3610
3599
  api({
3611
- url: `${this.basePath}/${this.getId(data)}`,
3600
+ url: `${this.getApiPath()}/${this.getId(data)}`,
3612
3601
  method: "GET"
3613
3602
  }),
3614
3603
  // 在请求成功后,将返回的数据绑定到目标类,并返回绑定后的对象
@@ -3637,7 +3626,7 @@ class CurdApi {
3637
3626
  }
3638
3627
  return api({
3639
3628
  // 构造请求 URL,包含基础路径
3640
- url: `${this.basePath}`,
3629
+ url: this.getApiPath(),
3641
3630
  // 设置请求方法为根据 saveTypeId 获取的方法
3642
3631
  method: editTypeMap[saveTypeId].method,
3643
3632
  // 扩展请求参数
@@ -3652,7 +3641,7 @@ class CurdApi {
3652
3641
  delete(data) {
3653
3642
  return api({
3654
3643
  // 构造请求 URL,包含基础路径和数据的 ID
3655
- url: `${this.basePath}/${this.getId(data)}`,
3644
+ url: `${this.getApiPath()}/${this.getId(data)}`,
3656
3645
  // 设置请求方法为 DELETE
3657
3646
  method: "DELETE"
3658
3647
  });
@@ -3666,7 +3655,7 @@ class CurdApi {
3666
3655
  changeState(data, state) {
3667
3656
  return api({
3668
3657
  // 构造请求 URL,包含基础路径和状态路径
3669
- url: `${this.basePath}/state`,
3658
+ url: this.getApiPath("/state"),
3670
3659
  // 设置请求方法为 PUT
3671
3660
  method: "PUT",
3672
3661
  // 设置请求数据,包含数据的 ID 和新的状态值
@@ -3688,7 +3677,7 @@ class CurdApi {
3688
3677
  return bindThenAjaxSource(
3689
3678
  // 使用api方法发送一个POST请求到指定的URL,请求体为查询参数,响应类型为blob
3690
3679
  api({
3691
- url: `${this.basePath}/export`,
3680
+ url: this.getApiPath("/export"),
3692
3681
  method: "POST",
3693
3682
  data: query,
3694
3683
  responseType: "blob"
@@ -3700,6 +3689,15 @@ class CurdApi {
3700
3689
  }
3701
3690
  );
3702
3691
  }
3692
+ /**
3693
+ * 生成 API 请求的完整路径。
3694
+ * 该方法会将基础路径和可选的子路径拼接起来,形成一个完整的 API 请求路径。
3695
+ * @param {string} [subpath=''] - 可选的子路径,默认为空字符串。
3696
+ * @returns {string} - 返回拼接后的完整 API 请求路径。
3697
+ */
3698
+ getApiPath(subpath = "") {
3699
+ return `${this.basePath}${subpath}`;
3700
+ }
3703
3701
  /**
3704
3702
  * 获取数据对象的ID。
3705
3703
  * @param {T} data - 包含ID的数据对象。
@@ -11022,6 +11020,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11022
11020
  __name: "CurdFormOperatorView",
11023
11021
  props: {
11024
11022
  operatorComponents: {},
11023
+ size: {},
11025
11024
  viewHandler: {}
11026
11025
  },
11027
11026
  setup(__props) {
@@ -11039,6 +11038,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11039
11038
  disabled: _ctx.viewHandler.formDisabled || _ctx.viewHandler.formStepIndex === 0,
11040
11039
  type: "info",
11041
11040
  icon: "ArrowLeft",
11041
+ size: _ctx.size,
11042
11042
  plain: "",
11043
11043
  onClick: _cache[0] || (_cache[0] = ($event) => onStepBtnClick(-1))
11044
11044
  }, {
@@ -11046,10 +11046,11 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11046
11046
  createTextVNode("上一步")
11047
11047
  ])),
11048
11048
  _: 1
11049
- }, 8, ["disabled"]),
11049
+ }, 8, ["disabled", "size"]),
11050
11050
  createVNode(_component_el_button, {
11051
11051
  disabled: _ctx.viewHandler.formDisabled || _ctx.viewHandler.formStepIndex === _ctx.viewHandler.displayStepFormItemsGroup.length - 1,
11052
11052
  type: "info",
11053
+ size: _ctx.size,
11053
11054
  plain: "",
11054
11055
  onClick: _cache[1] || (_cache[1] = ($event) => onStepBtnClick(1))
11055
11056
  }, {
@@ -11063,7 +11064,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11063
11064
  })
11064
11065
  ]),
11065
11066
  _: 1
11066
- }, 8, ["disabled"])
11067
+ }, 8, ["disabled", "size"])
11067
11068
  ], 64)) : createCommentVNode("", true),
11068
11069
  Array.isArray(_ctx.operatorComponents) ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.operatorComponents, (operatorComponent, index2) => {
11069
11070
  return openBlock(), createBlock(resolveDynamicComponent(operatorComponent), {
@@ -11075,6 +11076,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11075
11076
  key: 2,
11076
11077
  disabled: _ctx.viewHandler.formDisabled || _ctx.viewHandler.formStepIndex !== _ctx.viewHandler.displayStepFormItemsGroup.length - 1,
11077
11078
  icon: "SaveSvg",
11079
+ size: _ctx.size,
11078
11080
  type: "primary",
11079
11081
  onClick: _ctx.viewHandler.onSaveBtnClick
11080
11082
  }, {
@@ -11082,11 +11084,12 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11082
11084
  createTextVNode("保存")
11083
11085
  ])),
11084
11086
  _: 1
11085
- }, 8, ["disabled", "onClick"])) : createCommentVNode("", true),
11087
+ }, 8, ["disabled", "size", "onClick"])) : createCommentVNode("", true),
11086
11088
  _ctx.viewHandler.editType.id === unref(ZDecorators).CurdKey.EditTypeEnum.CREATE ? (openBlock(), createBlock(_component_el_button, {
11087
11089
  key: 3,
11088
11090
  disabled: _ctx.viewHandler.formDisabled || _ctx.viewHandler.formStepIndex !== _ctx.viewHandler.displayStepFormItemsGroup.length - 1,
11089
11091
  icon: "SaveContinueSvg",
11092
+ size: _ctx.size,
11090
11093
  type: "success",
11091
11094
  plain: "",
11092
11095
  onClick: _ctx.viewHandler.onSaveContinueBtnClick
@@ -11095,7 +11098,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
11095
11098
  createTextVNode("保存并继续")
11096
11099
  ])),
11097
11100
  _: 1
11098
- }, 8, ["disabled", "onClick"])) : createCommentVNode("", true),
11101
+ }, 8, ["disabled", "size", "onClick"])) : createCommentVNode("", true),
11099
11102
  createVNode(_component_el_button, {
11100
11103
  disabled: _ctx.viewHandler.saveEditorDataLoadStatus,
11101
11104
  icon: "Close",
@@ -11377,6 +11380,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
11377
11380
  footer: withCtx(() => [
11378
11381
  createVNode(_sfc_main$f, {
11379
11382
  "view-handler": _ctx.viewHandler,
11383
+ size: "large",
11380
11384
  class: "align-left"
11381
11385
  }, null, 8, ["view-handler"])
11382
11386
  ]),