zartui 2.1.26 → 2.1.27
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 +204 -42
- package/lib/index.js +1 -1
- package/lib/multiple-picker/MultiplePickerOptions.js +12 -3
- package/lib/multiple-picker/index.js +204 -42
- package/lib/zart.js +217 -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,8 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26027
26040
|
}),
|
|
26028
26041
|
data: function data() {
|
|
26029
26042
|
return {
|
|
26043
|
+
selectedValues: [],
|
|
26044
|
+
// 基于值的选中状态,用于支持 options 动态变化
|
|
26030
26045
|
currentIndexs: [],
|
|
26031
26046
|
confirmIndexs: null
|
|
26032
26047
|
};
|
|
@@ -26034,29 +26049,64 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26034
26049
|
watch: {
|
|
26035
26050
|
options: {
|
|
26036
26051
|
handler: function handler(newOptions) {
|
|
26037
|
-
|
|
26038
|
-
|
|
26039
|
-
|
|
26040
|
-
|
|
26052
|
+
var _this = this;
|
|
26053
|
+
// 当 options 变化时,基于 selectedValues 重新计算索引
|
|
26054
|
+
if (this.selectedValues && this.selectedValues.length > 0) {
|
|
26055
|
+
var newIndexs = [];
|
|
26056
|
+
newOptions.forEach(function (option, index) {
|
|
26057
|
+
var optionValue = _this.getOptionValue(option);
|
|
26058
|
+
if (_this.selectedValues.includes(optionValue)) {
|
|
26059
|
+
newIndexs.push(index);
|
|
26060
|
+
}
|
|
26041
26061
|
});
|
|
26042
|
-
this.
|
|
26043
|
-
this.
|
|
26062
|
+
this.currentIndexs = newIndexs;
|
|
26063
|
+
this.confirmIndexs = newIndexs.length > 0 ? newIndexs : null;
|
|
26044
26064
|
}
|
|
26045
26065
|
},
|
|
26046
26066
|
immediate: false
|
|
26047
26067
|
},
|
|
26068
|
+
filteredOptions: {
|
|
26069
|
+
handler: function handler() {
|
|
26070
|
+
var _this2 = this;
|
|
26071
|
+
// filteredOptions 变化时,需要基于 selectedValues 重新映射到 displayOptions 的索引
|
|
26072
|
+
this.$nextTick(function () {
|
|
26073
|
+
if (_this2.$refs.pickerOptions) {
|
|
26074
|
+
var displayIndexs = [];
|
|
26075
|
+
if (_this2.selectedValues && _this2.selectedValues.length > 0) {
|
|
26076
|
+
_this2.displayOptions.forEach(function (option, index) {
|
|
26077
|
+
var optionValue = _this2.getOptionValue(option);
|
|
26078
|
+
if (_this2.selectedValues.includes(optionValue)) {
|
|
26079
|
+
displayIndexs.push(index);
|
|
26080
|
+
}
|
|
26081
|
+
});
|
|
26082
|
+
}
|
|
26083
|
+
// 强制更新子组件,即使是空数组也要设置
|
|
26084
|
+
_this2.$refs.pickerOptions.confirmed = false;
|
|
26085
|
+
_this2.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26086
|
+
}
|
|
26087
|
+
});
|
|
26088
|
+
},
|
|
26089
|
+
immediate: false
|
|
26090
|
+
},
|
|
26048
26091
|
showPicker: {
|
|
26049
26092
|
handler: function handler(val) {
|
|
26050
|
-
var
|
|
26093
|
+
var _this3 = this;
|
|
26051
26094
|
if (val) {
|
|
26052
26095
|
this.$nextTick(function () {
|
|
26053
|
-
if (
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
|
|
26058
|
-
|
|
26059
|
-
|
|
26096
|
+
if (_this3.$refs.pickerOptions) {
|
|
26097
|
+
// 基于 selectedValues 计算在 displayOptions 中的索引
|
|
26098
|
+
var displayIndexs = [];
|
|
26099
|
+
if (_this3.selectedValues && _this3.selectedValues.length > 0) {
|
|
26100
|
+
_this3.displayOptions.forEach(function (option, index) {
|
|
26101
|
+
var optionValue = _this3.getOptionValue(option);
|
|
26102
|
+
if (_this3.selectedValues.includes(optionValue)) {
|
|
26103
|
+
displayIndexs.push(index);
|
|
26104
|
+
}
|
|
26105
|
+
});
|
|
26106
|
+
}
|
|
26107
|
+
_this3.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26108
|
+
// 同步 currentIndexs(基于原始 options)
|
|
26109
|
+
_this3.currentIndexs = _this3.confirmIndexs || [];
|
|
26060
26110
|
}
|
|
26061
26111
|
});
|
|
26062
26112
|
}
|
|
@@ -26065,11 +26115,32 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26065
26115
|
}
|
|
26066
26116
|
},
|
|
26067
26117
|
computed: {
|
|
26118
|
+
displayOptions: function displayOptions() {
|
|
26119
|
+
return this.filteredOptions || this.options;
|
|
26120
|
+
},
|
|
26068
26121
|
isAllSelected: function isAllSelected() {
|
|
26069
|
-
|
|
26122
|
+
var _this4 = this;
|
|
26123
|
+
// 判断是否全选应该基于当前显示的 displayOptions
|
|
26124
|
+
if (this.displayOptions.length === 0) return false;
|
|
26125
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26126
|
+
return _this4.getOptionValue(opt);
|
|
26127
|
+
});
|
|
26128
|
+
var selectedDisplayValues = this.selectedValues.filter(function (val) {
|
|
26129
|
+
return displayValues.includes(val);
|
|
26130
|
+
});
|
|
26131
|
+
return selectedDisplayValues.length > 0 && selectedDisplayValues.length === this.displayOptions.length;
|
|
26070
26132
|
},
|
|
26071
26133
|
isIndeterminate: function isIndeterminate() {
|
|
26072
|
-
|
|
26134
|
+
var _this5 = this;
|
|
26135
|
+
// 判断半选状态也应该基于当前显示的 displayOptions
|
|
26136
|
+
if (this.displayOptions.length === 0) return false;
|
|
26137
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26138
|
+
return _this5.getOptionValue(opt);
|
|
26139
|
+
});
|
|
26140
|
+
var selectedDisplayValues = this.selectedValues.filter(function (val) {
|
|
26141
|
+
return displayValues.includes(val);
|
|
26142
|
+
});
|
|
26143
|
+
return selectedDisplayValues.length > 0 && selectedDisplayValues.length < this.displayOptions.length;
|
|
26073
26144
|
},
|
|
26074
26145
|
itemPxHeight: function itemPxHeight() {
|
|
26075
26146
|
return this.itemHeight ? Object(unit["b" /* unitToPx */])(this.itemHeight) : shared_DEFAULT_ITEM_HEIGHT;
|
|
@@ -26084,21 +26155,56 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26084
26155
|
emit: function emit(event) {
|
|
26085
26156
|
this.$emit(event, this.getOptions());
|
|
26086
26157
|
},
|
|
26158
|
+
getOptionValue: function getOptionValue(option) {
|
|
26159
|
+
if (typeof option === 'string' || typeof option === 'number') {
|
|
26160
|
+
return option;
|
|
26161
|
+
}
|
|
26162
|
+
return option[this.valueKey] || JSON.stringify(option);
|
|
26163
|
+
},
|
|
26087
26164
|
getOptions: function getOptions() {
|
|
26088
|
-
var
|
|
26165
|
+
var _this6 = this;
|
|
26089
26166
|
var indexs = this.$refs.pickerOptions.currentIndexs;
|
|
26090
26167
|
var result = [];
|
|
26168
|
+
// 从 displayOptions 中获取选中项
|
|
26091
26169
|
indexs.forEach(function (index) {
|
|
26092
|
-
|
|
26093
|
-
|
|
26094
|
-
|
|
26170
|
+
var displayOption = _this6.displayOptions[index];
|
|
26171
|
+
if (displayOption) {
|
|
26172
|
+
// 查找在原始 options 中的索引
|
|
26173
|
+
var originalIndex = _this6.options.findIndex(function (opt) {
|
|
26174
|
+
return _this6.getOptionValue(opt) === _this6.getOptionValue(displayOption);
|
|
26175
|
+
});
|
|
26176
|
+
result.push(_extends({}, displayOption, {
|
|
26177
|
+
initialIndex: originalIndex >= 0 ? originalIndex : index
|
|
26178
|
+
}));
|
|
26179
|
+
}
|
|
26095
26180
|
});
|
|
26096
26181
|
return result;
|
|
26097
26182
|
},
|
|
26098
26183
|
onChange: function onChange() {
|
|
26184
|
+
var _this7 = this;
|
|
26099
26185
|
// 同步 currentIndexs 以触发计算属性更新
|
|
26100
26186
|
if (this.$refs.pickerOptions) {
|
|
26101
|
-
|
|
26187
|
+
// 实时更新 selectedValues,需要合并而不是覆盖
|
|
26188
|
+
var displayOptions = this.getOptions();
|
|
26189
|
+
var displayValues = displayOptions.map(function (v) {
|
|
26190
|
+
return _this7.getOptionValue(v);
|
|
26191
|
+
});
|
|
26192
|
+
var displayAllValues = this.displayOptions.map(function (opt) {
|
|
26193
|
+
return _this7.getOptionValue(opt);
|
|
26194
|
+
});
|
|
26195
|
+
|
|
26196
|
+
// 移除当前显示列表中的所有值(无论是否选中),然后添加当前选中的值
|
|
26197
|
+
this.selectedValues = [].concat(this.selectedValues.filter(function (val) {
|
|
26198
|
+
return !displayAllValues.includes(val);
|
|
26199
|
+
}), displayValues);
|
|
26200
|
+
|
|
26201
|
+
// 基于 selectedValues 更新 currentIndexs(用于显示已选数量)
|
|
26202
|
+
this.currentIndexs = [];
|
|
26203
|
+
this.options.forEach(function (option, index) {
|
|
26204
|
+
if (_this7.selectedValues.includes(_this7.getOptionValue(option))) {
|
|
26205
|
+
_this7.currentIndexs.push(index);
|
|
26206
|
+
}
|
|
26207
|
+
});
|
|
26102
26208
|
}
|
|
26103
26209
|
this.$emit('change', this.getOptions());
|
|
26104
26210
|
},
|
|
@@ -26107,32 +26213,96 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26107
26213
|
this.emit('cancel');
|
|
26108
26214
|
},
|
|
26109
26215
|
confirm: function confirm() {
|
|
26110
|
-
var
|
|
26111
|
-
|
|
26216
|
+
var _this8 = this;
|
|
26217
|
+
// 返回所有已选的数据,而不仅仅是当前显示的
|
|
26218
|
+
var allSelectedOptions = [];
|
|
26219
|
+
this.selectedValues.forEach(function (value) {
|
|
26220
|
+
var option = _this8.options.find(function (opt) {
|
|
26221
|
+
return _this8.getOptionValue(opt) === value;
|
|
26222
|
+
});
|
|
26223
|
+
if (option) {
|
|
26224
|
+
var originalIndex = _this8.options.findIndex(function (opt) {
|
|
26225
|
+
return _this8.getOptionValue(opt) === value;
|
|
26226
|
+
});
|
|
26227
|
+
allSelectedOptions.push(_extends({}, option, {
|
|
26228
|
+
initialIndex: originalIndex
|
|
26229
|
+
}));
|
|
26230
|
+
}
|
|
26231
|
+
});
|
|
26232
|
+
this.confirmIndexs = allSelectedOptions.map(function (v) {
|
|
26112
26233
|
return v.initialIndex;
|
|
26113
26234
|
});
|
|
26114
|
-
this
|
|
26235
|
+
this.$emit('confirm', allSelectedOptions);
|
|
26115
26236
|
},
|
|
26116
26237
|
handleSelectAll: function handleSelectAll() {
|
|
26117
|
-
var
|
|
26118
|
-
|
|
26119
|
-
|
|
26120
|
-
|
|
26121
|
-
|
|
26122
|
-
|
|
26238
|
+
var _this9 = this;
|
|
26239
|
+
// 全选应该基于当前显示的 displayOptions,只选中当前搜索结果
|
|
26240
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26241
|
+
return _this9.getOptionValue(opt);
|
|
26242
|
+
});
|
|
26243
|
+
if (!this.isAllSelected) {
|
|
26244
|
+
// 全选:只选中当前显示的值,清除其他值
|
|
26245
|
+
this.selectedValues = displayValues;
|
|
26246
|
+
|
|
26247
|
+
// 更新 currentIndexs(基于原始 options)
|
|
26248
|
+
this.currentIndexs = [];
|
|
26249
|
+
this.options.forEach(function (option, index) {
|
|
26250
|
+
if (displayValues.includes(_this9.getOptionValue(option))) {
|
|
26251
|
+
_this9.currentIndexs.push(index);
|
|
26252
|
+
}
|
|
26253
|
+
});
|
|
26254
|
+
|
|
26255
|
+
// 设置子组件索引(基于 displayOptions,全选所有显示项)
|
|
26256
|
+
var displayIndexs = this.displayOptions.map(function (_, index) {
|
|
26257
|
+
return index;
|
|
26258
|
+
});
|
|
26259
|
+
if (this.$refs.pickerOptions) {
|
|
26260
|
+
this.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26261
|
+
}
|
|
26262
|
+
} else {
|
|
26263
|
+
// 取消全选:清空所有选中
|
|
26264
|
+
this.selectedValues = [];
|
|
26265
|
+
this.currentIndexs = [];
|
|
26266
|
+
if (this.$refs.pickerOptions) {
|
|
26267
|
+
this.$refs.pickerOptions.setConfirmIndex([]);
|
|
26268
|
+
}
|
|
26123
26269
|
}
|
|
26124
26270
|
},
|
|
26125
26271
|
onSelectOther: function onSelectOther() {
|
|
26126
|
-
var
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
|
|
26130
|
-
|
|
26272
|
+
var _this10 = this;
|
|
26273
|
+
// 反选应该基于当前显示的 displayOptions,只操作当前搜索结果
|
|
26274
|
+
var displayValues = this.displayOptions.map(function (opt) {
|
|
26275
|
+
return _this10.getOptionValue(opt);
|
|
26276
|
+
});
|
|
26277
|
+
|
|
26278
|
+
// 计算当前显示项中未选中的值
|
|
26279
|
+
var displaySelectedValues = this.selectedValues.filter(function (val) {
|
|
26280
|
+
return displayValues.includes(val);
|
|
26281
|
+
});
|
|
26282
|
+
var displayUnselectedValues = displayValues.filter(function (val) {
|
|
26283
|
+
return !displaySelectedValues.includes(val);
|
|
26284
|
+
});
|
|
26285
|
+
|
|
26286
|
+
// 只保留当前显示列表中未选中的项(反选逻辑)
|
|
26287
|
+
this.selectedValues = displayUnselectedValues;
|
|
26288
|
+
|
|
26289
|
+
// 更新 currentIndexs(基于原始 options)
|
|
26290
|
+
this.currentIndexs = [];
|
|
26291
|
+
this.options.forEach(function (option, index) {
|
|
26292
|
+
if (displayUnselectedValues.includes(_this10.getOptionValue(option))) {
|
|
26293
|
+
_this10.currentIndexs.push(index);
|
|
26294
|
+
}
|
|
26295
|
+
});
|
|
26296
|
+
|
|
26297
|
+
// 映射到 displayOptions 的索引(反选后的状态)
|
|
26298
|
+
var displayIndexs = [];
|
|
26299
|
+
this.displayOptions.forEach(function (option, index) {
|
|
26300
|
+
if (displayUnselectedValues.includes(_this10.getOptionValue(option))) {
|
|
26301
|
+
displayIndexs.push(index);
|
|
26131
26302
|
}
|
|
26132
26303
|
});
|
|
26133
|
-
this.currentIndexs = newIndexs;
|
|
26134
26304
|
if (this.$refs.pickerOptions) {
|
|
26135
|
-
this.$refs.pickerOptions.setConfirmIndex(
|
|
26305
|
+
this.$refs.pickerOptions.setConfirmIndex(displayIndexs);
|
|
26136
26306
|
}
|
|
26137
26307
|
},
|
|
26138
26308
|
genTitle: function genTitle() {
|
|
@@ -26246,18 +26416,19 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26246
26416
|
}, [this.genOptionItems()]);
|
|
26247
26417
|
},
|
|
26248
26418
|
genOptionItems: function genOptionItems() {
|
|
26249
|
-
var
|
|
26419
|
+
var _this11 = this;
|
|
26250
26420
|
var h = this.$createElement;
|
|
26251
26421
|
var formatOptions = [];
|
|
26252
|
-
|
|
26253
|
-
|
|
26422
|
+
var sourceOptions = this.displayOptions;
|
|
26423
|
+
if (sourceOptions && sourceOptions[0] && typeof sourceOptions[0] !== 'object') {
|
|
26424
|
+
formatOptions = sourceOptions.map(function (v) {
|
|
26254
26425
|
return {
|
|
26255
26426
|
value: v,
|
|
26256
26427
|
text: v
|
|
26257
26428
|
};
|
|
26258
26429
|
});
|
|
26259
26430
|
} else {
|
|
26260
|
-
formatOptions =
|
|
26431
|
+
formatOptions = sourceOptions;
|
|
26261
26432
|
}
|
|
26262
26433
|
return h(MultiplePickerOptions, {
|
|
26263
26434
|
"ref": "pickerOptions",
|
|
@@ -26275,7 +26446,7 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
|
|
|
26275
26446
|
},
|
|
26276
26447
|
"on": {
|
|
26277
26448
|
"change": function change() {
|
|
26278
|
-
|
|
26449
|
+
_this11.onChange();
|
|
26279
26450
|
}
|
|
26280
26451
|
}
|
|
26281
26452
|
});
|
|
@@ -35212,7 +35383,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
|
|
|
35212
35383
|
|
|
35213
35384
|
|
|
35214
35385
|
|
|
35215
|
-
var es_version = '2.1.
|
|
35386
|
+
var es_version = '2.1.27';
|
|
35216
35387
|
function install(Vue) {
|
|
35217
35388
|
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
35389
|
components.forEach(function (item) {
|