@v2coding/ui 0.1.28 → 0.1.29

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.
@@ -3684,6 +3684,16 @@ var script$y = {
3684
3684
  },
3685
3685
  expandMap: function expandMap() {
3686
3686
  return this.getExpandMap(this.realData);
3687
+ },
3688
+ realAllValue: function realAllValue(_ref2) {
3689
+ var realProps = _ref2.realProps,
3690
+ allValue = _ref2.allValue;
3691
+
3692
+ if (realProps.multiple) {
3693
+ return false;
3694
+ }
3695
+
3696
+ return allValue;
3687
3697
  }
3688
3698
  },
3689
3699
  watch: {
@@ -3778,23 +3788,42 @@ var script$y = {
3778
3788
  }, null);
3779
3789
  },
3780
3790
  matchValue: function matchValue(data, value) {
3791
+ if (this.realProps.multiple) {
3792
+ return this.matchMultipleValue(data, value);
3793
+ }
3794
+
3795
+ return this.matchSingleValue(data, value);
3796
+ },
3797
+ matchSingleValue: function matchSingleValue(data, value) {
3781
3798
  if (!value) {
3782
3799
  return [];
3783
3800
  }
3784
3801
 
3785
- if (!this.allValue) {
3802
+ if (!this.realAllValue) {
3786
3803
  var fullValues = this.expandMap[value] || [];
3787
3804
  return _toConsumableArray(fullValues).reverse();
3788
3805
  }
3789
3806
 
3790
- return value.split(',');
3807
+ return String(value).split(',');
3808
+ },
3809
+ matchMultipleValue: function matchMultipleValue(data, values) {
3810
+ var _this3 = this;
3811
+
3812
+ if (!values) {
3813
+ return [];
3814
+ }
3815
+
3816
+ return values.split(',').map(function (value) {
3817
+ var fullValues = _this3.expandMap[value] || [];
3818
+ return _toConsumableArray(fullValues).reverse();
3819
+ });
3791
3820
  },
3792
3821
 
3793
3822
  /**
3794
3823
  * 展开有层级关系的 list
3795
3824
  */
3796
3825
  getExpandList: function getExpandList(data, valueKey, upValue) {
3797
- var _this3 = this;
3826
+ var _this4 = this;
3798
3827
 
3799
3828
  return data.reduce(function (prev, _ref) {
3800
3829
  var children = _ref.children,
@@ -3805,7 +3834,7 @@ var script$y = {
3805
3834
  }));
3806
3835
 
3807
3836
  if (Array.isArray(children) && children.length) {
3808
- prev.push.apply(prev, _toConsumableArray(_this3.getExpandList(children, valueKey, item[valueKey])));
3837
+ prev.push.apply(prev, _toConsumableArray(_this4.getExpandList(children, valueKey, item[valueKey])));
3809
3838
  }
3810
3839
 
3811
3840
  return prev;
@@ -3845,6 +3874,14 @@ var script$y = {
3845
3874
  }, {});
3846
3875
  },
3847
3876
  onChange: function onChange(value) {
3877
+ if (this.realProps.multiple) {
3878
+ this.onMultipleChange(value);
3879
+ return;
3880
+ }
3881
+
3882
+ this.onSingleChange(value);
3883
+ },
3884
+ onSingleChange: function onSingleChange(value) {
3848
3885
  var lastVal = value.length ? value[value.length - 1] : '';
3849
3886
 
3850
3887
  if (!lastVal) {
@@ -3852,7 +3889,7 @@ var script$y = {
3852
3889
  return;
3853
3890
  }
3854
3891
 
3855
- if (!this.allValue) {
3892
+ if (!this.realAllValue) {
3856
3893
  this.emitChange(lastVal);
3857
3894
  return;
3858
3895
  }
@@ -3861,6 +3898,19 @@ var script$y = {
3861
3898
 
3862
3899
  this.emitChange(_value);
3863
3900
  },
3901
+ onMultipleChange: function onMultipleChange(list) {
3902
+ if (!Array.isArray(list) || list.length <= 0) {
3903
+ this.emitChange(undefined);
3904
+ return;
3905
+ }
3906
+
3907
+ var _value = list.map(function (item) {
3908
+ var lastVal = item.length ? item[item.length - 1] : '';
3909
+ return lastVal;
3910
+ }).filter(Boolean).join(',');
3911
+
3912
+ this.emitChange(_value);
3913
+ },
3864
3914
  resetValue: function resetValue() {
3865
3915
  this.onChange([]);
3866
3916
  }
@@ -3898,7 +3948,7 @@ var __vue_render__$y = function __vue_render__() {
3898
3948
  on: {
3899
3949
  "change": _vm.onChange
3900
3950
  }
3901
- }, 'el-cascader', _vm.$attrs, false), _vm._listeners)) : _vm._e(), _vm._ssrNode(" "), _vm.hasRefresh ? _vm._ssrNode("<div class=\"el-input-group el-input-group--append\" data-v-682ee118>", "</div>", [_c('el-cascader', _vm._g(_vm._b({
3951
+ }, 'el-cascader', _vm.$attrs, false), _vm._listeners)) : _vm._e(), _vm._ssrNode(" "), _vm.hasRefresh ? _vm._ssrNode("<div class=\"el-input-group el-input-group--append\" data-v-e8617b10>", "</div>", [_c('el-cascader', _vm._g(_vm._b({
3902
3952
  directives: [{
3903
3953
  name: "loading",
3904
3954
  rawName: "v-loading",
@@ -3919,7 +3969,7 @@ var __vue_render__$y = function __vue_render__() {
3919
3969
  on: {
3920
3970
  "change": _vm.onChange
3921
3971
  }
3922
- }, 'el-cascader', _vm.$attrs, false), _vm._listeners)), _vm._ssrNode(" "), _vm._ssrNode("<div class=\"el-input-group__append\" data-v-682ee118>", "</div>", [_c('el-button', {
3972
+ }, 'el-cascader', _vm.$attrs, false), _vm._listeners)), _vm._ssrNode(" "), _vm._ssrNode("<div class=\"el-input-group__append\" data-v-e8617b10>", "</div>", [_c('el-button', {
3923
3973
  attrs: {
3924
3974
  "icon": "el-icon-refresh"
3925
3975
  },
@@ -3934,8 +3984,8 @@ var __vue_staticRenderFns__$y = [];
3934
3984
 
3935
3985
  var __vue_inject_styles__$z = function __vue_inject_styles__(inject) {
3936
3986
  if (!inject) return;
3937
- inject("data-v-682ee118_0", {
3938
- source: ".ui-cascade-field[data-v-682ee118]{width:100%}.ui-cascade-field-popper[data-v-682ee118]{z-index:99999!important}.ui-cascade-field-popper .el-cascader-menu__item[data-v-682ee118]{padding-right:30px}[data-v-682ee118] .el-loading-mask .el-loading-spinner{margin-top:-14px}",
3987
+ inject("data-v-e8617b10_0", {
3988
+ source: ".ui-cascade-field[data-v-e8617b10]{width:100%}.ui-cascade-field-popper[data-v-e8617b10]{z-index:99999!important}.ui-cascade-field-popper .el-cascader-menu__item[data-v-e8617b10]{padding-right:30px}[data-v-e8617b10] .el-loading-mask .el-loading-spinner{margin-top:-14px}",
3939
3989
  map: undefined,
3940
3990
  media: undefined
3941
3991
  });
@@ -3943,10 +3993,10 @@ var __vue_inject_styles__$z = function __vue_inject_styles__(inject) {
3943
3993
  /* scoped */
3944
3994
 
3945
3995
 
3946
- var __vue_scope_id__$z = "data-v-682ee118";
3996
+ var __vue_scope_id__$z = "data-v-e8617b10";
3947
3997
  /* module identifier */
3948
3998
 
3949
- var __vue_module_identifier__$z = "data-v-682ee118";
3999
+ var __vue_module_identifier__$z = "data-v-e8617b10";
3950
4000
  /* functional template */
3951
4001
 
3952
4002
  var __vue_is_functional_template__$z = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v2coding/ui",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "",
5
5
 
6
6
  "main": "dist/v2coding-ui.ssr.js",