@weitutech/by-components 1.1.96 → 1.1.98

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.
@@ -60503,6 +60503,7 @@ __webpack_require__.r(__webpack_exports__);
60503
60503
  // EXPORTS
60504
60504
  __webpack_require__.d(__webpack_exports__, {
60505
60505
  ByBatchQuerySelector: function() { return /* reexport */ BatchQuerySelector; },
60506
+ ByCascaderPanel: function() { return /* reexport */ ByCascaderPanel; },
60506
60507
  ByCommonSelector: function() { return /* reexport */ ByCommonSelector; },
60507
60508
  ByCustomDatePicker: function() { return /* reexport */ custom_date_picker; },
60508
60509
  ByDatePickerRange: function() { return /* reexport */ date_picker_range; },
@@ -76932,8 +76933,8 @@ var ByTreeSearch_component = normalizeComponent(
76932
76933
  )
76933
76934
 
76934
76935
  /* harmony default export */ var ByTreeSearch = (ByTreeSearch_component.exports);
76935
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"ffbc40de-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/by-dialog/ByDialog.vue?vue&type=template&id=7a5fdd30
76936
- var ByDialogvue_type_template_id_7a5fdd30_render = function render() {
76936
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"ffbc40de-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/by-dialog/ByDialog.vue?vue&type=template&id=75a24552
76937
+ var ByDialogvue_type_template_id_75a24552_render = function render() {
76937
76938
  var _vm = this,
76938
76939
  _c = _vm._self._c;
76939
76940
  return _c('el-dialog', _vm._g(_vm._b({
@@ -76950,11 +76951,9 @@ var ByDialogvue_type_template_id_7a5fdd30_render = function render() {
76950
76951
  }
76951
76952
  }, 'el-dialog', _vm.dialogAttrs, false), _vm.$listeners), [_c('div', {
76952
76953
  staticClass: "by-dialog__body"
76953
- }, [_vm._t("default", function () {
76954
- return [_vm.content ? _c('div', {
76955
- staticClass: "by-dialog__content"
76956
- }, [_vm._v(_vm._s(_vm.content))]) : _vm._e()];
76957
- })], 2), _vm.showFooter ? _c('div', {
76954
+ }, [_vm.content ? _c('div', {
76955
+ staticClass: "by-dialog__content"
76956
+ }, [_vm._v(_vm._s(_vm.content))]) : _vm._e(), _vm._t("default")], 2), _vm.showFooter ? _c('div', {
76958
76957
  staticClass: "by-dialog__footer"
76959
76958
  }, [_c('div', {
76960
76959
  staticClass: "by-dialog__buttons"
@@ -76965,7 +76964,7 @@ var ByDialogvue_type_template_id_7a5fdd30_render = function render() {
76965
76964
  style: button.style,
76966
76965
  attrs: {
76967
76966
  "type": button.type || 'default',
76968
- "size": button.size || 'medium',
76967
+ "size": button.size || 'mini',
76969
76968
  "loading": button.loading,
76970
76969
  "disabled": button.disabled,
76971
76970
  "icon": button.icon
@@ -76978,7 +76977,7 @@ var ByDialogvue_type_template_id_7a5fdd30_render = function render() {
76978
76977
  }, [_vm._v(" " + _vm._s(button.text) + " ")])];
76979
76978
  })], 2), _vm._t("footer")], 2) : _vm._e()]);
76980
76979
  };
76981
- var ByDialogvue_type_template_id_7a5fdd30_staticRenderFns = [];
76980
+ var ByDialogvue_type_template_id_75a24552_staticRenderFns = [];
76982
76981
 
76983
76982
  ;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/by-dialog/ByDialog.vue?vue&type=script&lang=js
76984
76983
  /* harmony default export */ var ByDialogvue_type_script_lang_js = ({
@@ -77117,8 +77116,8 @@ var ByDialogvue_type_template_id_7a5fdd30_staticRenderFns = [];
77117
77116
  ;
77118
77117
  var ByDialog_component = normalizeComponent(
77119
77118
  by_dialog_ByDialogvue_type_script_lang_js,
77120
- ByDialogvue_type_template_id_7a5fdd30_render,
77121
- ByDialogvue_type_template_id_7a5fdd30_staticRenderFns,
77119
+ ByDialogvue_type_template_id_75a24552_render,
77120
+ ByDialogvue_type_template_id_75a24552_staticRenderFns,
77122
77121
  false,
77123
77122
  null,
77124
77123
  null,
@@ -77518,6 +77517,1478 @@ ByDialogService.install = function (Vue) {
77518
77517
  Vue.prototype.$byDialog = ByDialogService;
77519
77518
  };
77520
77519
  /* harmony default export */ var by_dialog_ByDialogService = (ByDialogService);
77520
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"ffbc40de-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel/ByCascaderPanel.vue?vue&type=template&id=d3dd0512
77521
+ var ByCascaderPanelvue_type_template_id_d3dd0512_render = function render() {
77522
+ var _vm = this,
77523
+ _c = _vm._self._c;
77524
+ return _c('div', {
77525
+ staticClass: "by-cascader-panel"
77526
+ }, [_c('div', {
77527
+ staticClass: "cascade-box row"
77528
+ }, [_c('div', {
77529
+ staticClass: "cascade-container left-panel"
77530
+ }, [_c('div', {
77531
+ staticClass: "cascade-title row column-c"
77532
+ }, [!_vm.aggregationMode ? _c('div', {
77533
+ staticClass: "txt"
77534
+ }, [_vm._v("可选(" + _vm._s(_vm.selectedCount) + "/" + _vm._s(_vm.totalCount) + ")")]) : _vm._e(), _c('div', {
77535
+ staticClass: "cell",
77536
+ staticStyle: {
77537
+ "padding-left": "20px"
77538
+ }
77539
+ }, [_c('el-input', {
77540
+ staticClass: "search-input",
77541
+ attrs: {
77542
+ "placeholder": _vm.searchPlaceholder,
77543
+ "clearable": ""
77544
+ },
77545
+ on: {
77546
+ "input": _vm.handleSearch
77547
+ },
77548
+ model: {
77549
+ value: _vm.searchInput,
77550
+ callback: function ($$v) {
77551
+ _vm.searchInput = $$v;
77552
+ },
77553
+ expression: "searchInput"
77554
+ }
77555
+ })], 1), _c('div', {
77556
+ staticClass: "menu"
77557
+ }, [_vm.searchInput === '' && _vm.isMultiple && _vm.showSelectAll ? _c('div', {
77558
+ staticClass: "all-select",
77559
+ on: {
77560
+ "click": _vm.handleSelectAll
77561
+ }
77562
+ }, [_vm._v(" " + _vm._s(_vm.isAllSelected ? '取消全选' : '全选') + " ")]) : _vm._e()])]), _c('div', {
77563
+ staticClass: "cascade-content",
77564
+ staticStyle: {
77565
+ "border": "1px solid #dcdfe6",
77566
+ "overflow-x": "scroll",
77567
+ "padding": "20px 20px 20px 20px"
77568
+ },
77569
+ style: {
77570
+ height: _vm.computedPanelHeight + 'px'
77571
+ }
77572
+ }, [_c('div', [_vm.isShow && _vm.filteredOptions.length > 0 ? _c('el-cascader-panel', {
77573
+ directives: [{
77574
+ name: "show",
77575
+ rawName: "v-show",
77576
+ value: _vm.searchInput === '' || !_vm.isShowSearch,
77577
+ expression: "searchInput === '' || !isShowSearch"
77578
+ }],
77579
+ ref: "cascaderPanel",
77580
+ staticClass: "singleCascader",
77581
+ style: {
77582
+ height: _vm.computedPanelHeight - 50 + 'px'
77583
+ },
77584
+ attrs: {
77585
+ "append-to-body": false,
77586
+ "options": _vm.filteredOptions,
77587
+ "props": _vm.cascaderProps
77588
+ },
77589
+ on: {
77590
+ "expand-change": _vm.handleExpandChange,
77591
+ "change": _vm.handleValueChange
77592
+ },
77593
+ model: {
77594
+ value: _vm.mainPanelValue,
77595
+ callback: function ($$v) {
77596
+ _vm.mainPanelValue = $$v;
77597
+ },
77598
+ expression: "mainPanelValue"
77599
+ }
77600
+ }) : _vm._e(), _vm.searchOptions.length > 0 ? _c('el-cascader-panel', {
77601
+ directives: [{
77602
+ name: "show",
77603
+ rawName: "v-show",
77604
+ value: _vm.searchInput !== '' && _vm.isShowSearch,
77605
+ expression: "searchInput !== '' && isShowSearch"
77606
+ }],
77607
+ ref: "searchCascaderPanel",
77608
+ staticClass: "singleCascader",
77609
+ style: {
77610
+ height: _vm.computedPanelHeight - 50 + 'px'
77611
+ },
77612
+ attrs: {
77613
+ "append-to-body": false,
77614
+ "options": _vm.searchOptions,
77615
+ "props": _vm.cascaderProps
77616
+ },
77617
+ on: {
77618
+ "expand-change": _vm.handleExpandChange,
77619
+ "change": _vm.handleSearchValueChange
77620
+ },
77621
+ model: {
77622
+ value: _vm.searchPanelValue,
77623
+ callback: function ($$v) {
77624
+ _vm.searchPanelValue = $$v;
77625
+ },
77626
+ expression: "searchPanelValue"
77627
+ }
77628
+ }) : _vm._e()], 1), _vm.isShowSearch && _vm.searchOptions.length === 0 ? _c('div', {
77629
+ directives: [{
77630
+ name: "show",
77631
+ rawName: "v-show",
77632
+ value: _vm.searchInput !== '',
77633
+ expression: "searchInput !== ''"
77634
+ }],
77635
+ staticClass: "row column-c row-c",
77636
+ staticStyle: {
77637
+ "width": "100%",
77638
+ "height": "100%"
77639
+ }
77640
+ }, [_c('el-empty', {
77641
+ attrs: {
77642
+ "image-size": 100
77643
+ }
77644
+ })], 1) : _vm._e()])]), _c('div', {
77645
+ staticClass: "cascade-container bb right-panel"
77646
+ }, [_c('div', {
77647
+ staticClass: "cascade-title row column-c"
77648
+ }, [_c('div', {
77649
+ staticClass: "txt"
77650
+ }, [_vm._v("已选(" + _vm._s(_vm.selectedItems.length) + ")")]), _c('div', {
77651
+ staticClass: "menu"
77652
+ }, [_vm.selectedItems.length > 0 ? _c('div', {
77653
+ staticClass: "clear-btn",
77654
+ on: {
77655
+ "click": _vm.clearSelection
77656
+ }
77657
+ }, [_vm._v("清除")]) : _vm._e()])]), _c('div', {
77658
+ staticClass: "cascade-content",
77659
+ style: {
77660
+ height: _vm.computedPanelHeight - 5 + 'px'
77661
+ }
77662
+ }, [_c('div', {
77663
+ staticClass: "item",
77664
+ staticStyle: {
77665
+ "overflow-y": "auto",
77666
+ "height": "100%",
77667
+ "max-height": "100%"
77668
+ }
77669
+ }, _vm._l(_vm.selectedItems, function (item, index) {
77670
+ return _c('div', {
77671
+ key: item.value,
77672
+ staticClass: "check-box row column-c",
77673
+ staticStyle: {
77674
+ "height": "36px",
77675
+ "flex-shrink": "0"
77676
+ }
77677
+ }, [_c('div', {
77678
+ staticClass: "cell",
77679
+ staticStyle: {
77680
+ "white-space": "nowrap",
77681
+ "overflow": "hidden",
77682
+ "text-overflow": "ellipsis"
77683
+ }
77684
+ }, [_vm._v(" " + _vm._s(item.label || '') + " ")]), _c('div', {
77685
+ staticClass: "icon",
77686
+ staticStyle: {
77687
+ "cursor": "pointer"
77688
+ },
77689
+ on: {
77690
+ "click": function ($event) {
77691
+ return _vm.removeItem(item, index);
77692
+ }
77693
+ }
77694
+ }, [_c('i', {
77695
+ staticClass: "el-icon-close"
77696
+ })])]);
77697
+ }), 0)])])])]);
77698
+ };
77699
+ var ByCascaderPanelvue_type_template_id_d3dd0512_staticRenderFns = [];
77700
+
77701
+ ;// ./src/utils/cascaderUtils.js
77702
+
77703
+
77704
+
77705
+
77706
+
77707
+
77708
+
77709
+
77710
+
77711
+
77712
+
77713
+
77714
+
77715
+
77716
+
77717
+ /**
77718
+ * 级联选择器工具类
77719
+ */
77720
+ class CascaderUtils {
77721
+ /**
77722
+ * 判断项目是否禁用
77723
+ * @param {Object} item - 项目数据
77724
+ * @param {Object} config - 禁用配置
77725
+ * @param {String} config.disabledField - 禁用字段名
77726
+ * @param {*} config.disabledValue - 禁用值
77727
+ * @param {Function} config.disabledCheck - 自定义禁用判断函数
77728
+ * @returns {Boolean} 是否禁用
77729
+ */
77730
+ static isItemDisabled(item, config) {
77731
+ const {
77732
+ disabledField,
77733
+ disabledValue,
77734
+ disabledCheck
77735
+ } = config;
77736
+
77737
+ // 优先使用自定义禁用判断函数
77738
+ if (disabledCheck && typeof disabledCheck === 'function') {
77739
+ return disabledCheck(item);
77740
+ }
77741
+
77742
+ // 检查直接的 disabled 属性
77743
+ if (item.disabled === true) {
77744
+ return true;
77745
+ }
77746
+
77747
+ // 使用字段判断
77748
+ const fieldValue = item[disabledField];
77749
+ if (fieldValue !== undefined) {
77750
+ return fieldValue === disabledValue;
77751
+ }
77752
+ return false;
77753
+ }
77754
+
77755
+ /**
77756
+ * 检查路径上是否存在禁选项
77757
+ * @param {Array} tree - 树形数据
77758
+ * @param {Array} path - 路径数组
77759
+ * @param {Object} config - 禁用配置
77760
+ * @param {Object} cascaderProps - 级联配置
77761
+ * @returns {Boolean} 路径上是否存在禁选项
77762
+ */
77763
+ static isPathDisabled(tree, path, config, cascaderProps) {
77764
+ if (!path || path.length === 0) return false;
77765
+ const findPathInTree = (nodes, targetPath, currentIndex = 0) => {
77766
+ if (currentIndex >= targetPath.length) return false;
77767
+ for (const node of nodes) {
77768
+ if (node[cascaderProps.value] === targetPath[currentIndex]) {
77769
+ // 检查当前节点是否禁用
77770
+ if (this.isItemDisabled(node, config)) {
77771
+ return true;
77772
+ }
77773
+
77774
+ // 如果还有下一级,继续检查
77775
+ if (currentIndex < targetPath.length - 1 && node[cascaderProps.children]) {
77776
+ return findPathInTree(node[cascaderProps.children], targetPath, currentIndex + 1);
77777
+ }
77778
+
77779
+ // 如果已经到达路径末尾,返回false(路径上没有禁选项)
77780
+ return false;
77781
+ }
77782
+ }
77783
+ return false;
77784
+ };
77785
+ return findPathInTree(tree, path);
77786
+ }
77787
+
77788
+ /**
77789
+ * 设置禁用项
77790
+ * @param {Array} options - 选项数据
77791
+ * @param {Object} config - 禁用配置
77792
+ * @param {Object} cascaderProps - 级联配置
77793
+ */
77794
+ static setDisabledItems(options, config, cascaderProps) {
77795
+ const processItems = items => {
77796
+ items.forEach(item => {
77797
+ // 判断是否禁用
77798
+ if (this.isItemDisabled(item, config)) {
77799
+ item.disabled = true;
77800
+ }
77801
+ // 递归处理子项
77802
+ if (item[cascaderProps.children]) {
77803
+ processItems(item[cascaderProps.children]);
77804
+ }
77805
+ });
77806
+ };
77807
+ processItems(options);
77808
+ }
77809
+
77810
+ /**
77811
+ * 统计总项目数(排除禁用项和路径上有禁选项的项)
77812
+ * @param {Array} options - 选项数据
77813
+ * @param {Object} config - 禁用配置
77814
+ * @param {Object} cascaderProps - 级联配置
77815
+ * @returns {Number} 总项目数
77816
+ */
77817
+ static countTotalItems(options, config, cascaderProps) {
77818
+ let totalCount = 0;
77819
+ const countItems = (items, currentPath = []) => {
77820
+ items.forEach(item => {
77821
+ const newPath = [...currentPath, item[cascaderProps.value]];
77822
+
77823
+ // 检查当前节点是否禁用
77824
+ const isCurrentDisabled = this.isItemDisabled(item, config);
77825
+ if (!item[cascaderProps.children]) {
77826
+ // 只统计非禁用项且路径上没有禁选项的叶子节点
77827
+ if (!isCurrentDisabled && !this.isPathDisabled(options, newPath, config, cascaderProps)) {
77828
+ totalCount++;
77829
+ }
77830
+ } else {
77831
+ // 如果当前节点禁用,则其所有子节点都不可选
77832
+ if (!isCurrentDisabled) {
77833
+ countItems(item[cascaderProps.children], newPath);
77834
+ }
77835
+ }
77836
+ });
77837
+ };
77838
+ countItems(options);
77839
+ return totalCount;
77840
+ }
77841
+
77842
+ /**
77843
+ * 在树形数据中搜索
77844
+ * @param {Array} tree - 树形数据
77845
+ * @param {String} keyword - 搜索关键词
77846
+ * @param {Object} cascaderProps - 级联配置
77847
+ * @returns {Array} 搜索结果
77848
+ */
77849
+ static searchInTree(tree, keyword, cascaderProps) {
77850
+ const result = [];
77851
+ tree.forEach(node => {
77852
+ if (node[cascaderProps.label].includes(keyword)) {
77853
+ const matchedNode = {
77854
+ ...node
77855
+ };
77856
+ result.push(matchedNode);
77857
+ } else if (node[cascaderProps.children]) {
77858
+ const matchedChildren = this.searchInTree(node[cascaderProps.children], keyword, cascaderProps);
77859
+ if (matchedChildren.length > 0) {
77860
+ const matchedNode = {
77861
+ ...node,
77862
+ [cascaderProps.children]: matchedChildren
77863
+ };
77864
+ result.push(matchedNode);
77865
+ }
77866
+ }
77867
+ });
77868
+ return result;
77869
+ }
77870
+
77871
+ /**
77872
+ * 获取叶子节点的值
77873
+ * @param {Array} tree - 树形数据
77874
+ * @param {Object} cascaderProps - 级联配置
77875
+ * @returns {Array} 叶子节点值数组
77876
+ */
77877
+ static getLeafValues(tree, cascaderProps) {
77878
+ const leafValues = [];
77879
+ const traverse = nodes => {
77880
+ nodes.forEach(node => {
77881
+ if (!node[cascaderProps.children]) {
77882
+ leafValues.push(node[cascaderProps.value]);
77883
+ } else {
77884
+ traverse(node[cascaderProps.children]);
77885
+ }
77886
+ });
77887
+ };
77888
+ traverse(tree);
77889
+ return leafValues;
77890
+ }
77891
+
77892
+ /**
77893
+ * 获取所有叶子节点的路径(排除禁用项和路径上有禁选项的项)
77894
+ * @param {Array} tree - 树形数据
77895
+ * @param {Object} config - 禁用配置
77896
+ * @param {Object} cascaderProps - 级联配置
77897
+ * @returns {Array} 路径数组
77898
+ */
77899
+ static getAllLeafPaths(tree, config, cascaderProps) {
77900
+ const paths = [];
77901
+ const traverse = (nodes, currentPath = []) => {
77902
+ nodes.forEach(node => {
77903
+ const newPath = [...currentPath, node[cascaderProps.value]];
77904
+
77905
+ // 检查当前节点是否禁用
77906
+ const isCurrentDisabled = this.isItemDisabled(node, config);
77907
+ if (!node[cascaderProps.children]) {
77908
+ // 只包含非禁用项且路径上没有禁选项的叶子节点
77909
+ if (!isCurrentDisabled && !this.isPathDisabled(tree, newPath, config, cascaderProps)) {
77910
+ paths.push(newPath);
77911
+ }
77912
+ } else {
77913
+ // 如果当前节点禁用,则其所有子节点都不可选
77914
+ if (!isCurrentDisabled) {
77915
+ traverse(node[cascaderProps.children], newPath);
77916
+ }
77917
+ }
77918
+ });
77919
+ };
77920
+ traverse(tree);
77921
+ return paths;
77922
+ }
77923
+
77924
+ /**
77925
+ * 根据路径查找节点
77926
+ * @param {Array} tree - 树形数据
77927
+ * @param {Array} path - 路径数组
77928
+ * @param {Object} cascaderProps - 级联配置
77929
+ * @returns {Object|null} 找到的节点
77930
+ */
77931
+ static findNodeByPath(tree, path, cascaderProps) {
77932
+ if (!path || path.length === 0) return null;
77933
+ const findInTree = (nodes, targetPath) => {
77934
+ for (const node of nodes) {
77935
+ if (node[cascaderProps.value] == targetPath[0]) {
77936
+ if (targetPath.length === 1) {
77937
+ return node;
77938
+ } else if (node[cascaderProps.children]) {
77939
+ return findInTree(node[cascaderProps.children], targetPath.slice(1));
77940
+ }
77941
+ }
77942
+ }
77943
+ return null;
77944
+ };
77945
+ return findInTree(tree, path);
77946
+ }
77947
+
77948
+ /**
77949
+ * 基于 selectedValues 构建已选项列表
77950
+ * @param {Array} selectedValues - 已选值数组
77951
+ * @param {Array} options - 选项数据
77952
+ * @param {Object} cascaderProps - 级联配置
77953
+ * @returns {Array} 已选项列表
77954
+ */
77955
+ static buildSelectedItemsFromValues(selectedValues, options, cascaderProps) {
77956
+ const items = [];
77957
+ selectedValues.forEach(path => {
77958
+ if (path.length > 0) {
77959
+ const leafValue = path[path.length - 1];
77960
+ // 从原始数据中查找对应的节点信息
77961
+ const node = this.findNodeByPath(options, path, cascaderProps);
77962
+ if (node) {
77963
+ items.push({
77964
+ value: leafValue,
77965
+ label: node[cascaderProps.label],
77966
+ path: path
77967
+ });
77968
+ }
77969
+ }
77970
+ });
77971
+ return items;
77972
+ }
77973
+
77974
+ /**
77975
+ * 获取搜索范围内的选中值
77976
+ * @param {Array} selectedValues - 已选值数组
77977
+ * @param {Array} searchOptions - 搜索结果
77978
+ * @param {Object} cascaderProps - 级联配置
77979
+ * @returns {Array} 搜索范围内的选中值
77980
+ */
77981
+ static getSearchSelectedValues(selectedValues, searchOptions, cascaderProps) {
77982
+ const searchLeafValues = this.getLeafValues(searchOptions, cascaderProps);
77983
+ return selectedValues.filter(path => {
77984
+ const leafValue = path[path.length - 1];
77985
+ return searchLeafValues.includes(leafValue);
77986
+ });
77987
+ }
77988
+
77989
+ /**
77990
+ * 检查父项的所有子项是否都被选中
77991
+ * @param {Object} parentNode - 父节点
77992
+ * @param {Array} selectedValues - 已选值数组
77993
+ * @param {Object} cascaderProps - 级联配置
77994
+ * @returns {Boolean} 是否所有子项都被选中
77995
+ */
77996
+ static isParentFullySelected(parentNode, selectedValues, cascaderProps) {
77997
+ if (!parentNode[cascaderProps.children]) {
77998
+ return false;
77999
+ }
78000
+
78001
+ // 获取父项的所有叶子节点
78002
+ const allLeafValues = this.getLeafValues([parentNode], cascaderProps);
78003
+
78004
+ // 检查所有叶子节点是否都在选中值中
78005
+ return allLeafValues.every(leafValue => {
78006
+ return selectedValues.some(path => {
78007
+ const pathLeafValue = path[path.length - 1];
78008
+ return pathLeafValue === leafValue;
78009
+ });
78010
+ });
78011
+ }
78012
+
78013
+ /**
78014
+ * 根据路径获取对应的标签数组
78015
+ * @param {Array} path - 节点路径
78016
+ * @param {Array} options - 选项数据
78017
+ * @param {Object} cascaderProps - 级联配置
78018
+ * @returns {Array} 标签数组
78019
+ */
78020
+ static getPathLabels(path, options, cascaderProps) {
78021
+ const labels = [];
78022
+ let currentNodes = options;
78023
+ for (let i = 0; i < path.length; i++) {
78024
+ const targetValue = path[i];
78025
+ const foundNode = currentNodes.find(node => node[cascaderProps.value] === targetValue);
78026
+ if (foundNode) {
78027
+ labels.push(foundNode[cascaderProps.label]);
78028
+ if (foundNode[cascaderProps.children] && i < path.length - 1) {
78029
+ currentNodes = foundNode[cascaderProps.children];
78030
+ }
78031
+ } else {
78032
+ labels.push(targetValue); // 如果找不到对应的节点,使用原始值
78033
+ }
78034
+ }
78035
+ return labels;
78036
+ }
78037
+
78038
+ /**
78039
+ * 构建完整的节点信息对象
78040
+ * @param {Object} node - 原始节点数据
78041
+ * @param {Array} path - 节点路径
78042
+ * @param {Object} cascaderProps - 级联配置
78043
+ * @param {Array} options - 选项数据
78044
+ * @param {Boolean} isAggregated - 是否为聚合项
78045
+ * @returns {Object} 完整的节点信息对象
78046
+ */
78047
+ static buildCompleteNodeInfo(node, path, cascaderProps, options, isAggregated = false) {
78048
+ const hasChildren = !!node[cascaderProps.children];
78049
+ const level = path.length - 1;
78050
+ return {
78051
+ // 基本属性
78052
+ value: node[cascaderProps.value],
78053
+ label: node[cascaderProps.label],
78054
+ path: path,
78055
+ isAggregated: isAggregated,
78056
+ // 节点结构信息
78057
+ hasChildren: hasChildren,
78058
+ level: level,
78059
+ children: hasChildren ? node[cascaderProps.children] : undefined,
78060
+ // 级联面板相关属性
78061
+ checked: true,
78062
+ indeterminate: false,
78063
+ loaded: true,
78064
+ loading: false,
78065
+ // 原始数据
78066
+ data: node,
78067
+ // 路径相关
78068
+ pathLabels: this.getPathLabels(path, options, cascaderProps),
78069
+ // 其他可能需要的属性
78070
+ config: cascaderProps,
78071
+ parent: null,
78072
+ // 在级联面板中会动态设置
78073
+ pathNodes: null // 在级联面板中会动态设置
78074
+ };
78075
+ }
78076
+
78077
+ /**
78078
+ * 获取聚合模式下的选中项(如果父项完全选中,则只返回父项)
78079
+ * @param {Array} selectedValues - 已选值数组
78080
+ * @param {Array} options - 选项数据
78081
+ * @param {Object} cascaderProps - 级联配置
78082
+ * @returns {Array} 聚合后的选中项列表
78083
+ */
78084
+ static getAggregatedSelectedItems(selectedValues, options, cascaderProps) {
78085
+ const items = [];
78086
+ const processedPaths = new Set();
78087
+
78088
+ // 递归检查每个节点
78089
+ const checkNode = (nodes, currentPath = []) => {
78090
+ nodes.forEach(node => {
78091
+ const newPath = [...currentPath, node[cascaderProps.value]];
78092
+ const pathKey = newPath.join(',');
78093
+
78094
+ // 如果这个路径已经被处理过,跳过
78095
+ if (processedPaths.has(pathKey)) {
78096
+ return;
78097
+ }
78098
+
78099
+ // 检查当前节点是否完全选中
78100
+ if (this.isParentFullySelected(node, selectedValues, cascaderProps)) {
78101
+ // 父项完全选中,添加父项
78102
+ items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, true));
78103
+
78104
+ // 标记所有子路径为已处理
78105
+ const allLeafValues = this.getLeafValues([node], cascaderProps);
78106
+ selectedValues.forEach(path => {
78107
+ const pathLeafValue = path[path.length - 1];
78108
+ if (allLeafValues.includes(pathLeafValue)) {
78109
+ processedPaths.add(path.join(','));
78110
+ }
78111
+ });
78112
+ } else if (!node[cascaderProps.children]) {
78113
+ // 叶子节点,检查是否在选中值中且未被父项覆盖
78114
+ const leafValue = node[cascaderProps.value];
78115
+ const isSelected = selectedValues.some(path => {
78116
+ const pathLeafValue = path[path.length - 1];
78117
+ return pathLeafValue === leafValue;
78118
+ });
78119
+ if (isSelected && !processedPaths.has(pathKey)) {
78120
+ items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, false));
78121
+ processedPaths.add(pathKey);
78122
+ }
78123
+ } else {
78124
+ // 继续检查子节点
78125
+ checkNode(node[cascaderProps.children], newPath);
78126
+ }
78127
+ });
78128
+ };
78129
+ checkNode(options);
78130
+ return items;
78131
+ }
78132
+
78133
+ /**
78134
+ * 获取聚合模式下的选中值(只返回最终选中的值,不包含被聚合的子项)
78135
+ * @param {Array} selectedValues - 已选值数组
78136
+ * @param {Array} options - 选项数据
78137
+ * @param {Object} cascaderProps - 级联配置
78138
+ * @param {String} prefix - 前缀标识
78139
+ * @returns {Array} 聚合后的选中值
78140
+ */
78141
+ static getAggregatedSelectedValues(selectedValues, options, cascaderProps, prefix = '__parent__') {
78142
+ const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
78143
+ return aggregatedItems.map(item => {
78144
+ // 如果是聚合项(非叶子节点),添加前缀标识
78145
+ if (item.isAggregated) {
78146
+ return this.addParentNodePrefix(item.value, prefix);
78147
+ }
78148
+ return item.value;
78149
+ });
78150
+ }
78151
+
78152
+ /**
78153
+ * 获取聚合模式下的路径数组(只返回最终选中的路径,不包含被聚合的子项路径)
78154
+ * @param {Array} selectedValues - 已选值数组
78155
+ * @param {Array} options - 选项数据
78156
+ * @param {Object} cascaderProps - 级联配置
78157
+ * @returns {Array} 聚合后的路径数组
78158
+ */
78159
+ static getAggregatedSelectedPaths(selectedValues, options, cascaderProps) {
78160
+ const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
78161
+ return aggregatedItems.map(item => item.path);
78162
+ }
78163
+
78164
+ /**
78165
+ * 检查聚合模式下是否全选(所有可选的叶子节点都被选中)
78166
+ * @param {Array} selectedValues - 已选值数组
78167
+ * @param {Array} options - 选项数据
78168
+ * @param {Object} config - 禁用配置
78169
+ * @param {Object} cascaderProps - 级联配置
78170
+ * @returns {Boolean} 是否全选
78171
+ */
78172
+ static isAggregatedAllSelected(selectedValues, options, config, cascaderProps) {
78173
+ // 获取所有可选的叶子节点
78174
+ const allSelectableLeafValues = this.getAllLeafPaths(options, config, cascaderProps).map(path => path[path.length - 1]); // 获取叶子节点的值
78175
+
78176
+ // 获取当前选中的叶子节点值
78177
+ const selectedLeafValues = selectedValues.map(path => path[path.length - 1]);
78178
+
78179
+ // 检查所有可选的叶子节点是否都被选中
78180
+ return allSelectableLeafValues.every(leafValue => selectedLeafValues.includes(leafValue));
78181
+ }
78182
+
78183
+ /**
78184
+ * 检查值是否为非叶子节点标识
78185
+ * @param {*} value - 要检查的值
78186
+ * @param {String} prefix - 前缀标识
78187
+ * @returns {Boolean} 是否为非叶子节点标识
78188
+ */
78189
+ static isParentNodeValue(value, prefix = '__parent__') {
78190
+ return typeof value === 'string' && value.startsWith(prefix);
78191
+ }
78192
+
78193
+ /**
78194
+ * 从非叶子节点标识中提取实际值
78195
+ * @param {String} parentValue - 非叶子节点标识值
78196
+ * @param {String} prefix - 前缀标识
78197
+ * @returns {String} 实际值
78198
+ */
78199
+ static extractParentNodeValue(parentValue, prefix = '__parent__') {
78200
+ if (this.isParentNodeValue(parentValue, prefix)) {
78201
+ return parentValue.substring(prefix.length);
78202
+ }
78203
+ return parentValue;
78204
+ }
78205
+
78206
+ /**
78207
+ * 为非叶子节点值添加前缀标识
78208
+ * @param {String} value - 原始值
78209
+ * @param {String} prefix - 前缀标识
78210
+ * @returns {String} 带前缀的值
78211
+ */
78212
+ static addParentNodePrefix(value, prefix = '__parent__') {
78213
+ return prefix + value;
78214
+ }
78215
+
78216
+ /**
78217
+ * 根据非叶子节点值获取其所有叶子节点的路径
78218
+ * @param {String} parentValue - 非叶子节点值
78219
+ * @param {Array} options - 选项数据
78220
+ * @param {Object} cascaderProps - 级联配置
78221
+ * @returns {Array} 叶子节点路径数组
78222
+ */
78223
+ static getLeafPathsByParentValue(parentValue, options, cascaderProps) {
78224
+ const paths = [];
78225
+
78226
+ // 查找非叶子节点
78227
+ const findParentNode = (nodes, currentPath = []) => {
78228
+ for (const node of nodes) {
78229
+ const newPath = [...currentPath, node[cascaderProps.value]];
78230
+ if (node[cascaderProps.value] == parentValue) {
78231
+ // 找到目标非叶子节点,获取其所有叶子节点路径
78232
+ this.getAllLeafPaths([node], {}, cascaderProps).forEach(leafPath => {
78233
+ // 将叶子节点路径与当前路径合并
78234
+ const fullPath = [...currentPath, ...leafPath];
78235
+ paths.push(fullPath);
78236
+ });
78237
+ return true;
78238
+ }
78239
+
78240
+ // 递归查找子节点
78241
+ if (node[cascaderProps.children] && node[cascaderProps.children].length > 0) {
78242
+ if (findParentNode(node[cascaderProps.children], newPath)) {
78243
+ return true;
78244
+ }
78245
+ }
78246
+ }
78247
+ return false;
78248
+ };
78249
+ findParentNode(options);
78250
+ return paths;
78251
+ }
78252
+
78253
+ /**
78254
+ * 处理包含非叶子节点的值数组,将非叶子节点转换为对应的叶子节点路径
78255
+ * @param {Array} values - 值数组(可能包含非叶子节点标识)
78256
+ * @param {Array} options - 选项数据
78257
+ * @param {Object} cascaderProps - 级联配置
78258
+ * @param {String} prefix - 前缀标识
78259
+ * @returns {Array} 处理后的路径数组
78260
+ */
78261
+ static processValuesWithParentNodes(values, options, cascaderProps, prefix = '__parent__') {
78262
+ const paths = [];
78263
+ for (const value of values) {
78264
+ if (this.isParentNodeValue(value, prefix)) {
78265
+ // 非叶子节点,获取其所有叶子节点路径
78266
+ const actualValue = this.extractParentNodeValue(value, prefix);
78267
+ const leafPaths = this.getLeafPathsByParentValue(actualValue, options, cascaderProps);
78268
+ paths.push(...leafPaths);
78269
+ } else {
78270
+ // 普通值,查找对应的路径
78271
+ const valuePaths = this.findPathsByValues([value], options, cascaderProps);
78272
+ paths.push(...valuePaths);
78273
+ }
78274
+ }
78275
+ return paths;
78276
+ }
78277
+
78278
+ /**
78279
+ * 根据values找到对应的路径(支持非叶子节点)
78280
+ * @param {Array} values - 值数组
78281
+ * @param {Array} options - 选项数据
78282
+ * @param {Object} cascaderProps - 级联配置
78283
+ * @returns {Array} 路径数组
78284
+ */
78285
+ static findPathsByValues(values, options, cascaderProps) {
78286
+ const paths = [];
78287
+ const findPath = (nodes, targetValues, currentPath = []) => {
78288
+ for (const option of nodes) {
78289
+ const newPath = [...currentPath, option[cascaderProps.value]];
78290
+ if (targetValues.includes(option[cascaderProps.value])) {
78291
+ // 如果是叶子节点(没有children属性),添加到路径中
78292
+ if (!option[cascaderProps.children]) {
78293
+ paths.push(newPath);
78294
+ }
78295
+ }
78296
+
78297
+ // 递归查找子节点
78298
+ if (option[cascaderProps.children] && option[cascaderProps.children].length > 0) {
78299
+ findPath(option[cascaderProps.children], targetValues, newPath);
78300
+ }
78301
+ }
78302
+ };
78303
+ findPath(options, values);
78304
+ return paths;
78305
+ }
78306
+ }
78307
+ ;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel/ByCascaderPanel.vue?vue&type=script&lang=js
78308
+
78309
+
78310
+
78311
+
78312
+
78313
+
78314
+ /* harmony default export */ var ByCascaderPanelvue_type_script_lang_js = ({
78315
+ name: 'ByCascaderPanel',
78316
+ props: {
78317
+ // 级联数据源
78318
+ options: {
78319
+ type: Array,
78320
+ default: () => []
78321
+ },
78322
+ // 已选值
78323
+ value: {
78324
+ type: [Array, Number, String],
78325
+ default: () => []
78326
+ },
78327
+ // 级联面板配置
78328
+ cascaderProps: {
78329
+ type: Object,
78330
+ default: () => ({
78331
+ multiple: true,
78332
+ label: 'label',
78333
+ value: 'value',
78334
+ children: 'children'
78335
+ })
78336
+ },
78337
+ // 面板高度
78338
+ panelHeight: {
78339
+ type: [String, Number],
78340
+ default: 300,
78341
+ validator: value => {
78342
+ const numValue = Number(value);
78343
+ if (isNaN(numValue)) {
78344
+ console.warn(`[ByCascaderPanel] panelHeight 必须是数字,当前值: ${value}`);
78345
+ return false;
78346
+ }
78347
+ if (numValue < 200) {
78348
+ console.warn(`[ByCascaderPanel] panelHeight 不能小于 200px,当前值: ${value}px`);
78349
+ return false;
78350
+ }
78351
+ if (numValue > 800) {
78352
+ console.warn(`[ByCascaderPanel] panelHeight 不能大于 800px,当前值: ${value}px`);
78353
+ return false;
78354
+ }
78355
+ return true;
78356
+ }
78357
+ },
78358
+ // 搜索占位符
78359
+ searchPlaceholder: {
78360
+ type: String,
78361
+ default: '请输入名称搜索'
78362
+ },
78363
+ // 禁用字段名(只针对叶子节点,非叶子节点为disabled)
78364
+ disabledField: {
78365
+ type: String,
78366
+ default: 'disabled'
78367
+ },
78368
+ // 禁用值(只针对叶子节点,非叶子节点为disabled)
78369
+ disabledValue: {
78370
+ type: [String, Number, Boolean],
78371
+ default: true
78372
+ },
78373
+ // 自定义禁用判断函数
78374
+ disabledCheck: {
78375
+ type: Function,
78376
+ default: null
78377
+ },
78378
+ // 是否显示全选按钮
78379
+ showSelectAll: {
78380
+ type: Boolean,
78381
+ default: true
78382
+ },
78383
+ // 是否聚合模式 (聚合模式下如果子项全部选中,会直接返回父ID)
78384
+ aggregationMode: {
78385
+ type: Boolean,
78386
+ default: false
78387
+ },
78388
+ /**
78389
+ * 非叶子节点前缀标识 (聚合模式下用于标识非叶子节点)
78390
+ * 注意:聚合模式下,由于叶子节点和非叶子节点可能存在相同id,所以绑定数据中务必给非叶子节点加上parentNodePrefix前缀作为标识
78391
+ */
78392
+ parentNodePrefix: {
78393
+ type: String,
78394
+ default: '__parent__'
78395
+ }
78396
+ },
78397
+ data() {
78398
+ return {
78399
+ selectedValues: [],
78400
+ searchSelectedValues: [],
78401
+ filteredOptions: [],
78402
+ searchOptions: [],
78403
+ selectedItems: [],
78404
+ searchInput: '',
78405
+ isShow: true,
78406
+ isShowSearch: false,
78407
+ totalCount: 0,
78408
+ selectedCount: 0,
78409
+ isAllSelected: false,
78410
+ isInternalUpdate: false // 防止循环更新的标志
78411
+ };
78412
+ },
78413
+ computed: {
78414
+ // 处理后的面板高度,确保在有效范围内
78415
+ computedPanelHeight() {
78416
+ const height = Number(this.panelHeight);
78417
+ if (isNaN(height)) {
78418
+ return 300; // 默认值
78419
+ }
78420
+ // 限制在 200px 到 800px 之间
78421
+ return Math.max(200, Math.min(800, height));
78422
+ },
78423
+ // 是否为多选模式
78424
+ isMultiple() {
78425
+ return this.cascaderProps.multiple !== false;
78426
+ },
78427
+ // 当前选中的值(单选时返回单个值,多选时返回数组)
78428
+ currentValue() {
78429
+ if (this.isMultiple) {
78430
+ return this.selectedItems.map(item => item.value);
78431
+ } else {
78432
+ return this.selectedItems.length > 0 ? this.selectedItems[0].value : null;
78433
+ }
78434
+ },
78435
+ // 主面板的值(单选时返回单个路径,多选时返回路径数组)
78436
+ mainPanelValue: {
78437
+ get() {
78438
+ if (this.isMultiple) {
78439
+ return this.selectedValues;
78440
+ } else {
78441
+ return this.selectedValues.length > 0 ? this.selectedValues[0] : [];
78442
+ }
78443
+ },
78444
+ set(value) {
78445
+ if (this.isMultiple) {
78446
+ this.selectedValues = value || [];
78447
+ } else {
78448
+ this.selectedValues = value ? [value] : [];
78449
+ }
78450
+ }
78451
+ },
78452
+ // 搜索面板的值(单选时返回单个路径,多选时返回路径数组)
78453
+ searchPanelValue: {
78454
+ get() {
78455
+ if (this.isMultiple) {
78456
+ return this.searchSelectedValues;
78457
+ } else {
78458
+ return this.searchSelectedValues.length > 0 ? this.searchSelectedValues[0] : [];
78459
+ }
78460
+ },
78461
+ set(value) {
78462
+ if (this.isMultiple) {
78463
+ this.searchSelectedValues = value || [];
78464
+ } else {
78465
+ this.searchSelectedValues = value ? [value] : [];
78466
+ }
78467
+ }
78468
+ }
78469
+ },
78470
+ watch: {
78471
+ options: {
78472
+ handler(newVal) {
78473
+ this.initOptions();
78474
+ },
78475
+ deep: true,
78476
+ immediate: true
78477
+ },
78478
+ value: {
78479
+ handler(newVal) {
78480
+ // 如果是内部更新触发的,跳过处理
78481
+ if (this.isInternalUpdate) {
78482
+ this.isInternalUpdate = false;
78483
+ return;
78484
+ }
78485
+ this.processValue();
78486
+ },
78487
+ deep: true,
78488
+ immediate: true
78489
+ },
78490
+ selectedItems: {
78491
+ handler(newVal) {
78492
+ if (this.isMultiple) {
78493
+ this.selectedCount = newVal.length;
78494
+
78495
+ // 聚合模式下的全选判断
78496
+ if (this.aggregationMode) {
78497
+ const config = {
78498
+ disabledField: this.disabledField,
78499
+ disabledValue: this.disabledValue,
78500
+ disabledCheck: this.disabledCheck
78501
+ };
78502
+ this.isAllSelected = CascaderUtils.isAggregatedAllSelected(this.selectedValues, this.filteredOptions, config, this.cascaderProps);
78503
+ } else {
78504
+ // 普通模式下的全选判断
78505
+ this.isAllSelected = this.selectedCount === this.totalCount;
78506
+ }
78507
+ } else {
78508
+ // 单选模式:最多只能有一个选中项
78509
+ if (newVal.length > 1) {
78510
+ this.selectedItems = [newVal[newVal.length - 1]];
78511
+ }
78512
+ this.selectedCount = this.selectedItems.length;
78513
+ }
78514
+ this.$emit('change', this.getSelectedData());
78515
+ },
78516
+ deep: true
78517
+ }
78518
+ },
78519
+ mounted() {
78520
+ this.initOptions();
78521
+ // 确保在 mounted 后处理默认值
78522
+ this.$nextTick(() => {
78523
+ this.processValue();
78524
+ });
78525
+ },
78526
+ methods: {
78527
+ // 处理 value 值
78528
+ processValue() {
78529
+ if (this.isMultiple) {
78530
+ // 多选模式:支持直接传入value值或路径数组
78531
+ if (Array.isArray(this.value) && this.value.length > 0) {
78532
+ if (typeof this.value[0] === 'string' || typeof this.value[0] === 'number') {
78533
+ // 传入的是value值数组,需要转换为路径
78534
+ if (this.aggregationMode) {
78535
+ // 聚合模式下,支持非叶子节点标识
78536
+ this.selectedValues = CascaderUtils.processValuesWithParentNodes(this.value, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78537
+ } else {
78538
+ // 普通模式下,只处理叶子节点
78539
+ this.selectedValues = this.findPathsByValues(this.value);
78540
+ }
78541
+ } else {
78542
+ // 传入的是路径数组
78543
+ this.selectedValues = [...this.value];
78544
+ }
78545
+ } else {
78546
+ this.selectedValues = [];
78547
+ }
78548
+ } else {
78549
+ // 单选模式:支持单个值或路径数组
78550
+ if (this.value !== null && this.value !== undefined && this.value !== '') {
78551
+ if (Array.isArray(this.value)) {
78552
+ // 传入的是路径数组
78553
+ this.selectedValues = [...this.value];
78554
+ } else {
78555
+ // 传入的是单个值,需要转换为路径
78556
+ if (this.aggregationMode) {
78557
+ // 聚合模式下,支持非叶子节点标识
78558
+ this.selectedValues = CascaderUtils.processValuesWithParentNodes([this.value], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78559
+ } else {
78560
+ // 普通模式下,只处理叶子节点
78561
+ this.selectedValues = this.findPathsByValues([this.value]);
78562
+ }
78563
+ }
78564
+ } else {
78565
+ this.selectedValues = [];
78566
+ }
78567
+ }
78568
+ this.updateSelectedItems();
78569
+
78570
+ // 单选模式下,确保级联面板正确显示选中状态
78571
+ if (!this.isMultiple && this.selectedValues.length > 0) {
78572
+ this.$nextTick(() => {
78573
+ const panel = this.$refs.cascaderPanel;
78574
+ if (panel) {
78575
+ // 强制更新级联面板的选中状态
78576
+ panel.$forceUpdate();
78577
+ // 再次更新已选项列表,确保右侧面板显示正确
78578
+ this.updateSelectedItems();
78579
+ }
78580
+ });
78581
+ }
78582
+ },
78583
+ // 初始化选项数据
78584
+ initOptions() {
78585
+ this.filteredOptions = this.processOptions(this.options);
78586
+ this.countTotalItems();
78587
+ this.updateSelectedItems();
78588
+ },
78589
+ // 处理选项数据,添加禁用状态
78590
+ processOptions(options) {
78591
+ const processedOptions = JSON.parse(JSON.stringify(options));
78592
+ const config = {
78593
+ disabledField: this.disabledField,
78594
+ disabledValue: this.disabledValue,
78595
+ disabledCheck: this.disabledCheck
78596
+ };
78597
+ CascaderUtils.setDisabledItems(processedOptions, config, this.cascaderProps);
78598
+ return processedOptions;
78599
+ },
78600
+ // 判断项目是否禁用
78601
+ isItemDisabled(item) {
78602
+ const config = {
78603
+ disabledField: this.disabledField,
78604
+ disabledValue: this.disabledValue,
78605
+ disabledCheck: this.disabledCheck
78606
+ };
78607
+ return CascaderUtils.isItemDisabled(item, config);
78608
+ },
78609
+ // 统计总项目数
78610
+ countTotalItems() {
78611
+ const config = {
78612
+ disabledField: this.disabledField,
78613
+ disabledValue: this.disabledValue,
78614
+ disabledCheck: this.disabledCheck
78615
+ };
78616
+ this.totalCount = CascaderUtils.countTotalItems(this.filteredOptions, config, this.cascaderProps);
78617
+ },
78618
+ // 更新已选项列表
78619
+ updateSelectedItems() {
78620
+ this.$nextTick(() => {
78621
+ if (this.isShowSearch) {
78622
+ // 搜索模式下,基于 selectedValues 构建已选项列表
78623
+ if (this.aggregationMode) {
78624
+ // 聚合模式:使用聚合逻辑处理选中项
78625
+ this.selectedItems = CascaderUtils.getAggregatedSelectedItems(this.selectedValues, this.filteredOptions, this.cascaderProps);
78626
+ } else {
78627
+ this.selectedItems = this.buildSelectedItemsFromValues();
78628
+ }
78629
+ } else {
78630
+ // 正常模式下,优先从面板获取选中项,如果面板没有选中项则基于 selectedValues 构建
78631
+ const panel = this.$refs.cascaderPanel;
78632
+ if (panel) {
78633
+ const checkedNodes = panel.getCheckedNodes();
78634
+ if (this.aggregationMode) {
78635
+ // 聚合模式:使用聚合逻辑处理选中项
78636
+ this.selectedItems = CascaderUtils.getAggregatedSelectedItems(this.selectedValues, this.filteredOptions, this.cascaderProps);
78637
+ } else {
78638
+ // 普通模式:只显示叶子节点(最后一级),过滤掉父节点
78639
+ const panelSelectedItems = checkedNodes.filter(node => {
78640
+ // 如果是叶子节点(没有children属性),则显示
78641
+ return node && !node[this.cascaderProps.children];
78642
+ });
78643
+
78644
+ // 如果面板有选中项,使用面板的选中项;否则使用 selectedValues 构建
78645
+ if (panelSelectedItems.length > 0) {
78646
+ this.selectedItems = panelSelectedItems;
78647
+ } else {
78648
+ this.selectedItems = this.buildSelectedItemsFromValues();
78649
+ }
78650
+ }
78651
+ } else {
78652
+ // 面板不存在时,基于 selectedValues 构建
78653
+ if (this.aggregationMode) {
78654
+ // 聚合模式:使用聚合逻辑处理选中项
78655
+ this.selectedItems = CascaderUtils.getAggregatedSelectedItems(this.selectedValues, this.filteredOptions, this.cascaderProps);
78656
+ } else {
78657
+ this.selectedItems = this.buildSelectedItemsFromValues();
78658
+ }
78659
+ }
78660
+ }
78661
+ });
78662
+ },
78663
+ // 基于 selectedValues 构建已选项列表
78664
+ buildSelectedItemsFromValues() {
78665
+ return CascaderUtils.buildSelectedItemsFromValues(this.selectedValues, this.filteredOptions, this.cascaderProps);
78666
+ },
78667
+ // 搜索处理
78668
+ handleSearch() {
78669
+ this.searchInput = this.searchInput.trim();
78670
+ if (this.searchInput === '') {
78671
+ this.isShowSearch = false;
78672
+ return;
78673
+ }
78674
+ this.isShowSearch = false;
78675
+ this.searchOptions = CascaderUtils.searchInTree(this.filteredOptions, this.searchInput, this.cascaderProps);
78676
+
78677
+ // 只设置搜索范围内的选中值
78678
+ this.searchSelectedValues = CascaderUtils.getSearchSelectedValues(this.selectedValues, this.searchOptions, this.cascaderProps);
78679
+ this.$nextTick(() => {
78680
+ this.isShowSearch = true;
78681
+ if (this.searchOptions.length > 0) {
78682
+ // 等待搜索面板渲染完成后再展开
78683
+ this.$nextTick(() => {
78684
+ this.handleSearchExpand();
78685
+ });
78686
+ }
78687
+ });
78688
+ },
78689
+ // 搜索模式下的展开处理
78690
+ handleSearchExpand() {
78691
+ if (this.$refs.searchCascaderPanel && this.searchOptions.length > 0) {
78692
+ const panel = this.$refs.searchCascaderPanel;
78693
+ const firstOption = this.searchOptions[0];
78694
+
78695
+ // 确保面板已经渲染
78696
+ if (panel.menus && panel.menus[0]) {
78697
+ // 找到第一个选项的节点
78698
+ const targetNode = panel.menus[0].find(node => node.value == firstOption[this.cascaderProps.value]);
78699
+ if (targetNode) {
78700
+ // 展开第一个选项
78701
+ panel.handleExpand(targetNode, true);
78702
+ // 递归展开所有子节点
78703
+ this.expandAllChildren(targetNode, panel);
78704
+ }
78705
+ }
78706
+ }
78707
+ },
78708
+ // 展开变化处理
78709
+ handleExpandChange(values = []) {
78710
+ if (values.length === 1) {
78711
+ this.$nextTick(() => {
78712
+ const panel = this.$refs.cascaderPanel || this.$refs.searchCascaderPanel;
78713
+ if (panel) {
78714
+ const menus = panel.menus;
78715
+ const targetNode = menus[0].find(node => node.value == values[0]);
78716
+ if (targetNode) {
78717
+ panel.handleExpand(targetNode, true);
78718
+ this.expandAllChildren(targetNode, panel);
78719
+ }
78720
+ }
78721
+ });
78722
+ }
78723
+ },
78724
+ // 展开所有子节点
78725
+ expandAllChildren(node, panel) {
78726
+ if (node[this.cascaderProps.children] && node[this.cascaderProps.children].length > 0) {
78727
+ const firstChild = node[this.cascaderProps.children][0];
78728
+ panel.handleExpand(firstChild, true);
78729
+ this.expandAllChildren(firstChild, panel);
78730
+ }
78731
+ },
78732
+ // 值变化处理
78733
+ handleValueChange() {
78734
+ this.searchSelectedValues = [...this.selectedValues];
78735
+ this.updateSelectedItems();
78736
+
78737
+ // 等待updateSelectedItems完成后再发出事件
78738
+ this.$nextTick(() => {
78739
+ this.isInternalUpdate = true; // 标记为内部更新
78740
+ let emitValue = this.currentValue;
78741
+
78742
+ // 聚合模式下,发出聚合后的值
78743
+ if (this.aggregationMode) {
78744
+ emitValue = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78745
+ if (!this.isMultiple && emitValue.length > 0) {
78746
+ emitValue = emitValue[0]; // 单选模式下返回单个值
78747
+ }
78748
+ }
78749
+ this.$emit('input', emitValue);
78750
+ });
78751
+ },
78752
+ // 搜索模式值变化处理
78753
+ handleSearchValueChange(value) {
78754
+ // 获取搜索面板中所有可能的叶子节点值
78755
+ const searchLeafValues = CascaderUtils.getLeafValues(this.searchOptions, this.cascaderProps);
78756
+ if (this.isMultiple) {
78757
+ // 多选模式:从主选择列表中移除搜索范围内的项,然后添加搜索面板中选中的项
78758
+ this.selectedValues = this.selectedValues.filter(path => {
78759
+ const leafValue = path[path.length - 1];
78760
+ return !searchLeafValues.includes(leafValue);
78761
+ });
78762
+ this.selectedValues = [...this.selectedValues, ...this.searchSelectedValues];
78763
+ } else {
78764
+ // 单选模式:直接替换为搜索面板中选中的项
78765
+ if (value && value.length > 0) {
78766
+ this.selectedValues = [value];
78767
+ } else {
78768
+ this.selectedValues = [];
78769
+ }
78770
+ }
78771
+ this.isShow = false;
78772
+ this.$nextTick(() => {
78773
+ this.isShow = true;
78774
+ });
78775
+ this.updateSelectedItems();
78776
+
78777
+ // 等待updateSelectedItems完成后再发出事件
78778
+ this.$nextTick(() => {
78779
+ this.isInternalUpdate = true; // 标记为内部更新
78780
+ let emitValue = this.currentValue;
78781
+
78782
+ // 聚合模式下,发出聚合后的值
78783
+ if (this.aggregationMode) {
78784
+ emitValue = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78785
+ if (!this.isMultiple && emitValue.length > 0) {
78786
+ emitValue = emitValue[0]; // 单选模式下返回单个值
78787
+ }
78788
+ }
78789
+ this.$emit('input', emitValue);
78790
+ });
78791
+ },
78792
+ // 移除已选项
78793
+ removeItem(item, index) {
78794
+ const valueToRemove = item.value;
78795
+
78796
+ // 从选择值中移除
78797
+ this.selectedValues = this.selectedValues.filter(path => {
78798
+ return !path.includes(valueToRemove);
78799
+ });
78800
+
78801
+ // 从搜索选择值中移除
78802
+ this.searchSelectedValues = this.searchSelectedValues.filter(path => {
78803
+ return !path.includes(valueToRemove);
78804
+ });
78805
+
78806
+ // 从已选项列表中移除
78807
+ this.selectedItems.splice(index, 1);
78808
+
78809
+ // 等待updateSelectedItems完成后再发出事件
78810
+ this.$nextTick(() => {
78811
+ this.isInternalUpdate = true; // 标记为内部更新
78812
+ let emitValue = this.currentValue;
78813
+
78814
+ // 聚合模式下,发出聚合后的值
78815
+ if (this.aggregationMode) {
78816
+ emitValue = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78817
+ if (!this.isMultiple && emitValue.length > 0) {
78818
+ emitValue = emitValue[0]; // 单选模式下返回单个值
78819
+ }
78820
+ }
78821
+ this.$emit('input', emitValue);
78822
+ });
78823
+ },
78824
+ // 全选/取消全选
78825
+ handleSelectAll() {
78826
+ if (!this.isMultiple) {
78827
+ // 单选模式下不支持全选
78828
+ return;
78829
+ }
78830
+ if (this.isAllSelected) {
78831
+ this.selectedValues = [];
78832
+ this.selectedItems = [];
78833
+ } else {
78834
+ const config = {
78835
+ disabledField: this.disabledField,
78836
+ disabledValue: this.disabledValue,
78837
+ disabledCheck: this.disabledCheck
78838
+ };
78839
+ // 无论是普通模式还是聚合模式,全选时都选择所有可选的叶子节点
78840
+ this.selectedValues = CascaderUtils.getAllLeafPaths(this.filteredOptions, config, this.cascaderProps);
78841
+ this.updateSelectedItems();
78842
+ }
78843
+ // 等待updateSelectedItems完成后再发出事件
78844
+ this.$nextTick(() => {
78845
+ this.isInternalUpdate = true; // 标记为内部更新
78846
+ let emitValue = this.currentValue;
78847
+
78848
+ // 聚合模式下,发出聚合后的值
78849
+ if (this.aggregationMode) {
78850
+ emitValue = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78851
+ if (!this.isMultiple && emitValue.length > 0) {
78852
+ emitValue = emitValue[0]; // 单选模式下返回单个值
78853
+ }
78854
+ }
78855
+ this.$emit('input', emitValue);
78856
+ });
78857
+ },
78858
+ // 获取选中的数据
78859
+ getSelectedData() {
78860
+ let values = this.currentValue;
78861
+ let valuesPath = this.selectedValues;
78862
+
78863
+ // 聚合模式下,返回聚合后的值和路径
78864
+ if (this.aggregationMode) {
78865
+ values = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78866
+ valuesPath = CascaderUtils.getAggregatedSelectedPaths(this.selectedValues, this.filteredOptions, this.cascaderProps);
78867
+ if (!this.isMultiple && values.length > 0) {
78868
+ values = values[0]; // 单选模式下返回单个值
78869
+ }
78870
+ }
78871
+ return {
78872
+ valuesPath: valuesPath,
78873
+ // 路径数组(聚合模式下已聚合)
78874
+ values: values,
78875
+ // 外部value(单选时返回单个值,多选时返回数组)
78876
+ items: this.selectedItems,
78877
+ count: this.selectedItems.length
78878
+ };
78879
+ },
78880
+ // 清空选择
78881
+ clearSelection() {
78882
+ this.selectedValues = [];
78883
+ this.selectedItems = [];
78884
+ this.searchSelectedValues = [];
78885
+ // 等待updateSelectedItems完成后再发出事件
78886
+ this.$nextTick(() => {
78887
+ this.isInternalUpdate = true; // 标记为内部更新
78888
+ let emitValue = this.currentValue;
78889
+
78890
+ // 聚合模式下,发出聚合后的值
78891
+ if (this.aggregationMode) {
78892
+ emitValue = CascaderUtils.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78893
+ if (!this.isMultiple && emitValue.length > 0) {
78894
+ emitValue = emitValue[0]; // 单选模式下返回单个值
78895
+ }
78896
+ }
78897
+ this.$emit('input', emitValue);
78898
+ });
78899
+ },
78900
+ // 设置选择值
78901
+ setValue(values) {
78902
+ if (this.isMultiple) {
78903
+ // 多选模式:支持直接传入value值或路径数组
78904
+ if (Array.isArray(values) && values.length > 0) {
78905
+ if (typeof values[0] === 'string' || typeof values[0] === 'number') {
78906
+ // 传入的是value值数组,需要转换为路径
78907
+ if (this.aggregationMode) {
78908
+ // 聚合模式下,支持非叶子节点标识
78909
+ this.selectedValues = CascaderUtils.processValuesWithParentNodes(values, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78910
+ } else {
78911
+ // 普通模式下,只处理叶子节点
78912
+ this.selectedValues = this.findPathsByValues(values);
78913
+ }
78914
+ } else {
78915
+ // 传入的是路径数组
78916
+ this.selectedValues = [...values];
78917
+ }
78918
+ } else {
78919
+ this.selectedValues = [];
78920
+ }
78921
+ } else {
78922
+ // 单选模式:支持单个值或路径数组
78923
+ if (values !== null && values !== undefined && values !== '') {
78924
+ if (Array.isArray(values)) {
78925
+ // 传入的是路径数组
78926
+ this.selectedValues = [...values];
78927
+ } else {
78928
+ // 传入的是单个值,需要转换为路径
78929
+ if (this.aggregationMode) {
78930
+ // 聚合模式下,支持非叶子节点标识
78931
+ this.selectedValues = CascaderUtils.processValuesWithParentNodes([values], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
78932
+ } else {
78933
+ // 普通模式下,只处理叶子节点
78934
+ this.selectedValues = this.findPathsByValues([values]);
78935
+ }
78936
+ }
78937
+ } else {
78938
+ this.selectedValues = [];
78939
+ }
78940
+ }
78941
+ this.updateSelectedItems();
78942
+ },
78943
+ // 根据values找到对应的路径
78944
+ findPathsByValues(values) {
78945
+ const paths = [];
78946
+ const findPath = (options, targetValues, currentPath = []) => {
78947
+ for (const option of options) {
78948
+ const newPath = [...currentPath, option[this.cascaderProps.value]];
78949
+ if (targetValues.includes(option[this.cascaderProps.value])) {
78950
+ // 如果是叶子节点(没有children属性),添加到路径中
78951
+ if (!option[this.cascaderProps.children]) {
78952
+ paths.push(newPath);
78953
+ }
78954
+ }
78955
+
78956
+ // 递归查找子节点
78957
+ if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
78958
+ findPath(option[this.cascaderProps.children], targetValues, newPath);
78959
+ }
78960
+ }
78961
+ };
78962
+
78963
+ // 使用 filteredOptions 如果存在,否则使用原始 options
78964
+ const optionsToSearch = this.filteredOptions.length > 0 ? this.filteredOptions : this.options;
78965
+ findPath(optionsToSearch, values);
78966
+ return paths;
78967
+ }
78968
+ }
78969
+ });
78970
+ ;// ./src/components/cascader-panel/ByCascaderPanel.vue?vue&type=script&lang=js
78971
+ /* harmony default export */ var cascader_panel_ByCascaderPanelvue_type_script_lang_js = (ByCascaderPanelvue_type_script_lang_js);
78972
+ ;// ./src/components/cascader-panel/ByCascaderPanel.vue
78973
+
78974
+
78975
+
78976
+
78977
+
78978
+ /* normalize component */
78979
+ ;
78980
+ var ByCascaderPanel_component = normalizeComponent(
78981
+ cascader_panel_ByCascaderPanelvue_type_script_lang_js,
78982
+ ByCascaderPanelvue_type_template_id_d3dd0512_render,
78983
+ ByCascaderPanelvue_type_template_id_d3dd0512_staticRenderFns,
78984
+ false,
78985
+ null,
78986
+ null,
78987
+ null
78988
+
78989
+ )
78990
+
78991
+ /* harmony default export */ var ByCascaderPanel = (ByCascaderPanel_component.exports);
77521
78992
  ;// ./src/index.js
77522
78993
 
77523
78994
 
@@ -77537,6 +79008,7 @@ ByDialogService.install = function (Vue) {
77537
79008
 
77538
79009
 
77539
79010
 
79011
+
77540
79012
  const components = {
77541
79013
  ByPager: pager,
77542
79014
  ByTable: table,
@@ -77550,7 +79022,8 @@ const components = {
77550
79022
  ByCommonSelector: ByCommonSelector,
77551
79023
  ByBatchQuerySelector: BatchQuerySelector,
77552
79024
  ByTreeSearch: ByTreeSearch,
77553
- ByDialog: ByDialog
79025
+ ByDialog: ByDialog,
79026
+ ByCascaderPanel: ByCascaderPanel
77554
79027
  };
77555
79028
 
77556
79029
  // 设置当前 z-index 起始值