zartui 2.1.26 → 2.1.28
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/es/index.js +1 -1
- package/es/multiple-picker/MultiplePickerOptions.js +12 -3
- package/es/multiple-picker/index.js +223 -42
- package/lib/index.js +1 -1
- package/lib/multiple-picker/MultiplePickerOptions.js +12 -3
- package/lib/multiple-picker/index.js +223 -42
- package/lib/zart.js +236 -46
- package/lib/zart.min.js +3 -3
- package/package.json +1 -1
package/lib/zart.js
CHANGED
|
@@ -25871,10 +25871,19 @@ function MultiplePickerOptions_isOptionDisabled(option) {
|
|
|
25871
25871
|
methods: {
|
|
25872
25872
|
setOptions: function setOptions(options) {
|
|
25873
25873
|
if (JSON.stringify(options) !== JSON.stringify(this.options)) {
|
|
25874
|
+
// 保存当前的 confirmed 状态
|
|
25875
|
+
var wasConfirmed = this.confirmed;
|
|
25874
25876
|
this.options = deepClone(options);
|
|
25875
|
-
|
|
25876
|
-
|
|
25877
|
-
|
|
25877
|
+
|
|
25878
|
+
// 如果已经确认过选择,保持 confirmed 状态
|
|
25879
|
+
if (wasConfirmed) {
|
|
25880
|
+
// options 变化后,currentIndexs 会由父组件通过 setConfirmIndex 重新设置
|
|
25881
|
+
// 这里不做任何操作,等待父组件更新
|
|
25882
|
+
} else {
|
|
25883
|
+
// 未确认时才重置状态
|
|
25884
|
+
this.confirmed = false;
|
|
25885
|
+
this.setDefaultIndexs();
|
|
25886
|
+
}
|
|
25878
25887
|
}
|
|
25879
25888
|
},
|
|
25880
25889
|
setDefaultIndexs: function setDefaultIndexs() {
|
|
@@ -26004,6 +26013,10 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26004
26013
|
return [];
|
|
26005
26014
|
}
|
|
26006
26015
|
},
|
|
26016
|
+
filteredOptions: {
|
|
26017
|
+
type: Array,
|
|
26018
|
+
default: null
|
|
26019
|
+
},
|
|
26007
26020
|
toolbarPosition: {
|
|
26008
26021
|
type: String,
|
|
26009
26022
|
default: 'bottom'
|
|
@@ -26027,6 +26040,10 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26027
26040
|
}),
|
|
26028
26041
|
data: function data() {
|
|
26029
26042
|
return {
|
|
26043
|
+
selectedValues: [],
|
|
26044
|
+
// 基于值的选中状态,用于支持 options 动态变化
|
|
26045
|
+
confirmedSelectedValues: [],
|
|
26046
|
+
// 上次确认时的 selectedValues,用于取消时恢复
|
|
26030
26047
|
currentIndexs: [],
|
|
26031
26048
|
confirmIndexs: null
|
|
26032
26049
|
};
|
|
@@ -26034,29 +26051,68 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26034
26051
|
watch: {
|
|
26035
26052
|
options: {
|
|
26036
26053
|
handler: function handler(newOptions) {
|
|
26037
|
-
|
|
26038
|
-
|
|
26039
|
-
|
|
26040
|
-
|
|
26054
|
+
var _this = this;
|
|
26055
|
+
// 当 options 变化时,基于 selectedValues 重新计算索引
|
|
26056
|
+
if (this.selectedValues && this.selectedValues.length > 0) {
|
|
26057
|
+
var newIndexs = [];
|
|
26058
|
+
newOptions.forEach(function (option, index) {
|
|
26059
|
+
var optionValue = _this.getOptionValue(option);
|
|
26060
|
+
if (_this.selectedValues.includes(optionValue)) {
|
|
26061
|
+
newIndexs.push(index);
|
|
26062
|
+
}
|
|
26041
26063
|
});
|
|
26042
|
-
this.
|
|
26043
|
-
this.
|
|
26064
|
+
this.currentIndexs = newIndexs;
|
|
26065
|
+
this.confirmIndexs = newIndexs.length > 0 ? newIndexs : null;
|
|
26044
26066
|
}
|
|
26045
26067
|
},
|
|
26046
26068
|
immediate: false
|
|
26047
26069
|
},
|
|
26070
|
+
filteredOptions: {
|
|
26071
|
+
handler: function handler() {
|
|
26072
|
+
var _this2 = this;
|
|
26073
|
+
// filteredOptions 变化时,需要基于 selectedValues 重新映射到 displayOptions 的索引
|
|
26074
|
+
this.$nextTick(function () {
|
|
26075
|
+
if (_this2.$refs.pickerOptions) {
|
|
26076
|
+
var displayIndexs = [];
|
|
26077
|
+
if (_this2.selectedValues && _this2.selectedValues.length > 0) {
|
|
26078
|
+
_this2.displayOptions.forEach(function (option, index) {
|
|
26079
|
+
var optionValue = _this2.getOptionValue(option);
|
|
26080
|
+
if (_this2.selectedValues.includes(optionValue)) {
|
|
26081
|
+
displayIndexs.push(index);
|
|
26082
|
+
}
|
|
26083
|
+
});
|
|
26084
|
+
}
|
|
26085
|
+
// 强制更新子组件,即使是空数组也要设置
|
|
26086
|
+
_this2.$refs.pickerOptions.confirmed = false;
|
|
26087
|
+
_this2.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26088
|
+
}
|
|
26089
|
+
});
|
|
26090
|
+
},
|
|
26091
|
+
immediate: false
|
|
26092
|
+
},
|
|
26048
26093
|
showPicker: {
|
|
26049
26094
|
handler: function handler(val) {
|
|
26050
|
-
var
|
|
26095
|
+
var _this3 = this;
|
|
26051
26096
|
if (val) {
|
|
26052
26097
|
this.$nextTick(function () {
|
|
26053
|
-
if (
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
|
|
26058
|
-
|
|
26059
|
-
|
|
26098
|
+
if (_this3.$refs.pickerOptions) {
|
|
26099
|
+
// 基于 selectedValues 计算在 displayOptions 中的索引
|
|
26100
|
+
var displayIndexs = [];
|
|
26101
|
+
if (_this3.selectedValues && _this3.selectedValues.length > 0) {
|
|
26102
|
+
_this3.displayOptions.forEach(function (option, index) {
|
|
26103
|
+
var optionValue = _this3.getOptionValue(option);
|
|
26104
|
+
if (_this3.selectedValues.includes(optionValue)) {
|
|
26105
|
+
displayIndexs.push(index);
|
|
26106
|
+
}
|
|
26107
|
+
});
|
|
26108
|
+
}
|
|
26109
|
+
|
|
26110
|
+
// 弹出时直接设置 currentIndexs,不调用 setConfirmIndex,保持未确认状态
|
|
26111
|
+
_this3.$refs.pickerOptions.confirmed = false;
|
|
26112
|
+
_this3.$refs.pickerOptions.currentIndexs = displayIndexs;
|
|
26113
|
+
|
|
26114
|
+
// 同步 currentIndexs(基于原始 options)
|
|
26115
|
+
_this3.currentIndexs = _this3.confirmIndexs || [];
|
|
26060
26116
|
}
|
|
26061
26117
|
});
|
|
26062
26118
|
}
|
|
@@ -26065,11 +26121,32 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26065
26121
|
}
|
|
26066
26122
|
},
|
|
26067
26123
|
computed: {
|
|
26124
|
+
displayOptions: function displayOptions() {
|
|
26125
|
+
return this.filteredOptions || this.options;
|
|
26126
|
+
},
|
|
26068
26127
|
isAllSelected: function isAllSelected() {
|
|
26069
|
-
|
|
26128
|
+
var _this4 = this;
|
|
26129
|
+
// 判断是否全选应该基于当前显示的 displayOptions
|
|
26130
|
+
if (this.displayOptions.length === 0) return false;
|
|
26131
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26132
|
+
return _this4.getOptionValue(opt);
|
|
26133
|
+
});
|
|
26134
|
+
var selectedDisplayValues = this.selectedValues.filter(function (val) {
|
|
26135
|
+
return displayValues.includes(val);
|
|
26136
|
+
});
|
|
26137
|
+
return selectedDisplayValues.length > 0 && selectedDisplayValues.length === this.displayOptions.length;
|
|
26070
26138
|
},
|
|
26071
26139
|
isIndeterminate: function isIndeterminate() {
|
|
26072
|
-
|
|
26140
|
+
var _this5 = this;
|
|
26141
|
+
// 判断半选状态也应该基于当前显示的 displayOptions
|
|
26142
|
+
if (this.displayOptions.length === 0) return false;
|
|
26143
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26144
|
+
return _this5.getOptionValue(opt);
|
|
26145
|
+
});
|
|
26146
|
+
var selectedDisplayValues = this.selectedValues.filter(function (val) {
|
|
26147
|
+
return displayValues.includes(val);
|
|
26148
|
+
});
|
|
26149
|
+
return selectedDisplayValues.length > 0 && selectedDisplayValues.length < this.displayOptions.length;
|
|
26073
26150
|
},
|
|
26074
26151
|
itemPxHeight: function itemPxHeight() {
|
|
26075
26152
|
return this.itemHeight ? Object(unit["b" /* unitToPx */])(this.itemHeight) : shared_DEFAULT_ITEM_HEIGHT;
|
|
@@ -26084,55 +26161,167 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26084
26161
|
emit: function emit(event) {
|
|
26085
26162
|
this.$emit(event, this.getOptions());
|
|
26086
26163
|
},
|
|
26164
|
+
getOptionValue: function getOptionValue(option) {
|
|
26165
|
+
if (typeof option === 'string' || typeof option === 'number') {
|
|
26166
|
+
return option;
|
|
26167
|
+
}
|
|
26168
|
+
return option[this.valueKey] || JSON.stringify(option);
|
|
26169
|
+
},
|
|
26087
26170
|
getOptions: function getOptions() {
|
|
26088
|
-
var
|
|
26171
|
+
var _this6 = this;
|
|
26089
26172
|
var indexs = this.$refs.pickerOptions.currentIndexs;
|
|
26090
26173
|
var result = [];
|
|
26174
|
+
// 从 displayOptions 中获取选中项
|
|
26091
26175
|
indexs.forEach(function (index) {
|
|
26092
|
-
|
|
26093
|
-
|
|
26094
|
-
|
|
26176
|
+
var displayOption = _this6.displayOptions[index];
|
|
26177
|
+
if (displayOption) {
|
|
26178
|
+
// 查找在原始 options 中的索引
|
|
26179
|
+
var originalIndex = _this6.options.findIndex(function (opt) {
|
|
26180
|
+
return _this6.getOptionValue(opt) === _this6.getOptionValue(displayOption);
|
|
26181
|
+
});
|
|
26182
|
+
result.push(_extends({}, displayOption, {
|
|
26183
|
+
initialIndex: originalIndex >= 0 ? originalIndex : index
|
|
26184
|
+
}));
|
|
26185
|
+
}
|
|
26095
26186
|
});
|
|
26096
26187
|
return result;
|
|
26097
26188
|
},
|
|
26098
26189
|
onChange: function onChange() {
|
|
26190
|
+
var _this7 = this;
|
|
26099
26191
|
// 同步 currentIndexs 以触发计算属性更新
|
|
26100
26192
|
if (this.$refs.pickerOptions) {
|
|
26101
|
-
|
|
26193
|
+
// 实时更新 selectedValues,需要合并而不是覆盖
|
|
26194
|
+
var displayOptions = this.getOptions();
|
|
26195
|
+
var displayValues = displayOptions.map(function (v) {
|
|
26196
|
+
return _this7.getOptionValue(v);
|
|
26197
|
+
});
|
|
26198
|
+
var displayAllValues = this.displayOptions.map(function (opt) {
|
|
26199
|
+
return _this7.getOptionValue(opt);
|
|
26200
|
+
});
|
|
26201
|
+
|
|
26202
|
+
// 移除当前显示列表中的所有值(无论是否选中),然后添加当前选中的值
|
|
26203
|
+
this.selectedValues = [].concat(this.selectedValues.filter(function (val) {
|
|
26204
|
+
return !displayAllValues.includes(val);
|
|
26205
|
+
}), displayValues);
|
|
26206
|
+
|
|
26207
|
+
// 基于 selectedValues 更新 currentIndexs(用于显示已选数量)
|
|
26208
|
+
this.currentIndexs = [];
|
|
26209
|
+
this.options.forEach(function (option, index) {
|
|
26210
|
+
if (_this7.selectedValues.includes(_this7.getOptionValue(option))) {
|
|
26211
|
+
_this7.currentIndexs.push(index);
|
|
26212
|
+
}
|
|
26213
|
+
});
|
|
26102
26214
|
}
|
|
26103
26215
|
this.$emit('change', this.getOptions());
|
|
26104
26216
|
},
|
|
26105
26217
|
cancel: function cancel() {
|
|
26218
|
+
var _this8 = this;
|
|
26219
|
+
// 取消时恢复到上次确认的状态
|
|
26220
|
+
this.selectedValues = [].concat(this.confirmedSelectedValues);
|
|
26221
|
+
|
|
26222
|
+
// 重新计算 currentIndexs
|
|
26223
|
+
this.currentIndexs = [];
|
|
26224
|
+
this.options.forEach(function (option, index) {
|
|
26225
|
+
if (_this8.selectedValues.includes(_this8.getOptionValue(option))) {
|
|
26226
|
+
_this8.currentIndexs.push(index);
|
|
26227
|
+
}
|
|
26228
|
+
});
|
|
26106
26229
|
this.$emit('update:showPicker', false);
|
|
26107
26230
|
this.emit('cancel');
|
|
26108
26231
|
},
|
|
26109
26232
|
confirm: function confirm() {
|
|
26110
|
-
var
|
|
26111
|
-
|
|
26233
|
+
var _this9 = this;
|
|
26234
|
+
// 返回所有已选的数据,而不仅仅是当前显示的
|
|
26235
|
+
var allSelectedOptions = [];
|
|
26236
|
+
this.selectedValues.forEach(function (value) {
|
|
26237
|
+
var option = _this9.options.find(function (opt) {
|
|
26238
|
+
return _this9.getOptionValue(opt) === value;
|
|
26239
|
+
});
|
|
26240
|
+
if (option) {
|
|
26241
|
+
var originalIndex = _this9.options.findIndex(function (opt) {
|
|
26242
|
+
return _this9.getOptionValue(opt) === value;
|
|
26243
|
+
});
|
|
26244
|
+
allSelectedOptions.push(_extends({}, option, {
|
|
26245
|
+
initialIndex: originalIndex
|
|
26246
|
+
}));
|
|
26247
|
+
}
|
|
26248
|
+
});
|
|
26249
|
+
this.confirmIndexs = allSelectedOptions.map(function (v) {
|
|
26112
26250
|
return v.initialIndex;
|
|
26113
26251
|
});
|
|
26114
|
-
|
|
26252
|
+
// 确认时保存当前的 selectedValues
|
|
26253
|
+
this.confirmedSelectedValues = [].concat(this.selectedValues);
|
|
26254
|
+
this.$emit('confirm', allSelectedOptions);
|
|
26115
26255
|
},
|
|
26116
26256
|
handleSelectAll: function handleSelectAll() {
|
|
26117
|
-
var
|
|
26118
|
-
|
|
26119
|
-
|
|
26120
|
-
|
|
26121
|
-
|
|
26122
|
-
|
|
26257
|
+
var _this10 = this;
|
|
26258
|
+
// 全选应该基于当前显示的 displayOptions,只选中当前搜索结果
|
|
26259
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26260
|
+
return _this10.getOptionValue(opt);
|
|
26261
|
+
});
|
|
26262
|
+
if (!this.isAllSelected) {
|
|
26263
|
+
// 全选:只选中当前显示的值,清除其他值
|
|
26264
|
+
this.selectedValues = displayValues;
|
|
26265
|
+
|
|
26266
|
+
// 更新 currentIndexs(基于原始 options)
|
|
26267
|
+
this.currentIndexs = [];
|
|
26268
|
+
this.options.forEach(function (option, index) {
|
|
26269
|
+
if (displayValues.includes(_this10.getOptionValue(option))) {
|
|
26270
|
+
_this10.currentIndexs.push(index);
|
|
26271
|
+
}
|
|
26272
|
+
});
|
|
26273
|
+
|
|
26274
|
+
// 设置子组件索引(基于 displayOptions,全选所有显示项)
|
|
26275
|
+
var displayIndexs = this.displayOptions.map(function (_, index) {
|
|
26276
|
+
return index;
|
|
26277
|
+
});
|
|
26278
|
+
if (this.$refs.pickerOptions) {
|
|
26279
|
+
this.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26280
|
+
}
|
|
26281
|
+
} else {
|
|
26282
|
+
// 取消全选:清空所有选中
|
|
26283
|
+
this.selectedValues = [];
|
|
26284
|
+
this.currentIndexs = [];
|
|
26285
|
+
if (this.$refs.pickerOptions) {
|
|
26286
|
+
this.$refs.pickerOptions.setConfirmIndex([]);
|
|
26287
|
+
}
|
|
26123
26288
|
}
|
|
26124
26289
|
},
|
|
26125
26290
|
onSelectOther: function onSelectOther() {
|
|
26126
|
-
var
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
|
|
26130
|
-
|
|
26291
|
+
var _this11 = this;
|
|
26292
|
+
// 反选应该基于当前显示的 displayOptions,只操作当前搜索结果
|
|
26293
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26294
|
+
return _this11.getOptionValue(opt);
|
|
26295
|
+
});
|
|
26296
|
+
|
|
26297
|
+
// 计算当前显示项中未选中的值
|
|
26298
|
+
var displaySelectedValues = this.selectedValues.filter(function (val) {
|
|
26299
|
+
return displayValues.includes(val);
|
|
26300
|
+
});
|
|
26301
|
+
var displayUnselectedValues = displayValues.filter(function (val) {
|
|
26302
|
+
return !displaySelectedValues.includes(val);
|
|
26303
|
+
});
|
|
26304
|
+
|
|
26305
|
+
// 只保留当前显示列表中未选中的项(反选逻辑)
|
|
26306
|
+
this.selectedValues = displayUnselectedValues;
|
|
26307
|
+
|
|
26308
|
+
// 更新 currentIndexs(基于原始 options)
|
|
26309
|
+
this.currentIndexs = [];
|
|
26310
|
+
this.options.forEach(function (option, index) {
|
|
26311
|
+
if (displayUnselectedValues.includes(_this11.getOptionValue(option))) {
|
|
26312
|
+
_this11.currentIndexs.push(index);
|
|
26313
|
+
}
|
|
26314
|
+
});
|
|
26315
|
+
|
|
26316
|
+
// 映射到 displayOptions 的索引(反选后的状态)
|
|
26317
|
+
var displayIndexs = [];
|
|
26318
|
+
this.displayOptions.forEach(function (option, index) {
|
|
26319
|
+
if (displayUnselectedValues.includes(_this11.getOptionValue(option))) {
|
|
26320
|
+
displayIndexs.push(index);
|
|
26131
26321
|
}
|
|
26132
26322
|
});
|
|
26133
|
-
this.currentIndexs = newIndexs;
|
|
26134
26323
|
if (this.$refs.pickerOptions) {
|
|
26135
|
-
this.$refs.pickerOptions.setConfirmIndex(
|
|
26324
|
+
this.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26136
26325
|
}
|
|
26137
26326
|
},
|
|
26138
26327
|
genTitle: function genTitle() {
|
|
@@ -26246,18 +26435,19 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26246
26435
|
}, [this.genOptionItems()]);
|
|
26247
26436
|
},
|
|
26248
26437
|
genOptionItems: function genOptionItems() {
|
|
26249
|
-
var
|
|
26438
|
+
var _this12 = this;
|
|
26250
26439
|
var h = this.$createElement;
|
|
26251
26440
|
var formatOptions = [];
|
|
26252
|
-
|
|
26253
|
-
|
|
26441
|
+
var sourceOptions = this.displayOptions;
|
|
26442
|
+
if (sourceOptions && sourceOptions[0] && typeof sourceOptions[0] !== 'object') {
|
|
26443
|
+
formatOptions = sourceOptions.map(function (v) {
|
|
26254
26444
|
return {
|
|
26255
26445
|
value: v,
|
|
26256
26446
|
text: v
|
|
26257
26447
|
};
|
|
26258
26448
|
});
|
|
26259
26449
|
} else {
|
|
26260
|
-
formatOptions =
|
|
26450
|
+
formatOptions = sourceOptions;
|
|
26261
26451
|
}
|
|
26262
26452
|
return h(MultiplePickerOptions, {
|
|
26263
26453
|
"ref": "pickerOptions",
|
|
@@ -26275,7 +26465,7 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26275
26465
|
},
|
|
26276
26466
|
"on": {
|
|
26277
26467
|
"change": function change() {
|
|
26278
|
-
|
|
26468
|
+
_this12.onChange();
|
|
26279
26469
|
}
|
|
26280
26470
|
}
|
|
26281
26471
|
});
|
|
@@ -35212,7 +35402,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
|
|
|
35212
35402
|
|
|
35213
35403
|
|
|
35214
35404
|
|
|
35215
|
-
var es_version = '2.1.
|
|
35405
|
+
var es_version = '2.1.28';
|
|
35216
35406
|
function install(Vue) {
|
|
35217
35407
|
var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, speech_recognizer, es_step, stepper, steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, text_ellipsis, timeline, es_toast, uploader];
|
|
35218
35408
|
components.forEach(function (item) {
|