zartui 2.1.25 → 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/lib/zart.js CHANGED
@@ -25871,8 +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
- this.setDefaultIndexs();
25877
+
25878
+ // 如果已经确认过选择,保持 confirmed 状态
25879
+ if (wasConfirmed) {
25880
+ // options 变化后,currentIndexs 会由父组件通过 setConfirmIndex 重新设置
25881
+ // 这里不做任何操作,等待父组件更新
25882
+ } else {
25883
+ // 未确认时才重置状态
25884
+ this.confirmed = false;
25885
+ this.setDefaultIndexs();
25886
+ }
25876
25887
  }
25877
25888
  },
25878
25889
  setDefaultIndexs: function setDefaultIndexs() {
@@ -26002,6 +26013,10 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26002
26013
  return [];
26003
26014
  }
26004
26015
  },
26016
+ filteredOptions: {
26017
+ type: Array,
26018
+ default: null
26019
+ },
26005
26020
  toolbarPosition: {
26006
26021
  type: String,
26007
26022
  default: 'bottom'
@@ -26025,23 +26040,73 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26025
26040
  }),
26026
26041
  data: function data() {
26027
26042
  return {
26043
+ selectedValues: [],
26044
+ // 基于值的选中状态,用于支持 options 动态变化
26028
26045
  currentIndexs: [],
26029
26046
  confirmIndexs: null
26030
26047
  };
26031
26048
  },
26032
26049
  watch: {
26050
+ options: {
26051
+ handler: function handler(newOptions) {
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
+ }
26061
+ });
26062
+ this.currentIndexs = newIndexs;
26063
+ this.confirmIndexs = newIndexs.length > 0 ? newIndexs : null;
26064
+ }
26065
+ },
26066
+ immediate: false
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
+ },
26033
26091
  showPicker: {
26034
26092
  handler: function handler(val) {
26035
- var _this = this;
26093
+ var _this3 = this;
26036
26094
  if (val) {
26037
26095
  this.$nextTick(function () {
26038
- if (_this.$refs.pickerOptions && _this.confirmIndexs) {
26039
- _this.$refs.pickerOptions.setConfirmIndex(_this.confirmIndexs);
26040
- // 同步 currentIndexs 以更新底部全选和已选状态
26041
- _this.currentIndexs = [].concat(_this.confirmIndexs);
26042
- } else if (!_this.confirmIndexs && _this.defaultIndexs && _this.defaultIndexs.length === 0) {
26043
- _this.$refs.pickerOptions.setConfirmIndex([]);
26044
- _this.currentIndexs = [];
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 || [];
26045
26110
  }
26046
26111
  });
26047
26112
  }
@@ -26050,11 +26115,32 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26050
26115
  }
26051
26116
  },
26052
26117
  computed: {
26118
+ displayOptions: function displayOptions() {
26119
+ return this.filteredOptions || this.options;
26120
+ },
26053
26121
  isAllSelected: function isAllSelected() {
26054
- return this.currentIndexs.length > 0 && this.currentIndexs.length === this.options.length;
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;
26055
26132
  },
26056
26133
  isIndeterminate: function isIndeterminate() {
26057
- return this.currentIndexs.length > 0 && this.currentIndexs.length < this.options.length;
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;
26058
26144
  },
26059
26145
  itemPxHeight: function itemPxHeight() {
26060
26146
  return this.itemHeight ? Object(unit["b" /* unitToPx */])(this.itemHeight) : shared_DEFAULT_ITEM_HEIGHT;
@@ -26069,21 +26155,56 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26069
26155
  emit: function emit(event) {
26070
26156
  this.$emit(event, this.getOptions());
26071
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
+ },
26072
26164
  getOptions: function getOptions() {
26073
- var _this2 = this;
26165
+ var _this6 = this;
26074
26166
  var indexs = this.$refs.pickerOptions.currentIndexs;
26075
26167
  var result = [];
26168
+ // 从 displayOptions 中获取选中项
26076
26169
  indexs.forEach(function (index) {
26077
- result.push(_extends({}, _this2.options[index], {
26078
- initialIndex: index
26079
- }));
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
+ }
26080
26180
  });
26081
26181
  return result;
26082
26182
  },
26083
26183
  onChange: function onChange() {
26184
+ var _this7 = this;
26084
26185
  // 同步 currentIndexs 以触发计算属性更新
26085
26186
  if (this.$refs.pickerOptions) {
26086
- this.currentIndexs = [].concat(this.$refs.pickerOptions.currentIndexs);
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
+ });
26087
26208
  }
26088
26209
  this.$emit('change', this.getOptions());
26089
26210
  },
@@ -26092,32 +26213,96 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26092
26213
  this.emit('cancel');
26093
26214
  },
26094
26215
  confirm: function confirm() {
26095
- var options = this.getOptions();
26096
- this.confirmIndexs = options.map(function (v) {
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) {
26097
26233
  return v.initialIndex;
26098
26234
  });
26099
- this.emit('confirm', options);
26235
+ this.$emit('confirm', allSelectedOptions);
26100
26236
  },
26101
26237
  handleSelectAll: function handleSelectAll() {
26102
- var newIndexs = !this.isAllSelected ? this.options && this.options.map(function (_, index) {
26103
- return index;
26104
- }) : [];
26105
- this.currentIndexs = newIndexs;
26106
- if (this.$refs.pickerOptions) {
26107
- this.$refs.pickerOptions.setConfirmIndex(newIndexs);
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
+ }
26108
26269
  }
26109
26270
  },
26110
26271
  onSelectOther: function onSelectOther() {
26111
- var _this3 = this;
26112
- var newIndexs = [];
26113
- this.options && this.options.forEach(function (_, index) {
26114
- if (!_this3.currentIndexs.includes(index)) {
26115
- newIndexs.push(index);
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);
26116
26302
  }
26117
26303
  });
26118
- this.currentIndexs = newIndexs;
26119
26304
  if (this.$refs.pickerOptions) {
26120
- this.$refs.pickerOptions.setConfirmIndex(newIndexs);
26305
+ this.$refs.pickerOptions.setConfirmIndex(displayIndexs);
26121
26306
  }
26122
26307
  },
26123
26308
  genTitle: function genTitle() {
@@ -26231,18 +26416,19 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26231
26416
  }, [this.genOptionItems()]);
26232
26417
  },
26233
26418
  genOptionItems: function genOptionItems() {
26234
- var _this4 = this;
26419
+ var _this11 = this;
26235
26420
  var h = this.$createElement;
26236
26421
  var formatOptions = [];
26237
- if (this.options && this.options[0] && typeof this.options[0] !== 'object') {
26238
- formatOptions = this.options.map(function (v) {
26422
+ var sourceOptions = this.displayOptions;
26423
+ if (sourceOptions && sourceOptions[0] && typeof sourceOptions[0] !== 'object') {
26424
+ formatOptions = sourceOptions.map(function (v) {
26239
26425
  return {
26240
26426
  value: v,
26241
26427
  text: v
26242
26428
  };
26243
26429
  });
26244
26430
  } else {
26245
- formatOptions = this.options;
26431
+ formatOptions = sourceOptions;
26246
26432
  }
26247
26433
  return h(MultiplePickerOptions, {
26248
26434
  "ref": "pickerOptions",
@@ -26260,7 +26446,7 @@ var multiple_picker_createNamespace = Object(utils["b" /* createNamespace */])('
26260
26446
  },
26261
26447
  "on": {
26262
26448
  "change": function change() {
26263
- _this4.onChange();
26449
+ _this11.onChange();
26264
26450
  }
26265
26451
  }
26266
26452
  });
@@ -35197,7 +35383,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
35197
35383
 
35198
35384
 
35199
35385
 
35200
- var es_version = '2.1.25';
35386
+ var es_version = '2.1.27';
35201
35387
  function install(Vue) {
35202
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];
35203
35389
  components.forEach(function (item) {