bm-admin-ui 1.2.55-alpha → 1.2.57-alpha

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.
@@ -116,6 +116,7 @@ declare const BmStaffsSelector: import("bm-admin-ui/es/utils/with-install").SFCW
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {
@@ -556,7 +556,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
556
556
  _ctx.list && !_ctx.list.length ? (openBlock(), createElementBlock("div", _hoisted_7, [
557
557
  createVNode(_component_Empty, { image: _ctx.emptyPic }, {
558
558
  description: withCtx(() => [
559
- createElementVNode("span", _hoisted_8, toDisplayString(!!_ctx.searched ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u4EBA\u5458\u5173\u952E\u5B57"), 1)
559
+ createElementVNode("span", _hoisted_8, toDisplayString(!!_ctx.searched ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u90E8\u95E8\u5173\u952E\u8BCD"), 1)
560
560
  ]),
561
561
  _: 1
562
562
  }, 8, ["image"])
@@ -693,13 +693,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
693
693
  function getOptionName(key) {
694
694
  let data = selectState.dataMap.get(String(key));
695
695
  if (data && data.title)
696
- return `${data.title}`;
696
+ return `${data.title}${data.key ? `(${data.key})` : ""}${data.description ? `-(${data.description})` : ""}`;
697
697
  let arr = props.select;
698
698
  arr = arr.length ? arr : [];
699
699
  let had = arr.find(
700
700
  (item) => String(item) === String(key) || String(item?.key) === String(key)
701
701
  );
702
- return had?.title ? `${had.title}` : had;
702
+ return had?.title ? `${had.title}${had.key ? `(${had.key})` : ""}${had.description ? `-(${had.description})` : ""}` : had;
703
+ }
704
+ function findParentNode(tree, targetId, parent = null) {
705
+ for (const node of tree) {
706
+ if (node.id === targetId) {
707
+ return parent;
708
+ }
709
+ if (node.children && Array.isArray(node.children)) {
710
+ const found = findParentNode(node.children, targetId, node);
711
+ if (found !== null) {
712
+ return found;
713
+ }
714
+ }
715
+ }
716
+ return null;
703
717
  }
704
718
  function deleteOptions(key) {
705
719
  if (props.mode === MODE.MULTIPLE) {
@@ -707,10 +721,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
707
721
  selectState.multipleChecked[String(key)] = false;
708
722
  }
709
723
  } else if (props.mode === MODE.DEPARTMENT) {
710
- let index = selectState.multipDepartment.findIndex(
711
- (item) => String(item) === String(key)
724
+ const keyStr = String(key);
725
+ const parentNode = findParentNode(list.value, key);
726
+ const parentKeyStr = parentNode ? String(parentNode.id) : null;
727
+ selectState.multipDepartment = selectState.multipDepartment.filter(
728
+ (item) => {
729
+ const itemStr = String(item);
730
+ return itemStr !== keyStr && itemStr !== parentKeyStr;
731
+ }
712
732
  );
713
- index > -1 && selectState.multipDepartment.splice(index, 1);
714
733
  }
715
734
  }
716
735
  function onLoadData(treeNode, list2) {
@@ -116,6 +116,7 @@ declare const _default: import("vue").DefineComponent<{
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {
@@ -116,6 +116,7 @@ declare const BmStaffsSelector: import("bm-admin-ui/es/utils/with-install").SFCW
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {
@@ -560,7 +560,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
560
560
  _ctx.list && !_ctx.list.length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
561
561
  vue.createVNode(_component_Empty, { image: _ctx.emptyPic }, {
562
562
  description: vue.withCtx(() => [
563
- vue.createElementVNode("span", _hoisted_8, vue.toDisplayString(!!_ctx.searched ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u4EBA\u5458\u5173\u952E\u5B57"), 1)
563
+ vue.createElementVNode("span", _hoisted_8, vue.toDisplayString(!!_ctx.searched ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u90E8\u95E8\u5173\u952E\u8BCD"), 1)
564
564
  ]),
565
565
  _: 1
566
566
  }, 8, ["image"])
@@ -697,13 +697,27 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
697
697
  function getOptionName(key) {
698
698
  let data = selectState.dataMap.get(String(key));
699
699
  if (data && data.title)
700
- return `${data.title}`;
700
+ return `${data.title}${data.key ? `(${data.key})` : ""}${data.description ? `-(${data.description})` : ""}`;
701
701
  let arr = props.select;
702
702
  arr = arr.length ? arr : [];
703
703
  let had = arr.find(
704
704
  (item) => String(item) === String(key) || String(item?.key) === String(key)
705
705
  );
706
- return had?.title ? `${had.title}` : had;
706
+ return had?.title ? `${had.title}${had.key ? `(${had.key})` : ""}${had.description ? `-(${had.description})` : ""}` : had;
707
+ }
708
+ function findParentNode(tree, targetId, parent = null) {
709
+ for (const node of tree) {
710
+ if (node.id === targetId) {
711
+ return parent;
712
+ }
713
+ if (node.children && Array.isArray(node.children)) {
714
+ const found = findParentNode(node.children, targetId, node);
715
+ if (found !== null) {
716
+ return found;
717
+ }
718
+ }
719
+ }
720
+ return null;
707
721
  }
708
722
  function deleteOptions(key) {
709
723
  if (props.mode === MODE.MULTIPLE) {
@@ -711,10 +725,15 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
711
725
  selectState.multipleChecked[String(key)] = false;
712
726
  }
713
727
  } else if (props.mode === MODE.DEPARTMENT) {
714
- let index = selectState.multipDepartment.findIndex(
715
- (item) => String(item) === String(key)
728
+ const keyStr = String(key);
729
+ const parentNode = findParentNode(list.value, key);
730
+ const parentKeyStr = parentNode ? String(parentNode.id) : null;
731
+ selectState.multipDepartment = selectState.multipDepartment.filter(
732
+ (item) => {
733
+ const itemStr = String(item);
734
+ return itemStr !== keyStr && itemStr !== parentKeyStr;
735
+ }
716
736
  );
717
- index > -1 && selectState.multipDepartment.splice(index, 1);
718
737
  }
719
738
  }
720
739
  function onLoadData(treeNode, list2) {
@@ -116,6 +116,7 @@ declare const _default: import("vue").DefineComponent<{
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm-admin-ui",
3
- "version": "1.2.55-alpha",
3
+ "version": "1.2.57-alpha",
4
4
  "private": false,
5
5
  "description": "An Admin Component Library for Bm",
6
6
  "license": "UNLICENSED",
@@ -116,6 +116,7 @@ declare const BmStaffsSelector: import("bm-admin-ui/es/utils/with-install").SFCW
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {
@@ -116,6 +116,7 @@ declare const _default: import("vue").DefineComponent<{
116
116
  findDataByKey: (key: string) => any;
117
117
  summitSelect: () => void;
118
118
  getOptionName: (key: any) => any;
119
+ findParentNode: (tree: any, targetId: any, parent?: null) => any;
119
120
  deleteOptions: (key: any) => void;
120
121
  onLoadData: (treeNode: any, list: any) => any;
121
122
  AModal: {