@weitutech/by-components 1.1.221 → 1.2.0
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 +2914 -422
- package/lib/by-components.umd.js +3064 -572
- 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
|
@@ -10695,262 +10695,6 @@ exports["default"] = function (target) {
|
|
|
10695
10695
|
|
|
10696
10696
|
/***/ }),
|
|
10697
10697
|
|
|
10698
|
-
/***/ 2050:
|
|
10699
|
-
/***/ (function(module) {
|
|
10700
|
-
|
|
10701
|
-
/**
|
|
10702
|
-
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
10703
|
-
*
|
|
10704
|
-
* @providesModule UserAgent_DEPRECATED
|
|
10705
|
-
*/
|
|
10706
|
-
|
|
10707
|
-
/**
|
|
10708
|
-
* Provides entirely client-side User Agent and OS detection. You should prefer
|
|
10709
|
-
* the non-deprecated UserAgent module when possible, which exposes our
|
|
10710
|
-
* authoritative server-side PHP-based detection to the client.
|
|
10711
|
-
*
|
|
10712
|
-
* Usage is straightforward:
|
|
10713
|
-
*
|
|
10714
|
-
* if (UserAgent_DEPRECATED.ie()) {
|
|
10715
|
-
* // IE
|
|
10716
|
-
* }
|
|
10717
|
-
*
|
|
10718
|
-
* You can also do version checks:
|
|
10719
|
-
*
|
|
10720
|
-
* if (UserAgent_DEPRECATED.ie() >= 7) {
|
|
10721
|
-
* // IE7 or better
|
|
10722
|
-
* }
|
|
10723
|
-
*
|
|
10724
|
-
* The browser functions will return NaN if the browser does not match, so
|
|
10725
|
-
* you can also do version compares the other way:
|
|
10726
|
-
*
|
|
10727
|
-
* if (UserAgent_DEPRECATED.ie() < 7) {
|
|
10728
|
-
* // IE6 or worse
|
|
10729
|
-
* }
|
|
10730
|
-
*
|
|
10731
|
-
* Note that the version is a float and may include a minor version number,
|
|
10732
|
-
* so you should always use range operators to perform comparisons, not
|
|
10733
|
-
* strict equality.
|
|
10734
|
-
*
|
|
10735
|
-
* **Note:** You should **strongly** prefer capability detection to browser
|
|
10736
|
-
* version detection where it's reasonable:
|
|
10737
|
-
*
|
|
10738
|
-
* http://www.quirksmode.org/js/support.html
|
|
10739
|
-
*
|
|
10740
|
-
* Further, we have a large number of mature wrapper functions and classes
|
|
10741
|
-
* which abstract away many browser irregularities. Check the documentation,
|
|
10742
|
-
* grep for things, or ask on javascript@lists.facebook.com before writing yet
|
|
10743
|
-
* another copy of "event || window.event".
|
|
10744
|
-
*
|
|
10745
|
-
*/
|
|
10746
|
-
|
|
10747
|
-
var _populated = false;
|
|
10748
|
-
|
|
10749
|
-
// Browsers
|
|
10750
|
-
var _ie, _firefox, _opera, _webkit, _chrome;
|
|
10751
|
-
|
|
10752
|
-
// Actual IE browser for compatibility mode
|
|
10753
|
-
var _ie_real_version;
|
|
10754
|
-
|
|
10755
|
-
// Platforms
|
|
10756
|
-
var _osx, _windows, _linux, _android;
|
|
10757
|
-
|
|
10758
|
-
// Architectures
|
|
10759
|
-
var _win64;
|
|
10760
|
-
|
|
10761
|
-
// Devices
|
|
10762
|
-
var _iphone, _ipad, _native;
|
|
10763
|
-
var _mobile;
|
|
10764
|
-
function _populate() {
|
|
10765
|
-
if (_populated) {
|
|
10766
|
-
return;
|
|
10767
|
-
}
|
|
10768
|
-
_populated = true;
|
|
10769
|
-
|
|
10770
|
-
// To work around buggy JS libraries that can't handle multi-digit
|
|
10771
|
-
// version numbers, Opera 10's user agent string claims it's Opera
|
|
10772
|
-
// 9, then later includes a Version/X.Y field:
|
|
10773
|
-
//
|
|
10774
|
-
// Opera/9.80 (foo) Presto/2.2.15 Version/10.10
|
|
10775
|
-
var uas = navigator.userAgent;
|
|
10776
|
-
var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas);
|
|
10777
|
-
var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
|
|
10778
|
-
_iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
|
|
10779
|
-
_ipad = /\b(iP[ao]d)/.exec(uas);
|
|
10780
|
-
_android = /Android/i.exec(uas);
|
|
10781
|
-
_native = /FBAN\/\w+;/i.exec(uas);
|
|
10782
|
-
_mobile = /Mobile/i.exec(uas);
|
|
10783
|
-
|
|
10784
|
-
// Note that the IE team blog would have you believe you should be checking
|
|
10785
|
-
// for 'Win64; x64'. But MSDN then reveals that you can actually be coming
|
|
10786
|
-
// from either x64 or ia64; so ultimately, you should just check for Win64
|
|
10787
|
-
// as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit
|
|
10788
|
-
// Windows will send 'WOW64' instead.
|
|
10789
|
-
_win64 = !!/Win64/.exec(uas);
|
|
10790
|
-
if (agent) {
|
|
10791
|
-
_ie = agent[1] ? parseFloat(agent[1]) : agent[5] ? parseFloat(agent[5]) : NaN;
|
|
10792
|
-
// IE compatibility mode
|
|
10793
|
-
if (_ie && document && document.documentMode) {
|
|
10794
|
-
_ie = document.documentMode;
|
|
10795
|
-
}
|
|
10796
|
-
// grab the "true" ie version from the trident token if available
|
|
10797
|
-
var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
|
|
10798
|
-
_ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
|
|
10799
|
-
_firefox = agent[2] ? parseFloat(agent[2]) : NaN;
|
|
10800
|
-
_opera = agent[3] ? parseFloat(agent[3]) : NaN;
|
|
10801
|
-
_webkit = agent[4] ? parseFloat(agent[4]) : NaN;
|
|
10802
|
-
if (_webkit) {
|
|
10803
|
-
// We do not add the regexp to the above test, because it will always
|
|
10804
|
-
// match 'safari' only since 'AppleWebKit' appears before 'Chrome' in
|
|
10805
|
-
// the userAgent string.
|
|
10806
|
-
agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
|
|
10807
|
-
_chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
|
|
10808
|
-
} else {
|
|
10809
|
-
_chrome = NaN;
|
|
10810
|
-
}
|
|
10811
|
-
} else {
|
|
10812
|
-
_ie = _firefox = _opera = _chrome = _webkit = NaN;
|
|
10813
|
-
}
|
|
10814
|
-
if (os) {
|
|
10815
|
-
if (os[1]) {
|
|
10816
|
-
// Detect OS X version. If no version number matches, set _osx to true.
|
|
10817
|
-
// Version examples: 10, 10_6_1, 10.7
|
|
10818
|
-
// Parses version number as a float, taking only first two sets of
|
|
10819
|
-
// digits. If only one set of digits is found, returns just the major
|
|
10820
|
-
// version number.
|
|
10821
|
-
var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
|
|
10822
|
-
_osx = ver ? parseFloat(ver[1].replace('_', '.')) : true;
|
|
10823
|
-
} else {
|
|
10824
|
-
_osx = false;
|
|
10825
|
-
}
|
|
10826
|
-
_windows = !!os[2];
|
|
10827
|
-
_linux = !!os[3];
|
|
10828
|
-
} else {
|
|
10829
|
-
_osx = _windows = _linux = false;
|
|
10830
|
-
}
|
|
10831
|
-
}
|
|
10832
|
-
var UserAgent_DEPRECATED = {
|
|
10833
|
-
/**
|
|
10834
|
-
* Check if the UA is Internet Explorer.
|
|
10835
|
-
*
|
|
10836
|
-
*
|
|
10837
|
-
* @return float|NaN Version number (if match) or NaN.
|
|
10838
|
-
*/
|
|
10839
|
-
ie: function () {
|
|
10840
|
-
return _populate() || _ie;
|
|
10841
|
-
},
|
|
10842
|
-
/**
|
|
10843
|
-
* Check if we're in Internet Explorer compatibility mode.
|
|
10844
|
-
*
|
|
10845
|
-
* @return bool true if in compatibility mode, false if
|
|
10846
|
-
* not compatibility mode or not ie
|
|
10847
|
-
*/
|
|
10848
|
-
ieCompatibilityMode: function () {
|
|
10849
|
-
return _populate() || _ie_real_version > _ie;
|
|
10850
|
-
},
|
|
10851
|
-
/**
|
|
10852
|
-
* Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
|
|
10853
|
-
* only need this because Skype can't handle 64-bit IE yet. We need to remove
|
|
10854
|
-
* this when we don't need it -- tracked by #601957.
|
|
10855
|
-
*/
|
|
10856
|
-
ie64: function () {
|
|
10857
|
-
return UserAgent_DEPRECATED.ie() && _win64;
|
|
10858
|
-
},
|
|
10859
|
-
/**
|
|
10860
|
-
* Check if the UA is Firefox.
|
|
10861
|
-
*
|
|
10862
|
-
*
|
|
10863
|
-
* @return float|NaN Version number (if match) or NaN.
|
|
10864
|
-
*/
|
|
10865
|
-
firefox: function () {
|
|
10866
|
-
return _populate() || _firefox;
|
|
10867
|
-
},
|
|
10868
|
-
/**
|
|
10869
|
-
* Check if the UA is Opera.
|
|
10870
|
-
*
|
|
10871
|
-
*
|
|
10872
|
-
* @return float|NaN Version number (if match) or NaN.
|
|
10873
|
-
*/
|
|
10874
|
-
opera: function () {
|
|
10875
|
-
return _populate() || _opera;
|
|
10876
|
-
},
|
|
10877
|
-
/**
|
|
10878
|
-
* Check if the UA is WebKit.
|
|
10879
|
-
*
|
|
10880
|
-
*
|
|
10881
|
-
* @return float|NaN Version number (if match) or NaN.
|
|
10882
|
-
*/
|
|
10883
|
-
webkit: function () {
|
|
10884
|
-
return _populate() || _webkit;
|
|
10885
|
-
},
|
|
10886
|
-
/**
|
|
10887
|
-
* For Push
|
|
10888
|
-
* WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
|
|
10889
|
-
*/
|
|
10890
|
-
safari: function () {
|
|
10891
|
-
return UserAgent_DEPRECATED.webkit();
|
|
10892
|
-
},
|
|
10893
|
-
/**
|
|
10894
|
-
* Check if the UA is a Chrome browser.
|
|
10895
|
-
*
|
|
10896
|
-
*
|
|
10897
|
-
* @return float|NaN Version number (if match) or NaN.
|
|
10898
|
-
*/
|
|
10899
|
-
chrome: function () {
|
|
10900
|
-
return _populate() || _chrome;
|
|
10901
|
-
},
|
|
10902
|
-
/**
|
|
10903
|
-
* Check if the user is running Windows.
|
|
10904
|
-
*
|
|
10905
|
-
* @return bool `true' if the user's OS is Windows.
|
|
10906
|
-
*/
|
|
10907
|
-
windows: function () {
|
|
10908
|
-
return _populate() || _windows;
|
|
10909
|
-
},
|
|
10910
|
-
/**
|
|
10911
|
-
* Check if the user is running Mac OS X.
|
|
10912
|
-
*
|
|
10913
|
-
* @return float|bool Returns a float if a version number is detected,
|
|
10914
|
-
* otherwise true/false.
|
|
10915
|
-
*/
|
|
10916
|
-
osx: function () {
|
|
10917
|
-
return _populate() || _osx;
|
|
10918
|
-
},
|
|
10919
|
-
/**
|
|
10920
|
-
* Check if the user is running Linux.
|
|
10921
|
-
*
|
|
10922
|
-
* @return bool `true' if the user's OS is some flavor of Linux.
|
|
10923
|
-
*/
|
|
10924
|
-
linux: function () {
|
|
10925
|
-
return _populate() || _linux;
|
|
10926
|
-
},
|
|
10927
|
-
/**
|
|
10928
|
-
* Check if the user is running on an iPhone or iPod platform.
|
|
10929
|
-
*
|
|
10930
|
-
* @return bool `true' if the user is running some flavor of the
|
|
10931
|
-
* iPhone OS.
|
|
10932
|
-
*/
|
|
10933
|
-
iphone: function () {
|
|
10934
|
-
return _populate() || _iphone;
|
|
10935
|
-
},
|
|
10936
|
-
mobile: function () {
|
|
10937
|
-
return _populate() || _iphone || _ipad || _android || _mobile;
|
|
10938
|
-
},
|
|
10939
|
-
nativeApp: function () {
|
|
10940
|
-
// webviews inside of the native apps
|
|
10941
|
-
return _populate() || _native;
|
|
10942
|
-
},
|
|
10943
|
-
android: function () {
|
|
10944
|
-
return _populate() || _android;
|
|
10945
|
-
},
|
|
10946
|
-
ipad: function () {
|
|
10947
|
-
return _populate() || _ipad;
|
|
10948
|
-
}
|
|
10949
|
-
};
|
|
10950
|
-
module.exports = UserAgent_DEPRECATED;
|
|
10951
|
-
|
|
10952
|
-
/***/ }),
|
|
10953
|
-
|
|
10954
10698
|
/***/ 2063:
|
|
10955
10699
|
/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
|
|
10956
10700
|
|
|
@@ -55578,7 +55322,7 @@ module.exports = true;
|
|
|
55578
55322
|
|
|
55579
55323
|
|
|
55580
55324
|
|
|
55581
|
-
var UserAgent_DEPRECATED = __webpack_require__(
|
|
55325
|
+
var UserAgent_DEPRECATED = __webpack_require__(9669);
|
|
55582
55326
|
var isEventSupported = __webpack_require__(4544);
|
|
55583
55327
|
|
|
55584
55328
|
// Reasonable defaults
|
|
@@ -71636,6 +71380,262 @@ __webpack_require__(1806);
|
|
|
71636
71380
|
|
|
71637
71381
|
/***/ }),
|
|
71638
71382
|
|
|
71383
|
+
/***/ 9669:
|
|
71384
|
+
/***/ (function(module) {
|
|
71385
|
+
|
|
71386
|
+
/**
|
|
71387
|
+
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
71388
|
+
*
|
|
71389
|
+
* @providesModule UserAgent_DEPRECATED
|
|
71390
|
+
*/
|
|
71391
|
+
|
|
71392
|
+
/**
|
|
71393
|
+
* Provides entirely client-side User Agent and OS detection. You should prefer
|
|
71394
|
+
* the non-deprecated UserAgent module when possible, which exposes our
|
|
71395
|
+
* authoritative server-side PHP-based detection to the client.
|
|
71396
|
+
*
|
|
71397
|
+
* Usage is straightforward:
|
|
71398
|
+
*
|
|
71399
|
+
* if (UserAgent_DEPRECATED.ie()) {
|
|
71400
|
+
* // IE
|
|
71401
|
+
* }
|
|
71402
|
+
*
|
|
71403
|
+
* You can also do version checks:
|
|
71404
|
+
*
|
|
71405
|
+
* if (UserAgent_DEPRECATED.ie() >= 7) {
|
|
71406
|
+
* // IE7 or better
|
|
71407
|
+
* }
|
|
71408
|
+
*
|
|
71409
|
+
* The browser functions will return NaN if the browser does not match, so
|
|
71410
|
+
* you can also do version compares the other way:
|
|
71411
|
+
*
|
|
71412
|
+
* if (UserAgent_DEPRECATED.ie() < 7) {
|
|
71413
|
+
* // IE6 or worse
|
|
71414
|
+
* }
|
|
71415
|
+
*
|
|
71416
|
+
* Note that the version is a float and may include a minor version number,
|
|
71417
|
+
* so you should always use range operators to perform comparisons, not
|
|
71418
|
+
* strict equality.
|
|
71419
|
+
*
|
|
71420
|
+
* **Note:** You should **strongly** prefer capability detection to browser
|
|
71421
|
+
* version detection where it's reasonable:
|
|
71422
|
+
*
|
|
71423
|
+
* http://www.quirksmode.org/js/support.html
|
|
71424
|
+
*
|
|
71425
|
+
* Further, we have a large number of mature wrapper functions and classes
|
|
71426
|
+
* which abstract away many browser irregularities. Check the documentation,
|
|
71427
|
+
* grep for things, or ask on javascript@lists.facebook.com before writing yet
|
|
71428
|
+
* another copy of "event || window.event".
|
|
71429
|
+
*
|
|
71430
|
+
*/
|
|
71431
|
+
|
|
71432
|
+
var _populated = false;
|
|
71433
|
+
|
|
71434
|
+
// Browsers
|
|
71435
|
+
var _ie, _firefox, _opera, _webkit, _chrome;
|
|
71436
|
+
|
|
71437
|
+
// Actual IE browser for compatibility mode
|
|
71438
|
+
var _ie_real_version;
|
|
71439
|
+
|
|
71440
|
+
// Platforms
|
|
71441
|
+
var _osx, _windows, _linux, _android;
|
|
71442
|
+
|
|
71443
|
+
// Architectures
|
|
71444
|
+
var _win64;
|
|
71445
|
+
|
|
71446
|
+
// Devices
|
|
71447
|
+
var _iphone, _ipad, _native;
|
|
71448
|
+
var _mobile;
|
|
71449
|
+
function _populate() {
|
|
71450
|
+
if (_populated) {
|
|
71451
|
+
return;
|
|
71452
|
+
}
|
|
71453
|
+
_populated = true;
|
|
71454
|
+
|
|
71455
|
+
// To work around buggy JS libraries that can't handle multi-digit
|
|
71456
|
+
// version numbers, Opera 10's user agent string claims it's Opera
|
|
71457
|
+
// 9, then later includes a Version/X.Y field:
|
|
71458
|
+
//
|
|
71459
|
+
// Opera/9.80 (foo) Presto/2.2.15 Version/10.10
|
|
71460
|
+
var uas = navigator.userAgent;
|
|
71461
|
+
var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas);
|
|
71462
|
+
var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
|
|
71463
|
+
_iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
|
|
71464
|
+
_ipad = /\b(iP[ao]d)/.exec(uas);
|
|
71465
|
+
_android = /Android/i.exec(uas);
|
|
71466
|
+
_native = /FBAN\/\w+;/i.exec(uas);
|
|
71467
|
+
_mobile = /Mobile/i.exec(uas);
|
|
71468
|
+
|
|
71469
|
+
// Note that the IE team blog would have you believe you should be checking
|
|
71470
|
+
// for 'Win64; x64'. But MSDN then reveals that you can actually be coming
|
|
71471
|
+
// from either x64 or ia64; so ultimately, you should just check for Win64
|
|
71472
|
+
// as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit
|
|
71473
|
+
// Windows will send 'WOW64' instead.
|
|
71474
|
+
_win64 = !!/Win64/.exec(uas);
|
|
71475
|
+
if (agent) {
|
|
71476
|
+
_ie = agent[1] ? parseFloat(agent[1]) : agent[5] ? parseFloat(agent[5]) : NaN;
|
|
71477
|
+
// IE compatibility mode
|
|
71478
|
+
if (_ie && document && document.documentMode) {
|
|
71479
|
+
_ie = document.documentMode;
|
|
71480
|
+
}
|
|
71481
|
+
// grab the "true" ie version from the trident token if available
|
|
71482
|
+
var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
|
|
71483
|
+
_ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
|
|
71484
|
+
_firefox = agent[2] ? parseFloat(agent[2]) : NaN;
|
|
71485
|
+
_opera = agent[3] ? parseFloat(agent[3]) : NaN;
|
|
71486
|
+
_webkit = agent[4] ? parseFloat(agent[4]) : NaN;
|
|
71487
|
+
if (_webkit) {
|
|
71488
|
+
// We do not add the regexp to the above test, because it will always
|
|
71489
|
+
// match 'safari' only since 'AppleWebKit' appears before 'Chrome' in
|
|
71490
|
+
// the userAgent string.
|
|
71491
|
+
agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
|
|
71492
|
+
_chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
|
|
71493
|
+
} else {
|
|
71494
|
+
_chrome = NaN;
|
|
71495
|
+
}
|
|
71496
|
+
} else {
|
|
71497
|
+
_ie = _firefox = _opera = _chrome = _webkit = NaN;
|
|
71498
|
+
}
|
|
71499
|
+
if (os) {
|
|
71500
|
+
if (os[1]) {
|
|
71501
|
+
// Detect OS X version. If no version number matches, set _osx to true.
|
|
71502
|
+
// Version examples: 10, 10_6_1, 10.7
|
|
71503
|
+
// Parses version number as a float, taking only first two sets of
|
|
71504
|
+
// digits. If only one set of digits is found, returns just the major
|
|
71505
|
+
// version number.
|
|
71506
|
+
var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
|
|
71507
|
+
_osx = ver ? parseFloat(ver[1].replace('_', '.')) : true;
|
|
71508
|
+
} else {
|
|
71509
|
+
_osx = false;
|
|
71510
|
+
}
|
|
71511
|
+
_windows = !!os[2];
|
|
71512
|
+
_linux = !!os[3];
|
|
71513
|
+
} else {
|
|
71514
|
+
_osx = _windows = _linux = false;
|
|
71515
|
+
}
|
|
71516
|
+
}
|
|
71517
|
+
var UserAgent_DEPRECATED = {
|
|
71518
|
+
/**
|
|
71519
|
+
* Check if the UA is Internet Explorer.
|
|
71520
|
+
*
|
|
71521
|
+
*
|
|
71522
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
71523
|
+
*/
|
|
71524
|
+
ie: function () {
|
|
71525
|
+
return _populate() || _ie;
|
|
71526
|
+
},
|
|
71527
|
+
/**
|
|
71528
|
+
* Check if we're in Internet Explorer compatibility mode.
|
|
71529
|
+
*
|
|
71530
|
+
* @return bool true if in compatibility mode, false if
|
|
71531
|
+
* not compatibility mode or not ie
|
|
71532
|
+
*/
|
|
71533
|
+
ieCompatibilityMode: function () {
|
|
71534
|
+
return _populate() || _ie_real_version > _ie;
|
|
71535
|
+
},
|
|
71536
|
+
/**
|
|
71537
|
+
* Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
|
|
71538
|
+
* only need this because Skype can't handle 64-bit IE yet. We need to remove
|
|
71539
|
+
* this when we don't need it -- tracked by #601957.
|
|
71540
|
+
*/
|
|
71541
|
+
ie64: function () {
|
|
71542
|
+
return UserAgent_DEPRECATED.ie() && _win64;
|
|
71543
|
+
},
|
|
71544
|
+
/**
|
|
71545
|
+
* Check if the UA is Firefox.
|
|
71546
|
+
*
|
|
71547
|
+
*
|
|
71548
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
71549
|
+
*/
|
|
71550
|
+
firefox: function () {
|
|
71551
|
+
return _populate() || _firefox;
|
|
71552
|
+
},
|
|
71553
|
+
/**
|
|
71554
|
+
* Check if the UA is Opera.
|
|
71555
|
+
*
|
|
71556
|
+
*
|
|
71557
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
71558
|
+
*/
|
|
71559
|
+
opera: function () {
|
|
71560
|
+
return _populate() || _opera;
|
|
71561
|
+
},
|
|
71562
|
+
/**
|
|
71563
|
+
* Check if the UA is WebKit.
|
|
71564
|
+
*
|
|
71565
|
+
*
|
|
71566
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
71567
|
+
*/
|
|
71568
|
+
webkit: function () {
|
|
71569
|
+
return _populate() || _webkit;
|
|
71570
|
+
},
|
|
71571
|
+
/**
|
|
71572
|
+
* For Push
|
|
71573
|
+
* WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
|
|
71574
|
+
*/
|
|
71575
|
+
safari: function () {
|
|
71576
|
+
return UserAgent_DEPRECATED.webkit();
|
|
71577
|
+
},
|
|
71578
|
+
/**
|
|
71579
|
+
* Check if the UA is a Chrome browser.
|
|
71580
|
+
*
|
|
71581
|
+
*
|
|
71582
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
71583
|
+
*/
|
|
71584
|
+
chrome: function () {
|
|
71585
|
+
return _populate() || _chrome;
|
|
71586
|
+
},
|
|
71587
|
+
/**
|
|
71588
|
+
* Check if the user is running Windows.
|
|
71589
|
+
*
|
|
71590
|
+
* @return bool `true' if the user's OS is Windows.
|
|
71591
|
+
*/
|
|
71592
|
+
windows: function () {
|
|
71593
|
+
return _populate() || _windows;
|
|
71594
|
+
},
|
|
71595
|
+
/**
|
|
71596
|
+
* Check if the user is running Mac OS X.
|
|
71597
|
+
*
|
|
71598
|
+
* @return float|bool Returns a float if a version number is detected,
|
|
71599
|
+
* otherwise true/false.
|
|
71600
|
+
*/
|
|
71601
|
+
osx: function () {
|
|
71602
|
+
return _populate() || _osx;
|
|
71603
|
+
},
|
|
71604
|
+
/**
|
|
71605
|
+
* Check if the user is running Linux.
|
|
71606
|
+
*
|
|
71607
|
+
* @return bool `true' if the user's OS is some flavor of Linux.
|
|
71608
|
+
*/
|
|
71609
|
+
linux: function () {
|
|
71610
|
+
return _populate() || _linux;
|
|
71611
|
+
},
|
|
71612
|
+
/**
|
|
71613
|
+
* Check if the user is running on an iPhone or iPod platform.
|
|
71614
|
+
*
|
|
71615
|
+
* @return bool `true' if the user is running some flavor of the
|
|
71616
|
+
* iPhone OS.
|
|
71617
|
+
*/
|
|
71618
|
+
iphone: function () {
|
|
71619
|
+
return _populate() || _iphone;
|
|
71620
|
+
},
|
|
71621
|
+
mobile: function () {
|
|
71622
|
+
return _populate() || _iphone || _ipad || _android || _mobile;
|
|
71623
|
+
},
|
|
71624
|
+
nativeApp: function () {
|
|
71625
|
+
// webviews inside of the native apps
|
|
71626
|
+
return _populate() || _native;
|
|
71627
|
+
},
|
|
71628
|
+
android: function () {
|
|
71629
|
+
return _populate() || _android;
|
|
71630
|
+
},
|
|
71631
|
+
ipad: function () {
|
|
71632
|
+
return _populate() || _ipad;
|
|
71633
|
+
}
|
|
71634
|
+
};
|
|
71635
|
+
module.exports = UserAgent_DEPRECATED;
|
|
71636
|
+
|
|
71637
|
+
/***/ }),
|
|
71638
|
+
|
|
71639
71639
|
/***/ 9720:
|
|
71640
71640
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
71641
71641
|
|
|
@@ -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=4bdb9820
|
|
96029
|
+
var ByCascaderPanelProvue_type_template_id_4bdb9820_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,68 @@ 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
|
+
}
|
|
96169
|
+
}) : _vm._e(), _vm.searchOptions.length > 0 ? _c('VirtualCascaderPanel', {
|
|
96170
|
+
directives: [{
|
|
96171
|
+
name: "show",
|
|
96172
|
+
rawName: "v-show",
|
|
96173
|
+
value: _vm.searchInput !== '' && _vm.isShowSearch,
|
|
96174
|
+
expression: "searchInput !== '' && isShowSearch"
|
|
96175
|
+
}],
|
|
96176
|
+
ref: "searchCascaderPanel",
|
|
96177
|
+
staticClass: "cascader-panel-inner",
|
|
96178
|
+
attrs: {
|
|
96179
|
+
"value": _vm.compactSearchPanelValue,
|
|
96180
|
+
"sync-value-from-parent": false,
|
|
96181
|
+
"options": _vm.searchOptions,
|
|
96182
|
+
"props": _vm.cascaderProps,
|
|
96183
|
+
"height": _vm.computedPanelHeight - 20,
|
|
96184
|
+
"column-min-width": _vm.columnMinWidth,
|
|
96185
|
+
"column-max-width": _vm.columnMaxWidth,
|
|
96186
|
+
"disabled-config": _vm.disabledConfig,
|
|
96187
|
+
"is-view-mode": _vm.isViewMode
|
|
96155
96188
|
},
|
|
96156
96189
|
on: {
|
|
96157
|
-
"
|
|
96158
|
-
"
|
|
96190
|
+
"input": _vm.onSearchPanelInput,
|
|
96191
|
+
"change": _vm.handleSearchValueChange
|
|
96159
96192
|
}
|
|
96160
|
-
}) : _vm.
|
|
96193
|
+
}) : _vm._e(), _vm.isShowSearch && _vm.searchOptions.length === 0 ? _c('div', {
|
|
96194
|
+
directives: [{
|
|
96195
|
+
name: "show",
|
|
96196
|
+
rawName: "v-show",
|
|
96197
|
+
value: _vm.searchInput !== '',
|
|
96198
|
+
expression: "searchInput !== ''"
|
|
96199
|
+
}],
|
|
96161
96200
|
staticClass: "empty-search"
|
|
96162
96201
|
}, [_c('el-empty', {
|
|
96163
96202
|
attrs: {
|
|
@@ -96183,33 +96222,54 @@ var ByTreePanelvue_type_template_id_af06ba0a_render = function render() {
|
|
|
96183
96222
|
}
|
|
96184
96223
|
}, [_c('div', {
|
|
96185
96224
|
staticClass: "selected-list"
|
|
96186
|
-
}, [_vm.
|
|
96187
|
-
|
|
96188
|
-
|
|
96189
|
-
|
|
96190
|
-
},
|
|
96191
|
-
|
|
96192
|
-
|
|
96193
|
-
|
|
96194
|
-
|
|
96195
|
-
|
|
96196
|
-
|
|
96197
|
-
|
|
96198
|
-
|
|
96199
|
-
|
|
96200
|
-
|
|
96201
|
-
|
|
96225
|
+
}, [_vm.selectedItems.length > 0 ? _c('VcpVirtualList', {
|
|
96226
|
+
staticClass: "selected-virtual-list",
|
|
96227
|
+
style: {
|
|
96228
|
+
height: _vm.selectedListHeight + 'px'
|
|
96229
|
+
},
|
|
96230
|
+
attrs: {
|
|
96231
|
+
"items": _vm.selectedItems,
|
|
96232
|
+
"item-height": _vm.selectedItemHeight,
|
|
96233
|
+
"height": _vm.selectedListHeight,
|
|
96234
|
+
"list-padding": 0,
|
|
96235
|
+
"overscan": 10
|
|
96236
|
+
},
|
|
96237
|
+
scopedSlots: _vm._u([{
|
|
96238
|
+
key: "default",
|
|
96239
|
+
fn: function ({
|
|
96240
|
+
item,
|
|
96241
|
+
index
|
|
96242
|
+
}) {
|
|
96243
|
+
return [_c('div', {
|
|
96244
|
+
key: 'selected-' + item.value + '-' + index,
|
|
96245
|
+
staticClass: "selected-item-row"
|
|
96246
|
+
}, [_c('div', {
|
|
96247
|
+
staticClass: "selected-item"
|
|
96248
|
+
}, [_c('div', {
|
|
96249
|
+
staticClass: "item-content"
|
|
96250
|
+
}, [_c('div', {
|
|
96251
|
+
staticClass: "item-label"
|
|
96252
|
+
}, [_vm._v(_vm._s(item.label || ''))]), _vm.showSubtitle && _vm.subtitleField && item[_vm.subtitleField] ? _c('div', {
|
|
96253
|
+
staticClass: "item-subtitle"
|
|
96254
|
+
}, [_vm._v(" " + _vm._s(item[_vm.subtitleField]) + " ")]) : _vm._e()]), !_vm.isViewMode ? _c('div', {
|
|
96255
|
+
staticClass: "remove-btn",
|
|
96256
|
+
on: {
|
|
96257
|
+
"click": function ($event) {
|
|
96258
|
+
return _vm.removeItem(item, index);
|
|
96259
|
+
}
|
|
96260
|
+
}
|
|
96261
|
+
}, [_c('i', {
|
|
96262
|
+
staticClass: "el-icon-close"
|
|
96263
|
+
})]) : _vm._e()])])];
|
|
96202
96264
|
}
|
|
96203
|
-
},
|
|
96204
|
-
|
|
96205
|
-
})]) : _vm._e()]);
|
|
96206
|
-
}), _vm.selectedItems.length === 0 ? _c('div', {
|
|
96265
|
+
}], null, false, 2638469921)
|
|
96266
|
+
}) : _c('div', {
|
|
96207
96267
|
staticClass: "empty-state"
|
|
96208
|
-
}, [_vm._v("暂无选中项")])
|
|
96268
|
+
}, [_vm._v("暂无选中项")])], 1)])])])]);
|
|
96209
96269
|
};
|
|
96210
|
-
var
|
|
96270
|
+
var ByCascaderPanelProvue_type_template_id_4bdb9820_staticRenderFns = [];
|
|
96211
96271
|
|
|
96212
|
-
;// ./
|
|
96272
|
+
;// ./src/components/cascader-panel-pro/cascaderUtilsPro.js
|
|
96213
96273
|
|
|
96214
96274
|
|
|
96215
96275
|
|
|
@@ -96218,374 +96278,2669 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96218
96278
|
|
|
96219
96279
|
|
|
96220
96280
|
|
|
96221
|
-
|
|
96222
|
-
|
|
96223
|
-
|
|
96224
|
-
|
|
96225
|
-
|
|
96226
|
-
|
|
96227
|
-
|
|
96228
|
-
|
|
96229
|
-
|
|
96230
|
-
|
|
96231
|
-
|
|
96232
|
-
|
|
96233
|
-
|
|
96234
|
-
|
|
96235
|
-
|
|
96236
|
-
|
|
96237
|
-
|
|
96238
|
-
|
|
96239
|
-
|
|
96240
|
-
|
|
96241
|
-
|
|
96242
|
-
|
|
96243
|
-
|
|
96244
|
-
}
|
|
96245
|
-
|
|
96246
|
-
|
|
96247
|
-
|
|
96248
|
-
|
|
96249
|
-
|
|
96250
|
-
|
|
96251
|
-
|
|
96252
|
-
|
|
96281
|
+
|
|
96282
|
+
|
|
96283
|
+
|
|
96284
|
+
|
|
96285
|
+
|
|
96286
|
+
|
|
96287
|
+
|
|
96288
|
+
/**
|
|
96289
|
+
* 级联选择器工具类(Pro 版,独立于 CascaderUtils)
|
|
96290
|
+
*/
|
|
96291
|
+
class CascaderUtilsPro {
|
|
96292
|
+
/**
|
|
96293
|
+
* 估算级联节点标签文本宽度(px)
|
|
96294
|
+
*/
|
|
96295
|
+
static measureCascaderLabelWidth(label, fontSize = 14) {
|
|
96296
|
+
if (!label) {
|
|
96297
|
+
return 0;
|
|
96298
|
+
}
|
|
96299
|
+
const str = String(label);
|
|
96300
|
+
let width = 0;
|
|
96301
|
+
for (let i = 0; i < str.length; i++) {
|
|
96302
|
+
const code = str.charCodeAt(i);
|
|
96303
|
+
width += code > 255 ? fontSize : Math.ceil(fontSize * 0.55);
|
|
96304
|
+
}
|
|
96305
|
+
return width;
|
|
96306
|
+
}
|
|
96307
|
+
|
|
96308
|
+
/**
|
|
96309
|
+
* 根据列内最长标签计算列宽
|
|
96310
|
+
*/
|
|
96311
|
+
static getCascaderColumnWidth(nodes, options = {}) {
|
|
96312
|
+
const {
|
|
96313
|
+
minWidth = 180,
|
|
96314
|
+
maxWidth = 420,
|
|
96315
|
+
extraPadding = 56,
|
|
96316
|
+
hasCheckbox = true
|
|
96317
|
+
} = options;
|
|
96318
|
+
if (!nodes || nodes.length === 0) {
|
|
96319
|
+
return minWidth;
|
|
96320
|
+
}
|
|
96321
|
+
let maxLabelWidth = 0;
|
|
96322
|
+
nodes.forEach(node => {
|
|
96323
|
+
maxLabelWidth = Math.max(maxLabelWidth, this.measureCascaderLabelWidth(node.label));
|
|
96324
|
+
});
|
|
96325
|
+
const checkboxWidth = hasCheckbox ? 28 : 0;
|
|
96326
|
+
const arrowWidth = 24;
|
|
96327
|
+
const contentWidth = maxLabelWidth + extraPadding + checkboxWidth + arrowWidth;
|
|
96328
|
+
return Math.min(maxWidth, Math.max(minWidth, Math.ceil(contentWidth)));
|
|
96329
|
+
}
|
|
96330
|
+
|
|
96331
|
+
/**
|
|
96332
|
+
* 判断项目是否禁用
|
|
96333
|
+
* @param {Object} item - 项目数据
|
|
96334
|
+
* @param {Object} config - 禁用配置
|
|
96335
|
+
* @param {String} config.disabledField - 禁用字段名
|
|
96336
|
+
* @param {*} config.disabledValue - 禁用值
|
|
96337
|
+
* @param {Function} config.disabledCheck - 自定义禁用判断函数
|
|
96338
|
+
* @returns {Boolean} 是否禁用
|
|
96339
|
+
*/
|
|
96340
|
+
static isItemDisabled(item, config) {
|
|
96341
|
+
const {
|
|
96342
|
+
disabledField,
|
|
96343
|
+
disabledValue,
|
|
96344
|
+
disabledCheck
|
|
96345
|
+
} = config;
|
|
96346
|
+
|
|
96347
|
+
// 优先使用自定义禁用判断函数
|
|
96348
|
+
if (disabledCheck && typeof disabledCheck === 'function') {
|
|
96349
|
+
return disabledCheck(item);
|
|
96350
|
+
}
|
|
96351
|
+
|
|
96352
|
+
// 检查直接的 disabled 属性
|
|
96353
|
+
if (item.disabled === true) {
|
|
96354
|
+
return true;
|
|
96355
|
+
}
|
|
96356
|
+
|
|
96357
|
+
// 使用字段判断
|
|
96358
|
+
const fieldValue = item[disabledField];
|
|
96359
|
+
if (fieldValue !== undefined) {
|
|
96360
|
+
return fieldValue === disabledValue;
|
|
96361
|
+
}
|
|
96362
|
+
return false;
|
|
96363
|
+
}
|
|
96364
|
+
|
|
96365
|
+
/**
|
|
96366
|
+
* 检查路径上是否存在禁选项
|
|
96367
|
+
* @param {Array} tree - 树形数据
|
|
96368
|
+
* @param {Array} path - 路径数组
|
|
96369
|
+
* @param {Object} config - 禁用配置
|
|
96370
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96371
|
+
* @returns {Boolean} 路径上是否存在禁选项
|
|
96372
|
+
*/
|
|
96373
|
+
static isPathDisabled(tree, path, config, cascaderProps) {
|
|
96374
|
+
if (!path || path.length === 0) return false;
|
|
96375
|
+
const findPathInTree = (nodes, targetPath, currentIndex = 0) => {
|
|
96376
|
+
if (currentIndex >= targetPath.length) return false;
|
|
96377
|
+
for (const node of nodes) {
|
|
96378
|
+
if (node[cascaderProps.value] === targetPath[currentIndex]) {
|
|
96379
|
+
// 检查当前节点是否禁用
|
|
96380
|
+
if (this.isItemDisabled(node, config)) {
|
|
96381
|
+
return true;
|
|
96382
|
+
}
|
|
96383
|
+
|
|
96384
|
+
// 如果还有下一级,继续检查
|
|
96385
|
+
if (currentIndex < targetPath.length - 1 && node[cascaderProps.children]) {
|
|
96386
|
+
return findPathInTree(node[cascaderProps.children], targetPath, currentIndex + 1);
|
|
96387
|
+
}
|
|
96388
|
+
|
|
96389
|
+
// 如果已经到达路径末尾,返回false(路径上没有禁选项)
|
|
96390
|
+
return false;
|
|
96391
|
+
}
|
|
96392
|
+
}
|
|
96393
|
+
return false;
|
|
96394
|
+
};
|
|
96395
|
+
return findPathInTree(tree, path);
|
|
96396
|
+
}
|
|
96397
|
+
|
|
96398
|
+
/**
|
|
96399
|
+
* 设置禁用项
|
|
96400
|
+
* @param {Array} options - 选项数据
|
|
96401
|
+
* @param {Object} config - 禁用配置
|
|
96402
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96403
|
+
*/
|
|
96404
|
+
static setDisabledItems(options, config, cascaderProps) {
|
|
96405
|
+
const processItems = items => {
|
|
96406
|
+
items.forEach(item => {
|
|
96407
|
+
// 判断是否禁用
|
|
96408
|
+
if (this.isItemDisabled(item, config)) {
|
|
96409
|
+
item.disabled = true;
|
|
96410
|
+
}
|
|
96411
|
+
// 递归处理子项
|
|
96412
|
+
if (item[cascaderProps.children]) {
|
|
96413
|
+
processItems(item[cascaderProps.children]);
|
|
96414
|
+
}
|
|
96415
|
+
});
|
|
96416
|
+
};
|
|
96417
|
+
processItems(options);
|
|
96418
|
+
}
|
|
96419
|
+
|
|
96420
|
+
/**
|
|
96421
|
+
* 统计总项目数(排除禁用项和路径上有禁选项的项)
|
|
96422
|
+
* @param {Array} options - 选项数据
|
|
96423
|
+
* @param {Object} config - 禁用配置
|
|
96424
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96425
|
+
* @returns {Number} 总项目数
|
|
96426
|
+
*/
|
|
96427
|
+
static countTotalItems(options, config, cascaderProps) {
|
|
96428
|
+
let totalCount = 0;
|
|
96429
|
+
const countItems = (items, currentPath = []) => {
|
|
96430
|
+
items.forEach(item => {
|
|
96431
|
+
const newPath = [...currentPath, item[cascaderProps.value]];
|
|
96432
|
+
|
|
96433
|
+
// 检查当前节点是否禁用
|
|
96434
|
+
const isCurrentDisabled = this.isItemDisabled(item, config);
|
|
96435
|
+
if (!item[cascaderProps.children]) {
|
|
96436
|
+
// 只统计非禁用项且路径上没有禁选项的叶子节点
|
|
96437
|
+
if (!isCurrentDisabled && !this.isPathDisabled(options, newPath, config, cascaderProps)) {
|
|
96438
|
+
totalCount++;
|
|
96439
|
+
}
|
|
96440
|
+
} else {
|
|
96441
|
+
// 如果当前节点禁用,则其所有子节点都不可选
|
|
96442
|
+
if (!isCurrentDisabled) {
|
|
96443
|
+
countItems(item[cascaderProps.children], newPath);
|
|
96444
|
+
}
|
|
96445
|
+
}
|
|
96446
|
+
});
|
|
96447
|
+
};
|
|
96448
|
+
countItems(options);
|
|
96449
|
+
return totalCount;
|
|
96450
|
+
}
|
|
96451
|
+
|
|
96452
|
+
/**
|
|
96453
|
+
* 在树形数据中搜索
|
|
96454
|
+
* @param {Array} tree - 树形数据
|
|
96455
|
+
* @param {String} keyword - 搜索关键词
|
|
96456
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96457
|
+
* @returns {Array} 搜索结果
|
|
96458
|
+
*/
|
|
96459
|
+
static searchInTree(tree, keyword, cascaderProps) {
|
|
96460
|
+
const result = [];
|
|
96461
|
+
const labelKey = cascaderProps.label || 'label';
|
|
96462
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
96463
|
+
tree.forEach(node => {
|
|
96464
|
+
const label = node[labelKey];
|
|
96465
|
+
if (label && label.includes(keyword)) {
|
|
96466
|
+
result.push({
|
|
96467
|
+
...node
|
|
96468
|
+
});
|
|
96469
|
+
} else if (node[childrenKey]) {
|
|
96470
|
+
const matchedChildren = this.searchInTree(node[childrenKey], keyword, cascaderProps);
|
|
96471
|
+
if (matchedChildren.length > 0) {
|
|
96472
|
+
result.push({
|
|
96473
|
+
...node,
|
|
96474
|
+
[childrenKey]: matchedChildren
|
|
96475
|
+
});
|
|
96476
|
+
}
|
|
96477
|
+
}
|
|
96478
|
+
});
|
|
96479
|
+
return result;
|
|
96480
|
+
}
|
|
96481
|
+
|
|
96482
|
+
/**
|
|
96483
|
+
* 基于扁平 store 快速搜索(父节点命中时直接复用 raw 子树,跳过子级遍历)
|
|
96484
|
+
*/
|
|
96485
|
+
static searchFromStore(store, keyword, cascaderProps) {
|
|
96486
|
+
if (!store || !keyword) {
|
|
96487
|
+
return [];
|
|
96488
|
+
}
|
|
96489
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
96490
|
+
const walk = parentId => {
|
|
96491
|
+
const childIds = parentId == null ? store.rootIds : store.childrenByParentId.get(parentId) || [];
|
|
96492
|
+
const result = [];
|
|
96493
|
+
for (let i = 0; i < childIds.length; i++) {
|
|
96494
|
+
const node = store.nodeById.get(childIds[i]);
|
|
96495
|
+
if (!node) {
|
|
96496
|
+
continue;
|
|
96497
|
+
}
|
|
96498
|
+
const label = node.label || '';
|
|
96499
|
+
if (label.includes(keyword)) {
|
|
96500
|
+
result.push({
|
|
96501
|
+
...node.raw
|
|
96502
|
+
});
|
|
96503
|
+
} else if (!node.isLeaf) {
|
|
96504
|
+
const matchedChildren = walk(node.id);
|
|
96505
|
+
if (matchedChildren.length > 0) {
|
|
96506
|
+
result.push({
|
|
96507
|
+
...node.raw,
|
|
96508
|
+
[childrenKey]: matchedChildren
|
|
96509
|
+
});
|
|
96510
|
+
}
|
|
96511
|
+
}
|
|
96512
|
+
}
|
|
96513
|
+
return result;
|
|
96514
|
+
};
|
|
96515
|
+
return walk(null);
|
|
96516
|
+
}
|
|
96517
|
+
|
|
96518
|
+
/**
|
|
96519
|
+
* 获取叶子节点的值
|
|
96520
|
+
* @param {Array} tree - 树形数据
|
|
96521
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96522
|
+
* @returns {Array} 叶子节点值数组
|
|
96523
|
+
*/
|
|
96524
|
+
static getLeafValues(tree, cascaderProps) {
|
|
96525
|
+
const leafValues = [];
|
|
96526
|
+
const traverse = nodes => {
|
|
96527
|
+
nodes.forEach(node => {
|
|
96528
|
+
if (!node[cascaderProps.children]) {
|
|
96529
|
+
leafValues.push(node[cascaderProps.value]);
|
|
96530
|
+
} else {
|
|
96531
|
+
traverse(node[cascaderProps.children]);
|
|
96532
|
+
}
|
|
96533
|
+
});
|
|
96534
|
+
};
|
|
96535
|
+
traverse(tree);
|
|
96536
|
+
return leafValues;
|
|
96537
|
+
}
|
|
96538
|
+
|
|
96539
|
+
/**
|
|
96540
|
+
* 获取所有叶子节点的路径(排除禁用项和路径上有禁选项的项)
|
|
96541
|
+
* @param {Array} tree - 树形数据
|
|
96542
|
+
* @param {Object} config - 禁用配置
|
|
96543
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96544
|
+
* @returns {Array} 路径数组
|
|
96545
|
+
*/
|
|
96546
|
+
static getAllLeafPaths(tree, config, cascaderProps) {
|
|
96547
|
+
const paths = [];
|
|
96548
|
+
const traverse = (nodes, currentPath = []) => {
|
|
96549
|
+
nodes.forEach(node => {
|
|
96550
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96551
|
+
|
|
96552
|
+
// 检查当前节点是否禁用
|
|
96553
|
+
const isCurrentDisabled = this.isItemDisabled(node, config);
|
|
96554
|
+
if (!node[cascaderProps.children]) {
|
|
96555
|
+
// 只包含非禁用项且路径上没有禁选项的叶子节点
|
|
96556
|
+
if (!isCurrentDisabled && !this.isPathDisabled(tree, newPath, config, cascaderProps)) {
|
|
96557
|
+
paths.push(newPath);
|
|
96558
|
+
}
|
|
96559
|
+
} else {
|
|
96560
|
+
// 如果当前节点禁用,则其所有子节点都不可选
|
|
96561
|
+
if (!isCurrentDisabled) {
|
|
96562
|
+
traverse(node[cascaderProps.children], newPath);
|
|
96563
|
+
}
|
|
96564
|
+
}
|
|
96565
|
+
});
|
|
96566
|
+
};
|
|
96567
|
+
traverse(tree);
|
|
96568
|
+
return paths;
|
|
96569
|
+
}
|
|
96570
|
+
|
|
96571
|
+
/**
|
|
96572
|
+
* 根据路径查找节点
|
|
96573
|
+
* @param {Array} tree - 树形数据
|
|
96574
|
+
* @param {Array} path - 路径数组
|
|
96575
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96576
|
+
* @returns {Object|null} 找到的节点
|
|
96577
|
+
*/
|
|
96578
|
+
static findNodeByPath(tree, path, cascaderProps) {
|
|
96579
|
+
if (!path || path.length === 0) return null;
|
|
96580
|
+
const findInTree = (nodes, targetPath) => {
|
|
96581
|
+
for (const node of nodes) {
|
|
96582
|
+
if (node[cascaderProps.value] == targetPath[0]) {
|
|
96583
|
+
if (targetPath.length === 1) {
|
|
96584
|
+
return node;
|
|
96585
|
+
} else if (node[cascaderProps.children]) {
|
|
96586
|
+
return findInTree(node[cascaderProps.children], targetPath.slice(1));
|
|
96587
|
+
}
|
|
96588
|
+
}
|
|
96589
|
+
}
|
|
96590
|
+
return null;
|
|
96591
|
+
};
|
|
96592
|
+
return findInTree(tree, path);
|
|
96593
|
+
}
|
|
96594
|
+
|
|
96595
|
+
/**
|
|
96596
|
+
* 基于 selectedValues 构建已选项列表
|
|
96597
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96598
|
+
* @param {Array} options - 选项数据
|
|
96599
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96600
|
+
* @returns {Array} 已选项列表
|
|
96601
|
+
*/
|
|
96602
|
+
static buildSelectedItemsFromValues(selectedValues, options, cascaderProps) {
|
|
96603
|
+
const items = [];
|
|
96604
|
+
selectedValues.forEach(path => {
|
|
96605
|
+
if (path.length > 0) {
|
|
96606
|
+
const leafValue = path[path.length - 1];
|
|
96607
|
+
// 从原始数据中查找对应的节点信息
|
|
96608
|
+
const node = this.findNodeByPath(options, path, cascaderProps);
|
|
96609
|
+
if (node) {
|
|
96610
|
+
// 包含完整的节点数据,以便访问额外的字段(如子标题字段)
|
|
96611
|
+
items.push({
|
|
96612
|
+
...node,
|
|
96613
|
+
// 展开所有原始节点数据
|
|
96614
|
+
value: leafValue,
|
|
96615
|
+
label: node[cascaderProps.label],
|
|
96616
|
+
path: path
|
|
96617
|
+
});
|
|
96618
|
+
}
|
|
96619
|
+
}
|
|
96620
|
+
});
|
|
96621
|
+
return items;
|
|
96622
|
+
}
|
|
96623
|
+
|
|
96624
|
+
/**
|
|
96625
|
+
* 从自研面板 selection 直接构建已选项(紧凑模式,避免生成万级路径数组)
|
|
96626
|
+
*/
|
|
96627
|
+
static buildSelectedItemsFromSelection(store, selection, options, cascaderProps) {
|
|
96628
|
+
if (!store || !selection) {
|
|
96629
|
+
return [];
|
|
96630
|
+
}
|
|
96631
|
+
const items = [];
|
|
96632
|
+
selection.selectedLeafSet.forEach(leafValue => {
|
|
96633
|
+
const path = store.pathByLeafValue.get(leafValue);
|
|
96634
|
+
const node = store.nodeByValue.get(leafValue);
|
|
96635
|
+
if (!path || !node) {
|
|
96636
|
+
return;
|
|
96637
|
+
}
|
|
96638
|
+
items.push({
|
|
96639
|
+
...node.raw,
|
|
96640
|
+
value: leafValue,
|
|
96641
|
+
label: node.label,
|
|
96642
|
+
path
|
|
96643
|
+
});
|
|
96644
|
+
});
|
|
96645
|
+
return items;
|
|
96646
|
+
}
|
|
96647
|
+
|
|
96648
|
+
/**
|
|
96649
|
+
* 获取搜索范围内的选中值
|
|
96650
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96651
|
+
* @param {Array} searchOptions - 搜索结果
|
|
96652
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96653
|
+
* @returns {Array} 搜索范围内的选中值
|
|
96654
|
+
*/
|
|
96655
|
+
static getSearchSelectedValues(selectedValues, searchOptions, cascaderProps) {
|
|
96656
|
+
const searchLeafValues = this.getLeafValues(searchOptions, cascaderProps);
|
|
96657
|
+
return selectedValues.filter(path => {
|
|
96658
|
+
const leafValue = path[path.length - 1];
|
|
96659
|
+
return searchLeafValues.includes(leafValue);
|
|
96660
|
+
});
|
|
96661
|
+
}
|
|
96662
|
+
|
|
96663
|
+
/**
|
|
96664
|
+
* 检查父项的所有子项是否都被选中
|
|
96665
|
+
* @param {Object} parentNode - 父节点
|
|
96666
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96667
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96668
|
+
* @returns {Boolean} 是否所有子项都被选中
|
|
96669
|
+
*/
|
|
96670
|
+
static isParentFullySelected(parentNode, selectedValues, cascaderProps) {
|
|
96671
|
+
if (!parentNode[cascaderProps.children]) {
|
|
96672
|
+
return false;
|
|
96673
|
+
}
|
|
96674
|
+
|
|
96675
|
+
// 获取父项的所有叶子节点
|
|
96676
|
+
const allLeafValues = this.getLeafValues([parentNode], cascaderProps);
|
|
96677
|
+
|
|
96678
|
+
// 检查所有叶子节点是否都在选中值中
|
|
96679
|
+
return allLeafValues.every(leafValue => {
|
|
96680
|
+
return selectedValues.some(path => {
|
|
96681
|
+
const pathLeafValue = path[path.length - 1];
|
|
96682
|
+
return pathLeafValue === leafValue;
|
|
96683
|
+
});
|
|
96684
|
+
});
|
|
96685
|
+
}
|
|
96686
|
+
|
|
96687
|
+
/**
|
|
96688
|
+
* 根据路径获取对应的标签数组
|
|
96689
|
+
* @param {Array} path - 节点路径
|
|
96690
|
+
* @param {Array} options - 选项数据
|
|
96691
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96692
|
+
* @returns {Array} 标签数组
|
|
96693
|
+
*/
|
|
96694
|
+
static getPathLabels(path, options, cascaderProps) {
|
|
96695
|
+
const labels = [];
|
|
96696
|
+
let currentNodes = options;
|
|
96697
|
+
for (let i = 0; i < path.length; i++) {
|
|
96698
|
+
const targetValue = path[i];
|
|
96699
|
+
const foundNode = currentNodes.find(node => node[cascaderProps.value] === targetValue);
|
|
96700
|
+
if (foundNode) {
|
|
96701
|
+
labels.push(foundNode[cascaderProps.label]);
|
|
96702
|
+
if (foundNode[cascaderProps.children] && i < path.length - 1) {
|
|
96703
|
+
currentNodes = foundNode[cascaderProps.children];
|
|
96704
|
+
}
|
|
96705
|
+
} else {
|
|
96706
|
+
labels.push(targetValue); // 如果找不到对应的节点,使用原始值
|
|
96707
|
+
}
|
|
96708
|
+
}
|
|
96709
|
+
return labels;
|
|
96710
|
+
}
|
|
96711
|
+
|
|
96712
|
+
/**
|
|
96713
|
+
* 构建完整的节点信息对象
|
|
96714
|
+
* @param {Object} node - 原始节点数据
|
|
96715
|
+
* @param {Array} path - 节点路径
|
|
96716
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96717
|
+
* @param {Array} options - 选项数据
|
|
96718
|
+
* @param {Boolean} isAggregated - 是否为聚合项
|
|
96719
|
+
* @returns {Object} 完整的节点信息对象
|
|
96720
|
+
*/
|
|
96721
|
+
static buildCompleteNodeInfo(node, path, cascaderProps, options, isAggregated = false) {
|
|
96722
|
+
const hasChildren = !!node[cascaderProps.children];
|
|
96723
|
+
const level = path.length - 1;
|
|
96724
|
+
return {
|
|
96725
|
+
// 展开原始节点的所有属性,以便访问额外的字段(如子标题字段)
|
|
96726
|
+
...node,
|
|
96727
|
+
// 基本属性(覆盖原始节点中的同名属性)
|
|
96728
|
+
value: node[cascaderProps.value],
|
|
96729
|
+
label: node[cascaderProps.label],
|
|
96730
|
+
path: path,
|
|
96731
|
+
isAggregated: isAggregated,
|
|
96732
|
+
// 节点结构信息
|
|
96733
|
+
hasChildren: hasChildren,
|
|
96734
|
+
level: level,
|
|
96735
|
+
children: hasChildren ? node[cascaderProps.children] : undefined,
|
|
96736
|
+
// 级联面板相关属性
|
|
96737
|
+
checked: true,
|
|
96738
|
+
indeterminate: false,
|
|
96739
|
+
loaded: true,
|
|
96740
|
+
loading: false,
|
|
96741
|
+
// 原始数据
|
|
96742
|
+
data: node,
|
|
96743
|
+
// 路径相关
|
|
96744
|
+
pathLabels: this.getPathLabels(path, options, cascaderProps),
|
|
96745
|
+
// 其他可能需要的属性
|
|
96746
|
+
config: cascaderProps,
|
|
96747
|
+
parent: null,
|
|
96748
|
+
// 在级联面板中会动态设置
|
|
96749
|
+
pathNodes: null // 在级联面板中会动态设置
|
|
96750
|
+
};
|
|
96751
|
+
}
|
|
96752
|
+
|
|
96753
|
+
/**
|
|
96754
|
+
* 从自研面板的选中状态递归构建聚合列表(与 getAggregatedSelectedItems 逻辑一致)
|
|
96755
|
+
* 父节点全选时只返回父项;半选时向下展开到具体子项
|
|
96756
|
+
*/
|
|
96757
|
+
static getAggregatedItemsFromSelection(store, selection, options, cascaderProps) {
|
|
96758
|
+
if (!store || !selection) {
|
|
96759
|
+
return [];
|
|
96760
|
+
}
|
|
96761
|
+
const items = [];
|
|
96762
|
+
const walk = nodeId => {
|
|
96763
|
+
const node = store.nodeById.get(nodeId);
|
|
96764
|
+
if (!node || node.disabled) {
|
|
96765
|
+
return;
|
|
96766
|
+
}
|
|
96767
|
+
const state = selection.getCheckState(nodeId);
|
|
96768
|
+
if (state === 'unchecked' || state === 'disabled') {
|
|
96769
|
+
return;
|
|
96770
|
+
}
|
|
96771
|
+
if (!node.isLeaf && state === 'checked') {
|
|
96772
|
+
items.push(this.buildCompleteNodeInfo(node.raw, node.path, cascaderProps, options, true));
|
|
96773
|
+
return;
|
|
96774
|
+
}
|
|
96775
|
+
if (node.isLeaf && state === 'checked') {
|
|
96776
|
+
items.push(this.buildCompleteNodeInfo(node.raw, node.path, cascaderProps, options, false));
|
|
96777
|
+
return;
|
|
96778
|
+
}
|
|
96779
|
+
const childIds = node.childIds || [];
|
|
96780
|
+
childIds.forEach(childId => walk(childId));
|
|
96781
|
+
};
|
|
96782
|
+
store.rootIds.forEach(rootId => walk(rootId));
|
|
96783
|
+
return items;
|
|
96784
|
+
}
|
|
96785
|
+
|
|
96786
|
+
/** @deprecated 使用 getAggregatedItemsFromSelection */
|
|
96787
|
+
static getAggregatedItemsFromRootSelection(store, selection, options, cascaderProps) {
|
|
96788
|
+
return this.getAggregatedItemsFromSelection(store, selection, options, cascaderProps);
|
|
96789
|
+
}
|
|
96790
|
+
static getAggregatedEmitValues(items, prefix = '__parent__') {
|
|
96791
|
+
return items.map(item => {
|
|
96792
|
+
if (item.isAggregated) {
|
|
96793
|
+
return this.addParentNodePrefix(item.value, prefix);
|
|
96794
|
+
}
|
|
96795
|
+
return item.value;
|
|
96796
|
+
});
|
|
96797
|
+
}
|
|
96798
|
+
|
|
96799
|
+
/**
|
|
96800
|
+
* 获取聚合模式下的选中项(如果父项完全选中,则只返回父项)
|
|
96801
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96802
|
+
* @param {Array} options - 选项数据
|
|
96803
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96804
|
+
* @returns {Array} 聚合后的选中项列表
|
|
96805
|
+
*/
|
|
96806
|
+
static getAggregatedSelectedItems(selectedValues, options, cascaderProps) {
|
|
96807
|
+
const items = [];
|
|
96808
|
+
const processedPaths = new Set();
|
|
96809
|
+
|
|
96810
|
+
// 递归检查每个节点
|
|
96811
|
+
const checkNode = (nodes, currentPath = []) => {
|
|
96812
|
+
nodes.forEach(node => {
|
|
96813
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96814
|
+
const pathKey = newPath.join(',');
|
|
96815
|
+
|
|
96816
|
+
// 如果这个路径已经被处理过,跳过
|
|
96817
|
+
if (processedPaths.has(pathKey)) {
|
|
96818
|
+
return;
|
|
96819
|
+
}
|
|
96820
|
+
|
|
96821
|
+
// 检查当前节点是否完全选中
|
|
96822
|
+
if (this.isParentFullySelected(node, selectedValues, cascaderProps)) {
|
|
96823
|
+
// 父项完全选中,添加父项
|
|
96824
|
+
items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, true));
|
|
96825
|
+
|
|
96826
|
+
// 标记所有子路径为已处理
|
|
96827
|
+
const allLeafValues = this.getLeafValues([node], cascaderProps);
|
|
96828
|
+
selectedValues.forEach(path => {
|
|
96829
|
+
const pathLeafValue = path[path.length - 1];
|
|
96830
|
+
if (allLeafValues.includes(pathLeafValue)) {
|
|
96831
|
+
processedPaths.add(path.join(','));
|
|
96832
|
+
}
|
|
96833
|
+
});
|
|
96834
|
+
} else if (!node[cascaderProps.children]) {
|
|
96835
|
+
// 叶子节点,检查是否在选中值中且未被父项覆盖
|
|
96836
|
+
const leafValue = node[cascaderProps.value];
|
|
96837
|
+
const isSelected = selectedValues.some(path => {
|
|
96838
|
+
const pathLeafValue = path[path.length - 1];
|
|
96839
|
+
return pathLeafValue === leafValue;
|
|
96840
|
+
});
|
|
96841
|
+
if (isSelected && !processedPaths.has(pathKey)) {
|
|
96842
|
+
items.push(this.buildCompleteNodeInfo(node, newPath, cascaderProps, options, false));
|
|
96843
|
+
processedPaths.add(pathKey);
|
|
96844
|
+
}
|
|
96845
|
+
} else {
|
|
96846
|
+
// 继续检查子节点
|
|
96847
|
+
checkNode(node[cascaderProps.children], newPath);
|
|
96848
|
+
}
|
|
96849
|
+
});
|
|
96850
|
+
};
|
|
96851
|
+
checkNode(options);
|
|
96852
|
+
return items;
|
|
96853
|
+
}
|
|
96854
|
+
|
|
96855
|
+
/**
|
|
96856
|
+
* 获取聚合模式下的选中值(只返回最终选中的值,不包含被聚合的子项)
|
|
96857
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96858
|
+
* @param {Array} options - 选项数据
|
|
96859
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96860
|
+
* @param {String} prefix - 前缀标识
|
|
96861
|
+
* @returns {Array} 聚合后的选中值
|
|
96862
|
+
*/
|
|
96863
|
+
static getAggregatedSelectedValues(selectedValues, options, cascaderProps, prefix = '__parent__') {
|
|
96864
|
+
const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
|
|
96865
|
+
return aggregatedItems.map(item => {
|
|
96866
|
+
// 如果是聚合项(非叶子节点),添加前缀标识
|
|
96867
|
+
if (item.isAggregated) {
|
|
96868
|
+
return this.addParentNodePrefix(item.value, prefix);
|
|
96869
|
+
}
|
|
96870
|
+
return item.value;
|
|
96871
|
+
});
|
|
96872
|
+
}
|
|
96873
|
+
|
|
96874
|
+
/**
|
|
96875
|
+
* 获取聚合模式下的路径数组(只返回最终选中的路径,不包含被聚合的子项路径)
|
|
96876
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96877
|
+
* @param {Array} options - 选项数据
|
|
96878
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96879
|
+
* @returns {Array} 聚合后的路径数组
|
|
96880
|
+
*/
|
|
96881
|
+
static getAggregatedSelectedPaths(selectedValues, options, cascaderProps) {
|
|
96882
|
+
const aggregatedItems = this.getAggregatedSelectedItems(selectedValues, options, cascaderProps);
|
|
96883
|
+
return aggregatedItems.map(item => item.path);
|
|
96884
|
+
}
|
|
96885
|
+
|
|
96886
|
+
/**
|
|
96887
|
+
* 检查聚合模式下是否全选(所有可选的叶子节点都被选中)
|
|
96888
|
+
* @param {Array} selectedValues - 已选值数组
|
|
96889
|
+
* @param {Array} options - 选项数据
|
|
96890
|
+
* @param {Object} config - 禁用配置
|
|
96891
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96892
|
+
* @returns {Boolean} 是否全选
|
|
96893
|
+
*/
|
|
96894
|
+
static isAggregatedAllSelected(selectedValues, options, config, cascaderProps) {
|
|
96895
|
+
// 获取所有可选的叶子节点
|
|
96896
|
+
const allSelectableLeafValues = this.getAllLeafPaths(options, config, cascaderProps).map(path => path[path.length - 1]); // 获取叶子节点的值
|
|
96897
|
+
|
|
96898
|
+
// 获取当前选中的叶子节点值
|
|
96899
|
+
const selectedLeafValues = selectedValues.map(path => path[path.length - 1]);
|
|
96900
|
+
|
|
96901
|
+
// 检查所有可选的叶子节点是否都被选中
|
|
96902
|
+
return allSelectableLeafValues.every(leafValue => selectedLeafValues.includes(leafValue));
|
|
96903
|
+
}
|
|
96904
|
+
|
|
96905
|
+
/**
|
|
96906
|
+
* 检查值是否为非叶子节点标识
|
|
96907
|
+
* @param {*} value - 要检查的值
|
|
96908
|
+
* @param {String} prefix - 前缀标识
|
|
96909
|
+
* @returns {Boolean} 是否为非叶子节点标识
|
|
96910
|
+
*/
|
|
96911
|
+
static isParentNodeValue(value, prefix = '__parent__') {
|
|
96912
|
+
return typeof value === 'string' && value.startsWith(prefix);
|
|
96913
|
+
}
|
|
96914
|
+
|
|
96915
|
+
/**
|
|
96916
|
+
* 从非叶子节点标识中提取实际值
|
|
96917
|
+
* @param {String} parentValue - 非叶子节点标识值
|
|
96918
|
+
* @param {String} prefix - 前缀标识
|
|
96919
|
+
* @returns {String} 实际值
|
|
96920
|
+
*/
|
|
96921
|
+
static extractParentNodeValue(parentValue, prefix = '__parent__') {
|
|
96922
|
+
if (this.isParentNodeValue(parentValue, prefix)) {
|
|
96923
|
+
return parentValue.substring(prefix.length);
|
|
96924
|
+
}
|
|
96925
|
+
return parentValue;
|
|
96926
|
+
}
|
|
96927
|
+
|
|
96928
|
+
/**
|
|
96929
|
+
* 为非叶子节点值添加前缀标识
|
|
96930
|
+
* @param {String} value - 原始值
|
|
96931
|
+
* @param {String} prefix - 前缀标识
|
|
96932
|
+
* @returns {String} 带前缀的值
|
|
96933
|
+
*/
|
|
96934
|
+
static addParentNodePrefix(value, prefix = '__parent__') {
|
|
96935
|
+
return prefix + value;
|
|
96936
|
+
}
|
|
96937
|
+
|
|
96938
|
+
/**
|
|
96939
|
+
* 根据非叶子节点值获取其所有叶子节点的路径
|
|
96940
|
+
* @param {String} parentValue - 非叶子节点值
|
|
96941
|
+
* @param {Array} options - 选项数据
|
|
96942
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96943
|
+
* @returns {Array} 叶子节点路径数组
|
|
96944
|
+
*/
|
|
96945
|
+
static getLeafPathsByParentValue(parentValue, options, cascaderProps) {
|
|
96946
|
+
const paths = [];
|
|
96947
|
+
|
|
96948
|
+
// 查找非叶子节点
|
|
96949
|
+
const findParentNode = (nodes, currentPath = []) => {
|
|
96950
|
+
for (const node of nodes) {
|
|
96951
|
+
const newPath = [...currentPath, node[cascaderProps.value]];
|
|
96952
|
+
if (node[cascaderProps.value] == parentValue) {
|
|
96953
|
+
// 找到目标非叶子节点,获取其所有叶子节点路径
|
|
96954
|
+
this.getAllLeafPaths([node], {}, cascaderProps).forEach(leafPath => {
|
|
96955
|
+
// 将叶子节点路径与当前路径合并
|
|
96956
|
+
const fullPath = [...currentPath, ...leafPath];
|
|
96957
|
+
paths.push(fullPath);
|
|
96958
|
+
});
|
|
96959
|
+
return true;
|
|
96960
|
+
}
|
|
96961
|
+
|
|
96962
|
+
// 递归查找子节点
|
|
96963
|
+
if (node[cascaderProps.children] && node[cascaderProps.children].length > 0) {
|
|
96964
|
+
if (findParentNode(node[cascaderProps.children], newPath)) {
|
|
96965
|
+
return true;
|
|
96966
|
+
}
|
|
96967
|
+
}
|
|
96968
|
+
}
|
|
96969
|
+
return false;
|
|
96970
|
+
};
|
|
96971
|
+
findParentNode(options);
|
|
96972
|
+
return paths;
|
|
96973
|
+
}
|
|
96974
|
+
|
|
96975
|
+
/**
|
|
96976
|
+
* 处理包含非叶子节点的值数组,将非叶子节点转换为对应的叶子节点路径
|
|
96977
|
+
* @param {Array} values - 值数组(可能包含非叶子节点标识)
|
|
96978
|
+
* @param {Array} options - 选项数据
|
|
96979
|
+
* @param {Object} cascaderProps - 级联配置
|
|
96980
|
+
* @param {String} prefix - 前缀标识
|
|
96981
|
+
* @returns {Array} 处理后的路径数组
|
|
96982
|
+
*/
|
|
96983
|
+
static processValuesWithParentNodes(values, options, cascaderProps, prefix = '__parent__') {
|
|
96984
|
+
const paths = [];
|
|
96985
|
+
for (const value of values) {
|
|
96986
|
+
if (this.isParentNodeValue(value, prefix)) {
|
|
96987
|
+
// 非叶子节点,获取其所有叶子节点路径
|
|
96988
|
+
const actualValue = this.extractParentNodeValue(value, prefix);
|
|
96989
|
+
const leafPaths = this.getLeafPathsByParentValue(actualValue, options, cascaderProps);
|
|
96990
|
+
paths.push(...leafPaths);
|
|
96991
|
+
} else {
|
|
96992
|
+
// 普通值,查找对应的路径
|
|
96993
|
+
const valuePaths = this.findPathsByValues([value], options, cascaderProps);
|
|
96994
|
+
paths.push(...valuePaths);
|
|
96995
|
+
}
|
|
96996
|
+
}
|
|
96997
|
+
return paths;
|
|
96998
|
+
}
|
|
96999
|
+
|
|
97000
|
+
/**
|
|
97001
|
+
* 根据values找到对应的路径(支持非叶子节点)
|
|
97002
|
+
* @param {Array} values - 值数组
|
|
97003
|
+
* @param {Array} options - 选项数据
|
|
97004
|
+
* @param {Object} cascaderProps - 级联配置
|
|
97005
|
+
* @returns {Array} 路径数组
|
|
97006
|
+
*/
|
|
97007
|
+
static findPathsByValues(values, options, cascaderProps) {
|
|
97008
|
+
const paths = [];
|
|
97009
|
+
const findPath = (nodes, targetValues, currentPath = []) => {
|
|
97010
|
+
for (const option of nodes) {
|
|
97011
|
+
const newPath = [...currentPath, option[cascaderProps.value]];
|
|
97012
|
+
if (targetValues.includes(option[cascaderProps.value])) {
|
|
97013
|
+
// 如果是叶子节点(没有children属性),添加到路径中
|
|
97014
|
+
if (!option[cascaderProps.children]) {
|
|
97015
|
+
paths.push(newPath);
|
|
97016
|
+
}
|
|
97017
|
+
}
|
|
97018
|
+
|
|
97019
|
+
// 递归查找子节点
|
|
97020
|
+
if (option[cascaderProps.children] && option[cascaderProps.children].length > 0) {
|
|
97021
|
+
findPath(option[cascaderProps.children], targetValues, newPath);
|
|
97022
|
+
}
|
|
97023
|
+
}
|
|
97024
|
+
};
|
|
97025
|
+
findPath(options, values);
|
|
97026
|
+
return paths;
|
|
97027
|
+
}
|
|
97028
|
+
}
|
|
97029
|
+
;// ./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=23086f90
|
|
97030
|
+
var VirtualCascaderPanelvue_type_template_id_23086f90_render = function render() {
|
|
97031
|
+
var _vm = this,
|
|
97032
|
+
_c = _vm._self._c;
|
|
97033
|
+
return _c('div', {
|
|
97034
|
+
staticClass: "el-cascader-panel vcp-panel is-bordered",
|
|
97035
|
+
style: {
|
|
97036
|
+
height: _vm.height + 'px'
|
|
97037
|
+
}
|
|
97038
|
+
}, _vm._l(_vm.columns, function (columnNodes, colIndex) {
|
|
97039
|
+
return _c('div', {
|
|
97040
|
+
key: 'col-' + colIndex,
|
|
97041
|
+
staticClass: "el-cascader-menu vcp-menu",
|
|
97042
|
+
class: {
|
|
97043
|
+
'is-last': colIndex === _vm.columns.length - 1
|
|
97044
|
+
},
|
|
97045
|
+
style: _vm.getColumnStyle(colIndex, columnNodes)
|
|
97046
|
+
}, [_c('VcpVirtualList', {
|
|
97047
|
+
attrs: {
|
|
97048
|
+
"items": columnNodes,
|
|
97049
|
+
"item-height": _vm.itemHeight,
|
|
97050
|
+
"height": _vm.height
|
|
97051
|
+
},
|
|
97052
|
+
scopedSlots: _vm._u([{
|
|
97053
|
+
key: "default",
|
|
97054
|
+
fn: function ({
|
|
97055
|
+
item
|
|
97056
|
+
}) {
|
|
97057
|
+
return [_c('li', {
|
|
97058
|
+
key: 'vcp-node-' + item.id,
|
|
97059
|
+
staticClass: "el-cascader-node",
|
|
97060
|
+
class: _vm.getNodeClass(item, colIndex),
|
|
97061
|
+
attrs: {
|
|
97062
|
+
"role": "menuitem",
|
|
97063
|
+
"id": 'vcp-node-' + item.id,
|
|
97064
|
+
"aria-expanded": !item.isLeaf && _vm.isExpanded(item, colIndex),
|
|
97065
|
+
"tabindex": _vm.isActive(item, colIndex) ? 0 : -1
|
|
97066
|
+
},
|
|
97067
|
+
on: {
|
|
97068
|
+
"click": function ($event) {
|
|
97069
|
+
return _vm.onNodeClick(item, colIndex);
|
|
97070
|
+
}
|
|
97071
|
+
}
|
|
97072
|
+
}, [_vm.multiple ? _c('span', {
|
|
97073
|
+
staticClass: "el-cascader-node__prefix"
|
|
97074
|
+
}, [_c('el-checkbox', {
|
|
97075
|
+
attrs: {
|
|
97076
|
+
"value": _vm.isChecked(item),
|
|
97077
|
+
"indeterminate": _vm.isIndeterminate(item),
|
|
97078
|
+
"disabled": item.disabled || _vm.isViewMode
|
|
97079
|
+
},
|
|
97080
|
+
on: {
|
|
97081
|
+
"change": function ($event) {
|
|
97082
|
+
return _vm.onCheckClick(item, $event);
|
|
97083
|
+
}
|
|
97084
|
+
},
|
|
97085
|
+
nativeOn: {
|
|
97086
|
+
"click": function ($event) {
|
|
97087
|
+
$event.stopPropagation();
|
|
97088
|
+
}
|
|
97089
|
+
}
|
|
97090
|
+
})], 1) : _vm.checkStrictly ? _c('span', {
|
|
97091
|
+
staticClass: "el-cascader-node__prefix",
|
|
97092
|
+
on: {
|
|
97093
|
+
"click": function ($event) {
|
|
97094
|
+
$event.stopPropagation();
|
|
97095
|
+
return _vm.onRadioClick(item);
|
|
97096
|
+
}
|
|
97097
|
+
}
|
|
97098
|
+
}, [_c('el-radio', {
|
|
97099
|
+
attrs: {
|
|
97100
|
+
"value": _vm.singleCheckedValue,
|
|
97101
|
+
"label": item.value,
|
|
97102
|
+
"disabled": item.disabled || _vm.isViewMode
|
|
97103
|
+
},
|
|
97104
|
+
on: {
|
|
97105
|
+
"input": function ($event) {
|
|
97106
|
+
return _vm.onRadioClick(item);
|
|
97107
|
+
}
|
|
97108
|
+
}
|
|
97109
|
+
}, [_c('span')])], 1) : _vm._e(), _c('span', {
|
|
97110
|
+
staticClass: "el-cascader-node__label"
|
|
97111
|
+
}, [_vm._v(_vm._s(item.label))]), !item.isLeaf ? _c('span', {
|
|
97112
|
+
staticClass: "el-cascader-node__postfix"
|
|
97113
|
+
}, [_c('i', {
|
|
97114
|
+
staticClass: "el-icon-arrow-right el-cascader-node__icon-arrow"
|
|
97115
|
+
})]) : _vm._e()])];
|
|
97116
|
+
}
|
|
97117
|
+
}], null, true)
|
|
97118
|
+
})], 1);
|
|
97119
|
+
}), 0);
|
|
97120
|
+
};
|
|
97121
|
+
var VirtualCascaderPanelvue_type_template_id_23086f90_staticRenderFns = [];
|
|
97122
|
+
|
|
97123
|
+
;// ./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
|
|
97124
|
+
var VirtualListvue_type_template_id_43cb1148_render = function render() {
|
|
97125
|
+
var _vm = this,
|
|
97126
|
+
_c = _vm._self._c;
|
|
97127
|
+
return _c('div', {
|
|
97128
|
+
ref: "scroller",
|
|
97129
|
+
staticClass: "vcp-virtual-scroller el-scrollbar__wrap",
|
|
97130
|
+
on: {
|
|
97131
|
+
"scroll": _vm.onScroll
|
|
97132
|
+
}
|
|
97133
|
+
}, [!_vm.enableVirtual ? _c('ul', {
|
|
97134
|
+
staticClass: "el-cascader-menu__list vcp-native-list"
|
|
97135
|
+
}, [_vm._l(_vm.items, function (item, index) {
|
|
97136
|
+
return [_vm._t("default", null, {
|
|
97137
|
+
"item": item,
|
|
97138
|
+
"index": index
|
|
97139
|
+
})];
|
|
97140
|
+
})], 2) : [_c('div', {
|
|
97141
|
+
staticClass: "vcp-virtual-phantom",
|
|
97142
|
+
style: {
|
|
97143
|
+
height: _vm.totalHeight + 'px'
|
|
97144
|
+
}
|
|
97145
|
+
}), _c('ul', {
|
|
97146
|
+
staticClass: "el-cascader-menu__list vcp-virtual-list",
|
|
97147
|
+
style: {
|
|
97148
|
+
transform: 'translateY(' + _vm.offsetY + 'px)'
|
|
97149
|
+
}
|
|
97150
|
+
}, [_vm._l(_vm.visibleItems, function (item, index) {
|
|
97151
|
+
return [_vm._t("default", null, {
|
|
97152
|
+
"item": item,
|
|
97153
|
+
"index": _vm.startIndex + index
|
|
97154
|
+
})];
|
|
97155
|
+
})], 2)]], 2);
|
|
97156
|
+
};
|
|
97157
|
+
var VirtualListvue_type_template_id_43cb1148_staticRenderFns = [];
|
|
97158
|
+
|
|
97159
|
+
;// ./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
|
|
97160
|
+
/* harmony default export */ var VirtualListvue_type_script_lang_js = ({
|
|
97161
|
+
name: 'VcpVirtualList',
|
|
97162
|
+
props: {
|
|
97163
|
+
items: {
|
|
97164
|
+
type: Array,
|
|
97165
|
+
default: () => []
|
|
97166
|
+
},
|
|
97167
|
+
itemHeight: {
|
|
97168
|
+
type: Number,
|
|
97169
|
+
default: 34
|
|
97170
|
+
},
|
|
97171
|
+
height: {
|
|
97172
|
+
type: Number,
|
|
97173
|
+
default: 200
|
|
97174
|
+
},
|
|
97175
|
+
overscan: {
|
|
97176
|
+
type: Number,
|
|
97177
|
+
default: 8
|
|
97178
|
+
},
|
|
97179
|
+
listPadding: {
|
|
97180
|
+
type: Number,
|
|
97181
|
+
default: 12
|
|
97182
|
+
}
|
|
97183
|
+
},
|
|
97184
|
+
data() {
|
|
97185
|
+
return {
|
|
97186
|
+
scrollTop: 0
|
|
97187
|
+
};
|
|
97188
|
+
},
|
|
97189
|
+
computed: {
|
|
97190
|
+
totalHeight() {
|
|
97191
|
+
return this.items.length * this.itemHeight + this.listPadding;
|
|
97192
|
+
},
|
|
97193
|
+
enableVirtual() {
|
|
97194
|
+
return this.totalHeight > this.height;
|
|
97195
|
+
},
|
|
97196
|
+
startIndex() {
|
|
97197
|
+
const index = Math.floor(this.scrollTop / this.itemHeight) - this.overscan;
|
|
97198
|
+
return Math.max(0, index);
|
|
97199
|
+
},
|
|
97200
|
+
endIndex() {
|
|
97201
|
+
const visibleCount = Math.ceil(this.height / this.itemHeight) + this.overscan * 2;
|
|
97202
|
+
return Math.min(this.items.length, this.startIndex + visibleCount);
|
|
97203
|
+
},
|
|
97204
|
+
offsetY() {
|
|
97205
|
+
return this.startIndex * this.itemHeight;
|
|
97206
|
+
},
|
|
97207
|
+
visibleItems() {
|
|
97208
|
+
return this.items.slice(this.startIndex, this.endIndex);
|
|
97209
|
+
}
|
|
97210
|
+
},
|
|
97211
|
+
watch: {
|
|
97212
|
+
items(newItems, oldItems) {
|
|
97213
|
+
if (!this.isSameItemList(newItems, oldItems)) {
|
|
97214
|
+
this.resetScroll();
|
|
97215
|
+
}
|
|
97216
|
+
},
|
|
97217
|
+
enableVirtual(newVal, oldVal) {
|
|
97218
|
+
if (newVal !== oldVal) {
|
|
97219
|
+
this.resetScroll();
|
|
97220
|
+
}
|
|
97221
|
+
}
|
|
97222
|
+
},
|
|
97223
|
+
methods: {
|
|
97224
|
+
isSameItemList(nextItems, prevItems) {
|
|
97225
|
+
if (!nextItems || !prevItems) {
|
|
97226
|
+
return false;
|
|
97227
|
+
}
|
|
97228
|
+
if (nextItems.length !== prevItems.length) {
|
|
97229
|
+
return false;
|
|
97230
|
+
}
|
|
97231
|
+
for (let i = 0; i < nextItems.length; i++) {
|
|
97232
|
+
if (this.getItemKey(nextItems[i]) !== this.getItemKey(prevItems[i])) {
|
|
97233
|
+
return false;
|
|
97234
|
+
}
|
|
97235
|
+
}
|
|
97236
|
+
return true;
|
|
97237
|
+
},
|
|
97238
|
+
getItemKey(item) {
|
|
97239
|
+
if (!item) {
|
|
97240
|
+
return '';
|
|
97241
|
+
}
|
|
97242
|
+
return item.id != null ? item.id : item.value;
|
|
97243
|
+
},
|
|
97244
|
+
onScroll(event) {
|
|
97245
|
+
this.scrollTop = event.target.scrollTop;
|
|
97246
|
+
},
|
|
97247
|
+
resetScroll() {
|
|
97248
|
+
this.scrollTop = 0;
|
|
97249
|
+
if (this.$refs.scroller) {
|
|
97250
|
+
this.$refs.scroller.scrollTop = 0;
|
|
97251
|
+
}
|
|
97252
|
+
}
|
|
97253
|
+
}
|
|
97254
|
+
});
|
|
97255
|
+
;// ./src/components/cascader-panel-pro/VirtualList.vue?vue&type=script&lang=js
|
|
97256
|
+
/* harmony default export */ var cascader_panel_pro_VirtualListvue_type_script_lang_js = (VirtualListvue_type_script_lang_js);
|
|
97257
|
+
;// ./src/components/cascader-panel-pro/VirtualList.vue
|
|
97258
|
+
|
|
97259
|
+
|
|
97260
|
+
|
|
97261
|
+
|
|
97262
|
+
|
|
97263
|
+
/* normalize component */
|
|
97264
|
+
;
|
|
97265
|
+
var VirtualList_component = normalizeComponent(
|
|
97266
|
+
cascader_panel_pro_VirtualListvue_type_script_lang_js,
|
|
97267
|
+
VirtualListvue_type_template_id_43cb1148_render,
|
|
97268
|
+
VirtualListvue_type_template_id_43cb1148_staticRenderFns,
|
|
97269
|
+
false,
|
|
97270
|
+
null,
|
|
97271
|
+
null,
|
|
97272
|
+
null
|
|
97273
|
+
|
|
97274
|
+
)
|
|
97275
|
+
|
|
97276
|
+
/* harmony default export */ var VirtualList = (VirtualList_component.exports);
|
|
97277
|
+
;// ./src/components/cascader-panel-pro/cascaderStorePro.js
|
|
97278
|
+
|
|
97279
|
+
|
|
97280
|
+
|
|
97281
|
+
|
|
97282
|
+
|
|
97283
|
+
|
|
97284
|
+
/**
|
|
97285
|
+
* 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
|
|
97286
|
+
*/
|
|
97287
|
+
|
|
97288
|
+
let nodeIdSeed = 0;
|
|
97289
|
+
function nextId() {
|
|
97290
|
+
nodeIdSeed += 1;
|
|
97291
|
+
return nodeIdSeed;
|
|
97292
|
+
}
|
|
97293
|
+
function resetCascaderStoreIdSeed() {
|
|
97294
|
+
nodeIdSeed = 0;
|
|
97295
|
+
}
|
|
97296
|
+
|
|
97297
|
+
/**
|
|
97298
|
+
* @param {Array} options
|
|
97299
|
+
* @param {Object} config - disabledField/disabledValue/disabledCheck
|
|
97300
|
+
* @param {Object} cascaderProps
|
|
97301
|
+
* @param {Object} utils - CascaderUtilsPro
|
|
97302
|
+
*/
|
|
97303
|
+
function buildCascaderStore(options, config, cascaderProps, utils) {
|
|
97304
|
+
resetCascaderStoreIdSeed();
|
|
97305
|
+
const valueKey = cascaderProps.value || 'value';
|
|
97306
|
+
const labelKey = cascaderProps.label || 'label';
|
|
97307
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
97308
|
+
const disabledKey = cascaderProps.disabled || 'disabled';
|
|
97309
|
+
const nodes = [];
|
|
97310
|
+
const nodeById = new Map();
|
|
97311
|
+
const nodeByValue = new Map();
|
|
97312
|
+
const childrenByParentId = new Map();
|
|
97313
|
+
const rootIds = [];
|
|
97314
|
+
const pathByLeafValue = new Map();
|
|
97315
|
+
const allLeafValues = [];
|
|
97316
|
+
const allLeafPaths = [];
|
|
97317
|
+
const createNode = (raw, parentPath, level, parentId) => {
|
|
97318
|
+
const value = raw[valueKey];
|
|
97319
|
+
const children = raw[childrenKey];
|
|
97320
|
+
const hasChildren = Array.isArray(children) && children.length > 0;
|
|
97321
|
+
const id = nextId();
|
|
97322
|
+
const nodePath = parentId == null ? [value] : parentPath.concat(value);
|
|
97323
|
+
const node = {
|
|
97324
|
+
id,
|
|
97325
|
+
value,
|
|
97326
|
+
label: raw[labelKey],
|
|
97327
|
+
path: nodePath,
|
|
97328
|
+
level,
|
|
97329
|
+
parentId,
|
|
97330
|
+
childIds: [],
|
|
97331
|
+
isLeaf: !hasChildren,
|
|
97332
|
+
disabled: !!raw[disabledKey],
|
|
97333
|
+
raw,
|
|
97334
|
+
descendantLeafValues: [],
|
|
97335
|
+
descendantLeafCount: 0,
|
|
97336
|
+
descendantPaths: []
|
|
97337
|
+
};
|
|
97338
|
+
nodes.push(node);
|
|
97339
|
+
nodeById.set(id, node);
|
|
97340
|
+
if (!nodeByValue.has(value)) {
|
|
97341
|
+
nodeByValue.set(value, node);
|
|
97342
|
+
}
|
|
97343
|
+
if (parentId == null) {
|
|
97344
|
+
rootIds.push(id);
|
|
97345
|
+
} else {
|
|
97346
|
+
const siblings = childrenByParentId.get(parentId) || [];
|
|
97347
|
+
siblings.push(id);
|
|
97348
|
+
childrenByParentId.set(parentId, siblings);
|
|
97349
|
+
const parent = nodeById.get(parentId);
|
|
97350
|
+
if (parent) {
|
|
97351
|
+
parent.childIds.push(id);
|
|
97352
|
+
}
|
|
97353
|
+
}
|
|
97354
|
+
if (hasChildren) {
|
|
97355
|
+
children.forEach(child => {
|
|
97356
|
+
createNode(child, nodePath, level + 1, id);
|
|
97357
|
+
});
|
|
97358
|
+
} else if (!node.disabled) {
|
|
97359
|
+
pathByLeafValue.set(value, nodePath);
|
|
97360
|
+
allLeafValues.push(value);
|
|
97361
|
+
allLeafPaths.push(nodePath);
|
|
97362
|
+
}
|
|
97363
|
+
return node;
|
|
97364
|
+
};
|
|
97365
|
+
const walkRoots = (items, ancestorDisabled = false) => {
|
|
97366
|
+
items.forEach(item => {
|
|
97367
|
+
const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
|
|
97368
|
+
const cloned = {
|
|
97369
|
+
...item
|
|
97370
|
+
};
|
|
97371
|
+
if (isDisabled) {
|
|
97372
|
+
cloned[disabledKey] = true;
|
|
97373
|
+
}
|
|
97374
|
+
createNode(cloned, [], 0, null);
|
|
97375
|
+
});
|
|
97376
|
+
};
|
|
97377
|
+
walkRoots(options || []);
|
|
97378
|
+
|
|
97379
|
+
// 自底向上汇总子树叶子
|
|
97380
|
+
const sorted = nodes.slice().sort((a, b) => b.level - a.level);
|
|
97381
|
+
sorted.forEach(node => {
|
|
97382
|
+
if (node.isLeaf) {
|
|
97383
|
+
if (!node.disabled) {
|
|
97384
|
+
node.descendantLeafValues = [node.value];
|
|
97385
|
+
node.descendantLeafCount = 1;
|
|
97386
|
+
node.descendantPaths = [node.path];
|
|
97387
|
+
}
|
|
97388
|
+
return;
|
|
97389
|
+
}
|
|
97390
|
+
const leafValues = [];
|
|
97391
|
+
const leafPaths = [];
|
|
97392
|
+
node.childIds.forEach(childId => {
|
|
97393
|
+
const child = nodeById.get(childId);
|
|
97394
|
+
if (!child || child.descendantLeafCount === 0) {
|
|
97395
|
+
return;
|
|
97396
|
+
}
|
|
97397
|
+
leafValues.push(...child.descendantLeafValues);
|
|
97398
|
+
leafPaths.push(...child.descendantPaths);
|
|
97399
|
+
});
|
|
97400
|
+
node.descendantLeafValues = leafValues;
|
|
97401
|
+
node.descendantLeafCount = leafValues.length;
|
|
97402
|
+
node.descendantPaths = leafPaths;
|
|
97403
|
+
});
|
|
97404
|
+
return {
|
|
97405
|
+
nodes,
|
|
97406
|
+
nodeById,
|
|
97407
|
+
nodeByValue,
|
|
97408
|
+
childrenByParentId,
|
|
97409
|
+
rootIds,
|
|
97410
|
+
pathByLeafValue,
|
|
97411
|
+
allLeafValues,
|
|
97412
|
+
allLeafPaths,
|
|
97413
|
+
totalLeafCount: allLeafPaths.length
|
|
97414
|
+
};
|
|
97415
|
+
}
|
|
97416
|
+
function getStoreChildren(store, parentId) {
|
|
97417
|
+
if (parentId == null) {
|
|
97418
|
+
return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97419
|
+
}
|
|
97420
|
+
const childIds = store.childrenByParentId.get(parentId) || [];
|
|
97421
|
+
return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97422
|
+
}
|
|
97423
|
+
function findStoreNodeByPath(store, pathValues) {
|
|
97424
|
+
if (!pathValues || pathValues.length === 0) {
|
|
97425
|
+
return null;
|
|
97426
|
+
}
|
|
97427
|
+
let node = store.nodeByValue.get(pathValues[0]);
|
|
97428
|
+
if (!node || pathValues.length === 1) {
|
|
97429
|
+
return node;
|
|
97430
|
+
}
|
|
97431
|
+
for (let i = 1; i < pathValues.length; i++) {
|
|
97432
|
+
const target = pathValues[i];
|
|
97433
|
+
const children = getStoreChildren(store, node.id);
|
|
97434
|
+
node = children.find(child => child.value == target) || null;
|
|
97435
|
+
if (!node) {
|
|
97436
|
+
return null;
|
|
97437
|
+
}
|
|
97438
|
+
}
|
|
97439
|
+
return node;
|
|
97440
|
+
}
|
|
97441
|
+
;// ./src/components/cascader-panel-pro/selectionStatePro.js
|
|
97442
|
+
|
|
97443
|
+
|
|
97444
|
+
|
|
97445
|
+
|
|
97446
|
+
|
|
97447
|
+
|
|
97448
|
+
|
|
97449
|
+
|
|
97450
|
+
|
|
97451
|
+
|
|
97452
|
+
const COMPACT_EMIT_THRESHOLD = 300;
|
|
97453
|
+
|
|
97454
|
+
class SelectionStatePro {
|
|
97455
|
+
constructor(store) {
|
|
97456
|
+
this.store = store;
|
|
97457
|
+
this.selectedLeafSet = new Set();
|
|
97458
|
+
this.subtreeSelectedCount = new Map();
|
|
97459
|
+
}
|
|
97460
|
+
clear() {
|
|
97461
|
+
this.selectedLeafSet.clear();
|
|
97462
|
+
this.subtreeSelectedCount.clear();
|
|
97463
|
+
}
|
|
97464
|
+
isEmpty() {
|
|
97465
|
+
return this.selectedLeafSet.size === 0;
|
|
97466
|
+
}
|
|
97467
|
+
size() {
|
|
97468
|
+
return this.selectedLeafSet.size;
|
|
97469
|
+
}
|
|
97470
|
+
_incAncestors(nodeId, delta) {
|
|
97471
|
+
let current = this.store.nodeById.get(nodeId);
|
|
97472
|
+
while (current) {
|
|
97473
|
+
const prev = this.subtreeSelectedCount.get(current.id) || 0;
|
|
97474
|
+
const next = prev + delta;
|
|
97475
|
+
if (next <= 0) {
|
|
97476
|
+
this.subtreeSelectedCount.delete(current.id);
|
|
97477
|
+
} else {
|
|
97478
|
+
this.subtreeSelectedCount.set(current.id, next);
|
|
97479
|
+
}
|
|
97480
|
+
if (current.parentId == null) {
|
|
97481
|
+
break;
|
|
97482
|
+
}
|
|
97483
|
+
current = this.store.nodeById.get(current.parentId);
|
|
97484
|
+
}
|
|
97485
|
+
}
|
|
97486
|
+
|
|
97487
|
+
/**
|
|
97488
|
+
* 自底向上重算 nodeId 子树内各层选中数
|
|
97489
|
+
*/
|
|
97490
|
+
_reconcileSubtreeCounts(nodeId) {
|
|
97491
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97492
|
+
if (!node) {
|
|
97493
|
+
return 0;
|
|
97494
|
+
}
|
|
97495
|
+
if (node.isLeaf) {
|
|
97496
|
+
return this.selectedLeafSet.has(node.value) ? 1 : 0;
|
|
97497
|
+
}
|
|
97498
|
+
let selected = 0;
|
|
97499
|
+
node.childIds.forEach(childId => {
|
|
97500
|
+
selected += this._reconcileSubtreeCounts(childId);
|
|
97501
|
+
});
|
|
97502
|
+
if (selected > 0) {
|
|
97503
|
+
this.subtreeSelectedCount.set(nodeId, selected);
|
|
97504
|
+
} else {
|
|
97505
|
+
this.subtreeSelectedCount.delete(nodeId);
|
|
97506
|
+
}
|
|
97507
|
+
return selected;
|
|
97508
|
+
}
|
|
97509
|
+
|
|
97510
|
+
/**
|
|
97511
|
+
* 从当前节点向上汇总祖先的选中数(勾选子节点后父级需半选/全选)
|
|
97512
|
+
*/
|
|
97513
|
+
_reconcileAncestors(nodeId) {
|
|
97514
|
+
var _this$store$nodeById$;
|
|
97515
|
+
let parentId = (_this$store$nodeById$ = this.store.nodeById.get(nodeId)) === null || _this$store$nodeById$ === void 0 ? void 0 : _this$store$nodeById$.parentId;
|
|
97516
|
+
while (parentId != null) {
|
|
97517
|
+
const parent = this.store.nodeById.get(parentId);
|
|
97518
|
+
if (!parent) {
|
|
97519
|
+
break;
|
|
97520
|
+
}
|
|
97521
|
+
let selected = 0;
|
|
97522
|
+
parent.childIds.forEach(childId => {
|
|
97523
|
+
const child = this.store.nodeById.get(childId);
|
|
97524
|
+
if (!child) {
|
|
97525
|
+
return;
|
|
97526
|
+
}
|
|
97527
|
+
if (child.isLeaf) {
|
|
97528
|
+
if (this.selectedLeafSet.has(child.value)) {
|
|
97529
|
+
selected++;
|
|
97530
|
+
}
|
|
97531
|
+
} else {
|
|
97532
|
+
selected += this.subtreeSelectedCount.get(childId) || 0;
|
|
97533
|
+
}
|
|
97534
|
+
});
|
|
97535
|
+
if (selected > 0) {
|
|
97536
|
+
this.subtreeSelectedCount.set(parentId, selected);
|
|
97537
|
+
} else {
|
|
97538
|
+
this.subtreeSelectedCount.delete(parentId);
|
|
97539
|
+
}
|
|
97540
|
+
parentId = parent.parentId;
|
|
97541
|
+
}
|
|
97542
|
+
}
|
|
97543
|
+
_reconcileAllRoots() {
|
|
97544
|
+
this.subtreeSelectedCount.clear();
|
|
97545
|
+
this.store.rootIds.forEach(rootId => {
|
|
97546
|
+
this._reconcileSubtreeCounts(rootId);
|
|
97547
|
+
});
|
|
97548
|
+
}
|
|
97549
|
+
_applyLeaf(value, checked) {
|
|
97550
|
+
const has = this.selectedLeafSet.has(value);
|
|
97551
|
+
if (checked && !has) {
|
|
97552
|
+
this.selectedLeafSet.add(value);
|
|
97553
|
+
const node = this.store.nodeByValue.get(value);
|
|
97554
|
+
if (node) {
|
|
97555
|
+
this._incAncestors(node.id, 1);
|
|
97556
|
+
}
|
|
97557
|
+
} else if (!checked && has) {
|
|
97558
|
+
this.selectedLeafSet.delete(value);
|
|
97559
|
+
const node = this.store.nodeByValue.get(value);
|
|
97560
|
+
if (node) {
|
|
97561
|
+
this._incAncestors(node.id, -1);
|
|
97562
|
+
}
|
|
97563
|
+
}
|
|
97564
|
+
}
|
|
97565
|
+
toggleNode(nodeId, checked) {
|
|
97566
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97567
|
+
if (!node || node.disabled) {
|
|
97568
|
+
return;
|
|
97569
|
+
}
|
|
97570
|
+
if (node.isLeaf) {
|
|
97571
|
+
const had = this.selectedLeafSet.has(node.value);
|
|
97572
|
+
this._applyLeaf(node.value, checked);
|
|
97573
|
+
if (had !== this.selectedLeafSet.has(node.value)) {
|
|
97574
|
+
this._reconcileAncestors(node.id);
|
|
97575
|
+
}
|
|
97576
|
+
return;
|
|
97577
|
+
}
|
|
97578
|
+
const leaves = node.descendantLeafValues;
|
|
97579
|
+
if (leaves.length === 0) {
|
|
97580
|
+
return;
|
|
97581
|
+
}
|
|
97582
|
+
let changedCount = 0;
|
|
97583
|
+
leaves.forEach(v => {
|
|
97584
|
+
const has = this.selectedLeafSet.has(v);
|
|
97585
|
+
if (checked) {
|
|
97586
|
+
if (!has) {
|
|
97587
|
+
this.selectedLeafSet.add(v);
|
|
97588
|
+
changedCount++;
|
|
97589
|
+
}
|
|
97590
|
+
} else if (has) {
|
|
97591
|
+
this.selectedLeafSet.delete(v);
|
|
97592
|
+
changedCount++;
|
|
97593
|
+
}
|
|
97594
|
+
});
|
|
97595
|
+
if (changedCount > 0) {
|
|
97596
|
+
this._reconcileSubtreeCounts(nodeId);
|
|
97597
|
+
this._reconcileAncestors(nodeId);
|
|
97598
|
+
}
|
|
97599
|
+
}
|
|
97600
|
+
selectAll() {
|
|
97601
|
+
this.clear();
|
|
97602
|
+
const leaves = this.store.allLeafValues;
|
|
97603
|
+
leaves.forEach(v => this.selectedLeafSet.add(v));
|
|
97604
|
+
this._reconcileAllRoots();
|
|
97605
|
+
}
|
|
97606
|
+
syncFromPaths(paths) {
|
|
97607
|
+
this.clear();
|
|
97608
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
97609
|
+
return;
|
|
97610
|
+
}
|
|
97611
|
+
paths.forEach(path => {
|
|
97612
|
+
if (!Array.isArray(path) || path.length === 0) {
|
|
97613
|
+
return;
|
|
97614
|
+
}
|
|
97615
|
+
const leafValue = path[path.length - 1];
|
|
97616
|
+
if (this.store.pathByLeafValue.has(leafValue)) {
|
|
97617
|
+
this.selectedLeafSet.add(leafValue);
|
|
97618
|
+
}
|
|
97619
|
+
});
|
|
97620
|
+
this._reconcileAllRoots();
|
|
97621
|
+
}
|
|
97622
|
+
getCheckState(nodeId) {
|
|
97623
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97624
|
+
if (!node || node.disabled) {
|
|
97625
|
+
return 'disabled';
|
|
97626
|
+
}
|
|
97627
|
+
if (node.isLeaf) {
|
|
97628
|
+
return this.selectedLeafSet.has(node.value) ? 'checked' : 'unchecked';
|
|
97629
|
+
}
|
|
97630
|
+
const total = node.descendantLeafCount;
|
|
97631
|
+
if (total === 0) {
|
|
97632
|
+
return 'unchecked';
|
|
97633
|
+
}
|
|
97634
|
+
const selected = this.subtreeSelectedCount.get(node.id) || 0;
|
|
97635
|
+
if (selected === 0) {
|
|
97636
|
+
return 'unchecked';
|
|
97637
|
+
}
|
|
97638
|
+
if (selected >= total) {
|
|
97639
|
+
return 'checked';
|
|
97640
|
+
}
|
|
97641
|
+
return 'indeterminate';
|
|
97642
|
+
}
|
|
97643
|
+
isChecked(nodeId) {
|
|
97644
|
+
return this.getCheckState(nodeId) === 'checked';
|
|
97645
|
+
}
|
|
97646
|
+
isIndeterminate(nodeId) {
|
|
97647
|
+
return this.getCheckState(nodeId) === 'indeterminate';
|
|
97648
|
+
}
|
|
97649
|
+
isPathInCheckedValues(path) {
|
|
97650
|
+
if (!path || path.length === 0) {
|
|
97651
|
+
return false;
|
|
97652
|
+
}
|
|
97653
|
+
const leafValue = path[path.length - 1];
|
|
97654
|
+
return this.selectedLeafSet.has(leafValue);
|
|
97655
|
+
}
|
|
97656
|
+
isNodeInCheckedPath(node) {
|
|
97657
|
+
if (!node) {
|
|
97658
|
+
return false;
|
|
97659
|
+
}
|
|
97660
|
+
return this.isPathInCheckedValues(node.path);
|
|
97661
|
+
}
|
|
97662
|
+
getCheckedPaths() {
|
|
97663
|
+
const paths = [];
|
|
97664
|
+
this.selectedLeafSet.forEach(leafValue => {
|
|
97665
|
+
const path = this.store.pathByLeafValue.get(leafValue);
|
|
97666
|
+
if (path) {
|
|
97667
|
+
paths.push(path);
|
|
97668
|
+
}
|
|
97669
|
+
});
|
|
97670
|
+
return paths;
|
|
97671
|
+
}
|
|
97672
|
+
isCompactSelection() {
|
|
97673
|
+
return this.selectedLeafSet.size >= COMPACT_EMIT_THRESHOLD;
|
|
97674
|
+
}
|
|
97675
|
+
|
|
97676
|
+
/** 从聚合父节点值快速同步(如 __parent__province_0) */
|
|
97677
|
+
syncFromParentValues(parentValues, prefix = '__parent__') {
|
|
97678
|
+
this.clear();
|
|
97679
|
+
if (!Array.isArray(parentValues) || parentValues.length === 0) {
|
|
97680
|
+
return;
|
|
97681
|
+
}
|
|
97682
|
+
parentValues.forEach(val => {
|
|
97683
|
+
let rootValue = val;
|
|
97684
|
+
if (typeof val === 'string' && val.startsWith(prefix)) {
|
|
97685
|
+
rootValue = val.substring(prefix.length);
|
|
97686
|
+
}
|
|
97687
|
+
const node = this.store.nodeByValue.get(rootValue);
|
|
97688
|
+
if (node && !node.isLeaf && !node.disabled) {
|
|
97689
|
+
node.descendantLeafValues.forEach(v => this.selectedLeafSet.add(v));
|
|
97690
|
+
}
|
|
97691
|
+
});
|
|
97692
|
+
this._reconcileAllRoots();
|
|
97693
|
+
}
|
|
97694
|
+
}
|
|
97695
|
+
;// ./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
|
|
97696
|
+
|
|
97697
|
+
|
|
97698
|
+
|
|
97699
|
+
|
|
97700
|
+
|
|
97701
|
+
|
|
97702
|
+
|
|
97703
|
+
|
|
97704
|
+
/* harmony default export */ var VirtualCascaderPanelvue_type_script_lang_js = ({
|
|
97705
|
+
name: 'VirtualCascaderPanel',
|
|
97706
|
+
components: {
|
|
97707
|
+
VcpVirtualList: VirtualList
|
|
97708
|
+
},
|
|
97709
|
+
props: {
|
|
97710
|
+
value: {
|
|
97711
|
+
type: [Array, String, Number],
|
|
97712
|
+
default: () => []
|
|
97713
|
+
},
|
|
97714
|
+
options: {
|
|
97715
|
+
type: Array,
|
|
97716
|
+
default: () => []
|
|
97717
|
+
},
|
|
97718
|
+
props: {
|
|
97719
|
+
type: Object,
|
|
97720
|
+
default: () => ({
|
|
97721
|
+
multiple: true,
|
|
97722
|
+
label: 'label',
|
|
97723
|
+
value: 'value',
|
|
97724
|
+
children: 'children',
|
|
97725
|
+
checkStrictly: false
|
|
97726
|
+
})
|
|
97727
|
+
},
|
|
97728
|
+
height: {
|
|
97729
|
+
type: Number,
|
|
97730
|
+
default: 280
|
|
97731
|
+
},
|
|
97732
|
+
columnMinWidth: {
|
|
97733
|
+
type: Number,
|
|
97734
|
+
default: 180
|
|
97735
|
+
},
|
|
97736
|
+
columnMaxWidth: {
|
|
97737
|
+
type: Number,
|
|
97738
|
+
default: 420
|
|
97739
|
+
},
|
|
97740
|
+
disabledConfig: {
|
|
97741
|
+
type: Object,
|
|
97742
|
+
default: () => ({})
|
|
97743
|
+
},
|
|
97744
|
+
isViewMode: {
|
|
97745
|
+
type: Boolean,
|
|
97746
|
+
default: false
|
|
97747
|
+
},
|
|
97748
|
+
autoExpandDeep: {
|
|
97749
|
+
type: Boolean,
|
|
97750
|
+
default: true
|
|
97751
|
+
},
|
|
97752
|
+
// 是否从 value prop 同步选中(紧凑模式下由面板内部维护选中状态)
|
|
97753
|
+
syncValueFromParent: {
|
|
97754
|
+
type: Boolean,
|
|
97755
|
+
default: true
|
|
97756
|
+
}
|
|
97757
|
+
},
|
|
97758
|
+
data() {
|
|
97759
|
+
return {
|
|
97760
|
+
store: null,
|
|
97761
|
+
selection: null,
|
|
97762
|
+
activePath: [],
|
|
97763
|
+
itemHeight: 34,
|
|
97764
|
+
syncingValue: false,
|
|
97765
|
+
suppressValueSync: false,
|
|
97766
|
+
selectionTick: 0
|
|
97767
|
+
};
|
|
97768
|
+
},
|
|
97769
|
+
computed: {
|
|
97770
|
+
multiple() {
|
|
97771
|
+
return this.props.multiple !== false;
|
|
97772
|
+
},
|
|
97773
|
+
checkStrictly() {
|
|
97774
|
+
return !!this.props.checkStrictly;
|
|
97775
|
+
},
|
|
97776
|
+
columns() {
|
|
97777
|
+
if (!this.store) {
|
|
97778
|
+
return [];
|
|
97779
|
+
}
|
|
97780
|
+
const cols = [getStoreChildren(this.store, null)];
|
|
97781
|
+
this.activePath.forEach(nodeId => {
|
|
97782
|
+
const node = this.store.nodeById.get(nodeId);
|
|
97783
|
+
if (!node || node.isLeaf) {
|
|
97784
|
+
return;
|
|
97785
|
+
}
|
|
97786
|
+
const children = getStoreChildren(this.store, nodeId);
|
|
97787
|
+
if (children.length > 0) {
|
|
97788
|
+
cols.push(children);
|
|
97789
|
+
}
|
|
97790
|
+
});
|
|
97791
|
+
return cols;
|
|
97792
|
+
},
|
|
97793
|
+
singleCheckedValue() {
|
|
97794
|
+
if (this.multiple || !Array.isArray(this.value) || this.value.length === 0) {
|
|
97795
|
+
return null;
|
|
97796
|
+
}
|
|
97797
|
+
const path = Array.isArray(this.value[0]) ? this.value[0] : this.value;
|
|
97798
|
+
return path[path.length - 1];
|
|
97799
|
+
}
|
|
97800
|
+
},
|
|
97801
|
+
watch: {
|
|
97802
|
+
options: {
|
|
97803
|
+
handler() {
|
|
97804
|
+
this.rebuildStore();
|
|
97805
|
+
}
|
|
97806
|
+
},
|
|
97807
|
+
value: {
|
|
97808
|
+
handler() {
|
|
97809
|
+
if (this.suppressValueSync || !this.syncValueFromParent) {
|
|
97810
|
+
return;
|
|
97811
|
+
}
|
|
97812
|
+
this.syncFromValue();
|
|
97813
|
+
},
|
|
97814
|
+
deep: false
|
|
97815
|
+
},
|
|
97816
|
+
activePath: {
|
|
97817
|
+
handler() {
|
|
97818
|
+
this.$nextTick(() => {
|
|
97819
|
+
this.syncHorizontalOverflow();
|
|
97820
|
+
});
|
|
97821
|
+
},
|
|
97822
|
+
deep: true
|
|
97823
|
+
}
|
|
97824
|
+
},
|
|
97825
|
+
created() {
|
|
97826
|
+
this.rebuildStore();
|
|
97827
|
+
},
|
|
97828
|
+
mounted() {
|
|
97829
|
+
this._onWindowResize = () => {
|
|
97830
|
+
this.syncHorizontalOverflow();
|
|
97831
|
+
};
|
|
97832
|
+
window.addEventListener('resize', this._onWindowResize, {
|
|
97833
|
+
passive: true
|
|
97834
|
+
});
|
|
97835
|
+
this.syncHorizontalOverflow();
|
|
97836
|
+
},
|
|
97837
|
+
beforeDestroy() {
|
|
97838
|
+
if (this._onWindowResize) {
|
|
97839
|
+
window.removeEventListener('resize', this._onWindowResize);
|
|
97840
|
+
this._onWindowResize = null;
|
|
97841
|
+
}
|
|
97842
|
+
if (this._hScrollRaf) {
|
|
97843
|
+
cancelAnimationFrame(this._hScrollRaf);
|
|
97844
|
+
this._hScrollRaf = null;
|
|
97845
|
+
}
|
|
97846
|
+
},
|
|
97847
|
+
methods: {
|
|
97848
|
+
syncHorizontalOverflow() {
|
|
97849
|
+
if (this._hScrollRaf) {
|
|
97850
|
+
cancelAnimationFrame(this._hScrollRaf);
|
|
97851
|
+
}
|
|
97852
|
+
this._hScrollRaf = requestAnimationFrame(() => {
|
|
97853
|
+
this._hScrollRaf = null;
|
|
97854
|
+
const panel = this.$el;
|
|
97855
|
+
const wrapper = panel && panel.closest('.cascader-content-wrapper');
|
|
97856
|
+
if (!panel || !wrapper) {
|
|
97857
|
+
return;
|
|
97858
|
+
}
|
|
97859
|
+
const overflow = panel.scrollWidth - wrapper.clientWidth;
|
|
97860
|
+
const hadScroll = wrapper.classList.contains('is-horizontal-scroll');
|
|
97861
|
+
// 滞回区间,避免边界宽度下 overflow 来回切换
|
|
97862
|
+
const needsScroll = hadScroll ? overflow > -4 : overflow > 1;
|
|
97863
|
+
if (needsScroll !== hadScroll) {
|
|
97864
|
+
wrapper.classList.toggle('is-horizontal-scroll', needsScroll);
|
|
97865
|
+
}
|
|
97866
|
+
});
|
|
97867
|
+
},
|
|
97868
|
+
getColumnStyle(colIndex, columnNodes) {
|
|
97869
|
+
const width = CascaderUtilsPro.getCascaderColumnWidth(columnNodes, {
|
|
97870
|
+
minWidth: this.columnMinWidth,
|
|
97871
|
+
maxWidth: this.columnMaxWidth,
|
|
97872
|
+
hasCheckbox: this.multiple || this.checkStrictly
|
|
97873
|
+
});
|
|
97874
|
+
return {
|
|
97875
|
+
width: width + 'px',
|
|
97876
|
+
minWidth: width + 'px',
|
|
97877
|
+
maxWidth: width + 'px'
|
|
97878
|
+
};
|
|
97879
|
+
},
|
|
97880
|
+
rebuildStore() {
|
|
97881
|
+
this.store = buildCascaderStore(this.options, this.disabledConfig, this.props, CascaderUtilsPro);
|
|
97882
|
+
this.selection = new SelectionStatePro(this.store);
|
|
97883
|
+
this.activePath = [];
|
|
97884
|
+
if (this.syncValueFromParent) {
|
|
97885
|
+
this.syncFromValue();
|
|
97886
|
+
}
|
|
97887
|
+
this.$nextTick(() => {
|
|
97888
|
+
this.syncHorizontalOverflow();
|
|
97889
|
+
});
|
|
97890
|
+
},
|
|
97891
|
+
syncFromValue() {
|
|
97892
|
+
if (!this.selection) {
|
|
97893
|
+
return;
|
|
97894
|
+
}
|
|
97895
|
+
this.syncingValue = true;
|
|
97896
|
+
if (this.multiple) {
|
|
97897
|
+
const paths = Array.isArray(this.value) ? this.value : [];
|
|
97898
|
+
this.selection.syncFromPaths(paths);
|
|
97899
|
+
} else {
|
|
97900
|
+
const path = this.normalizeSinglePath(this.value);
|
|
97901
|
+
this.selection.syncFromPaths(path ? [path] : []);
|
|
97902
|
+
if (path && path.length > 1) {
|
|
97903
|
+
this.expandPathValues(path.slice(0, -1), false);
|
|
97904
|
+
}
|
|
97905
|
+
}
|
|
97906
|
+
this.syncingValue = false;
|
|
97907
|
+
},
|
|
97908
|
+
normalizeSinglePath(val) {
|
|
97909
|
+
if (val == null || val === '') {
|
|
97910
|
+
return null;
|
|
97911
|
+
}
|
|
97912
|
+
if (Array.isArray(val)) {
|
|
97913
|
+
if (val.length === 0) {
|
|
97914
|
+
return null;
|
|
97915
|
+
}
|
|
97916
|
+
if (Array.isArray(val[0])) {
|
|
97917
|
+
return val[0];
|
|
97918
|
+
}
|
|
97919
|
+
return val;
|
|
97920
|
+
}
|
|
97921
|
+
const node = this.store && this.store.nodeByValue.get(val);
|
|
97922
|
+
if (node) {
|
|
97923
|
+
return node.path;
|
|
97924
|
+
}
|
|
97925
|
+
return [val];
|
|
97926
|
+
},
|
|
97927
|
+
emitValue() {
|
|
97928
|
+
if (this.syncingValue || !this.selection) {
|
|
97929
|
+
return;
|
|
97930
|
+
}
|
|
97931
|
+
if (this.selection.isCompactSelection()) {
|
|
97932
|
+
this.$emit('change', {
|
|
97933
|
+
compact: true,
|
|
97934
|
+
count: this.selection.size()
|
|
97935
|
+
});
|
|
97936
|
+
return;
|
|
97937
|
+
}
|
|
97938
|
+
let emitVal;
|
|
97939
|
+
if (this.multiple) {
|
|
97940
|
+
emitVal = this.selection.getCheckedPaths();
|
|
97941
|
+
} else {
|
|
97942
|
+
const paths = this.selection.getCheckedPaths();
|
|
97943
|
+
emitVal = paths.length > 0 ? paths[0] : [];
|
|
97944
|
+
}
|
|
97945
|
+
this.$emit('input', emitVal);
|
|
97946
|
+
this.$emit('change', emitVal);
|
|
97947
|
+
},
|
|
97948
|
+
isActive(node, colIndex) {
|
|
97949
|
+
return colIndex < this.activePath.length && this.activePath[colIndex] === node.id;
|
|
97950
|
+
},
|
|
97951
|
+
isExpanded(node, colIndex) {
|
|
97952
|
+
return this.activePath[colIndex] === node.id;
|
|
97953
|
+
},
|
|
97954
|
+
isInActivePath(node) {
|
|
97955
|
+
return this.activePath.includes(node.id);
|
|
97956
|
+
},
|
|
97957
|
+
getNodeClass(node, colIndex) {
|
|
97958
|
+
return {
|
|
97959
|
+
'is-selectable': this.checkStrictly,
|
|
97960
|
+
'is-disabled': node.disabled || this.isViewMode,
|
|
97961
|
+
'in-active-path': this.isInActivePath(node),
|
|
97962
|
+
'in-checked-path': this.checkStrictly && this.isInCheckedPath(node),
|
|
97963
|
+
'is-active': this.isNodeActive(node)
|
|
97964
|
+
};
|
|
97965
|
+
},
|
|
97966
|
+
isInCheckedPath(node) {
|
|
97967
|
+
void this.selectionTick;
|
|
97968
|
+
if (!this.selection || !this.checkStrictly) {
|
|
97969
|
+
return false;
|
|
97970
|
+
}
|
|
97971
|
+
return this.selection.isNodeInCheckedPath(node);
|
|
97972
|
+
},
|
|
97973
|
+
isNodeActive(node) {
|
|
97974
|
+
void this.selectionTick;
|
|
97975
|
+
if (!this.selection) {
|
|
97976
|
+
return false;
|
|
97977
|
+
}
|
|
97978
|
+
if (this.multiple) {
|
|
97979
|
+
if (this.checkStrictly) {
|
|
97980
|
+
return this.selection.isNodeInCheckedPath(node);
|
|
97981
|
+
}
|
|
97982
|
+
return node.isLeaf && this.selection.selectedLeafSet.has(node.value);
|
|
97983
|
+
}
|
|
97984
|
+
const paths = this.selection.getCheckedPaths();
|
|
97985
|
+
if (paths.length === 0) {
|
|
97986
|
+
return false;
|
|
97987
|
+
}
|
|
97988
|
+
const activePath = paths[0];
|
|
97989
|
+
return activePath[activePath.length - 1] === node.value;
|
|
97990
|
+
},
|
|
97991
|
+
isChecked(node) {
|
|
97992
|
+
void this.selectionTick;
|
|
97993
|
+
return this.selection ? this.selection.isChecked(node.id) : false;
|
|
97994
|
+
},
|
|
97995
|
+
isIndeterminate(node) {
|
|
97996
|
+
void this.selectionTick;
|
|
97997
|
+
return this.selection ? this.selection.isIndeterminate(node.id) : false;
|
|
97998
|
+
},
|
|
97999
|
+
bumpSelectionView() {
|
|
98000
|
+
this.selectionTick += 1;
|
|
98001
|
+
},
|
|
98002
|
+
// activePath 只保留非叶子,避免多出一列空菜单(空列仍有 min-width 会撑出横向滚动)
|
|
98003
|
+
sanitizeActivePath(pathIds) {
|
|
98004
|
+
if (!this.store || !Array.isArray(pathIds)) {
|
|
98005
|
+
return [];
|
|
98006
|
+
}
|
|
98007
|
+
return pathIds.filter(id => {
|
|
98008
|
+
const node = this.store.nodeById.get(id);
|
|
98009
|
+
return node && !node.isLeaf;
|
|
98010
|
+
});
|
|
98011
|
+
},
|
|
98012
|
+
expandNode(node, silent = false) {
|
|
98013
|
+
if (node.isLeaf) {
|
|
98014
|
+
return;
|
|
98015
|
+
}
|
|
98016
|
+
const pathIds = [];
|
|
98017
|
+
let current = node;
|
|
98018
|
+
while (current) {
|
|
98019
|
+
pathIds.unshift(current.id);
|
|
98020
|
+
if (current.parentId == null) {
|
|
98021
|
+
break;
|
|
98022
|
+
}
|
|
98023
|
+
current = this.store.nodeById.get(current.parentId);
|
|
98024
|
+
}
|
|
98025
|
+
this.activePath = this.sanitizeActivePath(pathIds);
|
|
98026
|
+
if (!silent) {
|
|
98027
|
+
const pathValues = pathIds.map(id => this.store.nodeById.get(id).value);
|
|
98028
|
+
this.$emit('expand-change', pathValues);
|
|
98029
|
+
if (this.autoExpandDeep) {
|
|
98030
|
+
this.$nextTick(() => {
|
|
98031
|
+
this.expandDeepFromNode(node);
|
|
98032
|
+
});
|
|
98033
|
+
}
|
|
98034
|
+
}
|
|
98035
|
+
},
|
|
98036
|
+
expandDeepFromNode(node) {
|
|
98037
|
+
if (!node || node.isLeaf) {
|
|
98038
|
+
return;
|
|
98039
|
+
}
|
|
98040
|
+
const children = getStoreChildren(this.store, node.id);
|
|
98041
|
+
if (children.length === 0) {
|
|
98042
|
+
return;
|
|
98043
|
+
}
|
|
98044
|
+
const firstChild = children[0];
|
|
98045
|
+
const pathIds = [];
|
|
98046
|
+
let cursor = firstChild;
|
|
98047
|
+
while (cursor) {
|
|
98048
|
+
pathIds.push(cursor.id);
|
|
98049
|
+
if (cursor.isLeaf) {
|
|
98050
|
+
break;
|
|
98051
|
+
}
|
|
98052
|
+
const kids = getStoreChildren(this.store, cursor.id);
|
|
98053
|
+
if (kids.length === 0) {
|
|
98054
|
+
break;
|
|
98055
|
+
}
|
|
98056
|
+
cursor = kids[0];
|
|
98057
|
+
}
|
|
98058
|
+
const basePath = [];
|
|
98059
|
+
let parent = node;
|
|
98060
|
+
while (parent) {
|
|
98061
|
+
basePath.unshift(parent.id);
|
|
98062
|
+
if (parent.parentId == null) {
|
|
98063
|
+
break;
|
|
98064
|
+
}
|
|
98065
|
+
parent = this.store.nodeById.get(parent.parentId);
|
|
98066
|
+
}
|
|
98067
|
+
this.activePath = this.sanitizeActivePath(basePath.concat(pathIds));
|
|
98068
|
+
},
|
|
98069
|
+
expandPathValues(pathValues, deep = true) {
|
|
98070
|
+
if (!pathValues || pathValues.length === 0 || !this.store) {
|
|
98071
|
+
return;
|
|
98072
|
+
}
|
|
98073
|
+
const node = findStoreNodeByPath(this.store, pathValues);
|
|
98074
|
+
if (!node) {
|
|
98075
|
+
return;
|
|
98076
|
+
}
|
|
98077
|
+
const pathIds = [];
|
|
98078
|
+
let current = node;
|
|
98079
|
+
while (current) {
|
|
98080
|
+
pathIds.unshift(current.id);
|
|
98081
|
+
if (current.parentId == null) {
|
|
98082
|
+
break;
|
|
98083
|
+
}
|
|
98084
|
+
current = this.store.nodeById.get(current.parentId);
|
|
98085
|
+
}
|
|
98086
|
+
this.activePath = this.sanitizeActivePath(pathIds);
|
|
98087
|
+
if (deep && this.autoExpandDeep) {
|
|
98088
|
+
this.$nextTick(() => {
|
|
98089
|
+
this.expandDeepFromNode(node);
|
|
98090
|
+
});
|
|
98091
|
+
}
|
|
98092
|
+
},
|
|
98093
|
+
onNodeClick(node, colIndex) {
|
|
98094
|
+
if (node.disabled || this.isViewMode) {
|
|
98095
|
+
return;
|
|
98096
|
+
}
|
|
98097
|
+
if (!this.multiple && !this.checkStrictly) {
|
|
98098
|
+
if (node.isLeaf) {
|
|
98099
|
+
this.selection.clear();
|
|
98100
|
+
this.selection.toggleNode(node.id, true);
|
|
98101
|
+
this.emitValue();
|
|
98102
|
+
} else {
|
|
98103
|
+
this.expandNode(node);
|
|
98104
|
+
}
|
|
98105
|
+
return;
|
|
98106
|
+
}
|
|
98107
|
+
this.expandNode(node);
|
|
98108
|
+
},
|
|
98109
|
+
onCheckClick(node, checked) {
|
|
98110
|
+
if (!this.multiple || node.disabled || this.isViewMode) {
|
|
98111
|
+
return;
|
|
98112
|
+
}
|
|
98113
|
+
const nextChecked = typeof checked === 'boolean' ? checked : !this.isChecked(node);
|
|
98114
|
+
this.selection.toggleNode(node.id, nextChecked);
|
|
98115
|
+
this.bumpSelectionView();
|
|
98116
|
+
this.emitValue();
|
|
98117
|
+
|
|
98118
|
+
// 与 el-cascader-panel 一致:非 checkStrictly 时勾选会同步展开当前节点
|
|
98119
|
+
if (!this.checkStrictly && !node.isLeaf) {
|
|
98120
|
+
this.expandNode(node);
|
|
98121
|
+
}
|
|
98122
|
+
},
|
|
98123
|
+
onRadioClick(node) {
|
|
98124
|
+
if (this.multiple || node.disabled || this.isViewMode) {
|
|
98125
|
+
return;
|
|
98126
|
+
}
|
|
98127
|
+
this.selection.clear();
|
|
98128
|
+
this.selection.toggleNode(node.id, true);
|
|
98129
|
+
this.emitValue();
|
|
98130
|
+
if (!node.isLeaf) {
|
|
98131
|
+
this.expandNode(node);
|
|
98132
|
+
}
|
|
98133
|
+
},
|
|
98134
|
+
clearCheckedNodes() {
|
|
98135
|
+
if (this.selection) {
|
|
98136
|
+
this.selection.clear();
|
|
98137
|
+
this.bumpSelectionView();
|
|
98138
|
+
this.$emit('input', this.multiple ? [] : []);
|
|
98139
|
+
this.$emit('change', this.multiple ? [] : []);
|
|
98140
|
+
}
|
|
98141
|
+
},
|
|
98142
|
+
selectAllLeaves() {
|
|
98143
|
+
if (this.selection) {
|
|
98144
|
+
this.selection.selectAll();
|
|
98145
|
+
this.bumpSelectionView();
|
|
98146
|
+
this.emitValue();
|
|
98147
|
+
}
|
|
98148
|
+
},
|
|
98149
|
+
syncCheckedValue() {
|
|
98150
|
+
this.syncFromValue();
|
|
98151
|
+
},
|
|
98152
|
+
syncFromParentValues(values, prefix) {
|
|
98153
|
+
if (!this.selection) {
|
|
98154
|
+
return;
|
|
98155
|
+
}
|
|
98156
|
+
this.suppressValueSync = true;
|
|
98157
|
+
this.selection.syncFromParentValues(values, prefix);
|
|
98158
|
+
this.bumpSelectionView();
|
|
98159
|
+
this.suppressValueSync = false;
|
|
98160
|
+
},
|
|
98161
|
+
getSelectionSnapshot() {
|
|
98162
|
+
if (!this.selection || !this.store) {
|
|
98163
|
+
return null;
|
|
98164
|
+
}
|
|
98165
|
+
return {
|
|
98166
|
+
store: this.store,
|
|
98167
|
+
selection: this.selection,
|
|
98168
|
+
isCompact: this.selection.isCompactSelection(),
|
|
98169
|
+
count: this.selection.size()
|
|
98170
|
+
};
|
|
98171
|
+
}
|
|
98172
|
+
}
|
|
98173
|
+
});
|
|
98174
|
+
;// ./src/components/cascader-panel-pro/VirtualCascaderPanel.vue?vue&type=script&lang=js
|
|
98175
|
+
/* harmony default export */ var cascader_panel_pro_VirtualCascaderPanelvue_type_script_lang_js = (VirtualCascaderPanelvue_type_script_lang_js);
|
|
98176
|
+
;// ./src/components/cascader-panel-pro/VirtualCascaderPanel.vue
|
|
98177
|
+
|
|
98178
|
+
|
|
98179
|
+
|
|
98180
|
+
|
|
98181
|
+
|
|
98182
|
+
/* normalize component */
|
|
98183
|
+
;
|
|
98184
|
+
var VirtualCascaderPanel_component = normalizeComponent(
|
|
98185
|
+
cascader_panel_pro_VirtualCascaderPanelvue_type_script_lang_js,
|
|
98186
|
+
VirtualCascaderPanelvue_type_template_id_23086f90_render,
|
|
98187
|
+
VirtualCascaderPanelvue_type_template_id_23086f90_staticRenderFns,
|
|
98188
|
+
false,
|
|
98189
|
+
null,
|
|
98190
|
+
null,
|
|
98191
|
+
null
|
|
98192
|
+
|
|
98193
|
+
)
|
|
98194
|
+
|
|
98195
|
+
/* harmony default export */ var VirtualCascaderPanel = (VirtualCascaderPanel_component.exports);
|
|
98196
|
+
;// ./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
|
|
98197
|
+
|
|
98198
|
+
|
|
98199
|
+
|
|
98200
|
+
|
|
98201
|
+
|
|
98202
|
+
|
|
98203
|
+
|
|
98204
|
+
|
|
98205
|
+
|
|
98206
|
+
|
|
98207
|
+
|
|
98208
|
+
|
|
98209
|
+
|
|
98210
|
+
|
|
98211
|
+
|
|
98212
|
+
|
|
98213
|
+
|
|
98214
|
+
/* harmony default export */ var ByCascaderPanelProvue_type_script_lang_js = ({
|
|
98215
|
+
name: 'ByCascaderPanelPro',
|
|
98216
|
+
components: {
|
|
98217
|
+
VirtualCascaderPanel: VirtualCascaderPanel,
|
|
98218
|
+
VcpVirtualList: VirtualList
|
|
98219
|
+
},
|
|
98220
|
+
props: {
|
|
98221
|
+
// 级联数据源
|
|
98222
|
+
options: {
|
|
98223
|
+
type: Array,
|
|
98224
|
+
default: () => []
|
|
98225
|
+
},
|
|
98226
|
+
// 已选值
|
|
98227
|
+
value: {
|
|
98228
|
+
type: [Array, Number, String],
|
|
98229
|
+
default: () => []
|
|
98230
|
+
},
|
|
98231
|
+
// 级联面板配置
|
|
98232
|
+
cascaderProps: {
|
|
98233
|
+
type: Object,
|
|
98234
|
+
default: () => ({
|
|
98235
|
+
multiple: true,
|
|
98236
|
+
label: 'label',
|
|
98237
|
+
value: 'value',
|
|
98238
|
+
children: 'children'
|
|
98239
|
+
})
|
|
98240
|
+
},
|
|
98241
|
+
// 面板高度
|
|
98242
|
+
panelHeight: {
|
|
98243
|
+
type: [String, Number],
|
|
98244
|
+
default: 300,
|
|
98245
|
+
validator: value => {
|
|
98246
|
+
const numValue = Number(value);
|
|
98247
|
+
if (isNaN(numValue)) {
|
|
98248
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 必须是数字,当前值: ${value}`);
|
|
98249
|
+
return false;
|
|
98250
|
+
}
|
|
98251
|
+
if (numValue < 200) {
|
|
98252
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 不能小于 200px,当前值: ${value}px`);
|
|
98253
|
+
return false;
|
|
98254
|
+
}
|
|
98255
|
+
if (numValue > 800) {
|
|
98256
|
+
console.warn(`[ByCascaderPanelPro] panelHeight 不能大于 800px,当前值: ${value}px`);
|
|
98257
|
+
return false;
|
|
98258
|
+
}
|
|
98259
|
+
return true;
|
|
98260
|
+
}
|
|
98261
|
+
},
|
|
98262
|
+
// 搜索占位符
|
|
98263
|
+
searchPlaceholder: {
|
|
98264
|
+
type: String,
|
|
98265
|
+
default: '请输入名称搜索'
|
|
98266
|
+
},
|
|
98267
|
+
// 禁用字段名(只针对叶子节点,非叶子节点为disabled)
|
|
98268
|
+
disabledField: {
|
|
98269
|
+
type: String,
|
|
98270
|
+
default: 'disabled'
|
|
98271
|
+
},
|
|
98272
|
+
// 禁用值(只针对叶子节点,非叶子节点为disabled)
|
|
96253
98273
|
disabledValue: {
|
|
96254
98274
|
type: [String, Number, Boolean],
|
|
96255
98275
|
default: true
|
|
96256
98276
|
},
|
|
98277
|
+
// 自定义禁用判断函数
|
|
96257
98278
|
disabledCheck: {
|
|
96258
98279
|
type: Function,
|
|
96259
98280
|
default: null
|
|
96260
98281
|
},
|
|
98282
|
+
// 是否显示全选按钮
|
|
96261
98283
|
showSelectAll: {
|
|
96262
98284
|
type: Boolean,
|
|
96263
98285
|
default: true
|
|
96264
98286
|
},
|
|
98287
|
+
// 是否聚合模式 (聚合模式下如果子项全部选中,会直接返回父ID)
|
|
96265
98288
|
aggregationMode: {
|
|
96266
98289
|
type: Boolean,
|
|
96267
98290
|
default: false
|
|
96268
98291
|
},
|
|
98292
|
+
/**
|
|
98293
|
+
* 非叶子节点前缀标识 (聚合模式下用于标识非叶子节点)
|
|
98294
|
+
* 注意:聚合模式下,由于叶子节点和非叶子节点可能存在相同id,所以绑定数据中务必给非叶子节点加上parentNodePrefix前缀作为标识
|
|
98295
|
+
*/
|
|
96269
98296
|
parentNodePrefix: {
|
|
96270
98297
|
type: String,
|
|
96271
98298
|
default: '__parent__'
|
|
96272
98299
|
},
|
|
98300
|
+
// 是否为查看模式 (如果是查看模式,则组件中的操作交互将全部禁用,仅用于回显查看)
|
|
96273
98301
|
isViewMode: {
|
|
96274
98302
|
type: Boolean,
|
|
96275
98303
|
default: false
|
|
96276
98304
|
},
|
|
98305
|
+
// 是否显示子标题
|
|
96277
98306
|
showSubtitle: {
|
|
96278
98307
|
type: Boolean,
|
|
96279
98308
|
default: false
|
|
96280
98309
|
},
|
|
98310
|
+
// 子标题字段名
|
|
96281
98311
|
subtitleField: {
|
|
96282
98312
|
type: String,
|
|
96283
98313
|
default: ''
|
|
98314
|
+
},
|
|
98315
|
+
// 级联列最小宽度(px)
|
|
98316
|
+
columnMinWidth: {
|
|
98317
|
+
type: Number,
|
|
98318
|
+
default: 180
|
|
98319
|
+
},
|
|
98320
|
+
// 级联列最大宽度(px),超出后显示省略号
|
|
98321
|
+
columnMaxWidth: {
|
|
98322
|
+
type: Number,
|
|
98323
|
+
default: 420
|
|
96284
98324
|
}
|
|
96285
98325
|
},
|
|
96286
98326
|
data() {
|
|
96287
98327
|
return {
|
|
96288
98328
|
selectedValues: [],
|
|
98329
|
+
searchSelectedValues: [],
|
|
96289
98330
|
filteredOptions: [],
|
|
96290
|
-
|
|
98331
|
+
searchOptions: [],
|
|
96291
98332
|
selectedItems: [],
|
|
96292
98333
|
searchInput: '',
|
|
98334
|
+
isShow: true,
|
|
98335
|
+
isShowSearch: false,
|
|
96293
98336
|
totalCount: 0,
|
|
96294
98337
|
selectedCount: 0,
|
|
96295
98338
|
isAllSelected: false,
|
|
96296
98339
|
isInternalUpdate: false,
|
|
98340
|
+
// 防止循环更新的标志
|
|
96297
98341
|
batchSearchVisible: false,
|
|
98342
|
+
// 批量搜索弹窗显示状态
|
|
96298
98343
|
batchSearchContent: '',
|
|
98344
|
+
// 批量搜索输入内容
|
|
98345
|
+
compactPanelValue: [],
|
|
98346
|
+
// 紧凑模式下稳定的空 value 引用,避免 watch 误触发清空
|
|
96299
98347
|
searchDebounceTimer: null,
|
|
96300
|
-
|
|
98348
|
+
searchLeafSetCache: null
|
|
96301
98349
|
};
|
|
96302
98350
|
},
|
|
96303
98351
|
computed: {
|
|
98352
|
+
disabledConfig() {
|
|
98353
|
+
return {
|
|
98354
|
+
disabledField: this.disabledField,
|
|
98355
|
+
disabledValue: this.disabledValue,
|
|
98356
|
+
disabledCheck: this.disabledCheck
|
|
98357
|
+
};
|
|
98358
|
+
},
|
|
98359
|
+
// 处理后的面板高度,确保在有效范围内
|
|
96304
98360
|
computedPanelHeight() {
|
|
96305
98361
|
const height = Number(this.panelHeight);
|
|
96306
|
-
if (isNaN(height))
|
|
98362
|
+
if (isNaN(height)) {
|
|
98363
|
+
return 300; // 默认值
|
|
98364
|
+
}
|
|
98365
|
+
// 限制在 200px 到 800px 之间
|
|
96307
98366
|
return Math.max(200, Math.min(800, height));
|
|
96308
98367
|
},
|
|
98368
|
+
// 是否为多选模式
|
|
96309
98369
|
isMultiple() {
|
|
96310
98370
|
return this.cascaderProps.multiple !== false;
|
|
96311
98371
|
},
|
|
96312
|
-
|
|
96313
|
-
return this.
|
|
96314
|
-
},
|
|
96315
|
-
labelKey() {
|
|
96316
|
-
return this.cascaderProps.label || 'label';
|
|
98372
|
+
useCompactSelection() {
|
|
98373
|
+
return this.isMultiple && this.totalCount >= 300;
|
|
96317
98374
|
},
|
|
96318
|
-
|
|
96319
|
-
|
|
98375
|
+
panelPresentationValue() {
|
|
98376
|
+
if (this.useCompactSelection) {
|
|
98377
|
+
return this.compactPanelValue;
|
|
98378
|
+
}
|
|
98379
|
+
if (this.isMultiple) {
|
|
98380
|
+
return this.selectedValues;
|
|
98381
|
+
}
|
|
98382
|
+
return this.selectedValues.length > 0 ? this.selectedValues[0] : [];
|
|
96320
98383
|
},
|
|
96321
|
-
|
|
96322
|
-
return this.
|
|
98384
|
+
compactSearchPanelValue() {
|
|
98385
|
+
return this.compactPanelValue;
|
|
96323
98386
|
},
|
|
96324
|
-
|
|
96325
|
-
return
|
|
96326
|
-
label: this.labelKey,
|
|
96327
|
-
children: this.childrenKey,
|
|
96328
|
-
disabled: 'disabled'
|
|
96329
|
-
};
|
|
98387
|
+
selectedItemHeight() {
|
|
98388
|
+
return 40;
|
|
96330
98389
|
},
|
|
96331
|
-
|
|
96332
|
-
return
|
|
96333
|
-
disabledField: this.disabledField,
|
|
96334
|
-
disabledValue: this.disabledValue,
|
|
96335
|
-
disabledCheck: this.disabledCheck
|
|
96336
|
-
};
|
|
98390
|
+
selectedListHeight() {
|
|
98391
|
+
return Math.max(120, this.computedPanelHeight - 25);
|
|
96337
98392
|
},
|
|
98393
|
+
// 当前选中的值(单选时返回单个值,多选时返回数组)
|
|
96338
98394
|
currentValue() {
|
|
96339
98395
|
if (this.isMultiple) {
|
|
96340
98396
|
return this.selectedItems.map(item => item.value);
|
|
98397
|
+
} else {
|
|
98398
|
+
return this.selectedItems.length > 0 ? this.selectedItems[0].value : null;
|
|
98399
|
+
}
|
|
98400
|
+
},
|
|
98401
|
+
// 主面板的值(单选时返回单个路径,多选时返回路径数组)
|
|
98402
|
+
mainPanelValue: {
|
|
98403
|
+
get() {
|
|
98404
|
+
if (this.isMultiple) {
|
|
98405
|
+
return this.selectedValues;
|
|
98406
|
+
} else {
|
|
98407
|
+
return this.selectedValues.length > 0 ? this.selectedValues[0] : [];
|
|
98408
|
+
}
|
|
98409
|
+
},
|
|
98410
|
+
set(value) {
|
|
98411
|
+
if (this.isMultiple) {
|
|
98412
|
+
this.selectedValues = value || [];
|
|
98413
|
+
} else {
|
|
98414
|
+
this.selectedValues = value ? [value] : [];
|
|
98415
|
+
}
|
|
98416
|
+
}
|
|
98417
|
+
},
|
|
98418
|
+
// 搜索面板的值(单选时返回单个路径,多选时返回路径数组)
|
|
98419
|
+
searchPanelValue: {
|
|
98420
|
+
get() {
|
|
98421
|
+
if (this.isMultiple) {
|
|
98422
|
+
return this.searchSelectedValues;
|
|
98423
|
+
} else {
|
|
98424
|
+
return this.searchSelectedValues.length > 0 ? this.searchSelectedValues[0] : [];
|
|
98425
|
+
}
|
|
98426
|
+
},
|
|
98427
|
+
set(value) {
|
|
98428
|
+
if (this.isMultiple) {
|
|
98429
|
+
this.searchSelectedValues = value || [];
|
|
98430
|
+
} else {
|
|
98431
|
+
this.searchSelectedValues = value ? [value] : [];
|
|
98432
|
+
}
|
|
96341
98433
|
}
|
|
96342
|
-
return this.selectedItems.length > 0 ? this.selectedItems[0].value : null;
|
|
96343
98434
|
}
|
|
96344
98435
|
},
|
|
96345
98436
|
watch: {
|
|
96346
98437
|
options: {
|
|
96347
|
-
handler() {
|
|
98438
|
+
handler(newVal) {
|
|
96348
98439
|
this.initOptions();
|
|
96349
98440
|
},
|
|
98441
|
+
deep: true,
|
|
96350
98442
|
immediate: true
|
|
96351
98443
|
},
|
|
96352
98444
|
value: {
|
|
96353
|
-
handler() {
|
|
98445
|
+
handler(newVal) {
|
|
98446
|
+
// 如果是内部更新触发的,跳过处理
|
|
96354
98447
|
if (this.isInternalUpdate) {
|
|
96355
98448
|
this.isInternalUpdate = false;
|
|
96356
98449
|
return;
|
|
96357
98450
|
}
|
|
96358
|
-
if (!this.filteredOptions.length) return;
|
|
96359
98451
|
this.processValue();
|
|
96360
98452
|
},
|
|
96361
|
-
deep: true
|
|
98453
|
+
deep: true,
|
|
98454
|
+
immediate: true
|
|
96362
98455
|
},
|
|
96363
|
-
|
|
96364
|
-
|
|
96365
|
-
this.
|
|
98456
|
+
searchInput(val) {
|
|
98457
|
+
if (!val) {
|
|
98458
|
+
this.clearSearchState();
|
|
98459
|
+
return;
|
|
98460
|
+
}
|
|
98461
|
+
this.scheduleSearch();
|
|
98462
|
+
},
|
|
98463
|
+
selectedItems: {
|
|
98464
|
+
handler(newVal) {
|
|
98465
|
+
if (this.isMultiple) {
|
|
98466
|
+
const panel = this.$refs.cascaderPanel;
|
|
98467
|
+
if (this.useCompactSelection && !this.aggregationMode && panel && panel.selection && panel.selection.isCompactSelection()) {
|
|
98468
|
+
this.selectedCount = panel.selection.size();
|
|
98469
|
+
} else {
|
|
98470
|
+
this.selectedCount = newVal.length;
|
|
98471
|
+
}
|
|
98472
|
+
if (!this.useCompactSelection) {
|
|
98473
|
+
if (this.aggregationMode) {
|
|
98474
|
+
const config = {
|
|
98475
|
+
disabledField: this.disabledField,
|
|
98476
|
+
disabledValue: this.disabledValue,
|
|
98477
|
+
disabledCheck: this.disabledCheck
|
|
98478
|
+
};
|
|
98479
|
+
this.isAllSelected = CascaderUtilsPro.isAggregatedAllSelected(this.selectedValues, this.filteredOptions, config, this.cascaderProps);
|
|
98480
|
+
} else {
|
|
98481
|
+
this.isAllSelected = this.selectedCount === this.totalCount;
|
|
98482
|
+
}
|
|
98483
|
+
}
|
|
98484
|
+
} else {
|
|
98485
|
+
if (newVal.length > 1) {
|
|
98486
|
+
this.selectedItems = [newVal[newVal.length - 1]];
|
|
98487
|
+
}
|
|
98488
|
+
this.selectedCount = this.selectedItems.length;
|
|
98489
|
+
}
|
|
96366
98490
|
},
|
|
96367
|
-
deep:
|
|
98491
|
+
deep: false
|
|
96368
98492
|
}
|
|
96369
98493
|
},
|
|
96370
98494
|
mounted() {
|
|
98495
|
+
this.initOptions();
|
|
98496
|
+
// 确保在 mounted 后处理默认值
|
|
96371
98497
|
this.$nextTick(() => {
|
|
96372
|
-
this.
|
|
96373
|
-
this.syncTreeCheckedState();
|
|
98498
|
+
this.processValue();
|
|
96374
98499
|
});
|
|
98500
|
+
// 组件挂载后强制调整样式
|
|
98501
|
+
this.forceVerticalCenter();
|
|
96375
98502
|
},
|
|
96376
98503
|
beforeDestroy() {
|
|
96377
98504
|
if (this.searchDebounceTimer) {
|
|
96378
98505
|
clearTimeout(this.searchDebounceTimer);
|
|
98506
|
+
this.searchDebounceTimer = null;
|
|
96379
98507
|
}
|
|
96380
98508
|
},
|
|
96381
98509
|
methods: {
|
|
96382
|
-
|
|
96383
|
-
this.
|
|
96384
|
-
|
|
96385
|
-
|
|
96386
|
-
this.
|
|
98510
|
+
onMainPanelInput(value) {
|
|
98511
|
+
if (this.useCompactSelection && Array.isArray(value) && value.length >= 300) {
|
|
98512
|
+
return;
|
|
98513
|
+
}
|
|
98514
|
+
if (this.isMultiple) {
|
|
98515
|
+
this.selectedValues = Array.isArray(value) ? value : [];
|
|
98516
|
+
} else {
|
|
98517
|
+
this.selectedValues = value && value.length ? [value] : [];
|
|
98518
|
+
}
|
|
96387
98519
|
},
|
|
96388
|
-
|
|
96389
|
-
const
|
|
96390
|
-
if (
|
|
96391
|
-
|
|
96392
|
-
const dfs = items => {
|
|
96393
|
-
items.forEach(item => {
|
|
96394
|
-
item[disabledKey] = true;
|
|
96395
|
-
if (item[this.childrenKey] && item[this.childrenKey].length > 0) {
|
|
96396
|
-
dfs(item[this.childrenKey]);
|
|
96397
|
-
}
|
|
96398
|
-
});
|
|
96399
|
-
};
|
|
96400
|
-
dfs(processedOptions);
|
|
96401
|
-
return processedOptions;
|
|
98520
|
+
applyPanelSelectionChange() {
|
|
98521
|
+
const panel = this.$refs.cascaderPanel;
|
|
98522
|
+
if (!panel || !panel.store || !panel.selection) {
|
|
98523
|
+
return;
|
|
96402
98524
|
}
|
|
96403
|
-
|
|
96404
|
-
|
|
98525
|
+
const {
|
|
98526
|
+
store,
|
|
98527
|
+
selection
|
|
98528
|
+
} = panel;
|
|
98529
|
+
if (this.aggregationMode) {
|
|
98530
|
+
const items = CascaderUtilsPro.getAggregatedItemsFromSelection(store, selection, this.filteredOptions, this.cascaderProps);
|
|
98531
|
+
this.selectedItems = items;
|
|
98532
|
+
this.selectedCount = items.length;
|
|
98533
|
+
this.isAllSelected = selection.size() === store.totalLeafCount && store.totalLeafCount > 0;
|
|
98534
|
+
if (!selection.isCompactSelection()) {
|
|
98535
|
+
this.selectedValues = selection.getCheckedPaths();
|
|
98536
|
+
}
|
|
98537
|
+
this.isInternalUpdate = true;
|
|
98538
|
+
let emitValue = CascaderUtilsPro.getAggregatedEmitValues(items, this.parentNodePrefix);
|
|
98539
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
98540
|
+
emitValue = emitValue[0];
|
|
98541
|
+
}
|
|
98542
|
+
this.$emit('input', emitValue);
|
|
98543
|
+
this.$emit('change', this.getSelectedData());
|
|
98544
|
+
panel.bumpSelectionView();
|
|
98545
|
+
return;
|
|
98546
|
+
}
|
|
98547
|
+
if (selection.isCompactSelection()) {
|
|
98548
|
+
this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
|
|
98549
|
+
this.selectedCount = this.aggregationMode ? this.selectedItems.length : selection.size();
|
|
98550
|
+
this.isAllSelected = selection.size() === store.totalLeafCount;
|
|
98551
|
+
this.isInternalUpdate = true;
|
|
98552
|
+
this.$emit('input', this.currentValue);
|
|
98553
|
+
this.$emit('change', this.getSelectedData());
|
|
98554
|
+
panel.bumpSelectionView();
|
|
98555
|
+
return;
|
|
98556
|
+
}
|
|
98557
|
+
this.selectedValues = selection.getCheckedPaths();
|
|
98558
|
+
this.updateSelectedItems();
|
|
98559
|
+
panel.bumpSelectionView();
|
|
98560
|
+
this.$nextTick(() => {
|
|
98561
|
+
this.isInternalUpdate = true;
|
|
98562
|
+
let emitValue = this.currentValue;
|
|
98563
|
+
if (this.aggregationMode) {
|
|
98564
|
+
emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
98565
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
98566
|
+
emitValue = emitValue[0];
|
|
98567
|
+
}
|
|
98568
|
+
}
|
|
98569
|
+
this.$emit('input', emitValue);
|
|
98570
|
+
this.$emit('change', this.getSelectedData());
|
|
98571
|
+
});
|
|
96405
98572
|
},
|
|
96406
|
-
|
|
96407
|
-
if (!
|
|
96408
|
-
|
|
96409
|
-
|
|
96410
|
-
|
|
96411
|
-
|
|
96412
|
-
|
|
96413
|
-
|
|
98573
|
+
buildSelectedItemsFromValuesLazy(panel) {
|
|
98574
|
+
if (!panel || !panel.selection) {
|
|
98575
|
+
return [];
|
|
98576
|
+
}
|
|
98577
|
+
if (!panel.selection.isCompactSelection()) {
|
|
98578
|
+
return this.buildSelectedItemsFromValues();
|
|
98579
|
+
}
|
|
98580
|
+
return CascaderUtilsPro.buildSelectedItemsFromSelection(panel.store, panel.selection, this.filteredOptions, this.cascaderProps);
|
|
98581
|
+
},
|
|
98582
|
+
syncPanelFromExternalValue() {
|
|
98583
|
+
const panel = this.$refs.cascaderPanel;
|
|
98584
|
+
if (!panel || !panel.selection || !panel.store) {
|
|
98585
|
+
return;
|
|
98586
|
+
}
|
|
98587
|
+
if (!Array.isArray(this.value) || this.value.length === 0) {
|
|
98588
|
+
panel.clearCheckedNodes();
|
|
98589
|
+
this.selectedItems = [];
|
|
98590
|
+
this.selectedValues = [];
|
|
98591
|
+
return;
|
|
98592
|
+
}
|
|
98593
|
+
const paths = this.resolveExternalValueToPaths();
|
|
98594
|
+
panel.selection.clear();
|
|
98595
|
+
paths.forEach(path => {
|
|
98596
|
+
const leafValue = path[path.length - 1];
|
|
98597
|
+
if (panel.store.pathByLeafValue.has(leafValue)) {
|
|
98598
|
+
panel.selection.selectedLeafSet.add(leafValue);
|
|
96414
98599
|
}
|
|
96415
|
-
return cloned;
|
|
96416
98600
|
});
|
|
98601
|
+
panel.selection._reconcileAllRoots();
|
|
98602
|
+
panel.bumpSelectionView();
|
|
98603
|
+
this.applyPanelSelectionChange();
|
|
98604
|
+
this.expandPanelToExternalValue(panel);
|
|
96417
98605
|
},
|
|
96418
|
-
|
|
96419
|
-
|
|
98606
|
+
resolveExternalValueToPaths() {
|
|
98607
|
+
if (!Array.isArray(this.value) || this.value.length === 0) {
|
|
98608
|
+
return [];
|
|
98609
|
+
}
|
|
98610
|
+
if (typeof this.value[0] === 'string' || typeof this.value[0] === 'number') {
|
|
98611
|
+
if (this.aggregationMode) {
|
|
98612
|
+
return CascaderUtilsPro.processValuesWithParentNodes(this.value, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
98613
|
+
}
|
|
98614
|
+
return this.findPathsByValues(this.value);
|
|
98615
|
+
}
|
|
98616
|
+
return [...this.value];
|
|
98617
|
+
},
|
|
98618
|
+
expandPanelToExternalValue(panel) {
|
|
98619
|
+
if (!panel || !panel.store || !Array.isArray(this.value) || this.value.length === 0) {
|
|
98620
|
+
return;
|
|
98621
|
+
}
|
|
98622
|
+
const firstValue = this.value[0];
|
|
98623
|
+
let pathValues = [];
|
|
98624
|
+
if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(firstValue, this.parentNodePrefix)) {
|
|
98625
|
+
const actualValue = CascaderUtilsPro.extractParentNodeValue(firstValue, this.parentNodePrefix);
|
|
98626
|
+
const node = panel.store.nodeByValue.get(actualValue);
|
|
98627
|
+
pathValues = node ? [...node.path] : [];
|
|
98628
|
+
} else if (panel.store.pathByLeafValue.has(firstValue)) {
|
|
98629
|
+
const path = panel.store.pathByLeafValue.get(firstValue);
|
|
98630
|
+
pathValues = path ? path.slice(0, -1) : [];
|
|
98631
|
+
} else {
|
|
98632
|
+
const node = panel.store.nodeByValue.get(firstValue);
|
|
98633
|
+
if (node) {
|
|
98634
|
+
pathValues = node.isLeaf ? node.path.slice(0, -1) : [...node.path];
|
|
98635
|
+
}
|
|
98636
|
+
}
|
|
98637
|
+
if (pathValues.length > 0) {
|
|
98638
|
+
this.$nextTick(() => {
|
|
98639
|
+
panel.expandPathValues(pathValues, true);
|
|
98640
|
+
});
|
|
98641
|
+
}
|
|
98642
|
+
},
|
|
98643
|
+
onSearchPanelInput(value) {
|
|
98644
|
+
if (this.useCompactSelection && Array.isArray(value) && value.length >= 300) {
|
|
98645
|
+
return;
|
|
98646
|
+
}
|
|
98647
|
+
if (this.isMultiple) {
|
|
98648
|
+
this.searchSelectedValues = Array.isArray(value) ? value : [];
|
|
98649
|
+
} else {
|
|
98650
|
+
this.searchSelectedValues = value && value.length ? [value] : [];
|
|
98651
|
+
}
|
|
96420
98652
|
},
|
|
98653
|
+
// 处理 value 值
|
|
96421
98654
|
processValue() {
|
|
96422
|
-
if (
|
|
98655
|
+
if (this.useCompactSelection && this.isMultiple) {
|
|
98656
|
+
this.selectedValues = [];
|
|
98657
|
+
this.$nextTick(() => {
|
|
98658
|
+
this.syncPanelFromExternalValue();
|
|
98659
|
+
});
|
|
98660
|
+
return;
|
|
98661
|
+
}
|
|
96423
98662
|
if (this.isMultiple) {
|
|
98663
|
+
// 多选模式:支持直接传入value值或路径数组
|
|
96424
98664
|
if (Array.isArray(this.value) && this.value.length > 0) {
|
|
96425
98665
|
if (typeof this.value[0] === 'string' || typeof this.value[0] === 'number') {
|
|
98666
|
+
// 传入的是value值数组,需要转换为路径
|
|
96426
98667
|
if (this.aggregationMode) {
|
|
96427
|
-
|
|
98668
|
+
// 聚合模式下,支持非叶子节点标识
|
|
98669
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes(this.value, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
96428
98670
|
} else {
|
|
96429
|
-
|
|
98671
|
+
// 普通模式下,只处理叶子节点
|
|
98672
|
+
this.selectedValues = this.findPathsByValues(this.value);
|
|
96430
98673
|
}
|
|
96431
98674
|
} else {
|
|
98675
|
+
// 传入的是路径数组
|
|
96432
98676
|
this.selectedValues = [...this.value];
|
|
96433
98677
|
}
|
|
96434
98678
|
} else {
|
|
96435
98679
|
this.selectedValues = [];
|
|
96436
98680
|
}
|
|
96437
|
-
} else
|
|
96438
|
-
|
|
96439
|
-
|
|
96440
|
-
|
|
96441
|
-
|
|
98681
|
+
} else {
|
|
98682
|
+
// 单选模式:支持单个值或路径数组
|
|
98683
|
+
if (this.value !== null && this.value !== undefined && this.value !== '') {
|
|
98684
|
+
if (Array.isArray(this.value)) {
|
|
98685
|
+
// 传入的是路径数组
|
|
98686
|
+
this.selectedValues = [...this.value];
|
|
98687
|
+
} else {
|
|
98688
|
+
// 传入的是单个值,需要转换为路径
|
|
98689
|
+
if (this.aggregationMode) {
|
|
98690
|
+
// 聚合模式下,支持非叶子节点标识
|
|
98691
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes([this.value], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
98692
|
+
} else {
|
|
98693
|
+
// 普通模式下,只处理叶子节点
|
|
98694
|
+
this.selectedValues = this.findPathsByValues([this.value]);
|
|
98695
|
+
}
|
|
98696
|
+
}
|
|
96442
98697
|
} else {
|
|
96443
|
-
this.selectedValues =
|
|
98698
|
+
this.selectedValues = [];
|
|
96444
98699
|
}
|
|
96445
|
-
} else {
|
|
96446
|
-
this.selectedValues = [];
|
|
96447
98700
|
}
|
|
96448
98701
|
this.updateSelectedItems();
|
|
96449
|
-
|
|
96450
|
-
|
|
96451
|
-
|
|
96452
|
-
|
|
96453
|
-
|
|
96454
|
-
|
|
96455
|
-
|
|
98702
|
+
|
|
98703
|
+
// 单选模式下,确保级联面板正确显示选中状态
|
|
98704
|
+
if (!this.isMultiple && this.selectedValues.length > 0) {
|
|
98705
|
+
this.$nextTick(() => {
|
|
98706
|
+
const panel = this.$refs.cascaderPanel;
|
|
98707
|
+
if (panel) {
|
|
98708
|
+
panel.syncCheckedValue();
|
|
98709
|
+
this.updateSelectedItems();
|
|
98710
|
+
}
|
|
98711
|
+
});
|
|
96456
98712
|
}
|
|
96457
|
-
this.selectedCount = this.selectedItems.length;
|
|
96458
|
-
this.$emit('change', this.getSelectedData());
|
|
96459
98713
|
},
|
|
96460
|
-
|
|
96461
|
-
|
|
96462
|
-
|
|
96463
|
-
|
|
98714
|
+
// 初始化选项数据
|
|
98715
|
+
initOptions() {
|
|
98716
|
+
this.filteredOptions = this.processOptions(this.options);
|
|
98717
|
+
this.countTotalItems();
|
|
98718
|
+
if (this.isMultiple && Array.isArray(this.value) && this.value.length > 0 && (this.useCompactSelection || this.$refs.cascaderPanel)) {
|
|
98719
|
+
this.$nextTick(() => {
|
|
98720
|
+
this.syncPanelFromExternalValue();
|
|
98721
|
+
});
|
|
96464
98722
|
} else {
|
|
96465
|
-
this.
|
|
98723
|
+
this.updateSelectedItems();
|
|
96466
98724
|
}
|
|
96467
98725
|
},
|
|
96468
|
-
|
|
96469
|
-
|
|
96470
|
-
|
|
96471
|
-
|
|
96472
|
-
|
|
96473
|
-
|
|
96474
|
-
|
|
96475
|
-
|
|
96476
|
-
|
|
96477
|
-
|
|
96478
|
-
|
|
96479
|
-
|
|
96480
|
-
|
|
96481
|
-
|
|
96482
|
-
|
|
98726
|
+
// 处理选项数据,添加禁用状态(浅拷贝,避免 JSON 深拷贝大数据卡顿)
|
|
98727
|
+
processOptions(options) {
|
|
98728
|
+
const childrenKey = this.cascaderProps && this.cascaderProps.children || 'children';
|
|
98729
|
+
const disabledKey = this.cascaderProps && this.cascaderProps.disabled || 'disabled';
|
|
98730
|
+
const config = this.disabledConfig;
|
|
98731
|
+
const cloneItems = (items, ancestorDisabled = false) => {
|
|
98732
|
+
return items.map(item => {
|
|
98733
|
+
const isDisabled = ancestorDisabled || CascaderUtilsPro.isItemDisabled(item, config);
|
|
98734
|
+
const children = item[childrenKey];
|
|
98735
|
+
const cloned = {
|
|
98736
|
+
...item
|
|
98737
|
+
};
|
|
98738
|
+
if (this.isViewMode || isDisabled) {
|
|
98739
|
+
cloned[disabledKey] = true;
|
|
98740
|
+
}
|
|
98741
|
+
if (children && children.length > 0) {
|
|
98742
|
+
cloned[childrenKey] = cloneItems(children, isDisabled || this.isViewMode);
|
|
98743
|
+
}
|
|
98744
|
+
return cloned;
|
|
98745
|
+
});
|
|
98746
|
+
};
|
|
98747
|
+
return cloneItems(options || []);
|
|
98748
|
+
},
|
|
98749
|
+
// 判断项目是否禁用
|
|
98750
|
+
isItemDisabled(item) {
|
|
98751
|
+
const config = {
|
|
98752
|
+
disabledField: this.disabledField,
|
|
98753
|
+
disabledValue: this.disabledValue,
|
|
98754
|
+
disabledCheck: this.disabledCheck
|
|
98755
|
+
};
|
|
98756
|
+
return CascaderUtilsPro.isItemDisabled(item, config);
|
|
98757
|
+
},
|
|
98758
|
+
// 统计总项目数
|
|
98759
|
+
countTotalItems() {
|
|
98760
|
+
const config = {
|
|
98761
|
+
disabledField: this.disabledField,
|
|
98762
|
+
disabledValue: this.disabledValue,
|
|
98763
|
+
disabledCheck: this.disabledCheck
|
|
98764
|
+
};
|
|
98765
|
+
this.totalCount = CascaderUtilsPro.countTotalItems(this.filteredOptions, config, this.cascaderProps);
|
|
96483
98766
|
},
|
|
96484
|
-
|
|
98767
|
+
// 更新已选项列表
|
|
98768
|
+
updateSelectedItems() {
|
|
96485
98769
|
this.$nextTick(() => {
|
|
96486
|
-
const
|
|
96487
|
-
if (
|
|
96488
|
-
|
|
96489
|
-
|
|
96490
|
-
|
|
96491
|
-
|
|
96492
|
-
|
|
96493
|
-
const leafKey = this.selectedValues[0][this.selectedValues[0].length - 1];
|
|
96494
|
-
tree.setCurrentKey(leafKey);
|
|
98770
|
+
const panel = this.$refs.cascaderPanel;
|
|
98771
|
+
if (this.aggregationMode) {
|
|
98772
|
+
if (panel && panel.store && panel.selection) {
|
|
98773
|
+
this.selectedItems = CascaderUtilsPro.getAggregatedItemsFromSelection(panel.store, panel.selection, this.filteredOptions, this.cascaderProps);
|
|
98774
|
+
} else {
|
|
98775
|
+
this.selectedItems = CascaderUtilsPro.getAggregatedSelectedItems(this.selectedValues, this.filteredOptions, this.cascaderProps);
|
|
98776
|
+
}
|
|
96495
98777
|
} else {
|
|
96496
|
-
|
|
98778
|
+
this.selectedItems = this.buildSelectedItemsFromValues();
|
|
96497
98779
|
}
|
|
96498
|
-
this.$nextTick(() => {
|
|
96499
|
-
this.isSyncingTree = false;
|
|
96500
|
-
});
|
|
96501
98780
|
});
|
|
96502
98781
|
},
|
|
96503
|
-
|
|
96504
|
-
|
|
96505
|
-
|
|
96506
|
-
if (!tree) return;
|
|
96507
|
-
const leafKeys = tree.getCheckedKeys(true);
|
|
96508
|
-
this.selectedValues = CascaderUtils.findPathsByValues(leafKeys, this.filteredOptions, this.cascaderProps);
|
|
96509
|
-
this.updateSelectedItems();
|
|
96510
|
-
this.emitInput();
|
|
96511
|
-
},
|
|
96512
|
-
handleNodeClick(data, node) {
|
|
96513
|
-
if (this.isMultiple || this.isViewMode) return;
|
|
96514
|
-
const hasChildren = data[this.childrenKey] && data[this.childrenKey].length > 0;
|
|
96515
|
-
if (hasChildren) return;
|
|
96516
|
-
if (CascaderUtils.isItemDisabled(data, this.disabledConfig)) return;
|
|
96517
|
-
this.selectedValues = [this.getNodePath(node)];
|
|
96518
|
-
this.updateSelectedItems();
|
|
96519
|
-
this.emitInput();
|
|
98782
|
+
// 基于 selectedValues 构建已选项列表
|
|
98783
|
+
buildSelectedItemsFromValues() {
|
|
98784
|
+
return CascaderUtilsPro.buildSelectedItemsFromValues(this.selectedValues, this.filteredOptions, this.cascaderProps);
|
|
96520
98785
|
},
|
|
96521
|
-
|
|
98786
|
+
// 搜索处理(防抖,避免每次按键遍历整棵树)
|
|
98787
|
+
scheduleSearch() {
|
|
96522
98788
|
if (this.searchDebounceTimer) {
|
|
96523
98789
|
clearTimeout(this.searchDebounceTimer);
|
|
96524
98790
|
}
|
|
96525
98791
|
this.searchDebounceTimer = setTimeout(() => {
|
|
96526
|
-
|
|
96527
|
-
|
|
96528
|
-
|
|
96529
|
-
|
|
96530
|
-
|
|
96531
|
-
|
|
96532
|
-
|
|
96533
|
-
this
|
|
96534
|
-
|
|
96535
|
-
|
|
96536
|
-
|
|
96537
|
-
|
|
98792
|
+
this.searchDebounceTimer = null;
|
|
98793
|
+
this.runSearch();
|
|
98794
|
+
}, 100);
|
|
98795
|
+
},
|
|
98796
|
+
clearSearchState() {
|
|
98797
|
+
if (this.searchDebounceTimer) {
|
|
98798
|
+
clearTimeout(this.searchDebounceTimer);
|
|
98799
|
+
this.searchDebounceTimer = null;
|
|
98800
|
+
}
|
|
98801
|
+
this.isShowSearch = false;
|
|
98802
|
+
this.searchOptions = [];
|
|
98803
|
+
this.searchLeafSetCache = null;
|
|
98804
|
+
this.searchSelectedValues = [];
|
|
96538
98805
|
},
|
|
96539
|
-
|
|
96540
|
-
const
|
|
96541
|
-
if (!
|
|
96542
|
-
|
|
96543
|
-
|
|
96544
|
-
|
|
96545
|
-
|
|
98806
|
+
runSearch() {
|
|
98807
|
+
const keyword = this.searchInput.trim();
|
|
98808
|
+
if (!keyword) {
|
|
98809
|
+
this.clearSearchState();
|
|
98810
|
+
return;
|
|
98811
|
+
}
|
|
98812
|
+
const panel = this.$refs.cascaderPanel;
|
|
98813
|
+
if (panel && panel.store) {
|
|
98814
|
+
this.searchOptions = CascaderUtilsPro.searchFromStore(panel.store, keyword, this.cascaderProps);
|
|
98815
|
+
} else {
|
|
98816
|
+
this.searchOptions = CascaderUtilsPro.searchInTree(this.filteredOptions, keyword, this.cascaderProps);
|
|
98817
|
+
}
|
|
98818
|
+
this.searchLeafSetCache = new Set(CascaderUtilsPro.getLeafValues(this.searchOptions, this.cascaderProps));
|
|
98819
|
+
this.searchSelectedValues = this.getSearchSelectedPathsFromMain(this.searchLeafSetCache);
|
|
98820
|
+
this.isShowSearch = true;
|
|
98821
|
+
this.$nextTick(() => {
|
|
98822
|
+
if (this.searchOptions.length > 0) {
|
|
98823
|
+
this.syncSearchPanelSelection();
|
|
98824
|
+
this.handleSearchExpand();
|
|
96546
98825
|
}
|
|
96547
|
-
};
|
|
96548
|
-
tree.store.root.childNodes.forEach(expandNode);
|
|
98826
|
+
});
|
|
96549
98827
|
},
|
|
96550
|
-
|
|
96551
|
-
|
|
98828
|
+
getSearchSelectedPathsFromMain(searchLeafSet) {
|
|
98829
|
+
const panel = this.$refs.cascaderPanel;
|
|
98830
|
+
if (panel && panel.selection && panel.store) {
|
|
98831
|
+
const paths = [];
|
|
98832
|
+
panel.selection.selectedLeafSet.forEach(leaf => {
|
|
98833
|
+
if (searchLeafSet.has(leaf)) {
|
|
98834
|
+
const path = panel.store.pathByLeafValue.get(leaf);
|
|
98835
|
+
if (path) {
|
|
98836
|
+
paths.push(path);
|
|
98837
|
+
}
|
|
98838
|
+
}
|
|
98839
|
+
});
|
|
98840
|
+
return paths;
|
|
98841
|
+
}
|
|
98842
|
+
return CascaderUtilsPro.getSearchSelectedValues(this.selectedValues, this.searchOptions, this.cascaderProps);
|
|
96552
98843
|
},
|
|
96553
|
-
|
|
96554
|
-
if (
|
|
96555
|
-
|
|
96556
|
-
this.selectedValues = [];
|
|
96557
|
-
} else {
|
|
96558
|
-
this.selectedValues = CascaderUtils.getAllLeafPaths(this.filteredOptions, this.disabledConfig, this.cascaderProps);
|
|
98844
|
+
getSearchLeafSet() {
|
|
98845
|
+
if (this.searchLeafSetCache) {
|
|
98846
|
+
return this.searchLeafSetCache;
|
|
96559
98847
|
}
|
|
96560
|
-
this.
|
|
96561
|
-
this.syncTreeCheckedState();
|
|
96562
|
-
this.emitInput();
|
|
98848
|
+
return new Set(CascaderUtilsPro.getLeafValues(this.searchOptions, this.cascaderProps));
|
|
96563
98849
|
},
|
|
96564
|
-
|
|
96565
|
-
const
|
|
96566
|
-
|
|
96567
|
-
|
|
96568
|
-
|
|
96569
|
-
|
|
96570
|
-
|
|
96571
|
-
|
|
98850
|
+
syncSearchPanelSelection() {
|
|
98851
|
+
const searchPanel = this.$refs.searchCascaderPanel;
|
|
98852
|
+
const mainPanel = this.$refs.cascaderPanel;
|
|
98853
|
+
if (!searchPanel || !mainPanel || !searchPanel.selection || !mainPanel.selection) {
|
|
98854
|
+
return;
|
|
98855
|
+
}
|
|
98856
|
+
const searchLeafSet = this.getSearchLeafSet();
|
|
98857
|
+
searchPanel.selection.clear();
|
|
98858
|
+
mainPanel.selection.selectedLeafSet.forEach(leaf => {
|
|
98859
|
+
if (searchLeafSet.has(leaf)) {
|
|
98860
|
+
searchPanel.selection.selectedLeafSet.add(leaf);
|
|
96572
98861
|
}
|
|
98862
|
+
});
|
|
98863
|
+
searchPanel.selection._reconcileAllRoots();
|
|
98864
|
+
searchPanel.bumpSelectionView();
|
|
98865
|
+
},
|
|
98866
|
+
// 搜索模式下的展开处理
|
|
98867
|
+
handleSearchExpand() {
|
|
98868
|
+
if (this.$refs.searchCascaderPanel && this.searchOptions.length > 0) {
|
|
98869
|
+
const firstOption = this.searchOptions[0];
|
|
98870
|
+
const valueKey = this.cascaderProps.value || 'value';
|
|
98871
|
+
this.$refs.searchCascaderPanel.expandPathValues([firstOption[valueKey]], true);
|
|
96573
98872
|
}
|
|
96574
|
-
this.updateSelectedItems();
|
|
96575
|
-
this.emitInput();
|
|
96576
98873
|
},
|
|
96577
|
-
|
|
96578
|
-
|
|
96579
|
-
this.
|
|
96580
|
-
|
|
96581
|
-
|
|
98874
|
+
// 值变化处理
|
|
98875
|
+
handleValueChange() {
|
|
98876
|
+
this.applyPanelSelectionChange();
|
|
98877
|
+
},
|
|
98878
|
+
// 搜索模式值变化处理
|
|
98879
|
+
handleSearchValueChange() {
|
|
98880
|
+
const searchPanel = this.$refs.searchCascaderPanel;
|
|
98881
|
+
const mainPanel = this.$refs.cascaderPanel;
|
|
98882
|
+
if (!searchPanel || !mainPanel || !searchPanel.selection || !mainPanel.selection) {
|
|
98883
|
+
return;
|
|
98884
|
+
}
|
|
98885
|
+
const searchLeafSet = this.getSearchLeafSet();
|
|
98886
|
+
searchLeafSet.forEach(leaf => {
|
|
98887
|
+
const shouldSelect = searchPanel.selection.selectedLeafSet.has(leaf);
|
|
98888
|
+
const isSelected = mainPanel.selection.selectedLeafSet.has(leaf);
|
|
98889
|
+
if (shouldSelect && !isSelected) {
|
|
98890
|
+
mainPanel.selection.selectedLeafSet.add(leaf);
|
|
98891
|
+
} else if (!shouldSelect && isSelected) {
|
|
98892
|
+
mainPanel.selection.selectedLeafSet.delete(leaf);
|
|
98893
|
+
}
|
|
98894
|
+
});
|
|
98895
|
+
mainPanel.selection._reconcileAllRoots();
|
|
98896
|
+
mainPanel.bumpSelectionView();
|
|
98897
|
+
this.applyPanelSelectionChange();
|
|
96582
98898
|
},
|
|
96583
|
-
|
|
98899
|
+
// 移除已选项
|
|
98900
|
+
removeItem(item, index) {
|
|
98901
|
+
const panel = this.$refs.cascaderPanel;
|
|
98902
|
+
if (panel && panel.selection) {
|
|
98903
|
+
if (item.isAggregated) {
|
|
98904
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
98905
|
+
if (node) {
|
|
98906
|
+
panel.selection.toggleNode(node.id, false);
|
|
98907
|
+
}
|
|
98908
|
+
} else if (item.path && item.path.length > 0) {
|
|
98909
|
+
const leafValue = item.path[item.path.length - 1];
|
|
98910
|
+
const leafNode = panel.store.nodeByValue.get(leafValue);
|
|
98911
|
+
if (leafNode) {
|
|
98912
|
+
panel.selection.toggleNode(leafNode.id, false);
|
|
98913
|
+
} else {
|
|
98914
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
98915
|
+
if (node) {
|
|
98916
|
+
panel.selection.toggleNode(node.id, false);
|
|
98917
|
+
}
|
|
98918
|
+
}
|
|
98919
|
+
} else {
|
|
98920
|
+
const node = panel.store.nodeByValue.get(item.value);
|
|
98921
|
+
if (node) {
|
|
98922
|
+
panel.selection.toggleNode(node.id, false);
|
|
98923
|
+
}
|
|
98924
|
+
}
|
|
98925
|
+
this.applyPanelSelectionChange();
|
|
98926
|
+
if (this.isShowSearch) {
|
|
98927
|
+
this.syncSearchPanelSelection();
|
|
98928
|
+
}
|
|
98929
|
+
return;
|
|
98930
|
+
}
|
|
98931
|
+
const valueToRemove = item.value;
|
|
98932
|
+
this.selectedValues = this.selectedValues.filter(path => {
|
|
98933
|
+
return !path.includes(valueToRemove);
|
|
98934
|
+
});
|
|
98935
|
+
this.searchSelectedValues = this.searchSelectedValues.filter(path => {
|
|
98936
|
+
return !path.includes(valueToRemove);
|
|
98937
|
+
});
|
|
98938
|
+
this.selectedItems.splice(index, 1);
|
|
96584
98939
|
this.$nextTick(() => {
|
|
96585
98940
|
this.isInternalUpdate = true;
|
|
96586
98941
|
let emitValue = this.currentValue;
|
|
96587
98942
|
if (this.aggregationMode) {
|
|
96588
|
-
emitValue =
|
|
98943
|
+
emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
96589
98944
|
if (!this.isMultiple && emitValue.length > 0) {
|
|
96590
98945
|
emitValue = emitValue[0];
|
|
96591
98946
|
}
|
|
@@ -96593,12 +98948,43 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96593
98948
|
this.$emit('input', emitValue);
|
|
96594
98949
|
});
|
|
96595
98950
|
},
|
|
98951
|
+
// 全选/取消全选
|
|
98952
|
+
handleSelectAll() {
|
|
98953
|
+
if (!this.isMultiple) {
|
|
98954
|
+
// 单选模式下不支持全选
|
|
98955
|
+
return;
|
|
98956
|
+
}
|
|
98957
|
+
if (this.isAllSelected) {
|
|
98958
|
+
const panel = this.$refs.cascaderPanel;
|
|
98959
|
+
if (panel) {
|
|
98960
|
+
panel.clearCheckedNodes();
|
|
98961
|
+
} else {
|
|
98962
|
+
this.selectedValues = [];
|
|
98963
|
+
this.selectedItems = [];
|
|
98964
|
+
this.searchSelectedValues = [];
|
|
98965
|
+
this.applyPanelSelectionChange();
|
|
98966
|
+
}
|
|
98967
|
+
} else {
|
|
98968
|
+
const panel = this.$refs.cascaderPanel;
|
|
98969
|
+
if (panel) {
|
|
98970
|
+
panel.selectAllLeaves();
|
|
98971
|
+
} else {
|
|
98972
|
+
this.selectedValues = CascaderUtilsPro.getAllLeafPaths(this.filteredOptions, this.disabledConfig, this.cascaderProps);
|
|
98973
|
+
this.updateSelectedItems();
|
|
98974
|
+
this.applyPanelSelectionChange();
|
|
98975
|
+
}
|
|
98976
|
+
}
|
|
98977
|
+
},
|
|
98978
|
+
// 获取选中的数据
|
|
96596
98979
|
getSelectedData() {
|
|
96597
98980
|
let values = this.currentValue;
|
|
96598
98981
|
let valuesPath = this.selectedValues;
|
|
98982
|
+
if (!this.aggregationMode && this.selectedItems.length > 0 && valuesPath.length === 0) {
|
|
98983
|
+
valuesPath = this.selectedItems.map(item => item.path);
|
|
98984
|
+
}
|
|
96599
98985
|
if (this.aggregationMode) {
|
|
96600
|
-
values =
|
|
96601
|
-
valuesPath =
|
|
98986
|
+
values = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
98987
|
+
valuesPath = this.selectedItems.map(item => item.path);
|
|
96602
98988
|
if (!this.isMultiple && values.length > 0) {
|
|
96603
98989
|
values = values[0];
|
|
96604
98990
|
}
|
|
@@ -96610,102 +98996,208 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96610
98996
|
count: this.selectedItems.length
|
|
96611
98997
|
};
|
|
96612
98998
|
},
|
|
98999
|
+
// 清空选择
|
|
99000
|
+
clearSelection() {
|
|
99001
|
+
const panel = this.$refs.cascaderPanel;
|
|
99002
|
+
if (panel) {
|
|
99003
|
+
panel.clearCheckedNodes();
|
|
99004
|
+
} else {
|
|
99005
|
+
this.selectedValues = [];
|
|
99006
|
+
this.selectedItems = [];
|
|
99007
|
+
this.searchSelectedValues = [];
|
|
99008
|
+
this.applyPanelSelectionChange();
|
|
99009
|
+
}
|
|
99010
|
+
},
|
|
99011
|
+
// 设置选择值
|
|
96613
99012
|
setValue(values) {
|
|
96614
99013
|
if (this.isMultiple) {
|
|
99014
|
+
// 多选模式:支持直接传入value值或路径数组
|
|
96615
99015
|
if (Array.isArray(values) && values.length > 0) {
|
|
96616
99016
|
if (typeof values[0] === 'string' || typeof values[0] === 'number') {
|
|
99017
|
+
// 传入的是value值数组,需要转换为路径
|
|
96617
99018
|
if (this.aggregationMode) {
|
|
96618
|
-
|
|
99019
|
+
// 聚合模式下,支持非叶子节点标识
|
|
99020
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes(values, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
96619
99021
|
} else {
|
|
96620
|
-
|
|
99022
|
+
// 普通模式下,只处理叶子节点
|
|
99023
|
+
this.selectedValues = this.findPathsByValues(values);
|
|
96621
99024
|
}
|
|
96622
99025
|
} else {
|
|
99026
|
+
// 传入的是路径数组
|
|
96623
99027
|
this.selectedValues = [...values];
|
|
96624
99028
|
}
|
|
96625
99029
|
} else {
|
|
96626
99030
|
this.selectedValues = [];
|
|
96627
99031
|
}
|
|
96628
|
-
} else
|
|
96629
|
-
|
|
96630
|
-
|
|
96631
|
-
|
|
96632
|
-
|
|
99032
|
+
} else {
|
|
99033
|
+
// 单选模式:支持单个值或路径数组
|
|
99034
|
+
if (values !== null && values !== undefined && values !== '') {
|
|
99035
|
+
if (Array.isArray(values)) {
|
|
99036
|
+
// 传入的是路径数组
|
|
99037
|
+
this.selectedValues = [...values];
|
|
99038
|
+
} else {
|
|
99039
|
+
// 传入的是单个值,需要转换为路径
|
|
99040
|
+
if (this.aggregationMode) {
|
|
99041
|
+
// 聚合模式下,支持非叶子节点标识
|
|
99042
|
+
this.selectedValues = CascaderUtilsPro.processValuesWithParentNodes([values], this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
99043
|
+
} else {
|
|
99044
|
+
// 普通模式下,只处理叶子节点
|
|
99045
|
+
this.selectedValues = this.findPathsByValues([values]);
|
|
99046
|
+
}
|
|
99047
|
+
}
|
|
96633
99048
|
} else {
|
|
96634
|
-
this.selectedValues =
|
|
99049
|
+
this.selectedValues = [];
|
|
96635
99050
|
}
|
|
96636
|
-
} else {
|
|
96637
|
-
this.selectedValues = [];
|
|
96638
99051
|
}
|
|
96639
|
-
this.syncTreeCheckedState();
|
|
96640
99052
|
this.updateSelectedItems();
|
|
96641
99053
|
},
|
|
99054
|
+
// 根据values找到对应的路径
|
|
99055
|
+
findPathsByValues(values) {
|
|
99056
|
+
const paths = [];
|
|
99057
|
+
const findPath = (options, targetValues, currentPath = []) => {
|
|
99058
|
+
for (const option of options) {
|
|
99059
|
+
const newPath = [...currentPath, option[this.cascaderProps.value]];
|
|
99060
|
+
if (targetValues.includes(option[this.cascaderProps.value])) {
|
|
99061
|
+
// 如果是叶子节点(没有children属性),添加到路径中
|
|
99062
|
+
if (!option[this.cascaderProps.children]) {
|
|
99063
|
+
paths.push(newPath);
|
|
99064
|
+
}
|
|
99065
|
+
}
|
|
99066
|
+
|
|
99067
|
+
// 递归查找子节点
|
|
99068
|
+
if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
|
|
99069
|
+
findPath(option[this.cascaderProps.children], targetValues, newPath);
|
|
99070
|
+
}
|
|
99071
|
+
}
|
|
99072
|
+
};
|
|
99073
|
+
|
|
99074
|
+
// 使用 filteredOptions 如果存在,否则使用原始 options
|
|
99075
|
+
const optionsToSearch = this.filteredOptions.length > 0 ? this.filteredOptions : this.options;
|
|
99076
|
+
findPath(optionsToSearch, values);
|
|
99077
|
+
return paths;
|
|
99078
|
+
},
|
|
99079
|
+
// 处理批量搜索弹窗显示
|
|
96642
99080
|
handleBatchSearchShow() {
|
|
96643
99081
|
if (this.searchInput) {
|
|
96644
99082
|
this.searchInput = '';
|
|
96645
|
-
this.displayOptions = this.filteredOptions;
|
|
96646
99083
|
}
|
|
96647
99084
|
},
|
|
99085
|
+
// 处理批量搜索
|
|
96648
99086
|
handleBatchSearch() {
|
|
96649
99087
|
if (!this.batchSearchContent.trim()) {
|
|
96650
99088
|
this.batchSearchVisible = false;
|
|
96651
99089
|
return;
|
|
96652
99090
|
}
|
|
99091
|
+
|
|
99092
|
+
// 分割输入内容(支持换行、逗号、分号等分隔符)
|
|
96653
99093
|
const inputNames = this.batchSearchContent.split(/[\n,;,;\s]+/).filter(item => item.trim()).map(item => item.trim());
|
|
96654
99094
|
if (inputNames.length === 0) {
|
|
96655
99095
|
this.batchSearchVisible = false;
|
|
96656
99096
|
return;
|
|
96657
99097
|
}
|
|
96658
|
-
|
|
99098
|
+
|
|
99099
|
+
// 在级联数据中搜索匹配的名称
|
|
99100
|
+
const matchedPaths = this.searchNamesInCascader(inputNames);
|
|
96659
99101
|
if (matchedPaths.length > 0) {
|
|
96660
|
-
const
|
|
96661
|
-
|
|
96662
|
-
|
|
96663
|
-
|
|
96664
|
-
|
|
96665
|
-
|
|
96666
|
-
|
|
96667
|
-
|
|
96668
|
-
|
|
96669
|
-
|
|
96670
|
-
|
|
99102
|
+
const panel = this.$refs.cascaderPanel;
|
|
99103
|
+
if (panel && panel.selection && panel.store) {
|
|
99104
|
+
matchedPaths.forEach(path => {
|
|
99105
|
+
const leafValue = path[path.length - 1];
|
|
99106
|
+
if (panel.store.pathByLeafValue.has(leafValue)) {
|
|
99107
|
+
panel.selection.selectedLeafSet.add(leafValue);
|
|
99108
|
+
}
|
|
99109
|
+
});
|
|
99110
|
+
panel.selection._reconcileAllRoots();
|
|
99111
|
+
panel.bumpSelectionView();
|
|
99112
|
+
this.applyPanelSelectionChange();
|
|
99113
|
+
} else {
|
|
99114
|
+
const newSelectedValues = [...this.selectedValues];
|
|
99115
|
+
matchedPaths.forEach(path => {
|
|
99116
|
+
const exists = newSelectedValues.some(existingPath => existingPath.length === path.length && existingPath.every((value, index) => value === path[index]));
|
|
99117
|
+
if (!exists) {
|
|
99118
|
+
newSelectedValues.push(path);
|
|
99119
|
+
}
|
|
99120
|
+
});
|
|
99121
|
+
this.selectedValues = newSelectedValues;
|
|
99122
|
+
this.updateSelectedItems();
|
|
99123
|
+
this.$nextTick(() => {
|
|
99124
|
+
this.isInternalUpdate = true;
|
|
99125
|
+
let emitValue = this.currentValue;
|
|
99126
|
+
if (this.aggregationMode) {
|
|
99127
|
+
emitValue = CascaderUtilsPro.getAggregatedSelectedValues(this.selectedValues, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
|
|
99128
|
+
if (!this.isMultiple && emitValue.length > 0) {
|
|
99129
|
+
emitValue = emitValue[0];
|
|
99130
|
+
}
|
|
99131
|
+
}
|
|
99132
|
+
this.$emit('input', emitValue);
|
|
99133
|
+
});
|
|
99134
|
+
}
|
|
96671
99135
|
}
|
|
99136
|
+
|
|
99137
|
+
// 关闭弹窗并清空内容
|
|
96672
99138
|
this.batchSearchVisible = false;
|
|
96673
99139
|
this.batchSearchContent = '';
|
|
96674
99140
|
},
|
|
96675
|
-
|
|
99141
|
+
// 在级联数据中搜索匹配的名称(全匹配,忽略空格,排除禁用项)
|
|
99142
|
+
searchNamesInCascader(names) {
|
|
96676
99143
|
const matchedPaths = [];
|
|
99144
|
+
const labelKey = this.cascaderProps.label || 'label';
|
|
96677
99145
|
const searchInOptions = (options, currentPath = []) => {
|
|
96678
99146
|
for (const option of options) {
|
|
96679
|
-
const newPath = [...currentPath, option[this.
|
|
96680
|
-
const optionLabel = String(option[
|
|
99147
|
+
const newPath = [...currentPath, option[this.cascaderProps.value]];
|
|
99148
|
+
const optionLabel = String(option[labelKey] || '').replace(/\s+/g, ''); // 去掉所有空格
|
|
99149
|
+
|
|
99150
|
+
// 检查是否全匹配任何输入的名称(去掉空格后比较)
|
|
96681
99151
|
const isMatched = names.some(name => {
|
|
96682
|
-
const cleanName = name.replace(/\s+/g, '');
|
|
99152
|
+
const cleanName = name.replace(/\s+/g, ''); // 去掉输入名称中的空格
|
|
96683
99153
|
return optionLabel.toLowerCase() === cleanName.toLowerCase();
|
|
96684
99154
|
});
|
|
96685
|
-
|
|
96686
|
-
|
|
99155
|
+
|
|
99156
|
+
// 检查是否为叶子节点且匹配且未禁用
|
|
99157
|
+
const isLeafNode = !option[this.cascaderProps.children];
|
|
99158
|
+
const isNotDisabled = !this.isItemDisabled(option);
|
|
96687
99159
|
if (isMatched && isLeafNode && isNotDisabled) {
|
|
99160
|
+
// 如果是叶子节点、匹配且未禁用,添加到结果中
|
|
96688
99161
|
matchedPaths.push(newPath);
|
|
96689
99162
|
}
|
|
96690
|
-
|
|
96691
|
-
|
|
99163
|
+
|
|
99164
|
+
// 递归搜索子节点
|
|
99165
|
+
if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
|
|
99166
|
+
searchInOptions(option[this.cascaderProps.children], newPath);
|
|
96692
99167
|
}
|
|
96693
99168
|
}
|
|
96694
99169
|
};
|
|
96695
99170
|
searchInOptions(this.filteredOptions);
|
|
96696
99171
|
return matchedPaths;
|
|
96697
99172
|
},
|
|
96698
|
-
|
|
96699
|
-
|
|
96700
|
-
|
|
96701
|
-
|
|
96702
|
-
|
|
99173
|
+
// 强制调整已选项的垂直居中样式
|
|
99174
|
+
forceVerticalCenter() {
|
|
99175
|
+
this.$nextTick(() => {
|
|
99176
|
+
const itemLabels = this.$el.querySelectorAll('.item-label');
|
|
99177
|
+
itemLabels.forEach(label => {
|
|
99178
|
+
if (label) {
|
|
99179
|
+
// 使用JavaScript强制设置样式
|
|
99180
|
+
label.style.setProperty('display', 'flex', 'important');
|
|
99181
|
+
label.style.setProperty('align-items', 'center', 'important');
|
|
99182
|
+
label.style.setProperty('height', '36px', 'important');
|
|
99183
|
+
label.style.setProperty('line-height', '36px', 'important');
|
|
99184
|
+
label.style.setProperty('margin', '0', 'important');
|
|
99185
|
+
label.style.setProperty('padding', '0', 'important');
|
|
99186
|
+
label.style.setProperty('vertical-align', 'middle', 'important');
|
|
99187
|
+
label.style.setProperty('font-size', '14px', 'important');
|
|
99188
|
+
}
|
|
99189
|
+
});
|
|
99190
|
+
});
|
|
96703
99191
|
}
|
|
99192
|
+
},
|
|
99193
|
+
updated() {
|
|
99194
|
+
// 组件更新后强制调整样式
|
|
99195
|
+
this.forceVerticalCenter();
|
|
96704
99196
|
}
|
|
96705
99197
|
});
|
|
96706
|
-
;// ./src/components/
|
|
96707
|
-
/* harmony default export */ var
|
|
96708
|
-
;// ./src/components/
|
|
99198
|
+
;// ./src/components/cascader-panel-pro/ByCascaderPanelPro.vue?vue&type=script&lang=js
|
|
99199
|
+
/* harmony default export */ var cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js = (ByCascaderPanelProvue_type_script_lang_js);
|
|
99200
|
+
;// ./src/components/cascader-panel-pro/ByCascaderPanelPro.vue
|
|
96709
99201
|
|
|
96710
99202
|
|
|
96711
99203
|
|
|
@@ -96713,10 +99205,10 @@ var ByTreePanelvue_type_template_id_af06ba0a_staticRenderFns = [];
|
|
|
96713
99205
|
|
|
96714
99206
|
/* normalize component */
|
|
96715
99207
|
;
|
|
96716
|
-
var
|
|
96717
|
-
|
|
96718
|
-
|
|
96719
|
-
|
|
99208
|
+
var ByCascaderPanelPro_component = normalizeComponent(
|
|
99209
|
+
cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js,
|
|
99210
|
+
ByCascaderPanelProvue_type_template_id_4bdb9820_render,
|
|
99211
|
+
ByCascaderPanelProvue_type_template_id_4bdb9820_staticRenderFns,
|
|
96720
99212
|
false,
|
|
96721
99213
|
null,
|
|
96722
99214
|
null,
|
|
@@ -96724,7 +99216,7 @@ var ByTreePanel_component = normalizeComponent(
|
|
|
96724
99216
|
|
|
96725
99217
|
)
|
|
96726
99218
|
|
|
96727
|
-
/* harmony default export */ var
|
|
99219
|
+
/* harmony default export */ var ByCascaderPanelPro = (ByCascaderPanelPro_component.exports);
|
|
96728
99220
|
;// ./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
99221
|
var ByFloatingMenuvue_type_template_id_04723f13_render = function render() {
|
|
96730
99222
|
var _vm = this,
|
|
@@ -99438,7 +101930,7 @@ const components = {
|
|
|
99438
101930
|
ByTreeSearch: ByTreeSearch,
|
|
99439
101931
|
ByDialog: ByDialog,
|
|
99440
101932
|
ByCascaderPanel: ByCascaderPanel,
|
|
99441
|
-
|
|
101933
|
+
ByCascaderPanelPro: ByCascaderPanelPro,
|
|
99442
101934
|
ByFloatingMenu: ByFloatingMenu,
|
|
99443
101935
|
ByPopoverSelector: ByPopoverSelector,
|
|
99444
101936
|
ByGridLayout: ByGridLayout,
|