@@ -189,7 +189,6 @@ const openState = ref(false);
189
189
const _isSearching = ref (false );
190
190
const _searchValue = ref (" " );
191
191
const _matchedList: Ref <Array <CascaderPanelItemPropsInternal >> = ref ([]);
192
- const _innerProcess = computed (() => _context );
193
192
const _dataSource = ref (props .options );
194
193
const _multiple = ref (props .multiple );
195
194
const _decollator = ref (props .decollator );
@@ -201,11 +200,8 @@ const _replaceFields = ref({
201
200
value: props .replaceFields ?.value ?? " value" ,
202
201
children: props .replaceFields ?.children ?? " children" ,
203
202
});
204
- const _selectKeys = ref <Array <string >>(_innerProcess .value .selectKeys .value );
205
- const _displayValue = computed ({
206
- get : () => _innerProcess .value .selectLabel .value ,
207
- set : (v ) => {},
208
- });
203
+ const _selectKeys = ref <Array <string >>(_context .selectKeys .value );
204
+ const _displayValue = computed (() => _context .selectLabel .value );
209
205
const _changeOnSelect = ref (props .changeOnSelect );
210
206
/**
211
207
* 执行搜索
@@ -214,21 +210,21 @@ const _changeOnSelect = ref(props.changeOnSelect);
214
210
const doSearchValue = (str : string ) =>
215
211
(props .search &&
216
212
props .searchMethod &&
217
- _innerProcess . value .sanitizer (props .searchMethod (str ), undefined )) ||
218
- _innerProcess . value . flatData .value .filter (
219
- ( a : CascaderPanelItemPropsInternal ) => a .label .includes (str )
213
+ _context .sanitizer (props .searchMethod (str ), undefined )) ||
214
+ _context . flatData .value .filter (( a : CascaderPanelItemPropsInternal ) =>
215
+ a .label .includes (str )
220
216
);
221
217
222
218
/**
223
219
* 清空内容
224
220
*/
225
221
const onClear = () => {
226
- _innerProcess . value .multipleSelectItem .value .forEach (
222
+ _context .multipleSelectItem .value .forEach (
227
223
(a ) => (a .checked = a .indeterminate = false )
228
224
);
229
- _innerProcess . value .buildMultipleStatus ();
230
- _innerProcess . value .multipleSelectItem .value .clear ();
231
- _innerProcess . value .selectKeys .value = [];
225
+ _context .buildMultipleStatus ();
226
+ _context .multipleSelectItem .value .clear ();
227
+ _context .selectKeys .value = [];
232
228
_selectKeys .value = [];
233
229
emit (" update:modelValue" , _multiple .value ? [] : undefined );
234
230
emit (" clear" );
@@ -241,19 +237,19 @@ const onRemove = (value: string, e: KeyboardEvent) => {
241
237
let _k = value .split (_decollator .value );
242
238
const k = _k .shift ();
243
239
let obj: CascaderPanelItemPropsInternal | undefined =
244
- _innerProcess . value .flatData .value .find ((a ) => a .label === k );
240
+ _context .flatData .value .find ((a ) => a .label === k );
245
241
while (obj && _k .length ) {
246
242
const k = _k .shift ();
247
243
obj = obj .children ?.find ((a ) => a .label === k );
248
244
}
249
245
if (obj !== undefined )
250
- _innerProcess . value .selectKeys .value .splice (
251
- _innerProcess . value .selectKeys .value .findIndex ((a ) => a === obj ! .value ),
246
+ _context .selectKeys .value .splice (
247
+ _context .selectKeys .value .findIndex ((a ) => a === obj ! .value ),
252
248
1
253
249
);
254
250
obj ! .checked = obj ! .indeterminate = false ;
255
- _innerProcess . value .multipleSelectItem .value .delete (obj ! .value );
256
- _innerProcess . value .buildMultipleStatus ();
251
+ _context .multipleSelectItem .value .delete (obj ! .value );
252
+ _context .buildMultipleStatus ();
257
253
_selectKeys .value = [... _selectKeys .value .filter ((v ) => v !== obj ! .value )];
258
254
emit (" update:modelValue" , _selectKeys .value );
259
255
dropdownRef .value .hide ();
@@ -263,7 +259,7 @@ const onRemove = (value: string, e: KeyboardEvent) => {
263
259
* @param selectKeys 选中的keys
264
260
*/
265
261
const _updateValue = (selectKeys : string [] | string ) => {
266
- _innerProcess . value .selectKeys .value =
262
+ _context .selectKeys .value =
267
263
typeof selectKeys === " string"
268
264
? selectKeys .split (props .decollator )
269
265
: selectKeys ;
@@ -381,10 +377,10 @@ watch(
381
377
if (! val ) {
382
378
// 在这里手工更新内部状态
383
379
if (! _multiple .value && props .search ) {
384
- _innerProcess . value .selectKeys .value = [];
380
+ _context .selectKeys .value = [];
385
381
nextTick (() => {
386
- _innerProcess . value . selectKeys .value =
387
- _innerProcess . value . showKeys . value = _selectKeys .value ;
382
+ _context . selectKeys . value = _context . showKeys .value =
383
+ _selectKeys .value ;
388
384
});
389
385
}
390
386
_isSearching .value = false ;
@@ -398,7 +394,11 @@ watch(
398
394
watch (
399
395
() => props .modelValue ,
400
396
() => {
401
- _innerProcess . value .modelValue .value = props .modelValue ;
397
+ _context .modelValue .value = props .modelValue ;
402
398
}
403
399
);
400
+
401
+ defineExpose ({
402
+ selectLabel: _context .selectLabel ,
403
+ });
404
404
</script >
0 commit comments