@weitutech/by-components 1.1.221 → 1.2.1
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/lib/by-components.common.js +2994 -417
- package/lib/by-components.umd.js +2994 -417
- package/lib/by-components.umd.min.js +15 -15
- package/lib/index.css +1 -1
- package/package.json +1 -1
package/lib/by-components.umd.js
CHANGED
|
@@ -74286,6 +74286,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
74286
74286
|
ByCardSelector: function() { return /* reexport */ ByCardSelector; },
|
|
74287
74287
|
ByCardView: function() { return /* reexport */ ByCardView; },
|
|
74288
74288
|
ByCascaderPanel: function() { return /* reexport */ ByCascaderPanel; },
|
|
74289
|
+
ByCascaderPanelPro: function() { return /* reexport */ ByCascaderPanelPro; },
|
|
74289
74290
|
ByCommonInput: function() { return /* reexport */ ByCommonInput; },
|
|
74290
74291
|
ByCommonSelector: function() { return /* reexport */ ByCommonSelector; },
|
|
74291
74292
|
ByCustomDatePicker: function() { return /* reexport */ custom_date_picker; },
|
|
@@ -74303,7 +74304,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
74303
74304
|
ByTable: function() { return /* reexport */ table; },
|
|
74304
74305
|
ByTag: function() { return /* reexport */ ByTag; },
|
|
74305
74306
|
ByToolBar: function() { return /* reexport */ ByToolBar; },
|
|
74306
|
-
ByTreePanel: function() { return /* reexport */ ByTreePanel; },
|
|
74307
74307
|
ByTreeSearch: function() { return /* reexport */ ByTreeSearch; },
|
|
74308
74308
|
GridItem: function() { return /* reexport */ vue_grid_layout_common.GridItem; },
|
|
74309
74309
|
ToolBarItemType: function() { return /* reexport */ ToolBarItemType; },
|
|
@@ -96025,12 +96025,12 @@ var ByCascaderPanel_component = normalizeComponent(
|
|
|
96025
96025
|
)
|
|
96026
96026
|
|
|
96027
96027
|
/* harmony default export */ var ByCascaderPanel = (ByCascaderPanel_component.exports);
|
|
96028
|
-
;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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/
|
|
96029
|
-
var
|
|
96028
|
+
;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/ByCascaderPanelPro.vue?vue&type=template&id=804df886
|
|
96029
|
+
var ByCascaderPanelProvue_type_template_id_804df886_render = function render() {
|
|
96030
96030
|
var _vm = this,
|
|
96031
96031
|
_c = _vm._self._c;
|
|
96032
96032
|
return _c('div', {
|
|
96033
|
-
staticClass: "
|
|
96033
|
+
staticClass: "cascader-panel-pro"
|
|
96034
96034
|
}, [_c('div', {
|
|
96035
96035
|
staticClass: "panel-container"
|
|
96036
96036
|
}, [_c('div', {
|
|
@@ -96051,9 +96051,6 @@ var ByTreePanelvue_type_template_id_af06ba0a_render = function render() {
|
|
|
96051
96051
|
"size": "mini",
|
|
96052
96052
|
"disabled": _vm.isViewMode
|
|
96053
96053
|
},
|
|
96054
|
-
on: {
|
|
96055
|
-
"input": _vm.handleSearch
|
|
96056
|
-
},
|
|
96057
96054
|
model: {
|
|
96058
96055
|
value: _vm.searchInput,
|
|
96059
96056
|
callback: function ($$v) {
|
|
@@ -96066,7 +96063,7 @@ var ByTreePanelvue_type_template_id_af06ba0a_render = function render() {
|
|
|
96066
96063
|
"placement": "bottom-start",
|
|
96067
96064
|
"width": 300,
|
|
96068
96065
|
"trigger": "click",
|
|
96069
|
-
"popper-class": "batch-search-popover"
|
|
96066
|
+
"popper-class": "batch-search-popover-pro"
|
|
96070
96067
|
},
|
|
96071
96068
|
on: {
|
|
96072
96069
|
"show": _vm.handleBatchSearchShow
|
|
@@ -96138,26 +96135,69 @@ var ByTreePanelvue_type_template_id_af06ba0a_render = function render() {
|
|
|
96138
96135
|
height: _vm.computedPanelHeight + 'px'
|
|
96139
96136
|
}
|
|
96140
96137
|
}, [_c('div', {
|
|
96141
|
-
staticClass: "
|
|
96142
|
-
|
|
96143
|
-
|
|
96144
|
-
|
|
96138
|
+
staticClass: "cascader-content-wrapper",
|
|
96139
|
+
style: {
|
|
96140
|
+
height: '100%'
|
|
96141
|
+
}
|
|
96142
|
+
}, [_vm.isShow && _vm.filteredOptions.length > 0 ? _c('VirtualCascaderPanel', {
|
|
96143
|
+
directives: [{
|
|
96144
|
+
name: "show",
|
|
96145
|
+
rawName: "v-show",
|
|
96146
|
+
value: _vm.searchInput === '' || !_vm.isShowSearch,
|
|
96147
|
+
expression: "searchInput === '' || !isShowSearch"
|
|
96148
|
+
}],
|
|
96149
|
+
ref: "cascaderPanel",
|
|
96150
|
+
staticClass: "cascader-panel-inner",
|
|
96151
|
+
style: {
|
|
96152
|
+
height: _vm.computedPanelHeight - 20 + 'px'
|
|
96153
|
+
},
|
|
96145
96154
|
attrs: {
|
|
96146
|
-
"
|
|
96147
|
-
"
|
|
96148
|
-
"
|
|
96149
|
-
"
|
|
96150
|
-
"
|
|
96151
|
-
"
|
|
96152
|
-
"
|
|
96153
|
-
"
|
|
96154
|
-
"
|
|
96155
|
+
"value": _vm.panelPresentationValue,
|
|
96156
|
+
"sync-value-from-parent": !_vm.useCompactSelection,
|
|
96157
|
+
"options": _vm.filteredOptions,
|
|
96158
|
+
"props": _vm.cascaderProps,
|
|
96159
|
+
"height": _vm.computedPanelHeight - 20,
|
|
96160
|
+
"column-min-width": _vm.columnMinWidth,
|
|
96161
|
+
"column-max-width": _vm.columnMaxWidth,
|
|
96162
|
+
"disabled-config": _vm.disabledConfig,
|
|
96163
|
+
"is-view-mode": _vm.isViewMode
|
|
96164
|
+
},
|
|
96165
|
+
on: {
|
|
96166
|
+
"input": _vm.onMainPanelInput,
|
|
96167
|
+
"change": _vm.handleValueChange,
|
|
96168
|
+
"store-ready": _vm.schedulePanelSyncFromExternalValue
|
|
96169
|
+
}
|
|
96170
|
+
}) : _vm._e(), _vm.searchOptions.length > 0 ? _c('VirtualCascaderPanel', {
|
|
96171
|
+
directives: [{
|
|
96172
|
+
name: "show",
|
|
96173
|
+
rawName: "v-show",
|
|
96174
|
+
value: _vm.searchInput !== '' && _vm.isShowSearch,
|
|
96175
|
+
expression: "searchInput !== '' && isShowSearch"
|
|
96176
|
+
}],
|
|
96177
|
+
ref: "searchCascaderPanel",
|
|
96178
|
+
staticClass: "cascader-panel-inner",
|
|
96179
|
+
attrs: {
|
|
96180
|
+
"value": _vm.compactSearchPanelValue,
|
|
96181
|
+
"sync-value-from-parent": false,
|
|
96182
|
+
"options": _vm.searchOptions,
|
|
96183
|
+
"props": _vm.cascaderProps,
|
|
96184
|
+
"height": _vm.computedPanelHeight - 20,
|
|
96185
|
+
"column-min-width": _vm.columnMinWidth,
|
|
96186
|
+
"column-max-width": _vm.columnMaxWidth,
|
|
96187
|
+
"disabled-config": _vm.disabledConfig,
|
|
96188
|
+
"is-view-mode": _vm.isViewMode
|
|
96155
96189
|
},
|
|
96156
96190
|
on: {
|
|
96157
|
-
"
|
|
96158
|
-
"
|
|
96191
|
+
"input": _vm.onSearchPanelInput,
|
|
96192
|
+
"change": _vm.handleSearchValueChange
|
|
96159
96193
|
}
|
|
96160
|
-
}) : _vm.
|
|
96194
|
+
}) : _vm._e(), _vm.isShowSearch && _vm.searchOptions.length === 0 ? _c('div', {
|
|
96195
|
+
directives: [{
|
|
96196
|
+
name: "show",
|
|
96197
|
+
rawName: "v-show",
|
|
96198
|
+
value: _vm.searchInput !== '',
|
|
96199
|
+
expression: "searchInput !== ''"
|
|
96200
|
+
}],
|
|
96161
96201
|
staticClass: "empty-search"
|
|
96162
96202
|
}, [_c('el-empty', {
|
|
96163
96203
|
attrs: {
|
|
@@ -96183,33 +96223,54 @@ var ByTreePanelvue_type_template_id_af06ba0a_render = function render() {
|
|
|
96183
96223
|
}
|
|
96184
96224
|
}, [_c('div', {
|
|
96185
96225
|
staticClass: "selected-list"
|
|
96186
|
-
}, [_vm.
|
|
96187
|
-
|
|
96188
|
-
|
|
96189
|
-
|
|
96190
|
-
},
|
|
96191
|
-
|
|
96192
|
-
|
|
96193
|
-
|
|
96194
|
-
|
|
96195
|
-
|
|
96196
|
-
|
|
96197
|
-
|
|
96198
|
-
|
|
96199
|
-
|
|
96200
|
-
|
|
96201
|
-
|
|
96226
|
+
}, [_vm.selectedItems.length > 0 ? _c('VcpVirtualList', {
|
|
96227
|
+
staticClass: "selected-virtual-list",
|
|
96228
|
+
style: {
|
|
96229
|
+
height: _vm.selectedListHeight + 'px'
|
|
96230
|
+
},
|
|
96231
|
+
attrs: {
|
|
96232
|
+
"items": _vm.selectedItems,
|
|
96233
|
+
"item-height": _vm.selectedItemHeight,
|
|
96234
|
+
"height": _vm.selectedListHeight,
|
|
96235
|
+
"list-padding": 0,
|
|
96236
|
+
"overscan": 10
|
|
96237
|
+
},
|
|
96238
|
+
scopedSlots: _vm._u([{
|
|
96239
|
+
key: "default",
|
|
96240
|
+
fn: function ({
|
|
96241
|
+
item,
|
|
96242
|
+
index
|
|
96243
|
+
}) {
|
|
96244
|
+
return [_c('div', {
|
|
96245
|
+
key: 'selected-' + item.value + '-' + index,
|
|
96246
|
+
staticClass: "selected-item-row"
|
|
96247
|
+
}, [_c('div', {
|
|
96248
|
+
staticClass: "selected-item"
|
|
96249
|
+
}, [_c('div', {
|
|
96250
|
+
staticClass: "item-content"
|
|
96251
|
+
}, [_c('div', {
|
|
96252
|
+
staticClass: "item-label"
|
|
96253
|
+
}, [_vm._v(_vm._s(item.label || ''))]), _vm.showSubtitle && _vm.subtitleField && item[_vm.subtitleField] ? _c('div', {
|
|
96254
|
+
staticClass: "item-subtitle"
|
|
96255
|
+
}, [_vm._v(" " + _vm._s(item[_vm.subtitleField]) + " ")]) : _vm._e()]), !_vm.isViewMode ? _c('div', {
|
|
96256
|
+
staticClass: "remove-btn",
|
|
96257
|
+
on: {
|
|
96258
|
+
"click": function ($event) {
|
|
96259
|
+
return _vm.removeItem(item, index);
|
|
96260
|
+
}
|
|
96261
|
+
}
|
|
96262
|
+
}, [_c('i', {
|
|
96263
|
+
staticClass: "el-icon-close"
|
|
96264
|
+
})]) : _vm._e()])])];
|
|
96202
96265
|
}
|
|
96203
|
-
},
|
|
96204
|
-
|
|
96205
|
-
})]) : _vm._e()]);
|
|
96206
|
-
}), _vm.selectedItems.length === 0 ? _c('div', {
|
|
96266
|
+
}], null, false, 2638469921)
|
|
96267
|
+
}) : _c('div', {
|
|
96207
96268
|
staticClass: "empty-state"
|
|
96208
|
-
}, [_vm._v("暂无选中项")])
|
|
96269
|
+
}, [_vm._v("暂无选中项")])], 1)])])])]);
|
|
96209
96270
|
};
|
|
96210
|
-
var
|
|
96271
|
+
var ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns = [];
|
|
96211
96272
|
|
|
96212
|
-
;// ./
|
|
96273
|
+
;// ./src/components/cascader-panel-pro/cascaderUtilsPro.js
|
|
96213
96274
|
|
|
96214
96275
|
|
|
96215
96276
|
|
|
@@ -96218,374 +96279,2753 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96218
96279
|
|
|
96219
96280
|
|
|
96220
96281
|
|
|
96221
|
-
|
|
96222
|
-
|
|
96223
|
-
|
|
96224
|
-
|
|
96225
|
-
|
|
96226
|
-
|
|
96227
|
-
|
|
96228
|
-
|
|
96229
|
-
|
|
96230
|
-
|
|
96231
|
-
|
|
96232
|
-
|
|
96233
|
-
|
|
96234
|
-
|
|
96235
|
-
|
|
96236
|
-
|
|
96237
|
-
|
|
96238
|
-
children: 'children'
|
|
96239
|
-
})
|
|
96240
|
-
},
|
|
96241
|
-
panelHeight: {
|
|
96242
|
-
type: [String, Number],
|
|
96243
|
-
default: 300
|
|
96244
|
-
},
|
|
96245
|
-
searchPlaceholder: {
|
|
96246
|
-
type: String,
|
|
96247
|
-
default: '请输入名称搜索'
|
|
96248
|
-
},
|
|
96249
|
-
disabledField: {
|
|
96250
|
-
type: String,
|
|
96251
|
-
default: 'disabled'
|
|
96252
|
-
},
|
|
96253
|
-
disabledValue: {
|
|
96254
|
-
type: [String, Number, Boolean],
|
|
96255
|
-
default: true
|
|
96256
|
-
},
|
|
96257
|
-
disabledCheck: {
|
|
96258
|
-
type: Function,
|
|
96259
|
-
default: null
|
|
96260
|
-
},
|
|
96261
|
-
showSelectAll: {
|
|
96262
|
-
type: Boolean,
|
|
96263
|
-
default: true
|
|
96264
|
-
},
|
|
96265
|
-
aggregationMode: {
|
|
96266
|
-
type: Boolean,
|
|
96267
|
-
default: false
|
|
96268
|
-
},
|
|
96269
|
-
parentNodePrefix: {
|
|
96270
|
-
type: String,
|
|
96271
|
-
default: '__parent__'
|
|
96272
|
-
},
|
|
96273
|
-
isViewMode: {
|
|
96274
|
-
type: Boolean,
|
|
96275
|
-
default: false
|
|
96276
|
-
},
|
|
96277
|
-
showSubtitle: {
|
|
96278
|
-
type: Boolean,
|
|
96279
|
-
default: false
|
|
96280
|
-
},
|
|
96281
|
-
subtitleField: {
|
|
96282
|
-
type: String,
|
|
96283
|
-
default: ''
|
|
96284
|
-
}
|
|
96285
|
-
},
|
|
96286
|
-
data() {
|
|
96287
|
-
return {
|
|
96288
|
-
selectedValues: [],
|
|
96289
|
-
filteredOptions: [],
|
|
96290
|
-
displayOptions: [],
|
|
96291
|
-
selectedItems: [],
|
|
96292
|
-
searchInput: '',
|
|
96293
|
-
totalCount: 0,
|
|
96294
|
-
selectedCount: 0,
|
|
96295
|
-
isAllSelected: false,
|
|
96296
|
-
isInternalUpdate: false,
|
|
96297
|
-
batchSearchVisible: false,
|
|
96298
|
-
batchSearchContent: '',
|
|
96299
|
-
searchDebounceTimer: null,
|
|
96300
|
-
isSyncingTree: false
|
|
96301
|
-
};
|
|
96302
|
-
},
|
|
96303
|
-
computed: {
|
|
96304
|
-
computedPanelHeight() {
|
|
96305
|
-
const height = Number(this.panelHeight);
|
|
96306
|
-
if (isNaN(height)) return 300;
|
|
96307
|
-
return Math.max(200, Math.min(800, height));
|
|
96308
|
-
},
|
|
96309
|
-
isMultiple() {
|
|
96310
|
-
return this.cascaderProps.multiple !== false;
|
|
96311
|
-
},
|
|
96312
|
-
valueKey() {
|
|
96313
|
-
return this.cascaderProps.value || 'value';
|
|
96314
|
-
},
|
|
96315
|
-
labelKey() {
|
|
96316
|
-
return this.cascaderProps.label || 'label';
|
|
96317
|
-
},
|
|
96318
|
-
childrenKey() {
|
|
96319
|
-
return this.cascaderProps.children || 'children';
|
|
96320
|
-
},
|
|
96321
|
-
nodeKey() {
|
|
96322
|
-
return this.valueKey;
|
|
96323
|
-
},
|
|
96324
|
-
treeFieldProps() {
|
|
96325
|
-
return {
|
|
96326
|
-
label: this.labelKey,
|
|
96327
|
-
children: this.childrenKey,
|
|
96328
|
-
disabled: 'disabled'
|
|
96329
|
-
};
|
|
96330
|
-
},
|
|
96331
|
-
disabledConfig() {
|
|
96332
|
-
return {
|
|
96333
|
-
disabledField: this.disabledField,
|
|
96334
|
-
disabledValue: this.disabledValue,
|
|
96335
|
-
disabledCheck: this.disabledCheck
|
|
96336
|
-
};
|
|
96337
|
-
},
|
|
96338
|
-
currentValue() {
|
|
96339
|
-
if (this.isMultiple) {
|
|
96340
|
-
return this.selectedItems.map(item => item.value);
|
|
96341
|
-
}
|
|
96342
|
-
return this.selectedItems.length > 0 ? this.selectedItems[0].value : null;
|
|
96282
|
+
|
|
96283
|
+
|
|
96284
|
+
|
|
96285
|
+
|
|
96286
|
+
|
|
96287
|
+
|
|
96288
|
+
|
|
96289
|
+
/**
|
|
96290
|
+
* 级联选择器工具类(Pro 版,独立于 CascaderUtils)
|
|
96291
|
+
*/
|
|
96292
|
+
class CascaderUtilsPro {
|
|
96293
|
+
/**
|
|
96294
|
+
* 估算级联节点标签文本宽度(px)
|
|
96295
|
+
*/
|
|
96296
|
+
static measureCascaderLabelWidth(label, fontSize = 14) {
|
|
96297
|
+
if (!label) {
|
|
96298
|
+
return 0;
|
|
96343
96299
|
}
|
|
96344
|
-
|
|
96345
|
-
|
|
96346
|
-
|
|
96347
|
-
|
|
96348
|
-
|
|
96349
|
-
},
|
|
96350
|
-
immediate: true
|
|
96351
|
-
},
|
|
96352
|
-
value: {
|
|
96353
|
-
handler() {
|
|
96354
|
-
if (this.isInternalUpdate) {
|
|
96355
|
-
this.isInternalUpdate = false;
|
|
96356
|
-
return;
|
|
96357
|
-
}
|
|
96358
|
-
if (!this.filteredOptions.length) return;
|
|
96359
|
-
this.processValue();
|
|
96360
|
-
},
|
|
96361
|
-
deep: true
|
|
96362
|
-
},
|
|
96363
|
-
selectedValues: {
|
|
96364
|
-
handler() {
|
|
96365
|
-
this.updateSelectAllState();
|
|
96366
|
-
},
|
|
96367
|
-
deep: true
|
|
96300
|
+
const str = String(label);
|
|
96301
|
+
let width = 0;
|
|
96302
|
+
for (let i = 0; i < str.length; i++) {
|
|
96303
|
+
const code = str.charCodeAt(i);
|
|
96304
|
+
width += code > 255 ? fontSize : Math.ceil(fontSize * 0.55);
|
|
96368
96305
|
}
|
|
96369
|
-
|
|
96370
|
-
|
|
96371
|
-
|
|
96372
|
-
|
|
96373
|
-
|
|
96306
|
+
return width;
|
|
96307
|
+
}
|
|
96308
|
+
|
|
96309
|
+
/**
|
|
96310
|
+
* 根据列内最长标签计算列宽
|
|
96311
|
+
*/
|
|
96312
|
+
static getCascaderColumnWidth(nodes, options = {}) {
|
|
96313
|
+
const {
|
|
96314
|
+
minWidth = 180,
|
|
96315
|
+
maxWidth = 420,
|
|
96316
|
+
extraPadding = 56,
|
|
96317
|
+
hasCheckbox = true
|
|
96318
|
+
} = options;
|
|
96319
|
+
if (!nodes || nodes.length === 0) {
|
|
96320
|
+
return minWidth;
|
|
96321
|
+
}
|
|
96322
|
+
let maxLabelWidth = 0;
|
|
96323
|
+
nodes.forEach(node => {
|
|
96324
|
+
maxLabelWidth = Math.max(maxLabelWidth, this.measureCascaderLabelWidth(node.label));
|
|
96374
96325
|
});
|
|
96375
|
-
|
|
96376
|
-
|
|
96377
|
-
|
|
96378
|
-
|
|
96326
|
+
const checkboxWidth = hasCheckbox ? 28 : 0;
|
|
96327
|
+
const arrowWidth = 24;
|
|
96328
|
+
const contentWidth = maxLabelWidth + extraPadding + checkboxWidth + arrowWidth;
|
|
96329
|
+
return Math.min(maxWidth, Math.max(minWidth, Math.ceil(contentWidth)));
|
|
96330
|
+
}
|
|
96331
|
+
|
|
96332
|
+
/**
|
|
96333
|
+
* 判断项目是否禁用
|
|
96334
|
+
* @param {Object} item - 项目数据
|
|
96335
|
+
* @param {Object} config - 禁用配置
|
|
96336
|
+
* @param {String} config.disabledField - 禁用字段名
|
|
96337
|
+
* @param {*} config.disabledValue - 禁用值
|
|
96338
|
+
* @param {Function} config.disabledCheck - 自定义禁用判断函数
|
|
96339
|
+
* @returns {Boolean} 是否禁用
|
|
96340
|
+
*/
|
|
96341
|
+
static isItemDisabled(item, config) {
|
|
96342
|
+
const {
|
|
96343
|
+
disabledField,
|
|
96344
|
+
disabledValue,
|
|
96345
|
+
disabledCheck
|
|
96346
|
+
} = config;
|
|
96347
|
+
|
|
96348
|
+
// 优先使用自定义禁用判断函数
|
|
96349
|
+
if (disabledCheck && typeof disabledCheck === 'function') {
|
|
96350
|
+
return disabledCheck(item);
|
|
96379
96351
|
}
|
|
96380
|
-
|
|
96381
|
-
|
|
96382
|
-
|
|
96383
|
-
|
|
96384
|
-
|
|
96385
|
-
|
|
96386
|
-
|
|
96387
|
-
|
|
96388
|
-
|
|
96389
|
-
|
|
96390
|
-
|
|
96391
|
-
|
|
96392
|
-
|
|
96393
|
-
|
|
96394
|
-
|
|
96395
|
-
|
|
96396
|
-
|
|
96352
|
+
|
|
96353
|
+
// 检查直接的 disabled 属性
|
|
96354
|
+
if (item.disabled === true) {
|
|
96355
|
+
return true;
|
|
96356
|
+
}
|
|
96357
|
+
|
|
96358
|
+
// 使用字段判断
|
|
96359
|
+
const fieldValue = item[disabledField];
|
|
96360
|
+
if (fieldValue !== undefined) {
|
|
96361
|
+
return fieldValue === disabledValue;
|
|
96362
|
+
}
|
|
96363
|
+
return false;
|
|
96364
|
+
}
|
|
96365
|
+
|
|
96366
|
+
/**
|
|
96367
|
+
* 检查路径上是否存在禁选项
|
|
96368
|
+
* @param {Array} tree - 树形数据
|
|
96369
|
+
* @param {Array} path - 路径数组
|
|
96370
|
+
* @param {Object} config - 禁用配置
|
|
96371
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96372
|
+
* @returns {Boolean} 路径上是否存在禁选项
|
|
96373
|
+
*/
|
|
96374
|
+
static isPathDisabled(tree, path, config, cascaderProps) {
|
|
96375
|
+
if (!path || path.length === 0) return false;
|
|
96376
|
+
const findPathInTree = (nodes, targetPath, currentIndex = 0) => {
|
|
96377
|
+
if (currentIndex >= targetPath.length) return false;
|
|
96378
|
+
for (const node of nodes) {
|
|
96379
|
+
if (node[cascaderProps.value] === targetPath[currentIndex]) {
|
|
96380
|
+
// 检查当前节点是否禁用
|
|
96381
|
+
if (this.isItemDisabled(node, config)) {
|
|
96382
|
+
return true;
|
|
96383
|
+
}
|
|
96384
|
+
|
|
96385
|
+
// 如果还有下一级,继续检查
|
|
96386
|
+
if (currentIndex < targetPath.length - 1 && node[cascaderProps.children]) {
|
|
96387
|
+
return findPathInTree(node[cascaderProps.children], targetPath, currentIndex + 1);
|
|
96388
|
+
}
|
|
96389
|
+
|
|
96390
|
+
// 如果已经到达路径末尾,返回false(路径上没有禁选项)
|
|
96391
|
+
return false;
|
|
96392
|
+
}
|
|
96393
|
+
}
|
|
96394
|
+
return false;
|
|
96395
|
+
};
|
|
96396
|
+
return findPathInTree(tree, path);
|
|
96397
|
+
}
|
|
96398
|
+
|
|
96399
|
+
/**
|
|
96400
|
+
* 设置禁用项
|
|
96401
|
+
* @param {Array} options - 选项数据
|
|
96402
|
+
* @param {Object} config - 禁用配置
|
|
96403
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96404
|
+
*/
|
|
96405
|
+
static setDisabledItems(options, config, cascaderProps) {
|
|
96406
|
+
const processItems = items => {
|
|
96407
|
+
items.forEach(item => {
|
|
96408
|
+
// 判断是否禁用
|
|
96409
|
+
if (this.isItemDisabled(item, config)) {
|
|
96410
|
+
item.disabled = true;
|
|
96411
|
+
}
|
|
96412
|
+
// 递归处理子项
|
|
96413
|
+
if (item[cascaderProps.children]) {
|
|
96414
|
+
processItems(item[cascaderProps.children]);
|
|
96415
|
+
}
|
|
96416
|
+
});
|
|
96417
|
+
};
|
|
96418
|
+
processItems(options);
|
|
96419
|
+
}
|
|
96420
|
+
|
|
96421
|
+
/**
|
|
96422
|
+
* 统计总项目数(排除禁用项和路径上有禁选项的项)
|
|
96423
|
+
* @param {Array} options - 选项数据
|
|
96424
|
+
* @param {Object} config - 禁用配置
|
|
96425
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96426
|
+
* @returns {Number} 总项目数
|
|
96427
|
+
*/
|
|
96428
|
+
static countTotalItems(options, config, cascaderProps) {
|
|
96429
|
+
let totalCount = 0;
|
|
96430
|
+
const countItems = (items, currentPath = []) => {
|
|
96431
|
+
items.forEach(item => {
|
|
96432
|
+
const newPath = [...currentPath, item[cascaderProps.value]];
|
|
96433
|
+
|
|
96434
|
+
// 检查当前节点是否禁用
|
|
96435
|
+
const isCurrentDisabled = this.isItemDisabled(item, config);
|
|
96436
|
+
if (!item[cascaderProps.children]) {
|
|
96437
|
+
// 只统计非禁用项且路径上没有禁选项的叶子节点
|
|
96438
|
+
if (!isCurrentDisabled && !this.isPathDisabled(options, newPath, config, cascaderProps)) {
|
|
96439
|
+
totalCount++;
|
|
96440
|
+
}
|
|
96441
|
+
} else {
|
|
96442
|
+
// 如果当前节点禁用,则其所有子节点都不可选
|
|
96443
|
+
if (!isCurrentDisabled) {
|
|
96444
|
+
countItems(item[cascaderProps.children], newPath);
|
|
96445
|
+
}
|
|
96446
|
+
}
|
|
96447
|
+
});
|
|
96448
|
+
};
|
|
96449
|
+
countItems(options);
|
|
96450
|
+
return totalCount;
|
|
96451
|
+
}
|
|
96452
|
+
|
|
96453
|
+
/**
|
|
96454
|
+
* 在树形数据中搜索
|
|
96455
|
+
* @param {Array} tree - 树形数据
|
|
96456
|
+
* @param {String} keyword - 搜索关键词
|
|
96457
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96458
|
+
* @returns {Array} 搜索结果
|
|
96459
|
+
*/
|
|
96460
|
+
static searchInTree(tree, keyword, cascaderProps) {
|
|
96461
|
+
const result = [];
|
|
96462
|
+
const labelKey = cascaderProps.label || 'label';
|
|
96463
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
96464
|
+
tree.forEach(node => {
|
|
96465
|
+
const label = node[labelKey];
|
|
96466
|
+
if (label && label.includes(keyword)) {
|
|
96467
|
+
result.push({
|
|
96468
|
+
...node
|
|
96469
|
+
});
|
|
96470
|
+
} else if (node[childrenKey]) {
|
|
96471
|
+
const matchedChildren = this.searchInTree(node[childrenKey], keyword, cascaderProps);
|
|
96472
|
+
if (matchedChildren.length > 0) {
|
|
96473
|
+
result.push({
|
|
96474
|
+
...node,
|
|
96475
|
+
[childrenKey]: matchedChildren
|
|
96476
|
+
});
|
|
96477
|
+
}
|
|
96478
|
+
}
|
|
96479
|
+
});
|
|
96480
|
+
return result;
|
|
96481
|
+
}
|
|
96482
|
+
|
|
96483
|
+
/**
|
|
96484
|
+
* 基于扁平 store 快速搜索(父节点命中时直接复用 raw 子树,跳过子级遍历)
|
|
96485
|
+
*/
|
|
96486
|
+
static searchFromStore(store, keyword, cascaderProps) {
|
|
96487
|
+
if (!store || !keyword) {
|
|
96488
|
+
return [];
|
|
96489
|
+
}
|
|
96490
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
96491
|
+
const walk = parentId => {
|
|
96492
|
+
const childIds = parentId == null ? store.rootIds : store.childrenByParentId.get(parentId) || [];
|
|
96493
|
+
const result = [];
|
|
96494
|
+
for (let i = 0; i < childIds.length; i++) {
|
|
96495
|
+
const node = store.nodeById.get(childIds[i]);
|
|
96496
|
+
if (!node) {
|
|
96497
|
+
continue;
|
|
96498
|
+
}
|
|
96499
|
+
const label = node.label || '';
|
|
96500
|
+
if (label.includes(keyword)) {
|
|
96501
|
+
result.push({
|
|
96502
|
+
...node.raw
|
|
96503
|
+
});
|
|
96504
|
+
} else if (!node.isLeaf) {
|
|
96505
|
+
const matchedChildren = walk(node.id);
|
|
96506
|
+
if (matchedChildren.length > 0) {
|
|
96507
|
+
result.push({
|
|
96508
|
+
...node.raw,
|
|
96509
|
+
[childrenKey]: matchedChildren
|
|
96510
|
+
});
|
|
96511
|
+
}
|
|
96512
|
+
}
|
|
96513
|
+
}
|
|
96514
|
+
return result;
|
|
96515
|
+
};
|
|
96516
|
+
return walk(null);
|
|
96517
|
+
}
|
|
96518
|
+
|
|
96519
|
+
/**
|
|
96520
|
+
* 获取叶子节点的值
|
|
96521
|
+
* @param {Array} tree - 树形数据
|
|
96522
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96523
|
+
* @returns {Array} 叶子节点值数组
|
|
96524
|
+
*/
|
|
96525
|
+
static getLeafValues(tree, cascaderProps) {
|
|
96526
|
+
const leafValues = [];
|
|
96527
|
+
const traverse = nodes => {
|
|
96528
|
+
nodes.forEach(node => {
|
|
96529
|
+
if (!node[cascaderProps.children]) {
|
|
96530
|
+
leafValues.push(node[cascaderProps.value]);
|
|
96531
|
+
} else {
|
|
96532
|
+
traverse(node[cascaderProps.children]);
|
|
96533
|
+
}
|
|
96534
|
+
});
|
|
96535
|
+
};
|
|
96536
|
+
traverse(tree);
|
|
96537
|
+
return leafValues;
|
|
96538
|
+
}
|
|
96539
|
+
|
|
96540
|
+
/**
|
|
96541
|
+
* 获取所有叶子节点的路径(排除禁用项和路径上有禁选项的项)
|
|
96542
|
+
* @param {Array} tree - 树形数据
|
|
96543
|
+
* @param {Object} config - 禁用配置
|
|
96544
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96545
|
+
* @returns {Array} 路径数组
|
|
96546
|
+
*/
|
|
96547
|
+
static getAllLeafPaths(tree, config, cascaderProps) {
|
|
96548
|
+
const paths = [];
|
|
96549
|
+
const traverse = (nodes, currentPath = []) => {
|
|
96550
|
+
nodes.forEach(node => {
|
|
96551
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96552
|
+
|
|
96553
|
+
// 检查当前节点是否禁用
|
|
96554
|
+
const isCurrentDisabled = this.isItemDisabled(node, config);
|
|
96555
|
+
if (!node[cascaderProps.children]) {
|
|
96556
|
+
// 只包含非禁用项且路径上没有禁选项的叶子节点
|
|
96557
|
+
if (!isCurrentDisabled && !this.isPathDisabled(tree, newPath, config, cascaderProps)) {
|
|
96558
|
+
paths.push(newPath);
|
|
96559
|
+
}
|
|
96560
|
+
} else {
|
|
96561
|
+
// 如果当前节点禁用,则其所有子节点都不可选
|
|
96562
|
+
if (!isCurrentDisabled) {
|
|
96563
|
+
traverse(node[cascaderProps.children], newPath);
|
|
96564
|
+
}
|
|
96565
|
+
}
|
|
96566
|
+
});
|
|
96567
|
+
};
|
|
96568
|
+
traverse(tree);
|
|
96569
|
+
return paths;
|
|
96570
|
+
}
|
|
96571
|
+
|
|
96572
|
+
/**
|
|
96573
|
+
* 根据路径查找节点
|
|
96574
|
+
* @param {Array} tree - 树形数据
|
|
96575
|
+
* @param {Array} path - 路径数组
|
|
96576
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96577
|
+
* @returns {Object|null} 找到的节点
|
|
96578
|
+
*/
|
|
96579
|
+
static findNodeByPath(tree, path, cascaderProps) {
|
|
96580
|
+
if (!path || path.length === 0) return null;
|
|
96581
|
+
const findInTree = (nodes, targetPath) => {
|
|
96582
|
+
for (const node of nodes) {
|
|
96583
|
+
if (node[cascaderProps.value] == targetPath[0]) {
|
|
96584
|
+
if (targetPath.length === 1) {
|
|
96585
|
+
return node;
|
|
96586
|
+
} else if (node[cascaderProps.children]) {
|
|
96587
|
+
return findInTree(node[cascaderProps.children], targetPath.slice(1));
|
|
96588
|
+
}
|
|
96589
|
+
}
|
|
96590
|
+
}
|
|
96591
|
+
return null;
|
|
96592
|
+
};
|
|
96593
|
+
return findInTree(tree, path);
|
|
96594
|
+
}
|
|
96595
|
+
|
|
96596
|
+
/**
|
|
96597
|
+
* 基于 selectedValues 构建已选项列表
|
|
96598
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96599
|
+
* @param {Array} options - 选项数据
|
|
96600
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96601
|
+
* @returns {Array} 已选项列表
|
|
96602
|
+
*/
|
|
96603
|
+
static buildSelectedItemsFromValues(selectedValues, options, cascaderProps) {
|
|
96604
|
+
const items = [];
|
|
96605
|
+
selectedValues.forEach(path => {
|
|
96606
|
+
if (path.length > 0) {
|
|
96607
|
+
const leafValue = path[path.length - 1];
|
|
96608
|
+
// 从原始数据中查找对应的节点信息
|
|
96609
|
+
const node = this.findNodeByPath(options, path, cascaderProps);
|
|
96610
|
+
if (node) {
|
|
96611
|
+
// 包含完整的节点数据,以便访问额外的字段(如子标题字段)
|
|
96612
|
+
items.push({
|
|
96613
|
+
...node,
|
|
96614
|
+
// 展开所有原始节点数据
|
|
96615
|
+
value: leafValue,
|
|
96616
|
+
label: node[cascaderProps.label],
|
|
96617
|
+
path: path
|
|
96618
|
+
});
|
|
96619
|
+
}
|
|
96620
|
+
}
|
|
96621
|
+
});
|
|
96622
|
+
return items;
|
|
96623
|
+
}
|
|
96624
|
+
|
|
96625
|
+
/**
|
|
96626
|
+
* 从自研面板 selection 直接构建已选项(紧凑模式,避免生成万级路径数组)
|
|
96627
|
+
*/
|
|
96628
|
+
static buildSelectedItemsFromSelection(store, selection, options, cascaderProps) {
|
|
96629
|
+
if (!store || !selection) {
|
|
96630
|
+
return [];
|
|
96631
|
+
}
|
|
96632
|
+
const items = [];
|
|
96633
|
+
selection.selectedLeafSet.forEach(leafValue => {
|
|
96634
|
+
const path = store.pathByLeafValue.get(leafValue);
|
|
96635
|
+
const node = store.nodeByValue.get(leafValue);
|
|
96636
|
+
if (!path || !node) {
|
|
96637
|
+
return;
|
|
96638
|
+
}
|
|
96639
|
+
items.push({
|
|
96640
|
+
...node.raw,
|
|
96641
|
+
value: leafValue,
|
|
96642
|
+
label: node.label,
|
|
96643
|
+
path
|
|
96644
|
+
});
|
|
96645
|
+
});
|
|
96646
|
+
return items;
|
|
96647
|
+
}
|
|
96648
|
+
|
|
96649
|
+
/**
|
|
96650
|
+
* 获取搜索范围内的选中值
|
|
96651
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96652
|
+
* @param {Array} searchOptions - 搜索结果
|
|
96653
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96654
|
+
* @returns {Array} 搜索范围内的选中值
|
|
96655
|
+
*/
|
|
96656
|
+
static getSearchSelectedValues(selectedValues, searchOptions, cascaderProps) {
|
|
96657
|
+
const searchLeafValues = this.getLeafValues(searchOptions, cascaderProps);
|
|
96658
|
+
return selectedValues.filter(path => {
|
|
96659
|
+
const leafValue = path[path.length - 1];
|
|
96660
|
+
return searchLeafValues.includes(leafValue);
|
|
96661
|
+
});
|
|
96662
|
+
}
|
|
96663
|
+
|
|
96664
|
+
/**
|
|
96665
|
+
* 检查父项的所有子项是否都被选中
|
|
96666
|
+
* @param {Object} parentNode - 父节点
|
|
96667
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96668
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96669
|
+
* @returns {Boolean} 是否所有子项都被选中
|
|
96670
|
+
*/
|
|
96671
|
+
static isParentFullySelected(parentNode, selectedValues, cascaderProps) {
|
|
96672
|
+
if (!parentNode[cascaderProps.children]) {
|
|
96673
|
+
return false;
|
|
96674
|
+
}
|
|
96675
|
+
|
|
96676
|
+
// 获取父项的所有叶子节点
|
|
96677
|
+
const allLeafValues = this.getLeafValues([parentNode], cascaderProps);
|
|
96678
|
+
|
|
96679
|
+
// 检查所有叶子节点是否都在选中值中
|
|
96680
|
+
return allLeafValues.every(leafValue => {
|
|
96681
|
+
return selectedValues.some(path => {
|
|
96682
|
+
const pathLeafValue = path[path.length - 1];
|
|
96683
|
+
return pathLeafValue === leafValue;
|
|
96684
|
+
});
|
|
96685
|
+
});
|
|
96686
|
+
}
|
|
96687
|
+
|
|
96688
|
+
/**
|
|
96689
|
+
* 根据路径获取对应的标签数组
|
|
96690
|
+
* @param {Array} path - 节点路径
|
|
96691
|
+
* @param {Array} options - 选项数据
|
|
96692
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96693
|
+
* @returns {Array} 标签数组
|
|
96694
|
+
*/
|
|
96695
|
+
static getPathLabels(path, options, cascaderProps) {
|
|
96696
|
+
const labels = [];
|
|
96697
|
+
let currentNodes = options;
|
|
96698
|
+
for (let i = 0; i < path.length; i++) {
|
|
96699
|
+
const targetValue = path[i];
|
|
96700
|
+
const foundNode = currentNodes.find(node => node[cascaderProps.value] === targetValue);
|
|
96701
|
+
if (foundNode) {
|
|
96702
|
+
labels.push(foundNode[cascaderProps.label]);
|
|
96703
|
+
if (foundNode[cascaderProps.children] && i < path.length - 1) {
|
|
96704
|
+
currentNodes = foundNode[cascaderProps.children];
|
|
96705
|
+
}
|
|
96706
|
+
} else {
|
|
96707
|
+
labels.push(targetValue); // 如果找不到对应的节点,使用原始值
|
|
96708
|
+
}
|
|
96709
|
+
}
|
|
96710
|
+
return labels;
|
|
96711
|
+
}
|
|
96712
|
+
|
|
96713
|
+
/**
|
|
96714
|
+
* 构建完整的节点信息对象
|
|
96715
|
+
* @param {Object} node - 原始节点数据
|
|
96716
|
+
* @param {Array} path - 节点路径
|
|
96717
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96718
|
+
* @param {Array} options - 选项数据
|
|
96719
|
+
* @param {Boolean} isAggregated - 是否为聚合项
|
|
96720
|
+
* @returns {Object} 完整的节点信息对象
|
|
96721
|
+
*/
|
|
96722
|
+
static buildCompleteNodeInfo(node, path, cascaderProps, options, isAggregated = false) {
|
|
96723
|
+
const hasChildren = !!node[cascaderProps.children];
|
|
96724
|
+
const level = path.length - 1;
|
|
96725
|
+
return {
|
|
96726
|
+
// 展开原始节点的所有属性,以便访问额外的字段(如子标题字段)
|
|
96727
|
+
...node,
|
|
96728
|
+
// 基本属性(覆盖原始节点中的同名属性)
|
|
96729
|
+
value: node[cascaderProps.value],
|
|
96730
|
+
label: node[cascaderProps.label],
|
|
96731
|
+
path: path,
|
|
96732
|
+
isAggregated: isAggregated,
|
|
96733
|
+
// 节点结构信息
|
|
96734
|
+
hasChildren: hasChildren,
|
|
96735
|
+
level: level,
|
|
96736
|
+
children: hasChildren ? node[cascaderProps.children] : undefined,
|
|
96737
|
+
// 级联面板相关属性
|
|
96738
|
+
checked: true,
|
|
96739
|
+
indeterminate: false,
|
|
96740
|
+
loaded: true,
|
|
96741
|
+
loading: false,
|
|
96742
|
+
// 原始数据
|
|
96743
|
+
data: node,
|
|
96744
|
+
// 路径相关
|
|
96745
|
+
pathLabels: this.getPathLabels(path, options, cascaderProps),
|
|
96746
|
+
// 其他可能需要的属性
|
|
96747
|
+
config: cascaderProps,
|
|
96748
|
+
parent: null,
|
|
96749
|
+
// 在级联面板中会动态设置
|
|
96750
|
+
pathNodes: null // 在级联面板中会动态设置
|
|
96751
|
+
};
|
|
96752
|
+
}
|
|
96753
|
+
|
|
96754
|
+
/**
|
|
96755
|
+
* 从自研面板的选中状态递归构建聚合列表(与 getAggregatedSelectedItems 逻辑一致)
|
|
96756
|
+
* 父节点全选时只返回父项;半选时向下展开到具体子项
|
|
96757
|
+
*/
|
|
96758
|
+
static getAggregatedItemsFromSelection(store, selection, options, cascaderProps) {
|
|
96759
|
+
if (!store || !selection) {
|
|
96760
|
+
return [];
|
|
96761
|
+
}
|
|
96762
|
+
const items = [];
|
|
96763
|
+
const walk = nodeId => {
|
|
96764
|
+
const node = store.nodeById.get(nodeId);
|
|
96765
|
+
if (!node || node.disabled) {
|
|
96766
|
+
return;
|
|
96767
|
+
}
|
|
96768
|
+
const state = selection.getCheckState(nodeId);
|
|
96769
|
+
if (state === 'unchecked' || state === 'disabled') {
|
|
96770
|
+
return;
|
|
96771
|
+
}
|
|
96772
|
+
if (!node.isLeaf && state === 'checked') {
|
|
96773
|
+
items.push(this.buildCompleteNodeInfo(node.raw, node.path, cascaderProps, options, true));
|
|
96774
|
+
return;
|
|
96775
|
+
}
|
|
96776
|
+
if (node.isLeaf && state === 'checked') {
|
|
96777
|
+
items.push(this.buildCompleteNodeInfo(node.raw, node.path, cascaderProps, options, false));
|
|
96778
|
+
return;
|
|
96779
|
+
}
|
|
96780
|
+
const childIds = node.childIds || [];
|
|
96781
|
+
childIds.forEach(childId => walk(childId));
|
|
96782
|
+
};
|
|
96783
|
+
store.rootIds.forEach(rootId => walk(rootId));
|
|
96784
|
+
return items;
|
|
96785
|
+
}
|
|
96786
|
+
|
|
96787
|
+
/** @deprecated 使用 getAggregatedItemsFromSelection */
|
|
96788
|
+
static getAggregatedItemsFromRootSelection(store, selection, options, cascaderProps) {
|
|
96789
|
+
return this.getAggregatedItemsFromSelection(store, selection, options, cascaderProps);
|
|
96790
|
+
}
|
|
96791
|
+
static getAggregatedEmitValues(items, prefix = '__parent__') {
|
|
96792
|
+
return items.map(item => {
|
|
96793
|
+
if (item.isAggregated) {
|
|
96794
|
+
return this.addParentNodePrefix(item.value, prefix);
|
|
96795
|
+
}
|
|
96796
|
+
return item.value;
|
|
96797
|
+
});
|
|
96798
|
+
}
|
|
96799
|
+
|
|
96800
|
+
/**
|
|
96801
|
+
* 获取聚合模式下的选中项(如果父项完全选中,则只返回父项)
|
|
96802
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96803
|
+
* @param {Array} options - 选项数据
|
|
96804
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96805
|
+
* @returns {Array} 聚合后的选中项列表
|
|
96806
|
+
*/
|
|
96807
|
+
static getAggregatedSelectedItems(selectedValues, options, cascaderProps) {
|
|
96808
|
+
const items = [];
|
|
96809
|
+
const processedPaths = new Set();
|
|
96810
|
+
|
|
96811
|
+
// 递归检查每个节点
|
|
96812
|
+
const checkNode = (nodes, currentPath = []) => {
|
|
96813
|
+
nodes.forEach(node => {
|
|
96814
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96815
|
+
const pathKey = newPath.join(',');
|
|
96816
|
+
|
|
96817
|
+
// 如果这个路径已经被处理过,跳过
|
|
96818
|
+
if (processedPaths.has(pathKey)) {
|
|
96819
|
+
return;
|
|
96820
|
+
}
|
|
96821
|
+
|
|
96822
|
+
// 检查当前节点是否完全选中
|
|
96823
|
+
if (this.isParentFullySelected(node, selectedValues, cascaderProps)) {
|
|
96824
|
+
// 父项完全选中,添加父项
|
|
96825
|
+
items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, true));
|
|
96826
|
+
|
|
96827
|
+
// 标记所有子路径为已处理
|
|
96828
|
+
const allLeafValues = this.getLeafValues([node], cascaderProps);
|
|
96829
|
+
selectedValues.forEach(path => {
|
|
96830
|
+
const pathLeafValue = path[path.length - 1];
|
|
96831
|
+
if (allLeafValues.includes(pathLeafValue)) {
|
|
96832
|
+
processedPaths.add(path.join(','));
|
|
96833
|
+
}
|
|
96834
|
+
});
|
|
96835
|
+
} else if (!node[cascaderProps.children]) {
|
|
96836
|
+
// 叶子节点,检查是否在选中值中且未被父项覆盖
|
|
96837
|
+
const leafValue = node[cascaderProps.value];
|
|
96838
|
+
const isSelected = selectedValues.some(path => {
|
|
96839
|
+
const pathLeafValue = path[path.length - 1];
|
|
96840
|
+
return pathLeafValue === leafValue;
|
|
96841
|
+
});
|
|
96842
|
+
if (isSelected && !processedPaths.has(pathKey)) {
|
|
96843
|
+
items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, false));
|
|
96844
|
+
processedPaths.add(pathKey);
|
|
96845
|
+
}
|
|
96846
|
+
} else {
|
|
96847
|
+
// 继续检查子节点
|
|
96848
|
+
checkNode(node[cascaderProps.children], newPath);
|
|
96849
|
+
}
|
|
96850
|
+
});
|
|
96851
|
+
};
|
|
96852
|
+
checkNode(options);
|
|
96853
|
+
return items;
|
|
96854
|
+
}
|
|
96855
|
+
|
|
96856
|
+
/**
|
|
96857
|
+
* 获取聚合模式下的选中值(只返回最终选中的值,不包含被聚合的子项)
|
|
96858
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96859
|
+
* @param {Array} options - 选项数据
|
|
96860
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96861
|
+
* @param {String} prefix - 前缀标识
|
|
96862
|
+
* @returns {Array} 聚合后的选中值
|
|
96863
|
+
*/
|
|
96864
|
+
static getAggregatedSelectedValues(selectedValues, options, cascaderProps, prefix = '__parent__') {
|
|
96865
|
+
const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
|
|
96866
|
+
return aggregatedItems.map(item => {
|
|
96867
|
+
// 如果是聚合项(非叶子节点),添加前缀标识
|
|
96868
|
+
if (item.isAggregated) {
|
|
96869
|
+
return this.addParentNodePrefix(item.value, prefix);
|
|
96870
|
+
}
|
|
96871
|
+
return item.value;
|
|
96872
|
+
});
|
|
96873
|
+
}
|
|
96874
|
+
|
|
96875
|
+
/**
|
|
96876
|
+
* 获取聚合模式下的路径数组(只返回最终选中的路径,不包含被聚合的子项路径)
|
|
96877
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96878
|
+
* @param {Array} options - 选项数据
|
|
96879
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96880
|
+
* @returns {Array} 聚合后的路径数组
|
|
96881
|
+
*/
|
|
96882
|
+
static getAggregatedSelectedPaths(selectedValues, options, cascaderProps) {
|
|
96883
|
+
const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
|
|
96884
|
+
return aggregatedItems.map(item => item.path);
|
|
96885
|
+
}
|
|
96886
|
+
|
|
96887
|
+
/**
|
|
96888
|
+
* 检查聚合模式下是否全选(所有可选的叶子节点都被选中)
|
|
96889
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96890
|
+
* @param {Array} options - 选项数据
|
|
96891
|
+
* @param {Object} config - 禁用配置
|
|
96892
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96893
|
+
* @returns {Boolean} 是否全选
|
|
96894
|
+
*/
|
|
96895
|
+
static isAggregatedAllSelected(selectedValues, options, config, cascaderProps) {
|
|
96896
|
+
// 获取所有可选的叶子节点
|
|
96897
|
+
const allSelectableLeafValues = this.getAllLeafPaths(options, config, cascaderProps).map(path => path[path.length - 1]); // 获取叶子节点的值
|
|
96898
|
+
|
|
96899
|
+
// 获取当前选中的叶子节点值
|
|
96900
|
+
const selectedLeafValues = selectedValues.map(path => path[path.length - 1]);
|
|
96901
|
+
|
|
96902
|
+
// 检查所有可选的叶子节点是否都被选中
|
|
96903
|
+
return allSelectableLeafValues.every(leafValue => selectedLeafValues.includes(leafValue));
|
|
96904
|
+
}
|
|
96905
|
+
|
|
96906
|
+
/**
|
|
96907
|
+
* 检查值是否为非叶子节点标识
|
|
96908
|
+
* @param {*} value - 要检查的值
|
|
96909
|
+
* @param {String} prefix - 前缀标识
|
|
96910
|
+
* @returns {Boolean} 是否为非叶子节点标识
|
|
96911
|
+
*/
|
|
96912
|
+
static isParentNodeValue(value, prefix = '__parent__') {
|
|
96913
|
+
return typeof value === 'string' && value.startsWith(prefix);
|
|
96914
|
+
}
|
|
96915
|
+
|
|
96916
|
+
/**
|
|
96917
|
+
* 从非叶子节点标识中提取实际值
|
|
96918
|
+
* @param {String} parentValue - 非叶子节点标识值
|
|
96919
|
+
* @param {String} prefix - 前缀标识
|
|
96920
|
+
* @returns {String} 实际值
|
|
96921
|
+
*/
|
|
96922
|
+
static extractParentNodeValue(parentValue, prefix = '__parent__') {
|
|
96923
|
+
if (this.isParentNodeValue(parentValue, prefix)) {
|
|
96924
|
+
return parentValue.substring(prefix.length);
|
|
96925
|
+
}
|
|
96926
|
+
return parentValue;
|
|
96927
|
+
}
|
|
96928
|
+
|
|
96929
|
+
/**
|
|
96930
|
+
* 为非叶子节点值添加前缀标识
|
|
96931
|
+
* @param {String} value - 原始值
|
|
96932
|
+
* @param {String} prefix - 前缀标识
|
|
96933
|
+
* @returns {String} 带前缀的值
|
|
96934
|
+
*/
|
|
96935
|
+
static addParentNodePrefix(value, prefix = '__parent__') {
|
|
96936
|
+
return prefix + value;
|
|
96937
|
+
}
|
|
96938
|
+
|
|
96939
|
+
/**
|
|
96940
|
+
* 根据非叶子节点值获取其所有叶子节点的路径
|
|
96941
|
+
* @param {String} parentValue - 非叶子节点值
|
|
96942
|
+
* @param {Array} options - 选项数据
|
|
96943
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96944
|
+
* @returns {Array} 叶子节点路径数组
|
|
96945
|
+
*/
|
|
96946
|
+
static getLeafPathsByParentValue(parentValue, options, cascaderProps) {
|
|
96947
|
+
const paths = [];
|
|
96948
|
+
|
|
96949
|
+
// 查找非叶子节点
|
|
96950
|
+
const findParentNode = (nodes, currentPath = []) => {
|
|
96951
|
+
for (const node of nodes) {
|
|
96952
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96953
|
+
if (node[cascaderProps.value] == parentValue) {
|
|
96954
|
+
// 找到目标非叶子节点,获取其所有叶子节点路径
|
|
96955
|
+
this.getAllLeafPaths([node], {}, cascaderProps).forEach(leafPath => {
|
|
96956
|
+
// 将叶子节点路径与当前路径合并
|
|
96957
|
+
const fullPath = [...currentPath, ...leafPath];
|
|
96958
|
+
paths.push(fullPath);
|
|
96959
|
+
});
|
|
96960
|
+
return true;
|
|
96961
|
+
}
|
|
96962
|
+
|
|
96963
|
+
// 递归查找子节点
|
|
96964
|
+
if (node[cascaderProps.children] && node[cascaderProps.children].length > 0) {
|
|
96965
|
+
if (findParentNode(node[cascaderProps.children], newPath)) {
|
|
96966
|
+
return true;
|
|
96967
|
+
}
|
|
96968
|
+
}
|
|
96969
|
+
}
|
|
96970
|
+
return false;
|
|
96971
|
+
};
|
|
96972
|
+
findParentNode(options);
|
|
96973
|
+
return paths;
|
|
96974
|
+
}
|
|
96975
|
+
|
|
96976
|
+
/**
|
|
96977
|
+
* 处理包含非叶子节点的值数组,将非叶子节点转换为对应的叶子节点路径
|
|
96978
|
+
* @param {Array} values - 值数组(可能包含非叶子节点标识)
|
|
96979
|
+
* @param {Array} options - 选项数据
|
|
96980
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96981
|
+
* @param {String} prefix - 前缀标识
|
|
96982
|
+
* @returns {Array} 处理后的路径数组
|
|
96983
|
+
*/
|
|
96984
|
+
static processValuesWithParentNodes(values, options, cascaderProps, prefix = '__parent__') {
|
|
96985
|
+
const paths = [];
|
|
96986
|
+
for (const value of values) {
|
|
96987
|
+
if (this.isParentNodeValue(value, prefix)) {
|
|
96988
|
+
// 非叶子节点,获取其所有叶子节点路径
|
|
96989
|
+
const actualValue = this.extractParentNodeValue(value, prefix);
|
|
96990
|
+
const leafPaths = this.getLeafPathsByParentValue(actualValue, options, cascaderProps);
|
|
96991
|
+
paths.push(...leafPaths);
|
|
96992
|
+
} else {
|
|
96993
|
+
// 普通值,查找对应的路径
|
|
96994
|
+
const valuePaths = this.findPathsByValues([value], options, cascaderProps);
|
|
96995
|
+
paths.push(...valuePaths);
|
|
96996
|
+
}
|
|
96997
|
+
}
|
|
96998
|
+
return paths;
|
|
96999
|
+
}
|
|
97000
|
+
|
|
97001
|
+
/**
|
|
97002
|
+
* 根据values找到对应的路径(支持非叶子节点)
|
|
97003
|
+
* @param {Array} values - 值数组
|
|
97004
|
+
* @param {Array} options - 选项数据
|
|
97005
|
+
* @param {Object} cascaderProps - 级联配置
|
|
97006
|
+
* @returns {Array} 路径数组
|
|
97007
|
+
*/
|
|
97008
|
+
static findPathsByValues(values, options, cascaderProps) {
|
|
97009
|
+
const paths = [];
|
|
97010
|
+
const findPath = (nodes, targetValues, currentPath = []) => {
|
|
97011
|
+
for (const option of nodes) {
|
|
97012
|
+
const newPath = [...currentPath, option[cascaderProps.value]];
|
|
97013
|
+
if (targetValues.includes(option[cascaderProps.value])) {
|
|
97014
|
+
// 如果是叶子节点(没有children属性),添加到路径中
|
|
97015
|
+
if (!option[cascaderProps.children]) {
|
|
97016
|
+
paths.push(newPath);
|
|
97017
|
+
}
|
|
97018
|
+
}
|
|
97019
|
+
|
|
97020
|
+
// 递归查找子节点
|
|
97021
|
+
if (option[cascaderProps.children] && option[cascaderProps.children].length > 0) {
|
|
97022
|
+
findPath(option[cascaderProps.children], targetValues, newPath);
|
|
97023
|
+
}
|
|
97024
|
+
}
|
|
97025
|
+
};
|
|
97026
|
+
findPath(options, values);
|
|
97027
|
+
return paths;
|
|
97028
|
+
}
|
|
97029
|
+
}
|
|
97030
|
+
;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/VirtualCascaderPanel.vue?vue&type=template&id=05f77638
|
|
97031
|
+
var VirtualCascaderPanelvue_type_template_id_05f77638_render = function render() {
|
|
97032
|
+
var _vm = this,
|
|
97033
|
+
_c = _vm._self._c;
|
|
97034
|
+
return _c('div', {
|
|
97035
|
+
staticClass: "el-cascader-panel vcp-panel is-bordered",
|
|
97036
|
+
style: {
|
|
97037
|
+
height: _vm.height + 'px'
|
|
97038
|
+
}
|
|
97039
|
+
}, _vm._l(_vm.columns, function (columnNodes, colIndex) {
|
|
97040
|
+
return _c('div', {
|
|
97041
|
+
key: 'col-' + colIndex,
|
|
97042
|
+
staticClass: "el-cascader-menu vcp-menu",
|
|
97043
|
+
class: {
|
|
97044
|
+
'is-last': colIndex === _vm.columns.length - 1
|
|
97045
|
+
},
|
|
97046
|
+
style: _vm.getColumnStyle(colIndex, columnNodes)
|
|
97047
|
+
}, [_c('VcpVirtualList', {
|
|
97048
|
+
attrs: {
|
|
97049
|
+
"items": columnNodes,
|
|
97050
|
+
"item-height": _vm.itemHeight,
|
|
97051
|
+
"height": _vm.height
|
|
97052
|
+
},
|
|
97053
|
+
scopedSlots: _vm._u([{
|
|
97054
|
+
key: "default",
|
|
97055
|
+
fn: function ({
|
|
97056
|
+
item
|
|
97057
|
+
}) {
|
|
97058
|
+
return [_c('li', {
|
|
97059
|
+
key: 'vcp-node-' + item.id,
|
|
97060
|
+
staticClass: "el-cascader-node",
|
|
97061
|
+
class: _vm.getNodeClass(item, colIndex),
|
|
97062
|
+
attrs: {
|
|
97063
|
+
"role": "menuitem",
|
|
97064
|
+
"id": 'vcp-node-' + item.id,
|
|
97065
|
+
"aria-expanded": !item.isLeaf && _vm.isExpanded(item, colIndex),
|
|
97066
|
+
"tabindex": _vm.isActive(item, colIndex) ? 0 : -1
|
|
97067
|
+
},
|
|
97068
|
+
on: {
|
|
97069
|
+
"click": function ($event) {
|
|
97070
|
+
return _vm.onNodeClick(item, colIndex);
|
|
97071
|
+
}
|
|
97072
|
+
}
|
|
97073
|
+
}, [_vm.multiple ? _c('span', {
|
|
97074
|
+
staticClass: "el-cascader-node__prefix"
|
|
97075
|
+
}, [_c('el-checkbox', {
|
|
97076
|
+
attrs: {
|
|
97077
|
+
"value": _vm.isChecked(item),
|
|
97078
|
+
"indeterminate": _vm.isIndeterminate(item),
|
|
97079
|
+
"disabled": item.disabled || _vm.isViewMode
|
|
97080
|
+
},
|
|
97081
|
+
on: {
|
|
97082
|
+
"change": function ($event) {
|
|
97083
|
+
return _vm.onCheckClick(item, $event);
|
|
97084
|
+
}
|
|
97085
|
+
},
|
|
97086
|
+
nativeOn: {
|
|
97087
|
+
"click": function ($event) {
|
|
97088
|
+
$event.stopPropagation();
|
|
97089
|
+
}
|
|
97090
|
+
}
|
|
97091
|
+
})], 1) : _vm.checkStrictly ? _c('span', {
|
|
97092
|
+
staticClass: "el-cascader-node__prefix",
|
|
97093
|
+
on: {
|
|
97094
|
+
"click": function ($event) {
|
|
97095
|
+
$event.stopPropagation();
|
|
97096
|
+
return _vm.onRadioClick(item);
|
|
97097
|
+
}
|
|
97098
|
+
}
|
|
97099
|
+
}, [_c('el-radio', {
|
|
97100
|
+
attrs: {
|
|
97101
|
+
"value": _vm.singleCheckedValue,
|
|
97102
|
+
"label": item.value,
|
|
97103
|
+
"disabled": item.disabled || _vm.isViewMode
|
|
97104
|
+
},
|
|
97105
|
+
on: {
|
|
97106
|
+
"input": function ($event) {
|
|
97107
|
+
return _vm.onRadioClick(item);
|
|
97108
|
+
}
|
|
97109
|
+
}
|
|
97110
|
+
}, [_c('span')])], 1) : _vm._e(), _c('span', {
|
|
97111
|
+
staticClass: "el-cascader-node__label"
|
|
97112
|
+
}, [_vm._v(_vm._s(item.label))]), !item.isLeaf ? _c('span', {
|
|
97113
|
+
staticClass: "el-cascader-node__postfix"
|
|
97114
|
+
}, [_c('i', {
|
|
97115
|
+
staticClass: "el-icon-arrow-right el-cascader-node__icon-arrow"
|
|
97116
|
+
})]) : _vm._e()])];
|
|
97117
|
+
}
|
|
97118
|
+
}], null, true)
|
|
97119
|
+
})], 1);
|
|
97120
|
+
}), 0);
|
|
97121
|
+
};
|
|
97122
|
+
var VirtualCascaderPanelvue_type_template_id_05f77638_staticRenderFns = [];
|
|
97123
|
+
|
|
97124
|
+
;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/VirtualList.vue?vue&type=template&id=43cb1148
|
|
97125
|
+
var VirtualListvue_type_template_id_43cb1148_render = function render() {
|
|
97126
|
+
var _vm = this,
|
|
97127
|
+
_c = _vm._self._c;
|
|
97128
|
+
return _c('div', {
|
|
97129
|
+
ref: "scroller",
|
|
97130
|
+
staticClass: "vcp-virtual-scroller el-scrollbar__wrap",
|
|
97131
|
+
on: {
|
|
97132
|
+
"scroll": _vm.onScroll
|
|
97133
|
+
}
|
|
97134
|
+
}, [!_vm.enableVirtual ? _c('ul', {
|
|
97135
|
+
staticClass: "el-cascader-menu__list vcp-native-list"
|
|
97136
|
+
}, [_vm._l(_vm.items, function (item, index) {
|
|
97137
|
+
return [_vm._t("default", null, {
|
|
97138
|
+
"item": item,
|
|
97139
|
+
"index": index
|
|
97140
|
+
})];
|
|
97141
|
+
})], 2) : [_c('div', {
|
|
97142
|
+
staticClass: "vcp-virtual-phantom",
|
|
97143
|
+
style: {
|
|
97144
|
+
height: _vm.totalHeight + 'px'
|
|
97145
|
+
}
|
|
97146
|
+
}), _c('ul', {
|
|
97147
|
+
staticClass: "el-cascader-menu__list vcp-virtual-list",
|
|
97148
|
+
style: {
|
|
97149
|
+
transform: 'translateY(' + _vm.offsetY + 'px)'
|
|
97150
|
+
}
|
|
97151
|
+
}, [_vm._l(_vm.visibleItems, function (item, index) {
|
|
97152
|
+
return [_vm._t("default", null, {
|
|
97153
|
+
"item": item,
|
|
97154
|
+
"index": _vm.startIndex + index
|
|
97155
|
+
})];
|
|
97156
|
+
})], 2)]], 2);
|
|
97157
|
+
};
|
|
97158
|
+
var VirtualListvue_type_template_id_43cb1148_staticRenderFns = [];
|
|
97159
|
+
|
|
97160
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/VirtualList.vue?vue&type=script&lang=js
|
|
97161
|
+
/* harmony default export */ var VirtualListvue_type_script_lang_js = ({
|
|
97162
|
+
name: 'VcpVirtualList',
|
|
97163
|
+
props: {
|
|
97164
|
+
items: {
|
|
97165
|
+
type: Array,
|
|
97166
|
+
default: () => []
|
|
97167
|
+
},
|
|
97168
|
+
itemHeight: {
|
|
97169
|
+
type: Number,
|
|
97170
|
+
default: 34
|
|
97171
|
+
},
|
|
97172
|
+
height: {
|
|
97173
|
+
type: Number,
|
|
97174
|
+
default: 200
|
|
97175
|
+
},
|
|
97176
|
+
overscan: {
|
|
97177
|
+
type: Number,
|
|
97178
|
+
default: 8
|
|
97179
|
+
},
|
|
97180
|
+
listPadding: {
|
|
97181
|
+
type: Number,
|
|
97182
|
+
default: 12
|
|
97183
|
+
}
|
|
97184
|
+
},
|
|
97185
|
+
data() {
|
|
97186
|
+
return {
|
|
97187
|
+
scrollTop: 0
|
|
97188
|
+
};
|
|
97189
|
+
},
|
|
97190
|
+
computed: {
|
|
97191
|
+
totalHeight() {
|
|
97192
|
+
return this.items.length * this.itemHeight + this.listPadding;
|
|
97193
|
+
},
|
|
97194
|
+
enableVirtual() {
|
|
97195
|
+
return this.totalHeight > this.height;
|
|
97196
|
+
},
|
|
97197
|
+
startIndex() {
|
|
97198
|
+
const index = Math.floor(this.scrollTop / this.itemHeight) - this.overscan;
|
|
97199
|
+
return Math.max(0, index);
|
|
97200
|
+
},
|
|
97201
|
+
endIndex() {
|
|
97202
|
+
const visibleCount = Math.ceil(this.height / this.itemHeight) + this.overscan * 2;
|
|
97203
|
+
return Math.min(this.items.length, this.startIndex + visibleCount);
|
|
97204
|
+
},
|
|
97205
|
+
offsetY() {
|
|
97206
|
+
return this.startIndex * this.itemHeight;
|
|
97207
|
+
},
|
|
97208
|
+
visibleItems() {
|
|
97209
|
+
return this.items.slice(this.startIndex, this.endIndex);
|
|
97210
|
+
}
|
|
97211
|
+
},
|
|
97212
|
+
watch: {
|
|
97213
|
+
items(newItems, oldItems) {
|
|
97214
|
+
if (!this.isSameItemList(newItems, oldItems)) {
|
|
97215
|
+
this.resetScroll();
|
|
97216
|
+
}
|
|
97217
|
+
},
|
|
97218
|
+
enableVirtual(newVal, oldVal) {
|
|
97219
|
+
if (newVal !== oldVal) {
|
|
97220
|
+
this.resetScroll();
|
|
97221
|
+
}
|
|
97222
|
+
}
|
|
97223
|
+
},
|
|
97224
|
+
methods: {
|
|
97225
|
+
isSameItemList(nextItems, prevItems) {
|
|
97226
|
+
if (!nextItems || !prevItems) {
|
|
97227
|
+
return false;
|
|
97228
|
+
}
|
|
97229
|
+
if (nextItems.length !== prevItems.length) {
|
|
97230
|
+
return false;
|
|
97231
|
+
}
|
|
97232
|
+
for (let i = 0; i < nextItems.length; i++) {
|
|
97233
|
+
if (this.getItemKey(nextItems[i]) !== this.getItemKey(prevItems[i])) {
|
|
97234
|
+
return false;
|
|
97235
|
+
}
|
|
97236
|
+
}
|
|
97237
|
+
return true;
|
|
97238
|
+
},
|
|
97239
|
+
getItemKey(item) {
|
|
97240
|
+
if (!item) {
|
|
97241
|
+
return '';
|
|
97242
|
+
}
|
|
97243
|
+
return item.id != null ? item.id : item.value;
|
|
97244
|
+
},
|
|
97245
|
+
onScroll(event) {
|
|
97246
|
+
this.scrollTop = event.target.scrollTop;
|
|
97247
|
+
},
|
|
97248
|
+
resetScroll() {
|
|
97249
|
+
this.scrollTop = 0;
|
|
97250
|
+
if (this.$refs.scroller) {
|
|
97251
|
+
this.$refs.scroller.scrollTop = 0;
|
|
97252
|
+
}
|
|
97253
|
+
}
|
|
97254
|
+
}
|
|
97255
|
+
});
|
|
97256
|
+
;// ./src/components/cascader-panel-pro/VirtualList.vue?vue&type=script&lang=js
|
|
97257
|
+
/* harmony default export */ var cascader_panel_pro_VirtualListvue_type_script_lang_js = (VirtualListvue_type_script_lang_js);
|
|
97258
|
+
;// ./src/components/cascader-panel-pro/VirtualList.vue
|
|
97259
|
+
|
|
97260
|
+
|
|
97261
|
+
|
|
97262
|
+
|
|
97263
|
+
|
|
97264
|
+
/* normalize component */
|
|
97265
|
+
;
|
|
97266
|
+
var VirtualList_component = normalizeComponent(
|
|
97267
|
+
cascader_panel_pro_VirtualListvue_type_script_lang_js,
|
|
97268
|
+
VirtualListvue_type_template_id_43cb1148_render,
|
|
97269
|
+
VirtualListvue_type_template_id_43cb1148_staticRenderFns,
|
|
97270
|
+
false,
|
|
97271
|
+
null,
|
|
97272
|
+
null,
|
|
97273
|
+
null
|
|
97274
|
+
|
|
97275
|
+
)
|
|
97276
|
+
|
|
97277
|
+
/* harmony default export */ var VirtualList = (VirtualList_component.exports);
|
|
97278
|
+
;// ./src/components/cascader-panel-pro/cascaderStorePro.js
|
|
97279
|
+
|
|
97280
|
+
|
|
97281
|
+
|
|
97282
|
+
|
|
97283
|
+
|
|
97284
|
+
|
|
97285
|
+
/**
|
|
97286
|
+
* 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
|
|
97287
|
+
*/
|
|
97288
|
+
|
|
97289
|
+
let nodeIdSeed = 0;
|
|
97290
|
+
function nextId() {
|
|
97291
|
+
nodeIdSeed += 1;
|
|
97292
|
+
return nodeIdSeed;
|
|
97293
|
+
}
|
|
97294
|
+
function resetCascaderStoreIdSeed() {
|
|
97295
|
+
nodeIdSeed = 0;
|
|
97296
|
+
}
|
|
97297
|
+
|
|
97298
|
+
/**
|
|
97299
|
+
* @param {Array} options
|
|
97300
|
+
* @param {Object} config - disabledField/disabledValue/disabledCheck
|
|
97301
|
+
* @param {Object} cascaderProps
|
|
97302
|
+
* @param {Object} utils - CascaderUtilsPro
|
|
97303
|
+
*/
|
|
97304
|
+
function buildCascaderStore(options, config, cascaderProps, utils) {
|
|
97305
|
+
resetCascaderStoreIdSeed();
|
|
97306
|
+
const valueKey = cascaderProps.value || 'value';
|
|
97307
|
+
const labelKey = cascaderProps.label || 'label';
|
|
97308
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
97309
|
+
const disabledKey = cascaderProps.disabled || 'disabled';
|
|
97310
|
+
const nodes = [];
|
|
97311
|
+
const nodeById = new Map();
|
|
97312
|
+
const nodeByValue = new Map();
|
|
97313
|
+
const childrenByParentId = new Map();
|
|
97314
|
+
const rootIds = [];
|
|
97315
|
+
const pathByLeafValue = new Map();
|
|
97316
|
+
const allLeafValues = [];
|
|
97317
|
+
const allLeafPaths = [];
|
|
97318
|
+
const createNode = (raw, parentPath, level, parentId) => {
|
|
97319
|
+
const value = raw[valueKey];
|
|
97320
|
+
const children = raw[childrenKey];
|
|
97321
|
+
const hasChildren = Array.isArray(children) && children.length > 0;
|
|
97322
|
+
const id = nextId();
|
|
97323
|
+
const nodePath = parentId == null ? [value] : parentPath.concat(value);
|
|
97324
|
+
const node = {
|
|
97325
|
+
id,
|
|
97326
|
+
value,
|
|
97327
|
+
label: raw[labelKey],
|
|
97328
|
+
path: nodePath,
|
|
97329
|
+
level,
|
|
97330
|
+
parentId,
|
|
97331
|
+
childIds: [],
|
|
97332
|
+
isLeaf: !hasChildren,
|
|
97333
|
+
disabled: !!raw[disabledKey],
|
|
97334
|
+
raw,
|
|
97335
|
+
descendantLeafValues: [],
|
|
97336
|
+
descendantLeafCount: 0,
|
|
97337
|
+
descendantPaths: []
|
|
97338
|
+
};
|
|
97339
|
+
nodes.push(node);
|
|
97340
|
+
nodeById.set(id, node);
|
|
97341
|
+
if (!nodeByValue.has(value)) {
|
|
97342
|
+
nodeByValue.set(value, node);
|
|
97343
|
+
}
|
|
97344
|
+
if (parentId == null) {
|
|
97345
|
+
rootIds.push(id);
|
|
97346
|
+
} else {
|
|
97347
|
+
const siblings = childrenByParentId.get(parentId) || [];
|
|
97348
|
+
siblings.push(id);
|
|
97349
|
+
childrenByParentId.set(parentId, siblings);
|
|
97350
|
+
const parent = nodeById.get(parentId);
|
|
97351
|
+
if (parent) {
|
|
97352
|
+
parent.childIds.push(id);
|
|
97353
|
+
}
|
|
97354
|
+
}
|
|
97355
|
+
if (hasChildren) {
|
|
97356
|
+
children.forEach(child => {
|
|
97357
|
+
createNode(child, nodePath, level + 1, id);
|
|
97358
|
+
});
|
|
97359
|
+
} else if (!node.disabled) {
|
|
97360
|
+
pathByLeafValue.set(value, nodePath);
|
|
97361
|
+
allLeafValues.push(value);
|
|
97362
|
+
allLeafPaths.push(nodePath);
|
|
97363
|
+
}
|
|
97364
|
+
return node;
|
|
97365
|
+
};
|
|
97366
|
+
const walkRoots = (items, ancestorDisabled = false) => {
|
|
97367
|
+
items.forEach(item => {
|
|
97368
|
+
const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
|
|
97369
|
+
const cloned = {
|
|
97370
|
+
...item
|
|
97371
|
+
};
|
|
97372
|
+
if (isDisabled) {
|
|
97373
|
+
cloned[disabledKey] = true;
|
|
97374
|
+
}
|
|
97375
|
+
createNode(cloned, [], 0, null);
|
|
97376
|
+
});
|
|
97377
|
+
};
|
|
97378
|
+
walkRoots(options || []);
|
|
97379
|
+
|
|
97380
|
+
// 自底向上汇总子树叶子
|
|
97381
|
+
const sorted = nodes.slice().sort((a, b) => b.level - a.level);
|
|
97382
|
+
sorted.forEach(node => {
|
|
97383
|
+
if (node.isLeaf) {
|
|
97384
|
+
if (!node.disabled) {
|
|
97385
|
+
node.descendantLeafValues = [node.value];
|
|
97386
|
+
node.descendantLeafCount = 1;
|
|
97387
|
+
node.descendantPaths = [node.path];
|
|
97388
|
+
}
|
|
97389
|
+
return;
|
|
97390
|
+
}
|
|
97391
|
+
const leafValues = [];
|
|
97392
|
+
const leafPaths = [];
|
|
97393
|
+
node.childIds.forEach(childId => {
|
|
97394
|
+
const child = nodeById.get(childId);
|
|
97395
|
+
if (!child || child.descendantLeafCount === 0) {
|
|
97396
|
+
return;
|
|
97397
|
+
}
|
|
97398
|
+
leafValues.push(...child.descendantLeafValues);
|
|
97399
|
+
leafPaths.push(...child.descendantPaths);
|
|
97400
|
+
});
|
|
97401
|
+
node.descendantLeafValues = leafValues;
|
|
97402
|
+
node.descendantLeafCount = leafValues.length;
|
|
97403
|
+
node.descendantPaths = leafPaths;
|
|
97404
|
+
});
|
|
97405
|
+
return {
|
|
97406
|
+
nodes,
|
|
97407
|
+
nodeById,
|
|
97408
|
+
nodeByValue,
|
|
97409
|
+
childrenByParentId,
|
|
97410
|
+
rootIds,
|
|
97411
|
+
pathByLeafValue,
|
|
97412
|
+
allLeafValues,
|
|
97413
|
+
allLeafPaths,
|
|
97414
|
+
totalLeafCount: allLeafPaths.length
|
|
97415
|
+
};
|
|
97416
|
+
}
|
|
97417
|
+
function getStoreChildren(store, parentId) {
|
|
97418
|
+
if (parentId == null) {
|
|
97419
|
+
return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97420
|
+
}
|
|
97421
|
+
const childIds = store.childrenByParentId.get(parentId) || [];
|
|
97422
|
+
return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97423
|
+
}
|
|
97424
|
+
function findStoreNodeByPath(store, pathValues) {
|
|
97425
|
+
if (!pathValues || pathValues.length === 0) {
|
|
97426
|
+
return null;
|
|
97427
|
+
}
|
|
97428
|
+
let node = store.nodeByValue.get(pathValues[0]);
|
|
97429
|
+
if (!node || pathValues.length === 1) {
|
|
97430
|
+
return node;
|
|
97431
|
+
}
|
|
97432
|
+
for (let i = 1; i < pathValues.length; i++) {
|
|
97433
|
+
const target = pathValues[i];
|
|
97434
|
+
const children = getStoreChildren(store, node.id);
|
|
97435
|
+
node = children.find(child => child.value == target) || null;
|
|
97436
|
+
if (!node) {
|
|
97437
|
+
return null;
|
|
97438
|
+
}
|
|
97439
|
+
}
|
|
97440
|
+
return node;
|
|
97441
|
+
}
|
|
97442
|
+
;// ./src/components/cascader-panel-pro/selectionStatePro.js
|
|
97443
|
+
|
|
97444
|
+
|
|
97445
|
+
|
|
97446
|
+
|
|
97447
|
+
|
|
97448
|
+
|
|
97449
|
+
|
|
97450
|
+
|
|
97451
|
+
|
|
97452
|
+
|
|
97453
|
+
const COMPACT_EMIT_THRESHOLD = 300;
|
|
97454
|
+
|
|
97455
|
+
class SelectionStatePro {
|
|
97456
|
+
constructor(store) {
|
|
97457
|
+
this.store = store;
|
|
97458
|
+
this.selectedLeafSet = new Set();
|
|
97459
|
+
this.subtreeSelectedCount = new Map();
|
|
97460
|
+
}
|
|
97461
|
+
clear() {
|
|
97462
|
+
this.selectedLeafSet.clear();
|
|
97463
|
+
this.subtreeSelectedCount.clear();
|
|
97464
|
+
}
|
|
97465
|
+
isEmpty() {
|
|
97466
|
+
return this.selectedLeafSet.size === 0;
|
|
97467
|
+
}
|
|
97468
|
+
size() {
|
|
97469
|
+
return this.selectedLeafSet.size;
|
|
97470
|
+
}
|
|
97471
|
+
_incAncestors(nodeId, delta) {
|
|
97472
|
+
let current = this.store.nodeById.get(nodeId);
|
|
97473
|
+
while (current) {
|
|
97474
|
+
const prev = this.subtreeSelectedCount.get(current.id) || 0;
|
|
97475
|
+
const next = prev + delta;
|
|
97476
|
+
if (next <= 0) {
|
|
97477
|
+
this.subtreeSelectedCount.delete(current.id);
|
|
97478
|
+
} else {
|
|
97479
|
+
this.subtreeSelectedCount.set(current.id, next);
|
|
97480
|
+
}
|
|
97481
|
+
if (current.parentId == null) {
|
|
97482
|
+
break;
|
|
97483
|
+
}
|
|
97484
|
+
current = this.store.nodeById.get(current.parentId);
|
|
97485
|
+
}
|
|
97486
|
+
}
|
|
97487
|
+
|
|
97488
|
+
/**
|
|
97489
|
+
* 自底向上重算 nodeId 子树内各层选中数
|
|
97490
|
+
*/
|
|
97491
|
+
_reconcileSubtreeCounts(nodeId) {
|
|
97492
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97493
|
+
if (!node) {
|
|
97494
|
+
return 0;
|
|
97495
|
+
}
|
|
97496
|
+
if (node.isLeaf) {
|
|
97497
|
+
return this.selectedLeafSet.has(node.value) ? 1 : 0;
|
|
97498
|
+
}
|
|
97499
|
+
let selected = 0;
|
|
97500
|
+
node.childIds.forEach(childId => {
|
|
97501
|
+
selected += this._reconcileSubtreeCounts(childId);
|
|
97502
|
+
});
|
|
97503
|
+
if (selected > 0) {
|
|
97504
|
+
this.subtreeSelectedCount.set(nodeId, selected);
|
|
97505
|
+
} else {
|
|
97506
|
+
this.subtreeSelectedCount.delete(nodeId);
|
|
97507
|
+
}
|
|
97508
|
+
return selected;
|
|
97509
|
+
}
|
|
97510
|
+
|
|
97511
|
+
/**
|
|
97512
|
+
* 从当前节点向上汇总祖先的选中数(勾选子节点后父级需半选/全选)
|
|
97513
|
+
*/
|
|
97514
|
+
_reconcileAncestors(nodeId) {
|
|
97515
|
+
var _this$store$nodeById$;
|
|
97516
|
+
let parentId = (_this$store$nodeById$ = this.store.nodeById.get(nodeId)) === null || _this$store$nodeById$ === void 0 ? void 0 : _this$store$nodeById$.parentId;
|
|
97517
|
+
while (parentId != null) {
|
|
97518
|
+
const parent = this.store.nodeById.get(parentId);
|
|
97519
|
+
if (!parent) {
|
|
97520
|
+
break;
|
|
97521
|
+
}
|
|
97522
|
+
let selected = 0;
|
|
97523
|
+
parent.childIds.forEach(childId => {
|
|
97524
|
+
const child = this.store.nodeById.get(childId);
|
|
97525
|
+
if (!child) {
|
|
97526
|
+
return;
|
|
97527
|
+
}
|
|
97528
|
+
if (child.isLeaf) {
|
|
97529
|
+
if (this.selectedLeafSet.has(child.value)) {
|
|
97530
|
+
selected++;
|
|
97531
|
+
}
|
|
97532
|
+
} else {
|
|
97533
|
+
selected += this.subtreeSelectedCount.get(childId) || 0;
|
|
97534
|
+
}
|
|
97535
|
+
});
|
|
97536
|
+
if (selected > 0) {
|
|
97537
|
+
this.subtreeSelectedCount.set(parentId, selected);
|
|
97538
|
+
} else {
|
|
97539
|
+
this.subtreeSelectedCount.delete(parentId);
|
|
97540
|
+
}
|
|
97541
|
+
parentId = parent.parentId;
|
|
97542
|
+
}
|
|
97543
|
+
}
|
|
97544
|
+
_reconcileAllRoots() {
|
|
97545
|
+
this.subtreeSelectedCount.clear();
|
|
97546
|
+
this.store.rootIds.forEach(rootId => {
|
|
97547
|
+
this._reconcileSubtreeCounts(rootId);
|
|
97548
|
+
});
|
|
97549
|
+
}
|
|
97550
|
+
_applyLeaf(value, checked) {
|
|
97551
|
+
const has = this.selectedLeafSet.has(value);
|
|
97552
|
+
if (checked && !has) {
|
|
97553
|
+
this.selectedLeafSet.add(value);
|
|
97554
|
+
const node = this.store.nodeByValue.get(value);
|
|
97555
|
+
if (node) {
|
|
97556
|
+
this._incAncestors(node.id, 1);
|
|
97557
|
+
}
|
|
97558
|
+
} else if (!checked && has) {
|
|
97559
|
+
this.selectedLeafSet.delete(value);
|
|
97560
|
+
const node = this.store.nodeByValue.get(value);
|
|
97561
|
+
if (node) {
|
|
97562
|
+
this._incAncestors(node.id, -1);
|
|
97563
|
+
}
|
|
97564
|
+
}
|
|
97565
|
+
}
|
|
97566
|
+
toggleNode(nodeId, checked) {
|
|
97567
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97568
|
+
if (!node || node.disabled) {
|
|
97569
|
+
return;
|
|
97570
|
+
}
|
|
97571
|
+
if (node.isLeaf) {
|
|
97572
|
+
const had = this.selectedLeafSet.has(node.value);
|
|
97573
|
+
this._applyLeaf(node.value, checked);
|
|
97574
|
+
if (had !== this.selectedLeafSet.has(node.value)) {
|
|
97575
|
+
this._reconcileAncestors(node.id);
|
|
97576
|
+
}
|
|
97577
|
+
return;
|
|
97578
|
+
}
|
|
97579
|
+
const leaves = node.descendantLeafValues;
|
|
97580
|
+
if (leaves.length === 0) {
|
|
97581
|
+
return;
|
|
97582
|
+
}
|
|
97583
|
+
let changedCount = 0;
|
|
97584
|
+
leaves.forEach(v => {
|
|
97585
|
+
const has = this.selectedLeafSet.has(v);
|
|
97586
|
+
if (checked) {
|
|
97587
|
+
if (!has) {
|
|
97588
|
+
this.selectedLeafSet.add(v);
|
|
97589
|
+
changedCount++;
|
|
97590
|
+
}
|
|
97591
|
+
} else if (has) {
|
|
97592
|
+
this.selectedLeafSet.delete(v);
|
|
97593
|
+
changedCount++;
|
|
97594
|
+
}
|
|
97595
|
+
});
|
|
97596
|
+
if (changedCount > 0) {
|
|
97597
|
+
this._reconcileSubtreeCounts(nodeId);
|
|
97598
|
+
this._reconcileAncestors(nodeId);
|
|
97599
|
+
}
|
|
97600
|
+
}
|
|
97601
|
+
selectAll() {
|
|
97602
|
+
this.clear();
|
|
97603
|
+
const leaves = this.store.allLeafValues;
|
|
97604
|
+
leaves.forEach(v => this.selectedLeafSet.add(v));
|
|
97605
|
+
this._reconcileAllRoots();
|
|
97606
|
+
}
|
|
97607
|
+
syncFromPaths(paths) {
|
|
97608
|
+
this.clear();
|
|
97609
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
97610
|
+
return;
|
|
97611
|
+
}
|
|
97612
|
+
paths.forEach(path => {
|
|
97613
|
+
if (!Array.isArray(path) || path.length === 0) {
|
|
97614
|
+
return;
|
|
97615
|
+
}
|
|
97616
|
+
const leafValue = path[path.length - 1];
|
|
97617
|
+
if (this.store.pathByLeafValue.has(leafValue)) {
|
|
97618
|
+
this.selectedLeafSet.add(leafValue);
|
|
97619
|
+
}
|
|
97620
|
+
});
|
|
97621
|
+
this._reconcileAllRoots();
|
|
97622
|
+
}
|
|
97623
|
+
getCheckState(nodeId) {
|
|
97624
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97625
|
+
if (!node || node.disabled) {
|
|
97626
|
+
return 'disabled';
|
|
97627
|
+
}
|
|
97628
|
+
if (node.isLeaf) {
|
|
97629
|
+
return this.selectedLeafSet.has(node.value) ? 'checked' : 'unchecked';
|
|
97630
|
+
}
|
|
97631
|
+
const total = node.descendantLeafCount;
|
|
97632
|
+
if (total === 0) {
|
|
97633
|
+
return 'unchecked';
|
|
97634
|
+
}
|
|
97635
|
+
const selected = this.subtreeSelectedCount.get(node.id) || 0;
|
|
97636
|
+
if (selected === 0) {
|
|
97637
|
+
return 'unchecked';
|
|
97638
|
+
}
|
|
97639
|
+
if (selected >= total) {
|
|
97640
|
+
return 'checked';
|
|
97641
|
+
}
|
|
97642
|
+
return 'indeterminate';
|
|
97643
|
+
}
|
|
97644
|
+
isChecked(nodeId) {
|
|
97645
|
+
return this.getCheckState(nodeId) === 'checked';
|
|
97646
|
+
}
|
|
97647
|
+
isIndeterminate(nodeId) {
|
|
97648
|
+
return this.getCheckState(nodeId) === 'indeterminate';
|
|
97649
|
+
}
|
|
97650
|
+
isPathInCheckedValues(path) {
|
|
97651
|
+
if (!path || path.length === 0) {
|
|
97652
|
+
return false;
|
|
97653
|
+
}
|
|
97654
|
+
const leafValue = path[path.length - 1];
|
|
97655
|
+
return this.selectedLeafSet.has(leafValue);
|
|
97656
|
+
}
|
|
97657
|
+
isNodeInCheckedPath(node) {
|
|
97658
|
+
if (!node) {
|
|
97659
|
+
return false;
|
|
97660
|
+
}
|
|
97661
|
+
return this.isPathInCheckedValues(node.path);
|
|
97662
|
+
}
|
|
97663
|
+
getCheckedPaths() {
|
|
97664
|
+
const paths = [];
|
|
97665
|
+
this.selectedLeafSet.forEach(leafValue => {
|
|
97666
|
+
const path = this.store.pathByLeafValue.get(leafValue);
|
|
97667
|
+
if (path) {
|
|
97668
|
+
paths.push(path);
|
|
97669
|
+
}
|
|
97670
|
+
});
|
|
97671
|
+
return paths;
|
|
97672
|
+
}
|
|
97673
|
+
isCompactSelection() {
|
|
97674
|
+
return this.selectedLeafSet.size >= COMPACT_EMIT_THRESHOLD;
|
|
97675
|
+
}
|
|
97676
|
+
|
|
97677
|
+
/** 从聚合父节点值快速同步(如 __parent__province_0) */
|
|
97678
|
+
syncFromParentValues(parentValues, prefix = '__parent__') {
|
|
97679
|
+
this.clear();
|
|
97680
|
+
if (!Array.isArray(parentValues) || parentValues.length === 0) {
|
|
97681
|
+
return;
|
|
97682
|
+
}
|
|
97683
|
+
parentValues.forEach(val => {
|
|
97684
|
+
let rootValue = val;
|
|
97685
|
+
if (typeof val === 'string' && val.startsWith(prefix)) {
|
|
97686
|
+
rootValue = val.substring(prefix.length);
|
|
97687
|
+
}
|
|
97688
|
+
const node = this.store.nodeByValue.get(rootValue);
|
|
97689
|
+
if (node && !node.isLeaf && !node.disabled) {
|
|
97690
|
+
node.descendantLeafValues.forEach(v => this.selectedLeafSet.add(v));
|
|
97691
|
+
}
|
|
97692
|
+
});
|
|
97693
|
+
this._reconcileAllRoots();
|
|
97694
|
+
}
|
|
97695
|
+
}
|
|
97696
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/VirtualCascaderPanel.vue?vue&type=script&lang=js
|
|
97697
|
+
|
|
97698
|
+
|
|
97699
|
+
|
|
97700
|
+
|
|
97701
|
+
|
|
97702
|
+
|
|
97703
|
+
|
|
97704
|
+
|
|
97705
|
+
/* harmony default export */ var VirtualCascaderPanelvue_type_script_lang_js = ({
|
|
97706
|
+
name: 'VirtualCascaderPanel',
|
|
97707
|
+
components: {
|
|
97708
|
+
VcpVirtualList: VirtualList
|
|
97709
|
+
},
|
|
97710
|
+
props: {
|
|
97711
|
+
value: {
|
|
97712
|
+
type: [Array, String, Number],
|
|
97713
|
+
default: () => []
|
|
97714
|
+
},
|
|
97715
|
+
options: {
|
|
97716
|
+
type: Array,
|
|
97717
|
+
default: () => []
|
|
97718
|
+
},
|
|
97719
|
+
props: {
|
|
97720
|
+
type: Object,
|
|
97721
|
+
default: () => ({
|
|
97722
|
+
multiple: true,
|
|
97723
|
+
label: 'label',
|
|
97724
|
+
value: 'value',
|
|
97725
|
+
children: 'children',
|
|
97726
|
+
checkStrictly: false
|
|
97727
|
+
})
|
|
97728
|
+
},
|
|
97729
|
+
height: {
|
|
97730
|
+
type: Number,
|
|
97731
|
+
default: 280
|
|
97732
|
+
},
|
|
97733
|
+
columnMinWidth: {
|
|
97734
|
+
type: Number,
|
|
97735
|
+
default: 180
|
|
97736
|
+
},
|
|
97737
|
+
columnMaxWidth: {
|
|
97738
|
+
type: Number,
|
|
97739
|
+
default: 420
|
|
97740
|
+
},
|
|
97741
|
+
disabledConfig: {
|
|
97742
|
+
type: Object,
|
|
97743
|
+
default: () => ({})
|
|
97744
|
+
},
|
|
97745
|
+
isViewMode: {
|
|
97746
|
+
type: Boolean,
|
|
97747
|
+
default: false
|
|
97748
|
+
},
|
|
97749
|
+
autoExpandDeep: {
|
|
97750
|
+
type: Boolean,
|
|
97751
|
+
default: true
|
|
97752
|
+
},
|
|
97753
|
+
// 是否从 value prop 同步选中(紧凑模式下由面板内部维护选中状态)
|
|
97754
|
+
syncValueFromParent: {
|
|
97755
|
+
type: Boolean,
|
|
97756
|
+
default: true
|
|
97757
|
+
}
|
|
97758
|
+
},
|
|
97759
|
+
data() {
|
|
97760
|
+
return {
|
|
97761
|
+
store: null,
|
|
97762
|
+
selection: null,
|
|
97763
|
+
activePath: [],
|
|
97764
|
+
itemHeight: 34,
|
|
97765
|
+
syncingValue: false,
|
|
97766
|
+
suppressValueSync: false,
|
|
97767
|
+
selectionTick: 0
|
|
97768
|
+
};
|
|
97769
|
+
},
|
|
97770
|
+
computed: {
|
|
97771
|
+
multiple() {
|
|
97772
|
+
return this.props.multiple !== false;
|
|
97773
|
+
},
|
|
97774
|
+
checkStrictly() {
|
|
97775
|
+
return !!this.props.checkStrictly;
|
|
97776
|
+
},
|
|
97777
|
+
columns() {
|
|
97778
|
+
if (!this.store) {
|
|
97779
|
+
return [];
|
|
97780
|
+
}
|
|
97781
|
+
const cols = [getStoreChildren(this.store, null)];
|
|
97782
|
+
this.activePath.forEach(nodeId => {
|
|
97783
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97784
|
+
if (!node || node.isLeaf) {
|
|
97785
|
+
return;
|
|
97786
|
+
}
|
|
97787
|
+
const children = getStoreChildren(this.store, nodeId);
|
|
97788
|
+
if (children.length > 0) {
|
|
97789
|
+
cols.push(children);
|
|
97790
|
+
}
|
|
97791
|
+
});
|
|
97792
|
+
return cols;
|
|
97793
|
+
},
|
|
97794
|
+
singleCheckedValue() {
|
|
97795
|
+
if (this.multiple || !Array.isArray(this.value) || this.value.length === 0) {
|
|
97796
|
+
return null;
|
|
97797
|
+
}
|
|
97798
|
+
const path = Array.isArray(this.value[0]) ? this.value[0] : this.value;
|
|
97799
|
+
return path[path.length - 1];
|
|
97800
|
+
}
|
|
97801
|
+
},
|
|
97802
|
+
watch: {
|
|
97803
|
+
options: {
|
|
97804
|
+
handler() {
|
|
97805
|
+
this.rebuildStore();
|
|
97806
|
+
}
|
|
97807
|
+
},
|
|
97808
|
+
value: {
|
|
97809
|
+
handler() {
|
|
97810
|
+
if (this.suppressValueSync || !this.syncValueFromParent) {
|
|
97811
|
+
return;
|
|
97812
|
+
}
|
|
97813
|
+
this.syncFromValue();
|
|
97814
|
+
},
|
|
97815
|
+
deep: false
|
|
97816
|
+
},
|
|
97817
|
+
activePath: {
|
|
97818
|
+
handler() {
|
|
97819
|
+
this.$nextTick(() => {
|
|
97820
|
+
this.syncHorizontalOverflow();
|
|
97821
|
+
});
|
|
97822
|
+
},
|
|
97823
|
+
deep: true
|
|
97824
|
+
}
|
|
97825
|
+
},
|
|
97826
|
+
created() {
|
|
97827
|
+
this.rebuildStore();
|
|
97828
|
+
},
|
|
97829
|
+
mounted() {
|
|
97830
|
+
this._onWindowResize = () => {
|
|
97831
|
+
this.syncHorizontalOverflow();
|
|
97832
|
+
};
|
|
97833
|
+
window.addEventListener('resize', this._onWindowResize, {
|
|
97834
|
+
passive: true
|
|
97835
|
+
});
|
|
97836
|
+
this.syncHorizontalOverflow();
|
|
97837
|
+
},
|
|
97838
|
+
beforeDestroy() {
|
|
97839
|
+
if (this._onWindowResize) {
|
|
97840
|
+
window.removeEventListener('resize', this._onWindowResize);
|
|
97841
|
+
this._onWindowResize = null;
|
|
97842
|
+
}
|
|
97843
|
+
if (this._hScrollRaf) {
|
|
97844
|
+
cancelAnimationFrame(this._hScrollRaf);
|
|
97845
|
+
this._hScrollRaf = null;
|
|
97846
|
+
}
|
|
97847
|
+
},
|
|
97848
|
+
methods: {
|
|
97849
|
+
syncHorizontalOverflow() {
|
|
97850
|
+
if (this._hScrollRaf) {
|
|
97851
|
+
cancelAnimationFrame(this._hScrollRaf);
|
|
97852
|
+
}
|
|
97853
|
+
this._hScrollRaf = requestAnimationFrame(() => {
|
|
97854
|
+
this._hScrollRaf = null;
|
|
97855
|
+
const panel = this.$el;
|
|
97856
|
+
const wrapper = panel && panel.closest('.cascader-content-wrapper');
|
|
97857
|
+
if (!panel || !wrapper) {
|
|
97858
|
+
return;
|
|
97859
|
+
}
|
|
97860
|
+
const overflow = panel.scrollWidth - wrapper.clientWidth;
|
|
97861
|
+
const hadScroll = wrapper.classList.contains('is-horizontal-scroll');
|
|
97862
|
+
// 滞回区间,避免边界宽度下 overflow 来回切换
|
|
97863
|
+
const needsScroll = hadScroll ? overflow > -4 : overflow > 1;
|
|
97864
|
+
if (needsScroll !== hadScroll) {
|
|
97865
|
+
wrapper.classList.toggle('is-horizontal-scroll', needsScroll);
|
|
97866
|
+
}
|
|
97867
|
+
});
|
|
97868
|
+
},
|
|
97869
|
+
getColumnStyle(colIndex, columnNodes) {
|
|
97870
|
+
const width = CascaderUtilsPro.getCascaderColumnWidth(columnNodes, {
|
|
97871
|
+
minWidth: this.columnMinWidth,
|
|
97872
|
+
maxWidth: this.columnMaxWidth,
|
|
97873
|
+
hasCheckbox: this.multiple || this.checkStrictly
|
|
97874
|
+
});
|
|
97875
|
+
return {
|
|
97876
|
+
width: width + 'px',
|
|
97877
|
+
minWidth: width + 'px',
|
|
97878
|
+
maxWidth: width + 'px'
|
|
97879
|
+
};
|
|
97880
|
+
},
|
|
97881
|
+
rebuildStore() {
|
|
97882
|
+
this.store = buildCascaderStore(this.options, this.disabledConfig, this.props, CascaderUtilsPro);
|
|
97883
|
+
this.selection = new SelectionStatePro(this.store);
|
|
97884
|
+
this.activePath = [];
|
|
97885
|
+
if (this.syncValueFromParent) {
|
|
97886
|
+
this.syncFromValue();
|
|
97887
|
+
}
|
|
97888
|
+
this.$nextTick(() => {
|
|
97889
|
+
this.syncHorizontalOverflow();
|
|
97890
|
+
if (!this.syncValueFromParent) {
|
|
97891
|
+
this.$emit('store-ready');
|
|
97892
|
+
}
|
|
97893
|
+
});
|
|
97894
|
+
},
|
|
97895
|
+
syncFromValue() {
|
|
97896
|
+
if (!this.selection) {
|
|
97897
|
+
return;
|
|
97898
|
+
}
|
|
97899
|
+
this.syncingValue = true;
|
|
97900
|
+
if (this.multiple) {
|
|
97901
|
+
const paths = Array.isArray(this.value) ? this.value : [];
|
|
97902
|
+
this.selection.syncFromPaths(paths);
|
|
97903
|
+
} else {
|
|
97904
|
+
const path = this.normalizeSinglePath(this.value);
|
|
97905
|
+
this.selection.syncFromPaths(path ? [path] : []);
|
|
97906
|
+
if (path && path.length > 1) {
|
|
97907
|
+
this.expandPathValues(path.slice(0, -1), false);
|
|
97908
|
+
}
|
|
97909
|
+
}
|
|
97910
|
+
this.syncingValue = false;
|
|
97911
|
+
},
|
|
97912
|
+
normalizeSinglePath(val) {
|
|
97913
|
+
if (val == null || val === '') {
|
|
97914
|
+
return null;
|
|
97915
|
+
}
|
|
97916
|
+
if (Array.isArray(val)) {
|
|
97917
|
+
if (val.length === 0) {
|
|
97918
|
+
return null;
|
|
97919
|
+
}
|
|
97920
|
+
if (Array.isArray(val[0])) {
|
|
97921
|
+
return val[0];
|
|
97922
|
+
}
|
|
97923
|
+
return val;
|
|
97924
|
+
}
|
|
97925
|
+
const node = this.store && this.store.nodeByValue.get(val);
|
|
97926
|
+
if (node) {
|
|
97927
|
+
return node.path;
|
|
97928
|
+
}
|
|
97929
|
+
return [val];
|
|
97930
|
+
},
|
|
97931
|
+
emitValue() {
|
|
97932
|
+
if (this.syncingValue || !this.selection) {
|
|
97933
|
+
return;
|
|
97934
|
+
}
|
|
97935
|
+
if (this.selection.isCompactSelection()) {
|
|
97936
|
+
this.$emit('change', {
|
|
97937
|
+
compact: true,
|
|
97938
|
+
count: this.selection.size()
|
|
97939
|
+
});
|
|
97940
|
+
return;
|
|
97941
|
+
}
|
|
97942
|
+
let emitVal;
|
|
97943
|
+
if (this.multiple) {
|
|
97944
|
+
emitVal = this.selection.getCheckedPaths();
|
|
97945
|
+
} else {
|
|
97946
|
+
const paths = this.selection.getCheckedPaths();
|
|
97947
|
+
emitVal = paths.length > 0 ? paths[0] : [];
|
|
97948
|
+
}
|
|
97949
|
+
this.$emit('input', emitVal);
|
|
97950
|
+
this.$emit('change', emitVal);
|
|
97951
|
+
},
|
|
97952
|
+
isActive(node, colIndex) {
|
|
97953
|
+
return colIndex < this.activePath.length && this.activePath[colIndex] === node.id;
|
|
97954
|
+
},
|
|
97955
|
+
isExpanded(node, colIndex) {
|
|
97956
|
+
return this.activePath[colIndex] === node.id;
|
|
97957
|
+
},
|
|
97958
|
+
isInActivePath(node) {
|
|
97959
|
+
return this.activePath.includes(node.id);
|
|
97960
|
+
},
|
|
97961
|
+
getNodeClass(node, colIndex) {
|
|
97962
|
+
return {
|
|
97963
|
+
'is-selectable': this.checkStrictly,
|
|
97964
|
+
'is-disabled': node.disabled || this.isViewMode,
|
|
97965
|
+
'in-active-path': this.isInActivePath(node),
|
|
97966
|
+
'in-checked-path': this.checkStrictly && this.isInCheckedPath(node),
|
|
97967
|
+
'is-active': this.isNodeActive(node)
|
|
97968
|
+
};
|
|
97969
|
+
},
|
|
97970
|
+
isInCheckedPath(node) {
|
|
97971
|
+
void this.selectionTick;
|
|
97972
|
+
if (!this.selection || !this.checkStrictly) {
|
|
97973
|
+
return false;
|
|
97974
|
+
}
|
|
97975
|
+
return this.selection.isNodeInCheckedPath(node);
|
|
97976
|
+
},
|
|
97977
|
+
isNodeActive(node) {
|
|
97978
|
+
void this.selectionTick;
|
|
97979
|
+
if (!this.selection) {
|
|
97980
|
+
return false;
|
|
97981
|
+
}
|
|
97982
|
+
if (this.multiple) {
|
|
97983
|
+
if (this.checkStrictly) {
|
|
97984
|
+
return this.selection.isNodeInCheckedPath(node);
|
|
97985
|
+
}
|
|
97986
|
+
return node.isLeaf && this.selection.selectedLeafSet.has(node.value);
|
|
97987
|
+
}
|
|
97988
|
+
const paths = this.selection.getCheckedPaths();
|
|
97989
|
+
if (paths.length === 0) {
|
|
97990
|
+
return false;
|
|
97991
|
+
}
|
|
97992
|
+
const activePath = paths[0];
|
|
97993
|
+
return activePath[activePath.length - 1] === node.value;
|
|
97994
|
+
},
|
|
97995
|
+
isChecked(node) {
|
|
97996
|
+
void this.selectionTick;
|
|
97997
|
+
return this.selection ? this.selection.isChecked(node.id) : false;
|
|
97998
|
+
},
|
|
97999
|
+
isIndeterminate(node) {
|
|
98000
|
+
void this.selectionTick;
|
|
98001
|
+
return this.selection ? this.selection.isIndeterminate(node.id) : false;
|
|
98002
|
+
},
|
|
98003
|
+
bumpSelectionView() {
|
|
98004
|
+
this.selectionTick += 1;
|
|
98005
|
+
},
|
|
98006
|
+
// activePath 只保留非叶子,避免多出一列空菜单(空列仍有 min-width 会撑出横向滚动)
|
|
98007
|
+
sanitizeActivePath(pathIds) {
|
|
98008
|
+
if (!this.store || !Array.isArray(pathIds)) {
|
|
98009
|
+
return [];
|
|
98010
|
+
}
|
|
98011
|
+
return pathIds.filter(id => {
|
|
98012
|
+
const node = this.store.nodeById.get(id);
|
|
98013
|
+
return node && !node.isLeaf;
|
|
98014
|
+
});
|
|
98015
|
+
},
|
|
98016
|
+
expandNode(node, silent = false) {
|
|
98017
|
+
if (node.isLeaf) {
|
|
98018
|
+
return;
|
|
98019
|
+
}
|
|
98020
|
+
const pathIds = [];
|
|
98021
|
+
let current = node;
|
|
98022
|
+
while (current) {
|
|
98023
|
+
pathIds.unshift(current.id);
|
|
98024
|
+
if (current.parentId == null) {
|
|
98025
|
+
break;
|
|
98026
|
+
}
|
|
98027
|
+
current = this.store.nodeById.get(current.parentId);
|
|
98028
|
+
}
|
|
98029
|
+
this.activePath = this.sanitizeActivePath(pathIds);
|
|
98030
|
+
if (!silent) {
|
|
98031
|
+
const pathValues = pathIds.map(id => this.store.nodeById.get(id).value);
|
|
98032
|
+
this.$emit('expand-change', pathValues);
|
|
98033
|
+
if (this.autoExpandDeep) {
|
|
98034
|
+
this.$nextTick(() => {
|
|
98035
|
+
this.expandDeepFromNode(node);
|
|
98036
|
+
});
|
|
98037
|
+
}
|
|
98038
|
+
}
|
|
98039
|
+
},
|
|
98040
|
+
expandDeepFromNode(node) {
|
|
98041
|
+
if (!node || node.isLeaf) {
|
|
98042
|
+
return;
|
|
98043
|
+
}
|
|
98044
|
+
const children = getStoreChildren(this.store, node.id);
|
|
98045
|
+
if (children.length === 0) {
|
|
98046
|
+
return;
|
|
98047
|
+
}
|
|
98048
|
+
const firstChild = children[0];
|
|
98049
|
+
const pathIds = [];
|
|
98050
|
+
let cursor = firstChild;
|
|
98051
|
+
while (cursor) {
|
|
98052
|
+
pathIds.push(cursor.id);
|
|
98053
|
+
if (cursor.isLeaf) {
|
|
98054
|
+
break;
|
|
98055
|
+
}
|
|
98056
|
+
const kids = getStoreChildren(this.store, cursor.id);
|
|
98057
|
+
if (kids.length === 0) {
|
|
98058
|
+
break;
|
|
98059
|
+
}
|
|
98060
|
+
cursor = kids[0];
|
|
98061
|
+
}
|
|
98062
|
+
const basePath = [];
|
|
98063
|
+
let parent = node;
|
|
98064
|
+
while (parent) {
|
|
98065
|
+
basePath.unshift(parent.id);
|
|
98066
|
+
if (parent.parentId == null) {
|
|
98067
|
+
break;
|
|
98068
|
+
}
|
|
98069
|
+
parent = this.store.nodeById.get(parent.parentId);
|
|
98070
|
+
}
|
|
98071
|
+
this.activePath = this.sanitizeActivePath(basePath.concat(pathIds));
|
|
98072
|
+
},
|
|
98073
|
+
expandPathValues(pathValues, deep = true) {
|
|
98074
|
+
if (!pathValues || pathValues.length === 0 || !this.store) {
|
|
98075
|
+
return;
|
|
98076
|
+
}
|
|
98077
|
+
const node = findStoreNodeByPath(this.store, pathValues);
|
|
98078
|
+
if (!node) {
|
|
98079
|
+
return;
|
|
98080
|
+
}
|
|
98081
|
+
const pathIds = [];
|
|
98082
|
+
let current = node;
|
|
98083
|
+
while (current) {
|
|
98084
|
+
pathIds.unshift(current.id);
|
|
98085
|
+
if (current.parentId == null) {
|
|
98086
|
+
break;
|
|
98087
|
+
}
|
|
98088
|
+
current = this.store.nodeById.get(current.parentId);
|
|
98089
|
+
}
|
|
98090
|
+
this.activePath = this.sanitizeActivePath(pathIds);
|
|
98091
|
+
if (deep && this.autoExpandDeep) {
|
|
98092
|
+
this.$nextTick(() => {
|
|
98093
|
+
this.expandDeepFromNode(node);
|
|
98094
|
+
});
|
|
98095
|
+
}
|
|
98096
|
+
},
|
|
98097
|
+
onNodeClick(node, colIndex) {
|
|
98098
|
+
if (node.disabled || this.isViewMode) {
|
|
98099
|
+
return;
|
|
98100
|
+
}
|
|
98101
|
+
if (!this.multiple && !this.checkStrictly) {
|
|
98102
|
+
if (node.isLeaf) {
|
|
98103
|
+
this.selection.clear();
|
|
98104
|
+
this.selection.toggleNode(node.id, true);
|
|
98105
|
+
this.emitValue();
|
|
98106
|
+
} else {
|
|
98107
|
+
this.expandNode(node);
|
|
98108
|
+
}
|
|
98109
|
+
return;
|
|
98110
|
+
}
|
|
98111
|
+
this.expandNode(node);
|
|
98112
|
+
},
|
|
98113
|
+
onCheckClick(node, checked) {
|
|
98114
|
+
if (!this.multiple || node.disabled || this.isViewMode) {
|
|
98115
|
+
return;
|
|
98116
|
+
}
|
|
98117
|
+
const nextChecked = typeof checked === 'boolean' ? checked : !this.isChecked(node);
|
|
98118
|
+
this.selection.toggleNode(node.id, nextChecked);
|
|
98119
|
+
this.bumpSelectionView();
|
|
98120
|
+
this.emitValue();
|
|
98121
|
+
|
|
98122
|
+
// 与 el-cascader-panel 一致:非 checkStrictly 时勾选会同步展开当前节点
|
|
98123
|
+
if (!this.checkStrictly && !node.isLeaf) {
|
|
98124
|
+
this.expandNode(node);
|
|
98125
|
+
}
|
|
98126
|
+
},
|
|
98127
|
+
onRadioClick(node) {
|
|
98128
|
+
if (this.multiple || node.disabled || this.isViewMode) {
|
|
98129
|
+
return;
|
|
98130
|
+
}
|
|
98131
|
+
this.selection.clear();
|
|
98132
|
+
this.selection.toggleNode(node.id, true);
|
|
98133
|
+
this.emitValue();
|
|
98134
|
+
if (!node.isLeaf) {
|
|
98135
|
+
this.expandNode(node);
|
|
98136
|
+
}
|
|
98137
|
+
},
|
|
98138
|
+
clearCheckedNodes() {
|
|
98139
|
+
if (this.selection) {
|
|
98140
|
+
this.selection.clear();
|
|
98141
|
+
this.bumpSelectionView();
|
|
98142
|
+
this.$emit('input', this.multiple ? [] : []);
|
|
98143
|
+
this.$emit('change', this.multiple ? [] : []);
|
|
98144
|
+
}
|
|
98145
|
+
},
|
|
98146
|
+
selectAllLeaves() {
|
|
98147
|
+
if (this.selection) {
|
|
98148
|
+
this.selection.selectAll();
|
|
98149
|
+
this.bumpSelectionView();
|
|
98150
|
+
this.emitValue();
|
|
98151
|
+
}
|
|
98152
|
+
},
|
|
98153
|
+
syncCheckedValue() {
|
|
98154
|
+
this.syncFromValue();
|
|
98155
|
+
},
|
|
98156
|
+
syncFromParentValues(values, prefix) {
|
|
98157
|
+
if (!this.selection) {
|
|
98158
|
+
return;
|
|
98159
|
+
}
|
|
98160
|
+
this.suppressValueSync = true;
|
|
98161
|
+
this.selection.syncFromParentValues(values, prefix);
|
|
98162
|
+
this.bumpSelectionView();
|
|
98163
|
+
this.suppressValueSync = false;
|
|
98164
|
+
},
|
|
98165
|
+
getSelectionSnapshot() {
|
|
98166
|
+
if (!this.selection || !this.store) {
|
|
98167
|
+
return null;
|
|
98168
|
+
}
|
|
98169
|
+
return {
|
|
98170
|
+
store: this.store,
|
|
98171
|
+
selection: this.selection,
|
|
98172
|
+
isCompact: this.selection.isCompactSelection(),
|
|
98173
|
+
count: this.selection.size()
|
|
98174
|
+
};
|
|
98175
|
+
}
|
|
98176
|
+
}
|
|
98177
|
+
});
|
|
98178
|
+
;// ./src/components/cascader-panel-pro/VirtualCascaderPanel.vue?vue&type=script&lang=js
|
|
98179
|
+
/* harmony default export */ var cascader_panel_pro_VirtualCascaderPanelvue_type_script_lang_js = (VirtualCascaderPanelvue_type_script_lang_js);
|
|
98180
|
+
;// ./src/components/cascader-panel-pro/VirtualCascaderPanel.vue
|
|
98181
|
+
|
|
98182
|
+
|
|
98183
|
+
|
|
98184
|
+
|
|
98185
|
+
|
|
98186
|
+
/* normalize component */
|
|
98187
|
+
;
|
|
98188
|
+
var VirtualCascaderPanel_component = normalizeComponent(
|
|
98189
|
+
cascader_panel_pro_VirtualCascaderPanelvue_type_script_lang_js,
|
|
98190
|
+
VirtualCascaderPanelvue_type_template_id_05f77638_render,
|
|
98191
|
+
VirtualCascaderPanelvue_type_template_id_05f77638_staticRenderFns,
|
|
98192
|
+
false,
|
|
98193
|
+
null,
|
|
98194
|
+
null,
|
|
98195
|
+
null
|
|
98196
|
+
|
|
98197
|
+
)
|
|
98198
|
+
|
|
98199
|
+
/* harmony default export */ var VirtualCascaderPanel = (VirtualCascaderPanel_component.exports);
|
|
98200
|
+
;// ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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-pro/ByCascaderPanelPro.vue?vue&type=script&lang=js
|
|
98201
|
+
|
|
98202
|
+
|
|
98203
|
+
|
|
98204
|
+
|
|
98205
|
+
|
|
98206
|
+
|
|
98207
|
+
|
|
98208
|
+
|
|
98209
|
+
|
|
98210
|
+
|
|
98211
|
+
|
|
98212
|
+
|
|
98213
|
+
|
|
98214
|
+
|
|
98215
|
+
|
|
98216
|
+
|
|
98217
|
+
|
|
98218
|
+
/* harmony default export */ var ByCascaderPanelProvue_type_script_lang_js = ({
|
|
98219
|
+
name: 'ByCascaderPanelPro',
|
|
98220
|
+
components: {
|
|
98221
|
+
VirtualCascaderPanel: VirtualCascaderPanel,
|
|
98222
|
+
VcpVirtualList: VirtualList
|
|
98223
|
+
},
|
|
98224
|
+
props: {
|
|
98225
|
+
// 级联数据源
|
|
98226
|
+
options: {
|
|
98227
|
+
type: Array,
|
|
98228
|
+
default: () => []
|
|
98229
|
+
},
|
|
98230
|
+
// 已选值
|
|
98231
|
+
value: {
|
|
98232
|
+
type: [Array, Number, String],
|
|
98233
|
+
default: () => []
|
|
98234
|
+
},
|
|
98235
|
+
// 级联面板配置
|
|
98236
|
+
cascaderProps: {
|
|
98237
|
+
type: Object,
|
|
98238
|
+
default: () => ({
|
|
98239
|
+
multiple: true,
|
|
98240
|
+
label: 'label',
|
|
98241
|
+
value: 'value',
|
|
98242
|
+
children: 'children'
|
|
98243
|
+
})
|
|
98244
|
+
},
|
|
98245
|
+
// 面板高度
|
|
98246
|
+
panelHeight: {
|
|
98247
|
+
type: [String, Number],
|
|
98248
|
+
default: 300,
|
|
98249
|
+
validator: value => {
|
|
98250
|
+
const numValue = Number(value);
|
|
98251
|
+
if (isNaN(numValue)) {
|
|
98252
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 必须是数字,当前值: ${value}`);
|
|
98253
|
+
return false;
|
|
98254
|
+
}
|
|
98255
|
+
if (numValue < 200) {
|
|
98256
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 不能小于 200px,当前值: ${value}px`);
|
|
98257
|
+
return false;
|
|
98258
|
+
}
|
|
98259
|
+
if (numValue > 800) {
|
|
98260
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 不能大于 800px,当前值: ${value}px`);
|
|
98261
|
+
return false;
|
|
98262
|
+
}
|
|
98263
|
+
return true;
|
|
98264
|
+
}
|
|
98265
|
+
},
|
|
98266
|
+
// 搜索占位符
|
|
98267
|
+
searchPlaceholder: {
|
|
98268
|
+
type: String,
|
|
98269
|
+
default: '请输入名称搜索'
|
|
98270
|
+
},
|
|
98271
|
+
// 禁用字段名(只针对叶子节点,非叶子节点为disabled)
|
|
98272
|
+
disabledField: {
|
|
98273
|
+
type: String,
|
|
98274
|
+
default: 'disabled'
|
|
98275
|
+
},
|
|
98276
|
+
// 禁用值(只针对叶子节点,非叶子节点为disabled)
|
|
98277
|
+
disabledValue: {
|
|
98278
|
+
type: [String, Number, Boolean],
|
|
98279
|
+
default: true
|
|
98280
|
+
},
|
|
98281
|
+
// 自定义禁用判断函数
|
|
98282
|
+
disabledCheck: {
|
|
98283
|
+
type: Function,
|
|
98284
|
+
default: null
|
|
98285
|
+
},
|
|
98286
|
+
// 是否显示全选按钮
|
|
98287
|
+
showSelectAll: {
|
|
98288
|
+
type: Boolean,
|
|
98289
|
+
default: true
|
|
98290
|
+
},
|
|
98291
|
+
// 是否聚合模式 (聚合模式下如果子项全部选中,会直接返回父ID)
|
|
98292
|
+
aggregationMode: {
|
|
98293
|
+
type: Boolean,
|
|
98294
|
+
default: false
|
|
98295
|
+
},
|
|
98296
|
+
/**
|
|
98297
|
+
* 非叶子节点前缀标识 (聚合模式下用于标识非叶子节点)
|
|
98298
|
+
* 注意:聚合模式下,由于叶子节点和非叶子节点可能存在相同id,所以绑定数据中务必给非叶子节点加上parentNodePrefix前缀作为标识
|
|
98299
|
+
*/
|
|
98300
|
+
parentNodePrefix: {
|
|
98301
|
+
type: String,
|
|
98302
|
+
default: '__parent__'
|
|
98303
|
+
},
|
|
98304
|
+
// 是否为查看模式 (如果是查看模式,则组件中的操作交互将全部禁用,仅用于回显查看)
|
|
98305
|
+
isViewMode: {
|
|
98306
|
+
type: Boolean,
|
|
98307
|
+
default: false
|
|
98308
|
+
},
|
|
98309
|
+
// 是否显示子标题
|
|
98310
|
+
showSubtitle: {
|
|
98311
|
+
type: Boolean,
|
|
98312
|
+
default: false
|
|
98313
|
+
},
|
|
98314
|
+
// 子标题字段名
|
|
98315
|
+
subtitleField: {
|
|
98316
|
+
type: String,
|
|
98317
|
+
default: ''
|
|
98318
|
+
},
|
|
98319
|
+
// 级联列最小宽度(px)
|
|
98320
|
+
columnMinWidth: {
|
|
98321
|
+
type: Number,
|
|
98322
|
+
default: 180
|
|
98323
|
+
},
|
|
98324
|
+
// 级联列最大宽度(px),超出后显示省略号
|
|
98325
|
+
columnMaxWidth: {
|
|
98326
|
+
type: Number,
|
|
98327
|
+
default: 420
|
|
98328
|
+
}
|
|
98329
|
+
},
|
|
98330
|
+
data() {
|
|
98331
|
+
return {
|
|
98332
|
+
selectedValues: [],
|
|
98333
|
+
searchSelectedValues: [],
|
|
98334
|
+
filteredOptions: [],
|
|
98335
|
+
searchOptions: [],
|
|
98336
|
+
selectedItems: [],
|
|
98337
|
+
searchInput: '',
|
|
98338
|
+
isShow: true,
|
|
98339
|
+
isShowSearch: false,
|
|
98340
|
+
totalCount: 0,
|
|
98341
|
+
selectedCount: 0,
|
|
98342
|
+
isAllSelected: false,
|
|
98343
|
+
isInternalUpdate: false,
|
|
98344
|
+
// 防止循环更新的标志
|
|
98345
|
+
batchSearchVisible: false,
|
|
98346
|
+
// 批量搜索弹窗显示状态
|
|
98347
|
+
batchSearchContent: '',
|
|
98348
|
+
// 批量搜索输入内容
|
|
98349
|
+
compactPanelValue: [],
|
|
98350
|
+
// 紧凑模式下稳定的空 value 引用,避免 watch 误触发清空
|
|
98351
|
+
searchDebounceTimer: null,
|
|
98352
|
+
searchLeafSetCache: null,
|
|
98353
|
+
panelSyncTimer: null
|
|
98354
|
+
};
|
|
98355
|
+
},
|
|
98356
|
+
computed: {
|
|
98357
|
+
disabledConfig() {
|
|
98358
|
+
return {
|
|
98359
|
+
disabledField: this.disabledField,
|
|
98360
|
+
disabledValue: this.disabledValue,
|
|
98361
|
+
disabledCheck: this.disabledCheck
|
|
98362
|
+
};
|
|
98363
|
+
},
|
|
98364
|
+
// 处理后的面板高度,确保在有效范围内
|
|
98365
|
+
computedPanelHeight() {
|
|
98366
|
+
const height = Number(this.panelHeight);
|
|
98367
|
+
if (isNaN(height)) {
|
|
98368
|
+
return 300; // 默认值
|
|
98369
|
+
}
|
|
98370
|
+
// 限制在 200px 到 800px 之间
|
|
98371
|
+
return Math.max(200, Math.min(800, height));
|
|
98372
|
+
},
|
|
98373
|
+
// 是否为多选模式
|
|
98374
|
+
isMultiple() {
|
|
98375
|
+
return this.cascaderProps.multiple !== false;
|
|
98376
|
+
},
|
|
98377
|
+
useCompactSelection() {
|
|
98378
|
+
return this.isMultiple && this.totalCount >= 300;
|
|
98379
|
+
},
|
|
98380
|
+
panelPresentationValue() {
|
|
98381
|
+
if (this.useCompactSelection) {
|
|
98382
|
+
return this.compactPanelValue;
|
|
98383
|
+
}
|
|
98384
|
+
if (this.isMultiple) {
|
|
98385
|
+
return this.selectedValues;
|
|
98386
|
+
}
|
|
98387
|
+
return this.selectedValues.length > 0 ? this.selectedValues[0] : [];
|
|
98388
|
+
},
|
|
98389
|
+
compactSearchPanelValue() {
|
|
98390
|
+
return this.compactPanelValue;
|
|
98391
|
+
},
|
|
98392
|
+
selectedItemHeight() {
|
|
98393
|
+
return 40;
|
|
98394
|
+
},
|
|
98395
|
+
selectedListHeight() {
|
|
98396
|
+
return Math.max(120, this.computedPanelHeight - 25);
|
|
98397
|
+
},
|
|
98398
|
+
// 当前选中的值(单选时返回单个值,多选时返回数组)
|
|
98399
|
+
currentValue() {
|
|
98400
|
+
if (this.isMultiple) {
|
|
98401
|
+
return this.selectedItems.map(item => item.value);
|
|
98402
|
+
} else {
|
|
98403
|
+
return this.selectedItems.length > 0 ? this.selectedItems[0].value : null;
|
|
98404
|
+
}
|
|
98405
|
+
},
|
|
98406
|
+
// 主面板的值(单选时返回单个路径,多选时返回路径数组)
|
|
98407
|
+
mainPanelValue: {
|
|
98408
|
+
get() {
|
|
98409
|
+
if (this.isMultiple) {
|
|
98410
|
+
return this.selectedValues;
|
|
98411
|
+
} else {
|
|
98412
|
+
return this.selectedValues.length > 0 ? this.selectedValues[0] : [];
|
|
98413
|
+
}
|
|
98414
|
+
},
|
|
98415
|
+
set(value) {
|
|
98416
|
+
if (this.isMultiple) {
|
|
98417
|
+
this.selectedValues = value || [];
|
|
98418
|
+
} else {
|
|
98419
|
+
this.selectedValues = value ? [value] : [];
|
|
98420
|
+
}
|
|
98421
|
+
}
|
|
98422
|
+
},
|
|
98423
|
+
// 搜索面板的值(单选时返回单个路径,多选时返回路径数组)
|
|
98424
|
+
searchPanelValue: {
|
|
98425
|
+
get() {
|
|
98426
|
+
if (this.isMultiple) {
|
|
98427
|
+
return this.searchSelectedValues;
|
|
98428
|
+
} else {
|
|
98429
|
+
return this.searchSelectedValues.length > 0 ? this.searchSelectedValues[0] : [];
|
|
98430
|
+
}
|
|
98431
|
+
},
|
|
98432
|
+
set(value) {
|
|
98433
|
+
if (this.isMultiple) {
|
|
98434
|
+
this.searchSelectedValues = value || [];
|
|
98435
|
+
} else {
|
|
98436
|
+
this.searchSelectedValues = value ? [value] : [];
|
|
98437
|
+
}
|
|
98438
|
+
}
|
|
98439
|
+
}
|
|
98440
|
+
},
|
|
98441
|
+
watch: {
|
|
98442
|
+
options: {
|
|
98443
|
+
handler(newVal) {
|
|
98444
|
+
this.initOptions();
|
|
98445
|
+
},
|
|
98446
|
+
deep: true,
|
|
98447
|
+
immediate: true
|
|
98448
|
+
},
|
|
98449
|
+
value: {
|
|
98450
|
+
handler(newVal) {
|
|
98451
|
+
// 如果是内部更新触发的,跳过处理
|
|
98452
|
+
if (this.isInternalUpdate) {
|
|
98453
|
+
this.isInternalUpdate = false;
|
|
98454
|
+
return;
|
|
98455
|
+
}
|
|
98456
|
+
this.processValue();
|
|
98457
|
+
},
|
|
98458
|
+
deep: true,
|
|
98459
|
+
immediate: true
|
|
98460
|
+
},
|
|
98461
|
+
searchInput(val) {
|
|
98462
|
+
if (!val) {
|
|
98463
|
+
this.clearSearchState();
|
|
98464
|
+
return;
|
|
98465
|
+
}
|
|
98466
|
+
this.scheduleSearch();
|
|
98467
|
+
},
|
|
98468
|
+
selectedItems: {
|
|
98469
|
+
handler(newVal) {
|
|
98470
|
+
if (this.isMultiple) {
|
|
98471
|
+
const panel = this.$refs.cascaderPanel;
|
|
98472
|
+
if (this.useCompactSelection && !this.aggregationMode && panel && panel.selection && panel.selection.isCompactSelection()) {
|
|
98473
|
+
this.selectedCount = panel.selection.size();
|
|
98474
|
+
} else {
|
|
98475
|
+
this.selectedCount = newVal.length;
|
|
98476
|
+
}
|
|
98477
|
+
if (!this.useCompactSelection) {
|
|
98478
|
+
if (this.aggregationMode) {
|
|
98479
|
+
const config = {
|
|
98480
|
+
disabledField: this.disabledField,
|
|
98481
|
+
disabledValue: this.disabledValue,
|
|
98482
|
+
disabledCheck: this.disabledCheck
|
|
98483
|
+
};
|
|
98484
|
+
this.isAllSelected = CascaderUtilsPro.isAggregatedAllSelected(this.selectedValues, this.filteredOptions, config, this.cascaderProps);
|
|
98485
|
+
} else {
|
|
98486
|
+
this.isAllSelected = this.selectedCount === this.totalCount;
|
|
96397
98487
|
}
|
|
96398
|
-
}
|
|
96399
|
-
}
|
|
96400
|
-
|
|
96401
|
-
|
|
98488
|
+
}
|
|
98489
|
+
} else {
|
|
98490
|
+
if (newVal.length > 1) {
|
|
98491
|
+
this.selectedItems = [newVal[newVal.length - 1]];
|
|
98492
|
+
}
|
|
98493
|
+
this.selectedCount = this.selectedItems.length;
|
|
98494
|
+
}
|
|
98495
|
+
},
|
|
98496
|
+
deep: false
|
|
98497
|
+
}
|
|
98498
|
+
},
|
|
98499
|
+
mounted() {
|
|
98500
|
+
this.initOptions();
|
|
98501
|
+
// 确保在 mounted 后处理默认值
|
|
98502
|
+
this.$nextTick(() => {
|
|
98503
|
+
this.processValue();
|
|
98504
|
+
});
|
|
98505
|
+
// 组件挂载后强制调整样式
|
|
98506
|
+
this.forceVerticalCenter();
|
|
98507
|
+
},
|
|
98508
|
+
beforeDestroy() {
|
|
98509
|
+
if (this.searchDebounceTimer) {
|
|
98510
|
+
clearTimeout(this.searchDebounceTimer);
|
|
98511
|
+
this.searchDebounceTimer = null;
|
|
98512
|
+
}
|
|
98513
|
+
this.clearPanelSyncTimer();
|
|
98514
|
+
},
|
|
98515
|
+
methods: {
|
|
98516
|
+
onMainPanelInput(value) {
|
|
98517
|
+
if (this.useCompactSelection && Array.isArray(value) && value.length >= 300) {
|
|
98518
|
+
return;
|
|
98519
|
+
}
|
|
98520
|
+
if (this.isMultiple) {
|
|
98521
|
+
this.selectedValues = Array.isArray(value) ? value : [];
|
|
98522
|
+
} else {
|
|
98523
|
+
this.selectedValues = value && value.length ? [value] : [];
|
|
96402
98524
|
}
|
|
96403
|
-
CascaderUtils.setDisabledItems(processedOptions, this.disabledConfig, this.cascaderProps);
|
|
96404
|
-
return processedOptions;
|
|
96405
98525
|
},
|
|
96406
|
-
|
|
96407
|
-
|
|
96408
|
-
|
|
96409
|
-
|
|
96410
|
-
|
|
96411
|
-
|
|
96412
|
-
|
|
96413
|
-
|
|
98526
|
+
applyPanelSelectionChange() {
|
|
98527
|
+
const panel = this.$refs.cascaderPanel;
|
|
98528
|
+
if (!panel || !panel.store || !panel.selection) {
|
|
98529
|
+
return;
|
|
98530
|
+
}
|
|
98531
|
+
const {
|
|
98532
|
+
store,
|
|
98533
|
+
selection
|
|
98534
|
+
} = panel;
|
|
98535
|
+
if (this.aggregationMode) {
|
|
98536
|
+
const items = CascaderUtilsPro.getAggregatedItemsFromSelection(store, selection, this.filteredOptions, this.cascaderProps);
|
|
98537
|
+
this.selectedItems = items;
|
|
98538
|
+
this.selectedCount = items.length;
|
|
98539
|
+
this.isAllSelected = selection.size() === store.totalLeafCount && store.totalLeafCount > 0;
|
|
98540
|
+
if (!selection.isCompactSelection()) {
|
|
98541
|
+
this.selectedValues = selection.getCheckedPaths();
|
|
98542
|
+
}
|
|
98543
|
+
this.isInternalUpdate = true;
|
|
98544
|
+
let emitValue = CascaderUtilsPro.getAggregatedEmitValues(items, this.parentNodePrefix);
|
|
98545
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
98546
|
+
emitValue = emitValue[0];
|
|
98547
|
+
}
|
|
98548
|
+
this.$emit('input', emitValue);
|
|
98549
|
+
this.$emit('change', this.getSelectedData());
|
|
98550
|
+
panel.bumpSelectionView();
|
|
98551
|
+
return;
|
|
98552
|
+
}
|
|
98553
|
+
if (selection.isCompactSelection()) {
|
|
98554
|
+
this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
|
|
98555
|
+
this.selectedCount = this.aggregationMode ? this.selectedItems.length : selection.size();
|
|
98556
|
+
this.isAllSelected = selection.size() === store.totalLeafCount;
|
|
98557
|
+
this.isInternalUpdate = true;
|
|
98558
|
+
this.$emit('input', this.currentValue);
|
|
98559
|
+
this.$emit('change', this.getSelectedData());
|
|
98560
|
+
panel.bumpSelectionView();
|
|
98561
|
+
return;
|
|
98562
|
+
}
|
|
98563
|
+
this.selectedValues = selection.getCheckedPaths();
|
|
98564
|
+
this.updateSelectedItems();
|
|
98565
|
+
panel.bumpSelectionView();
|
|
98566
|
+
this.$nextTick(() => {
|
|
98567
|
+
this.isInternalUpdate = true;
|
|
98568
|
+
let emitValue = this.currentValue;
|
|
98569
|
+
if (this.aggregationMode) {
|
|
98570
|
+
emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
98571
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
98572
|
+
emitValue = emitValue[0];
|
|
98573
|
+
}
|
|
96414
98574
|
}
|
|
96415
|
-
|
|
98575
|
+
this.$emit('input', emitValue);
|
|
98576
|
+
this.$emit('change', this.getSelectedData());
|
|
96416
98577
|
});
|
|
96417
98578
|
},
|
|
96418
|
-
|
|
96419
|
-
|
|
98579
|
+
buildSelectedItemsFromValuesLazy(panel) {
|
|
98580
|
+
if (!panel || !panel.selection) {
|
|
98581
|
+
return [];
|
|
98582
|
+
}
|
|
98583
|
+
if (!panel.selection.isCompactSelection()) {
|
|
98584
|
+
return this.buildSelectedItemsFromValues();
|
|
98585
|
+
}
|
|
98586
|
+
return CascaderUtilsPro.buildSelectedItemsFromSelection(panel.store, panel.selection, this.filteredOptions, this.cascaderProps);
|
|
98587
|
+
},
|
|
98588
|
+
syncPanelFromExternalValue() {
|
|
98589
|
+
const panel = this.$refs.cascaderPanel;
|
|
98590
|
+
if (!panel || !panel.selection || !panel.store) {
|
|
98591
|
+
return false;
|
|
98592
|
+
}
|
|
98593
|
+
if (!this.hasExternalValue()) {
|
|
98594
|
+
panel.clearCheckedNodes();
|
|
98595
|
+
this.selectedItems = [];
|
|
98596
|
+
this.selectedValues = [];
|
|
98597
|
+
return true;
|
|
98598
|
+
}
|
|
98599
|
+
panel.selection.clear();
|
|
98600
|
+
this.applyExternalValueToPanelSelection(panel);
|
|
98601
|
+
panel.selection._reconcileAllRoots();
|
|
98602
|
+
panel.bumpSelectionView();
|
|
98603
|
+
this.applyPanelSelectionChange();
|
|
98604
|
+
this.expandPanelToExternalValue(panel);
|
|
98605
|
+
return true;
|
|
98606
|
+
},
|
|
98607
|
+
hasExternalValue() {
|
|
98608
|
+
const val = this.value;
|
|
98609
|
+
if (val == null || val === '') {
|
|
98610
|
+
return false;
|
|
98611
|
+
}
|
|
98612
|
+
if (Array.isArray(val)) {
|
|
98613
|
+
return val.length > 0;
|
|
98614
|
+
}
|
|
98615
|
+
return true;
|
|
98616
|
+
},
|
|
98617
|
+
applyExternalValueToPanelSelection(panel) {
|
|
98618
|
+
const {
|
|
98619
|
+
store,
|
|
98620
|
+
selection
|
|
98621
|
+
} = panel;
|
|
98622
|
+
const paths = this.resolveExternalValueToPaths();
|
|
98623
|
+
paths.forEach(path => {
|
|
98624
|
+
const leafValue = path[path.length - 1];
|
|
98625
|
+
if (store.pathByLeafValue.has(leafValue)) {
|
|
98626
|
+
selection.selectedLeafSet.add(leafValue);
|
|
98627
|
+
}
|
|
98628
|
+
});
|
|
98629
|
+
|
|
98630
|
+
// 直接按外部 value 再补一遍,避免 paths 解析遗漏(聚合父节点、异步 options 等)
|
|
98631
|
+
this.getExternalValueList().forEach(val => {
|
|
98632
|
+
if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(val, this.parentNodePrefix)) {
|
|
98633
|
+
const actualValue = CascaderUtilsPro.extractParentNodeValue(val, this.parentNodePrefix);
|
|
98634
|
+
const node = store.nodeByValue.get(actualValue);
|
|
98635
|
+
if (node && !node.isLeaf && !node.disabled) {
|
|
98636
|
+
node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
|
|
98637
|
+
}
|
|
98638
|
+
return;
|
|
98639
|
+
}
|
|
98640
|
+
if (store.pathByLeafValue.has(val)) {
|
|
98641
|
+
selection.selectedLeafSet.add(val);
|
|
98642
|
+
return;
|
|
98643
|
+
}
|
|
98644
|
+
const node = store.nodeByValue.get(val);
|
|
98645
|
+
if (node && node.isLeaf && !node.disabled) {
|
|
98646
|
+
selection.selectedLeafSet.add(val);
|
|
98647
|
+
} else if (node && !node.isLeaf && !node.disabled) {
|
|
98648
|
+
node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
|
|
98649
|
+
}
|
|
98650
|
+
});
|
|
98651
|
+
},
|
|
98652
|
+
getExternalValueList() {
|
|
98653
|
+
const val = this.value;
|
|
98654
|
+
if (val == null || val === '') {
|
|
98655
|
+
return [];
|
|
98656
|
+
}
|
|
98657
|
+
if (Array.isArray(val)) {
|
|
98658
|
+
if (val.length === 0) {
|
|
98659
|
+
return [];
|
|
98660
|
+
}
|
|
98661
|
+
if (Array.isArray(val[0])) {
|
|
98662
|
+
return val.map(path => path[path.length - 1]);
|
|
98663
|
+
}
|
|
98664
|
+
return val;
|
|
98665
|
+
}
|
|
98666
|
+
return [val];
|
|
98667
|
+
},
|
|
98668
|
+
clearPanelSyncTimer() {
|
|
98669
|
+
if (this.panelSyncTimer) {
|
|
98670
|
+
clearTimeout(this.panelSyncTimer);
|
|
98671
|
+
this.panelSyncTimer = null;
|
|
98672
|
+
}
|
|
98673
|
+
},
|
|
98674
|
+
schedulePanelSyncFromExternalValue(retry = 0) {
|
|
98675
|
+
this.clearPanelSyncTimer();
|
|
98676
|
+
this.$nextTick(() => {
|
|
98677
|
+
if (!this.hasExternalValue()) {
|
|
98678
|
+
const panel = this.$refs.cascaderPanel;
|
|
98679
|
+
if (panel && panel.selection) {
|
|
98680
|
+
panel.clearCheckedNodes();
|
|
98681
|
+
}
|
|
98682
|
+
this.selectedItems = [];
|
|
98683
|
+
this.selectedValues = [];
|
|
98684
|
+
return;
|
|
98685
|
+
}
|
|
98686
|
+
const synced = this.syncPanelFromExternalValue();
|
|
98687
|
+
if (!synced && retry < 20) {
|
|
98688
|
+
this.panelSyncTimer = setTimeout(() => {
|
|
98689
|
+
this.schedulePanelSyncFromExternalValue(retry + 1);
|
|
98690
|
+
}, 50);
|
|
98691
|
+
}
|
|
98692
|
+
});
|
|
98693
|
+
},
|
|
98694
|
+
resolveExternalValueToPaths() {
|
|
98695
|
+
const val = this.value;
|
|
98696
|
+
if (val == null || val === '') {
|
|
98697
|
+
return [];
|
|
98698
|
+
}
|
|
98699
|
+
if (Array.isArray(val) && val.length > 0 && Array.isArray(val[0])) {
|
|
98700
|
+
return [...val];
|
|
98701
|
+
}
|
|
98702
|
+
const values = Array.isArray(val) ? val : [val];
|
|
98703
|
+
if (typeof values[0] === 'string' || typeof values[0] === 'number') {
|
|
98704
|
+
if (this.aggregationMode) {
|
|
98705
|
+
return CascaderUtilsPro.processValuesWithParentNodes(values, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
98706
|
+
}
|
|
98707
|
+
return this.findPathsByValues(values);
|
|
98708
|
+
}
|
|
98709
|
+
return Array.isArray(val) ? [...val] : [];
|
|
98710
|
+
},
|
|
98711
|
+
expandPanelToExternalValue(panel) {
|
|
98712
|
+
if (!panel || !panel.store || !this.hasExternalValue()) {
|
|
98713
|
+
return;
|
|
98714
|
+
}
|
|
98715
|
+
const values = this.getExternalValueList();
|
|
98716
|
+
const firstValue = values[0];
|
|
98717
|
+
let pathValues = [];
|
|
98718
|
+
if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(firstValue, this.parentNodePrefix)) {
|
|
98719
|
+
const actualValue = CascaderUtilsPro.extractParentNodeValue(firstValue, this.parentNodePrefix);
|
|
98720
|
+
const node = panel.store.nodeByValue.get(actualValue);
|
|
98721
|
+
pathValues = node ? [...node.path] : [];
|
|
98722
|
+
} else if (panel.store.pathByLeafValue.has(firstValue)) {
|
|
98723
|
+
const path = panel.store.pathByLeafValue.get(firstValue);
|
|
98724
|
+
pathValues = path ? path.slice(0, -1) : [];
|
|
98725
|
+
} else {
|
|
98726
|
+
const node = panel.store.nodeByValue.get(firstValue);
|
|
98727
|
+
if (node) {
|
|
98728
|
+
pathValues = node.isLeaf ? node.path.slice(0, -1) : [...node.path];
|
|
98729
|
+
}
|
|
98730
|
+
}
|
|
98731
|
+
if (pathValues.length > 0) {
|
|
98732
|
+
this.$nextTick(() => {
|
|
98733
|
+
panel.expandPathValues(pathValues, true);
|
|
98734
|
+
});
|
|
98735
|
+
}
|
|
96420
98736
|
},
|
|
98737
|
+
onSearchPanelInput(value) {
|
|
98738
|
+
if (this.useCompactSelection && Array.isArray(value) && value.length >= 300) {
|
|
98739
|
+
return;
|
|
98740
|
+
}
|
|
98741
|
+
if (this.isMultiple) {
|
|
98742
|
+
this.searchSelectedValues = Array.isArray(value) ? value : [];
|
|
98743
|
+
} else {
|
|
98744
|
+
this.searchSelectedValues = value && value.length ? [value] : [];
|
|
98745
|
+
}
|
|
98746
|
+
},
|
|
98747
|
+
// 处理 value 值
|
|
96421
98748
|
processValue() {
|
|
96422
|
-
if (!this.
|
|
98749
|
+
if (!this.hasExternalValue()) {
|
|
98750
|
+
this.selectedValues = [];
|
|
98751
|
+
this.selectedItems = [];
|
|
98752
|
+
this.schedulePanelSyncFromExternalValue();
|
|
98753
|
+
return;
|
|
98754
|
+
}
|
|
98755
|
+
if (this.useCompactSelection && this.isMultiple) {
|
|
98756
|
+
this.selectedValues = [];
|
|
98757
|
+
this.schedulePanelSyncFromExternalValue();
|
|
98758
|
+
return;
|
|
98759
|
+
}
|
|
96423
98760
|
if (this.isMultiple) {
|
|
98761
|
+
// 多选模式:支持直接传入value值或路径数组
|
|
96424
98762
|
if (Array.isArray(this.value) && this.value.length > 0) {
|
|
96425
98763
|
if (typeof this.value[0] === 'string' || typeof this.value[0] === 'number') {
|
|
98764
|
+
// 传入的是value值数组,需要转换为路径
|
|
96426
98765
|
if (this.aggregationMode) {
|
|
96427
|
-
|
|
98766
|
+
// 聚合模式下,支持非叶子节点标识
|
|
98767
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes(this.value, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
98768
|
+
} else {
|
|
98769
|
+
// 普通模式下,只处理叶子节点
|
|
98770
|
+
this.selectedValues = this.findPathsByValues(this.value);
|
|
98771
|
+
}
|
|
98772
|
+
} else {
|
|
98773
|
+
// 传入的是路径数组
|
|
98774
|
+
this.selectedValues = [...this.value];
|
|
98775
|
+
}
|
|
98776
|
+
} else {
|
|
98777
|
+
this.selectedValues = [];
|
|
98778
|
+
}
|
|
98779
|
+
} else {
|
|
98780
|
+
// 单选模式:支持单个值或路径数组
|
|
98781
|
+
if (this.value !== null && this.value !== undefined && this.value !== '') {
|
|
98782
|
+
if (Array.isArray(this.value)) {
|
|
98783
|
+
// 传入的是路径数组
|
|
98784
|
+
this.selectedValues = [...this.value];
|
|
98785
|
+
} else {
|
|
98786
|
+
// 传入的是单个值,需要转换为路径
|
|
98787
|
+
if (this.aggregationMode) {
|
|
98788
|
+
// 聚合模式下,支持非叶子节点标识
|
|
98789
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes([this.value], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
96428
98790
|
} else {
|
|
96429
|
-
|
|
98791
|
+
// 普通模式下,只处理叶子节点
|
|
98792
|
+
this.selectedValues = this.findPathsByValues([this.value]);
|
|
96430
98793
|
}
|
|
98794
|
+
}
|
|
98795
|
+
} else {
|
|
98796
|
+
this.selectedValues = [];
|
|
98797
|
+
}
|
|
98798
|
+
}
|
|
98799
|
+
this.schedulePanelSyncFromExternalValue();
|
|
98800
|
+
},
|
|
98801
|
+
// 初始化选项数据
|
|
98802
|
+
initOptions() {
|
|
98803
|
+
this.filteredOptions = this.processOptions(this.options);
|
|
98804
|
+
this.countTotalItems();
|
|
98805
|
+
if (this.hasExternalValue()) {
|
|
98806
|
+
this.schedulePanelSyncFromExternalValue();
|
|
98807
|
+
} else {
|
|
98808
|
+
this.updateSelectedItems();
|
|
98809
|
+
}
|
|
98810
|
+
},
|
|
98811
|
+
// 处理选项数据,添加禁用状态(浅拷贝,避免 JSON 深拷贝大数据卡顿)
|
|
98812
|
+
processOptions(options) {
|
|
98813
|
+
const childrenKey = this.cascaderProps && this.cascaderProps.children || 'children';
|
|
98814
|
+
const disabledKey = this.cascaderProps && this.cascaderProps.disabled || 'disabled';
|
|
98815
|
+
const config = this.disabledConfig;
|
|
98816
|
+
const cloneItems = (items, ancestorDisabled = false) => {
|
|
98817
|
+
return items.map(item => {
|
|
98818
|
+
const isDisabled = ancestorDisabled || CascaderUtilsPro.isItemDisabled(item, config);
|
|
98819
|
+
const children = item[childrenKey];
|
|
98820
|
+
const cloned = {
|
|
98821
|
+
...item
|
|
98822
|
+
};
|
|
98823
|
+
if (this.isViewMode || isDisabled) {
|
|
98824
|
+
cloned[disabledKey] = true;
|
|
98825
|
+
}
|
|
98826
|
+
if (children && children.length > 0) {
|
|
98827
|
+
cloned[childrenKey] = cloneItems(children, isDisabled || this.isViewMode);
|
|
98828
|
+
}
|
|
98829
|
+
return cloned;
|
|
98830
|
+
});
|
|
98831
|
+
};
|
|
98832
|
+
return cloneItems(options || []);
|
|
98833
|
+
},
|
|
98834
|
+
// 判断项目是否禁用
|
|
98835
|
+
isItemDisabled(item) {
|
|
98836
|
+
const config = {
|
|
98837
|
+
disabledField: this.disabledField,
|
|
98838
|
+
disabledValue: this.disabledValue,
|
|
98839
|
+
disabledCheck: this.disabledCheck
|
|
98840
|
+
};
|
|
98841
|
+
return CascaderUtilsPro.isItemDisabled(item, config);
|
|
98842
|
+
},
|
|
98843
|
+
// 统计总项目数
|
|
98844
|
+
countTotalItems() {
|
|
98845
|
+
const config = {
|
|
98846
|
+
disabledField: this.disabledField,
|
|
98847
|
+
disabledValue: this.disabledValue,
|
|
98848
|
+
disabledCheck: this.disabledCheck
|
|
98849
|
+
};
|
|
98850
|
+
this.totalCount = CascaderUtilsPro.countTotalItems(this.filteredOptions, config, this.cascaderProps);
|
|
98851
|
+
},
|
|
98852
|
+
// 更新已选项列表
|
|
98853
|
+
updateSelectedItems() {
|
|
98854
|
+
this.$nextTick(() => {
|
|
98855
|
+
const panel = this.$refs.cascaderPanel;
|
|
98856
|
+
if (this.aggregationMode) {
|
|
98857
|
+
if (panel && panel.store && panel.selection) {
|
|
98858
|
+
this.selectedItems = CascaderUtilsPro.getAggregatedItemsFromSelection(panel.store, panel.selection, this.filteredOptions, this.cascaderProps);
|
|
96431
98859
|
} else {
|
|
96432
|
-
this.
|
|
98860
|
+
this.selectedItems = CascaderUtilsPro.getAggregatedSelectedItems(this.selectedValues, this.filteredOptions, this.cascaderProps);
|
|
96433
98861
|
}
|
|
96434
98862
|
} else {
|
|
96435
|
-
this.
|
|
96436
|
-
}
|
|
96437
|
-
} else if (this.value !== null && this.value !== undefined && this.value !== '') {
|
|
96438
|
-
if (Array.isArray(this.value)) {
|
|
96439
|
-
this.selectedValues = [...this.value];
|
|
96440
|
-
} else if (this.aggregationMode) {
|
|
96441
|
-
this.selectedValues = CascaderUtils.processValuesWithParentNodes([this.value], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
96442
|
-
} else {
|
|
96443
|
-
this.selectedValues = CascaderUtils.findPathsByValues([this.value], this.filteredOptions, this.cascaderProps);
|
|
98863
|
+
this.selectedItems = this.buildSelectedItemsFromValues();
|
|
96444
98864
|
}
|
|
96445
|
-
}
|
|
96446
|
-
this.selectedValues = [];
|
|
96447
|
-
}
|
|
96448
|
-
this.updateSelectedItems();
|
|
96449
|
-
this.syncTreeCheckedState();
|
|
98865
|
+
});
|
|
96450
98866
|
},
|
|
96451
|
-
|
|
96452
|
-
|
|
96453
|
-
|
|
96454
|
-
|
|
96455
|
-
|
|
98867
|
+
// 基于 selectedValues 构建已选项列表
|
|
98868
|
+
buildSelectedItemsFromValues() {
|
|
98869
|
+
return CascaderUtilsPro.buildSelectedItemsFromValues(this.selectedValues, this.filteredOptions, this.cascaderProps);
|
|
98870
|
+
},
|
|
98871
|
+
// 搜索处理(防抖,避免每次按键遍历整棵树)
|
|
98872
|
+
scheduleSearch() {
|
|
98873
|
+
if (this.searchDebounceTimer) {
|
|
98874
|
+
clearTimeout(this.searchDebounceTimer);
|
|
96456
98875
|
}
|
|
96457
|
-
this.
|
|
96458
|
-
|
|
98876
|
+
this.searchDebounceTimer = setTimeout(() => {
|
|
98877
|
+
this.searchDebounceTimer = null;
|
|
98878
|
+
this.runSearch();
|
|
98879
|
+
}, 100);
|
|
96459
98880
|
},
|
|
96460
|
-
|
|
96461
|
-
if (
|
|
96462
|
-
|
|
96463
|
-
this.
|
|
96464
|
-
} else {
|
|
96465
|
-
this.isAllSelected = this.selectedCount === this.totalCount && this.totalCount > 0;
|
|
98881
|
+
clearSearchState() {
|
|
98882
|
+
if (this.searchDebounceTimer) {
|
|
98883
|
+
clearTimeout(this.searchDebounceTimer);
|
|
98884
|
+
this.searchDebounceTimer = null;
|
|
96466
98885
|
}
|
|
98886
|
+
this.isShowSearch = false;
|
|
98887
|
+
this.searchOptions = [];
|
|
98888
|
+
this.searchLeafSetCache = null;
|
|
98889
|
+
this.searchSelectedValues = [];
|
|
96467
98890
|
},
|
|
96468
|
-
|
|
96469
|
-
const
|
|
96470
|
-
|
|
96471
|
-
|
|
96472
|
-
|
|
96473
|
-
if (tree && treeNode && typeof treeNode.level !== 'number') {
|
|
96474
|
-
treeNode = tree.getNode(treeNode);
|
|
98891
|
+
runSearch() {
|
|
98892
|
+
const keyword = this.searchInput.trim();
|
|
98893
|
+
if (!keyword) {
|
|
98894
|
+
this.clearSearchState();
|
|
98895
|
+
return;
|
|
96475
98896
|
}
|
|
96476
|
-
const
|
|
96477
|
-
|
|
96478
|
-
|
|
96479
|
-
|
|
96480
|
-
|
|
98897
|
+
const panel = this.$refs.cascaderPanel;
|
|
98898
|
+
if (panel && panel.store) {
|
|
98899
|
+
this.searchOptions = CascaderUtilsPro.searchFromStore(panel.store, keyword, this.cascaderProps);
|
|
98900
|
+
} else {
|
|
98901
|
+
this.searchOptions = CascaderUtilsPro.searchInTree(this.filteredOptions, keyword, this.cascaderProps);
|
|
96481
98902
|
}
|
|
96482
|
-
|
|
96483
|
-
|
|
96484
|
-
|
|
98903
|
+
this.searchLeafSetCache = new Set(CascaderUtilsPro.getLeafValues(this.searchOptions, this.cascaderProps));
|
|
98904
|
+
this.searchSelectedValues = this.getSearchSelectedPathsFromMain(this.searchLeafSetCache);
|
|
98905
|
+
this.isShowSearch = true;
|
|
96485
98906
|
this.$nextTick(() => {
|
|
96486
|
-
|
|
96487
|
-
|
|
96488
|
-
|
|
96489
|
-
if (this.isMultiple) {
|
|
96490
|
-
const leafKeys = this.selectedValues.map(path => path[path.length - 1]);
|
|
96491
|
-
tree.setCheckedKeys(leafKeys);
|
|
96492
|
-
} else if (this.selectedValues.length > 0) {
|
|
96493
|
-
const leafKey = this.selectedValues[0][this.selectedValues[0].length - 1];
|
|
96494
|
-
tree.setCurrentKey(leafKey);
|
|
96495
|
-
} else {
|
|
96496
|
-
tree.setCurrentKey(null);
|
|
98907
|
+
if (this.searchOptions.length > 0) {
|
|
98908
|
+
this.syncSearchPanelSelection();
|
|
98909
|
+
this.handleSearchExpand();
|
|
96497
98910
|
}
|
|
96498
|
-
this.$nextTick(() => {
|
|
96499
|
-
this.isSyncingTree = false;
|
|
96500
|
-
});
|
|
96501
98911
|
});
|
|
96502
98912
|
},
|
|
96503
|
-
|
|
96504
|
-
|
|
96505
|
-
|
|
96506
|
-
|
|
96507
|
-
|
|
96508
|
-
|
|
96509
|
-
|
|
96510
|
-
|
|
96511
|
-
|
|
96512
|
-
|
|
96513
|
-
|
|
96514
|
-
|
|
96515
|
-
|
|
96516
|
-
|
|
96517
|
-
this.selectedValues
|
|
96518
|
-
this.updateSelectedItems();
|
|
96519
|
-
this.emitInput();
|
|
98913
|
+
getSearchSelectedPathsFromMain(searchLeafSet) {
|
|
98914
|
+
const panel = this.$refs.cascaderPanel;
|
|
98915
|
+
if (panel && panel.selection && panel.store) {
|
|
98916
|
+
const paths = [];
|
|
98917
|
+
panel.selection.selectedLeafSet.forEach(leaf => {
|
|
98918
|
+
if (searchLeafSet.has(leaf)) {
|
|
98919
|
+
const path = panel.store.pathByLeafValue.get(leaf);
|
|
98920
|
+
if (path) {
|
|
98921
|
+
paths.push(path);
|
|
98922
|
+
}
|
|
98923
|
+
}
|
|
98924
|
+
});
|
|
98925
|
+
return paths;
|
|
98926
|
+
}
|
|
98927
|
+
return CascaderUtilsPro.getSearchSelectedValues(this.selectedValues, this.searchOptions, this.cascaderProps);
|
|
96520
98928
|
},
|
|
96521
|
-
|
|
96522
|
-
if (this.
|
|
96523
|
-
|
|
98929
|
+
getSearchLeafSet() {
|
|
98930
|
+
if (this.searchLeafSetCache) {
|
|
98931
|
+
return this.searchLeafSetCache;
|
|
96524
98932
|
}
|
|
96525
|
-
|
|
96526
|
-
const keyword = this.searchInput.trim();
|
|
96527
|
-
if (!keyword) {
|
|
96528
|
-
this.displayOptions = this.filteredOptions;
|
|
96529
|
-
this.$nextTick(() => this.syncTreeCheckedState());
|
|
96530
|
-
return;
|
|
96531
|
-
}
|
|
96532
|
-
this.displayOptions = CascaderUtils.searchInTree(this.filteredOptions, keyword, this.cascaderProps);
|
|
96533
|
-
this.$nextTick(() => {
|
|
96534
|
-
this.syncTreeCheckedState();
|
|
96535
|
-
this.expandAllNodes();
|
|
96536
|
-
});
|
|
96537
|
-
}, 300);
|
|
98933
|
+
return new Set(CascaderUtilsPro.getLeafValues(this.searchOptions, this.cascaderProps));
|
|
96538
98934
|
},
|
|
96539
|
-
|
|
96540
|
-
const
|
|
96541
|
-
|
|
96542
|
-
|
|
96543
|
-
|
|
96544
|
-
|
|
96545
|
-
|
|
98935
|
+
syncSearchPanelSelection() {
|
|
98936
|
+
const searchPanel = this.$refs.searchCascaderPanel;
|
|
98937
|
+
const mainPanel = this.$refs.cascaderPanel;
|
|
98938
|
+
if (!searchPanel || !mainPanel || !searchPanel.selection || !mainPanel.selection) {
|
|
98939
|
+
return;
|
|
98940
|
+
}
|
|
98941
|
+
const searchLeafSet = this.getSearchLeafSet();
|
|
98942
|
+
searchPanel.selection.clear();
|
|
98943
|
+
mainPanel.selection.selectedLeafSet.forEach(leaf => {
|
|
98944
|
+
if (searchLeafSet.has(leaf)) {
|
|
98945
|
+
searchPanel.selection.selectedLeafSet.add(leaf);
|
|
96546
98946
|
}
|
|
96547
|
-
};
|
|
96548
|
-
|
|
98947
|
+
});
|
|
98948
|
+
searchPanel.selection._reconcileAllRoots();
|
|
98949
|
+
searchPanel.bumpSelectionView();
|
|
96549
98950
|
},
|
|
96550
|
-
|
|
96551
|
-
|
|
98951
|
+
// 搜索模式下的展开处理
|
|
98952
|
+
handleSearchExpand() {
|
|
98953
|
+
if (this.$refs.searchCascaderPanel && this.searchOptions.length > 0) {
|
|
98954
|
+
const firstOption = this.searchOptions[0];
|
|
98955
|
+
const valueKey = this.cascaderProps.value || 'value';
|
|
98956
|
+
this.$refs.searchCascaderPanel.expandPathValues([firstOption[valueKey]], true);
|
|
98957
|
+
}
|
|
96552
98958
|
},
|
|
96553
|
-
|
|
96554
|
-
|
|
96555
|
-
|
|
96556
|
-
|
|
96557
|
-
|
|
96558
|
-
|
|
98959
|
+
// 值变化处理
|
|
98960
|
+
handleValueChange() {
|
|
98961
|
+
this.applyPanelSelectionChange();
|
|
98962
|
+
},
|
|
98963
|
+
// 搜索模式值变化处理
|
|
98964
|
+
handleSearchValueChange() {
|
|
98965
|
+
const searchPanel = this.$refs.searchCascaderPanel;
|
|
98966
|
+
const mainPanel = this.$refs.cascaderPanel;
|
|
98967
|
+
if (!searchPanel || !mainPanel || !searchPanel.selection || !mainPanel.selection) {
|
|
98968
|
+
return;
|
|
96559
98969
|
}
|
|
96560
|
-
this.
|
|
96561
|
-
|
|
96562
|
-
|
|
98970
|
+
const searchLeafSet = this.getSearchLeafSet();
|
|
98971
|
+
searchLeafSet.forEach(leaf => {
|
|
98972
|
+
const shouldSelect = searchPanel.selection.selectedLeafSet.has(leaf);
|
|
98973
|
+
const isSelected = mainPanel.selection.selectedLeafSet.has(leaf);
|
|
98974
|
+
if (shouldSelect && !isSelected) {
|
|
98975
|
+
mainPanel.selection.selectedLeafSet.add(leaf);
|
|
98976
|
+
} else if (!shouldSelect && isSelected) {
|
|
98977
|
+
mainPanel.selection.selectedLeafSet.delete(leaf);
|
|
98978
|
+
}
|
|
98979
|
+
});
|
|
98980
|
+
mainPanel.selection._reconcileAllRoots();
|
|
98981
|
+
mainPanel.bumpSelectionView();
|
|
98982
|
+
this.applyPanelSelectionChange();
|
|
96563
98983
|
},
|
|
96564
|
-
|
|
96565
|
-
|
|
96566
|
-
|
|
96567
|
-
|
|
96568
|
-
|
|
96569
|
-
|
|
96570
|
-
|
|
96571
|
-
|
|
98984
|
+
// 移除已选项
|
|
98985
|
+
removeItem(item, index) {
|
|
98986
|
+
const panel = this.$refs.cascaderPanel;
|
|
98987
|
+
if (panel && panel.selection) {
|
|
98988
|
+
if (item.isAggregated) {
|
|
98989
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
98990
|
+
if (node) {
|
|
98991
|
+
panel.selection.toggleNode(node.id, false);
|
|
98992
|
+
}
|
|
98993
|
+
} else if (item.path && item.path.length > 0) {
|
|
98994
|
+
const leafValue = item.path[item.path.length - 1];
|
|
98995
|
+
const leafNode = panel.store.nodeByValue.get(leafValue);
|
|
98996
|
+
if (leafNode) {
|
|
98997
|
+
panel.selection.toggleNode(leafNode.id, false);
|
|
98998
|
+
} else {
|
|
98999
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
99000
|
+
if (node) {
|
|
99001
|
+
panel.selection.toggleNode(node.id, false);
|
|
99002
|
+
}
|
|
99003
|
+
}
|
|
99004
|
+
} else {
|
|
99005
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
99006
|
+
if (node) {
|
|
99007
|
+
panel.selection.toggleNode(node.id, false);
|
|
99008
|
+
}
|
|
99009
|
+
}
|
|
99010
|
+
this.applyPanelSelectionChange();
|
|
99011
|
+
if (this.isShowSearch) {
|
|
99012
|
+
this.syncSearchPanelSelection();
|
|
96572
99013
|
}
|
|
99014
|
+
return;
|
|
96573
99015
|
}
|
|
96574
|
-
|
|
96575
|
-
this.
|
|
96576
|
-
|
|
96577
|
-
|
|
96578
|
-
this.
|
|
96579
|
-
|
|
96580
|
-
|
|
96581
|
-
this.
|
|
96582
|
-
},
|
|
96583
|
-
emitInput() {
|
|
99016
|
+
const valueToRemove = item.value;
|
|
99017
|
+
this.selectedValues = this.selectedValues.filter(path => {
|
|
99018
|
+
return !path.includes(valueToRemove);
|
|
99019
|
+
});
|
|
99020
|
+
this.searchSelectedValues = this.searchSelectedValues.filter(path => {
|
|
99021
|
+
return !path.includes(valueToRemove);
|
|
99022
|
+
});
|
|
99023
|
+
this.selectedItems.splice(index, 1);
|
|
96584
99024
|
this.$nextTick(() => {
|
|
96585
99025
|
this.isInternalUpdate = true;
|
|
96586
99026
|
let emitValue = this.currentValue;
|
|
96587
99027
|
if (this.aggregationMode) {
|
|
96588
|
-
emitValue =
|
|
99028
|
+
emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
96589
99029
|
if (!this.isMultiple && emitValue.length > 0) {
|
|
96590
99030
|
emitValue = emitValue[0];
|
|
96591
99031
|
}
|
|
@@ -96593,12 +99033,43 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96593
99033
|
this.$emit('input', emitValue);
|
|
96594
99034
|
});
|
|
96595
99035
|
},
|
|
99036
|
+
// 全选/取消全选
|
|
99037
|
+
handleSelectAll() {
|
|
99038
|
+
if (!this.isMultiple) {
|
|
99039
|
+
// 单选模式下不支持全选
|
|
99040
|
+
return;
|
|
99041
|
+
}
|
|
99042
|
+
if (this.isAllSelected) {
|
|
99043
|
+
const panel = this.$refs.cascaderPanel;
|
|
99044
|
+
if (panel) {
|
|
99045
|
+
panel.clearCheckedNodes();
|
|
99046
|
+
} else {
|
|
99047
|
+
this.selectedValues = [];
|
|
99048
|
+
this.selectedItems = [];
|
|
99049
|
+
this.searchSelectedValues = [];
|
|
99050
|
+
this.applyPanelSelectionChange();
|
|
99051
|
+
}
|
|
99052
|
+
} else {
|
|
99053
|
+
const panel = this.$refs.cascaderPanel;
|
|
99054
|
+
if (panel) {
|
|
99055
|
+
panel.selectAllLeaves();
|
|
99056
|
+
} else {
|
|
99057
|
+
this.selectedValues = CascaderUtilsPro.getAllLeafPaths(this.filteredOptions, this.disabledConfig, this.cascaderProps);
|
|
99058
|
+
this.updateSelectedItems();
|
|
99059
|
+
this.applyPanelSelectionChange();
|
|
99060
|
+
}
|
|
99061
|
+
}
|
|
99062
|
+
},
|
|
99063
|
+
// 获取选中的数据
|
|
96596
99064
|
getSelectedData() {
|
|
96597
99065
|
let values = this.currentValue;
|
|
96598
99066
|
let valuesPath = this.selectedValues;
|
|
99067
|
+
if (!this.aggregationMode && this.selectedItems.length > 0 && valuesPath.length === 0) {
|
|
99068
|
+
valuesPath = this.selectedItems.map(item => item.path);
|
|
99069
|
+
}
|
|
96599
99070
|
if (this.aggregationMode) {
|
|
96600
|
-
values =
|
|
96601
|
-
valuesPath =
|
|
99071
|
+
values = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
99072
|
+
valuesPath = this.selectedItems.map(item => item.path);
|
|
96602
99073
|
if (!this.isMultiple && values.length > 0) {
|
|
96603
99074
|
values = values[0];
|
|
96604
99075
|
}
|
|
@@ -96610,102 +99081,208 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96610
99081
|
count: this.selectedItems.length
|
|
96611
99082
|
};
|
|
96612
99083
|
},
|
|
99084
|
+
// 清空选择
|
|
99085
|
+
clearSelection() {
|
|
99086
|
+
const panel = this.$refs.cascaderPanel;
|
|
99087
|
+
if (panel) {
|
|
99088
|
+
panel.clearCheckedNodes();
|
|
99089
|
+
} else {
|
|
99090
|
+
this.selectedValues = [];
|
|
99091
|
+
this.selectedItems = [];
|
|
99092
|
+
this.searchSelectedValues = [];
|
|
99093
|
+
this.applyPanelSelectionChange();
|
|
99094
|
+
}
|
|
99095
|
+
},
|
|
99096
|
+
// 设置选择值
|
|
96613
99097
|
setValue(values) {
|
|
96614
99098
|
if (this.isMultiple) {
|
|
99099
|
+
// 多选模式:支持直接传入value值或路径数组
|
|
96615
99100
|
if (Array.isArray(values) && values.length > 0) {
|
|
96616
99101
|
if (typeof values[0] === 'string' || typeof values[0] === 'number') {
|
|
99102
|
+
// 传入的是value值数组,需要转换为路径
|
|
96617
99103
|
if (this.aggregationMode) {
|
|
96618
|
-
|
|
99104
|
+
// 聚合模式下,支持非叶子节点标识
|
|
99105
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes(values, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
96619
99106
|
} else {
|
|
96620
|
-
|
|
99107
|
+
// 普通模式下,只处理叶子节点
|
|
99108
|
+
this.selectedValues = this.findPathsByValues(values);
|
|
96621
99109
|
}
|
|
96622
99110
|
} else {
|
|
99111
|
+
// 传入的是路径数组
|
|
96623
99112
|
this.selectedValues = [...values];
|
|
96624
99113
|
}
|
|
96625
99114
|
} else {
|
|
96626
99115
|
this.selectedValues = [];
|
|
96627
99116
|
}
|
|
96628
|
-
} else
|
|
96629
|
-
|
|
96630
|
-
|
|
96631
|
-
|
|
96632
|
-
|
|
99117
|
+
} else {
|
|
99118
|
+
// 单选模式:支持单个值或路径数组
|
|
99119
|
+
if (values !== null && values !== undefined && values !== '') {
|
|
99120
|
+
if (Array.isArray(values)) {
|
|
99121
|
+
// 传入的是路径数组
|
|
99122
|
+
this.selectedValues = [...values];
|
|
99123
|
+
} else {
|
|
99124
|
+
// 传入的是单个值,需要转换为路径
|
|
99125
|
+
if (this.aggregationMode) {
|
|
99126
|
+
// 聚合模式下,支持非叶子节点标识
|
|
99127
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes([values], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
99128
|
+
} else {
|
|
99129
|
+
// 普通模式下,只处理叶子节点
|
|
99130
|
+
this.selectedValues = this.findPathsByValues([values]);
|
|
99131
|
+
}
|
|
99132
|
+
}
|
|
96633
99133
|
} else {
|
|
96634
|
-
this.selectedValues =
|
|
99134
|
+
this.selectedValues = [];
|
|
96635
99135
|
}
|
|
96636
|
-
} else {
|
|
96637
|
-
this.selectedValues = [];
|
|
96638
99136
|
}
|
|
96639
|
-
this.
|
|
96640
|
-
|
|
99137
|
+
this.schedulePanelSyncFromExternalValue();
|
|
99138
|
+
},
|
|
99139
|
+
// 根据values找到对应的路径
|
|
99140
|
+
findPathsByValues(values) {
|
|
99141
|
+
const paths = [];
|
|
99142
|
+
const findPath = (options, targetValues, currentPath = []) => {
|
|
99143
|
+
for (const option of options) {
|
|
99144
|
+
const newPath = [...currentPath, option[this.cascaderProps.value]];
|
|
99145
|
+
if (targetValues.includes(option[this.cascaderProps.value])) {
|
|
99146
|
+
// 如果是叶子节点(没有children属性),添加到路径中
|
|
99147
|
+
if (!option[this.cascaderProps.children]) {
|
|
99148
|
+
paths.push(newPath);
|
|
99149
|
+
}
|
|
99150
|
+
}
|
|
99151
|
+
|
|
99152
|
+
// 递归查找子节点
|
|
99153
|
+
if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
|
|
99154
|
+
findPath(option[this.cascaderProps.children], targetValues, newPath);
|
|
99155
|
+
}
|
|
99156
|
+
}
|
|
99157
|
+
};
|
|
99158
|
+
|
|
99159
|
+
// 使用 filteredOptions 如果存在,否则使用原始 options
|
|
99160
|
+
const optionsToSearch = this.filteredOptions.length > 0 ? this.filteredOptions : this.options;
|
|
99161
|
+
findPath(optionsToSearch, values);
|
|
99162
|
+
return paths;
|
|
96641
99163
|
},
|
|
99164
|
+
// 处理批量搜索弹窗显示
|
|
96642
99165
|
handleBatchSearchShow() {
|
|
96643
99166
|
if (this.searchInput) {
|
|
96644
99167
|
this.searchInput = '';
|
|
96645
|
-
this.displayOptions = this.filteredOptions;
|
|
96646
99168
|
}
|
|
96647
99169
|
},
|
|
99170
|
+
// 处理批量搜索
|
|
96648
99171
|
handleBatchSearch() {
|
|
96649
99172
|
if (!this.batchSearchContent.trim()) {
|
|
96650
99173
|
this.batchSearchVisible = false;
|
|
96651
99174
|
return;
|
|
96652
99175
|
}
|
|
99176
|
+
|
|
99177
|
+
// 分割输入内容(支持换行、逗号、分号等分隔符)
|
|
96653
99178
|
const inputNames = this.batchSearchContent.split(/[\n,;,;\s]+/).filter(item => item.trim()).map(item => item.trim());
|
|
96654
99179
|
if (inputNames.length === 0) {
|
|
96655
99180
|
this.batchSearchVisible = false;
|
|
96656
99181
|
return;
|
|
96657
99182
|
}
|
|
96658
|
-
|
|
99183
|
+
|
|
99184
|
+
// 在级联数据中搜索匹配的名称
|
|
99185
|
+
const matchedPaths = this.searchNamesInCascader(inputNames);
|
|
96659
99186
|
if (matchedPaths.length > 0) {
|
|
96660
|
-
const
|
|
96661
|
-
|
|
96662
|
-
|
|
96663
|
-
|
|
96664
|
-
|
|
96665
|
-
|
|
96666
|
-
|
|
96667
|
-
|
|
96668
|
-
|
|
96669
|
-
|
|
96670
|
-
|
|
99187
|
+
const panel = this.$refs.cascaderPanel;
|
|
99188
|
+
if (panel && panel.selection && panel.store) {
|
|
99189
|
+
matchedPaths.forEach(path => {
|
|
99190
|
+
const leafValue = path[path.length - 1];
|
|
99191
|
+
if (panel.store.pathByLeafValue.has(leafValue)) {
|
|
99192
|
+
panel.selection.selectedLeafSet.add(leafValue);
|
|
99193
|
+
}
|
|
99194
|
+
});
|
|
99195
|
+
panel.selection._reconcileAllRoots();
|
|
99196
|
+
panel.bumpSelectionView();
|
|
99197
|
+
this.applyPanelSelectionChange();
|
|
99198
|
+
} else {
|
|
99199
|
+
const newSelectedValues = [...this.selectedValues];
|
|
99200
|
+
matchedPaths.forEach(path => {
|
|
99201
|
+
const exists = newSelectedValues.some(existingPath => existingPath.length === path.length && existingPath.every((value, index) => value === path[index]));
|
|
99202
|
+
if (!exists) {
|
|
99203
|
+
newSelectedValues.push(path);
|
|
99204
|
+
}
|
|
99205
|
+
});
|
|
99206
|
+
this.selectedValues = newSelectedValues;
|
|
99207
|
+
this.updateSelectedItems();
|
|
99208
|
+
this.$nextTick(() => {
|
|
99209
|
+
this.isInternalUpdate = true;
|
|
99210
|
+
let emitValue = this.currentValue;
|
|
99211
|
+
if (this.aggregationMode) {
|
|
99212
|
+
emitValue = CascaderUtilsPro.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
99213
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
99214
|
+
emitValue = emitValue[0];
|
|
99215
|
+
}
|
|
99216
|
+
}
|
|
99217
|
+
this.$emit('input', emitValue);
|
|
99218
|
+
});
|
|
99219
|
+
}
|
|
96671
99220
|
}
|
|
99221
|
+
|
|
99222
|
+
// 关闭弹窗并清空内容
|
|
96672
99223
|
this.batchSearchVisible = false;
|
|
96673
99224
|
this.batchSearchContent = '';
|
|
96674
99225
|
},
|
|
96675
|
-
|
|
99226
|
+
// 在级联数据中搜索匹配的名称(全匹配,忽略空格,排除禁用项)
|
|
99227
|
+
searchNamesInCascader(names) {
|
|
96676
99228
|
const matchedPaths = [];
|
|
99229
|
+
const labelKey = this.cascaderProps.label || 'label';
|
|
96677
99230
|
const searchInOptions = (options, currentPath = []) => {
|
|
96678
99231
|
for (const option of options) {
|
|
96679
|
-
const newPath = [...currentPath, option[this.
|
|
96680
|
-
const optionLabel = String(option[
|
|
99232
|
+
const newPath = [...currentPath, option[this.cascaderProps.value]];
|
|
99233
|
+
const optionLabel = String(option[labelKey] || '').replace(/\s+/g, ''); // 去掉所有空格
|
|
99234
|
+
|
|
99235
|
+
// 检查是否全匹配任何输入的名称(去掉空格后比较)
|
|
96681
99236
|
const isMatched = names.some(name => {
|
|
96682
|
-
const cleanName = name.replace(/\s+/g, '');
|
|
99237
|
+
const cleanName = name.replace(/\s+/g, ''); // 去掉输入名称中的空格
|
|
96683
99238
|
return optionLabel.toLowerCase() === cleanName.toLowerCase();
|
|
96684
99239
|
});
|
|
96685
|
-
|
|
96686
|
-
|
|
99240
|
+
|
|
99241
|
+
// 检查是否为叶子节点且匹配且未禁用
|
|
99242
|
+
const isLeafNode = !option[this.cascaderProps.children];
|
|
99243
|
+
const isNotDisabled = !this.isItemDisabled(option);
|
|
96687
99244
|
if (isMatched && isLeafNode && isNotDisabled) {
|
|
99245
|
+
// 如果是叶子节点、匹配且未禁用,添加到结果中
|
|
96688
99246
|
matchedPaths.push(newPath);
|
|
96689
99247
|
}
|
|
96690
|
-
|
|
96691
|
-
|
|
99248
|
+
|
|
99249
|
+
// 递归搜索子节点
|
|
99250
|
+
if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
|
|
99251
|
+
searchInOptions(option[this.cascaderProps.children], newPath);
|
|
96692
99252
|
}
|
|
96693
99253
|
}
|
|
96694
99254
|
};
|
|
96695
99255
|
searchInOptions(this.filteredOptions);
|
|
96696
99256
|
return matchedPaths;
|
|
96697
99257
|
},
|
|
96698
|
-
|
|
96699
|
-
|
|
96700
|
-
|
|
96701
|
-
|
|
96702
|
-
|
|
99258
|
+
// 强制调整已选项的垂直居中样式
|
|
99259
|
+
forceVerticalCenter() {
|
|
99260
|
+
this.$nextTick(() => {
|
|
99261
|
+
const itemLabels = this.$el.querySelectorAll('.item-label');
|
|
99262
|
+
itemLabels.forEach(label => {
|
|
99263
|
+
if (label) {
|
|
99264
|
+
// 使用JavaScript强制设置样式
|
|
99265
|
+
label.style.setProperty('display', 'flex', 'important');
|
|
99266
|
+
label.style.setProperty('align-items', 'center', 'important');
|
|
99267
|
+
label.style.setProperty('height', '36px', 'important');
|
|
99268
|
+
label.style.setProperty('line-height', '36px', 'important');
|
|
99269
|
+
label.style.setProperty('margin', '0', 'important');
|
|
99270
|
+
label.style.setProperty('padding', '0', 'important');
|
|
99271
|
+
label.style.setProperty('vertical-align', 'middle', 'important');
|
|
99272
|
+
label.style.setProperty('font-size', '14px', 'important');
|
|
99273
|
+
}
|
|
99274
|
+
});
|
|
99275
|
+
});
|
|
96703
99276
|
}
|
|
99277
|
+
},
|
|
99278
|
+
updated() {
|
|
99279
|
+
// 组件更新后强制调整样式
|
|
99280
|
+
this.forceVerticalCenter();
|
|
96704
99281
|
}
|
|
96705
99282
|
});
|
|
96706
|
-
;// ./src/components/
|
|
96707
|
-
/* harmony default export */ var
|
|
96708
|
-
;// ./src/components/
|
|
99283
|
+
;// ./src/components/cascader-panel-pro/ByCascaderPanelPro.vue?vue&type=script&lang=js
|
|
99284
|
+
/* harmony default export */ var cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js = (ByCascaderPanelProvue_type_script_lang_js);
|
|
99285
|
+
;// ./src/components/cascader-panel-pro/ByCascaderPanelPro.vue
|
|
96709
99286
|
|
|
96710
99287
|
|
|
96711
99288
|
|
|
@@ -96713,10 +99290,10 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96713
99290
|
|
|
96714
99291
|
/* normalize component */
|
|
96715
99292
|
;
|
|
96716
|
-
var
|
|
96717
|
-
|
|
96718
|
-
|
|
96719
|
-
|
|
99293
|
+
var ByCascaderPanelPro_component = normalizeComponent(
|
|
99294
|
+
cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js,
|
|
99295
|
+
ByCascaderPanelProvue_type_template_id_804df886_render,
|
|
99296
|
+
ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns,
|
|
96720
99297
|
false,
|
|
96721
99298
|
null,
|
|
96722
99299
|
null,
|
|
@@ -96724,7 +99301,7 @@ var ByTreePanel_component = normalizeComponent(
|
|
|
96724
99301
|
|
|
96725
99302
|
)
|
|
96726
99303
|
|
|
96727
|
-
/* harmony default export */ var
|
|
99304
|
+
/* harmony default export */ var ByCascaderPanelPro = (ByCascaderPanelPro_component.exports);
|
|
96728
99305
|
;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.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/floating-menu/ByFloatingMenu.vue?vue&type=template&id=04723f13
|
|
96729
99306
|
var ByFloatingMenuvue_type_template_id_04723f13_render = function render() {
|
|
96730
99307
|
var _vm = this,
|
|
@@ -99438,7 +102015,7 @@ const components = {
|
|
|
99438
102015
|
ByTreeSearch: ByTreeSearch,
|
|
99439
102016
|
ByDialog: ByDialog,
|
|
99440
102017
|
ByCascaderPanel: ByCascaderPanel,
|
|
99441
|
-
|
|
102018
|
+
ByCascaderPanelPro: ByCascaderPanelPro,
|
|
99442
102019
|
ByFloatingMenu: ByFloatingMenu,
|
|
99443
102020
|
ByPopoverSelector: ByPopoverSelector,
|
|
99444
102021
|
ByGridLayout: ByGridLayout,
|