@10yun/cv-mobile-ui 0.5.3 → 0.5.5

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/ui-cv/{cv-button/cv-button.vue → cv-btn-base/cv-btn-base.vue} +19 -14
  3. package/ui-cv/cv-checkbox-group/cv-checkbox-group.vue +89 -56
  4. package/ui-cv/cv-checkbox-opt-base/cv-checkbox-opt-base.vue +43 -3
  5. package/ui-cv/cv-checkbox-opt-tag/cv-checkbox-opt-tag.vue +6 -2
  6. package/ui-cv/cv-code-sms/cv-code-sms.vue +34 -24
  7. package/ui-cv/cv-date-base/cv-date-base.vue +27 -6
  8. package/ui-cv/cv-datetime-base/cv-datetime-base.vue +31 -7
  9. package/ui-cv/cv-datetime5-base/cv-datetime5-base.vue +24 -7
  10. package/ui-cv/cv-dialog-share/cv-dialog-share.vue +2 -0
  11. package/ui-cv/cv-editor-quill/cv-editor-quill.vue +14 -13
  12. package/ui-cv/cv-form-base/cv-form-base.vue +1 -1
  13. package/ui-cv/cv-form-item/cv-form-item.vue +5 -2
  14. package/ui-cv/cv-geo-local/cv-geo-local.vue +118 -27
  15. package/ui-cv/{cv-picker-region/cv-picker-region.vue → cv-geo-region/cv-geo-region.vue} +30 -8
  16. package/ui-cv/cv-input-digit/cv-input-digit.vue +69 -13
  17. package/ui-cv/cv-input-idcard/cv-input-idcard.vue +70 -14
  18. package/ui-cv/cv-input-number/cv-input-number.vue +56 -13
  19. package/ui-cv/cv-input-password/cv-input-password.vue +66 -12
  20. package/ui-cv/cv-input-text/cv-input-text.vue +74 -7
  21. package/ui-cv/cv-picker1/cv-picker1.vue +28 -4
  22. package/ui-cv/cv-picker2/cv-picker2.vue +34 -11
  23. package/ui-cv/cv-picker3/cv-picker3.vue +41 -16
  24. package/ui-cv/cv-radio-group/cv-radio-group.vue +35 -13
  25. package/ui-cv/cv-radio-opt-base/cv-radio-opt-base.vue +37 -3
  26. package/ui-cv/cv-radio-opt-tag/cv-radio-opt-tag.vue +1 -1
  27. package/ui-cv/cv-rate/cv-rate.vue +24 -15
  28. package/ui-cv/cv-search/cv-search.vue +7 -1
  29. package/ui-cv/cv-specs/cv-specs.vue +13 -13
  30. package/ui-cv/cv-switch/cv-switch.vue +24 -16
  31. package/ui-cv/cv-textarea/cv-textarea.vue +18 -12
  32. package/ui-cv/cv-time-base/cv-time-base.vue +30 -3
  33. package/ui-cv/cv-treaty/cv-treaty.vue +18 -13
  34. package/ui-cv/cv-upload-avatar/cv-upload-avatar.vue +12 -5
  35. package/ui-cv/cv-upload-image/cv-upload-image.vue +21 -10
  36. package/ui-cv/cv-input-btn/cv-input-btn.vue +0 -124
  37. package/ui-cv/mixins/mixins-input.js +0 -75
  38. package/ui-cv/mixins/mixins-picker.js +0 -34
@@ -32,17 +32,17 @@
32
32
  </picker>
33
33
  </view>
34
34
  </template>
35
-
36
35
  <script>
37
- import MixinsPicker from '../mixins/mixins-picker.js';
38
36
  export default {
39
- mixins: [MixinsPicker],
40
37
  name: 'cvPicker3',
41
38
  props: {
42
- //默认输入框内容
43
39
  value: {
44
- type: Array,
45
- default: () => {}
40
+ type: [Array],
41
+ default: () => []
42
+ },
43
+ modelValue: {
44
+ type: [Array],
45
+ default: () => []
46
46
  },
47
47
  dataType: {
48
48
  type: String,
@@ -70,6 +70,11 @@ export default {
70
70
  joint: {
71
71
  type: String,
72
72
  default: ''
73
+ },
74
+ // 占位符
75
+ placeholder: {
76
+ type: String,
77
+ default: '请选择'
73
78
  }
74
79
  },
75
80
  watch: {
@@ -82,12 +87,16 @@ export default {
82
87
  value(newVal) {
83
88
  this.localVal = newVal;
84
89
  this.itemsSortOut();
90
+ },
91
+ modelValue(newVal) {
92
+ this.localVal = newVal;
93
+ this.itemsSortOut();
85
94
  }
86
95
  },
87
96
  data() {
88
97
  return {
89
98
  iconTop: false,
90
- localVal: '',
99
+ localVal: [],
91
100
  items: [], //全部数据
92
101
  range_data: [], //弹窗临时数组
93
102
  last_range_data: [], //最终显示页面数组
@@ -95,15 +104,26 @@ export default {
95
104
  items_sub2: [],
96
105
  items_index: [0, 0, 0], //当前下标
97
106
  lastRetDataIndex: [0, 0, 0], // 最终确定选中的下标
98
- localDataType: ''
107
+ localDataType: 'value',
108
+ localDataValue: 'value',
109
+ localDataText: 'label'
99
110
  };
100
111
  },
101
112
  created() {
102
- this.localVal = this.value;
113
+ this.localVal = this.doValueGet();
103
114
  this.localDataType = this.dataType != 'text' ? 'value' : 'text';
104
115
  this.itemsSortOut();
105
116
  },
106
117
  methods: {
118
+ doValueGet() {
119
+ if (this.value === '' || (Array.prototype.isPrototypeOf(this.value) && this.value.length === 0)) {
120
+ return this.modelValue;
121
+ }
122
+ if (this.modelValue === '' || (Array.prototype.isPrototypeOf(this.modelValue) && this.modelValue.length === 0)) {
123
+ return this.value;
124
+ }
125
+ return this.value;
126
+ },
107
127
  itemsSortOut() {
108
128
  let original = [];
109
129
  original = this.dataLists || [];
@@ -111,7 +131,8 @@ export default {
111
131
  if (typeof original == 'string') {
112
132
  original = JSON.parse(original);
113
133
  }
114
- if (!original) {
134
+ if (!original || original.length <= 0) {
135
+ console.warn('original 暂无数据', original);
115
136
  return;
116
137
  }
117
138
  //整理数据
@@ -126,7 +147,7 @@ export default {
126
147
  let data = original[i];
127
148
  //查找一级绑定参数
128
149
 
129
- if (this.localVal.length >= 1) {
150
+ if (this.localVal && this.localVal.length >= 1) {
130
151
  if (dataType == 'text' && this.localVal[0] == data[dataText]) {
131
152
  items_index[0] = i;
132
153
  } else if (dataType == 'value' && this.localVal[0] == data[dataValue]) {
@@ -144,7 +165,7 @@ export default {
144
165
  let data = tree_data[ii];
145
166
 
146
167
  //查找二级绑定参数
147
- if (this.localVal.length >= 2) {
168
+ if (this.localVal && this.localVal.length >= 2) {
148
169
  if (dataType == 'text' && this.localVal[1] == data[dataText]) {
149
170
  items_index[1] = ii;
150
171
  } else if (dataType == 'value' && this.localVal[1] == data[dataValue]) {
@@ -164,7 +185,7 @@ export default {
164
185
  for (const iii in tree_data2) {
165
186
  let data = tree_data2[iii];
166
187
  //查找三级绑定参数
167
- if (this.localVal.length >= 3) {
188
+ if (this.localVal && this.localVal.length >= 3) {
168
189
  if (dataType == 'text' && this.localVal[2] == data[dataText]) {
169
190
  items_index[2] = iii;
170
191
  } else if (dataType == 'value' && this.localVal[2] == data[dataValue]) {
@@ -199,16 +220,19 @@ export default {
199
220
  this.range_data = [items, this.items_sub, this.items_sub2];
200
221
  this.items_index = items_index;
201
222
  this.last_range_data = [...this.range_data];
202
- if (this.value.length == 3) {
223
+ if (this.localVal && this.localVal.length == 3) {
203
224
  this.lastRetDataIndex = [...this.items_index];
204
225
  }
205
226
  },
206
227
  bindPickerChange: function (e) {
207
228
  let items_index = e.detail.value;
208
229
  this.items_index = items_index;
209
- this.updatelocalVal();
230
+ this.updateLocalVal();
210
231
  this.iconTop = false;
211
232
  },
233
+ changeIconTop() {
234
+ this.iconTop = true;
235
+ },
212
236
  /* 取消选择 */
213
237
  onCancel(e) {
214
238
  this.iconTop = false;
@@ -242,7 +266,7 @@ export default {
242
266
  this.$forceUpdate();
243
267
  // this.funcOnInput();
244
268
  },
245
- updatelocalVal() {
269
+ updateLocalVal() {
246
270
  let items_index = this.items_index;
247
271
  this.last_range_data = [...this.range_data];
248
272
  this.lastRetDataIndex = [...items_index];
@@ -262,6 +286,7 @@ export default {
262
286
  value[2] = items[items_index[0]].tree[items_index[1]].tree[items_index[2]].value;
263
287
  }
264
288
  this.$emit('input', value);
289
+ this.$emit('update:modelValue', value);
265
290
  }
266
291
  }
267
292
  };
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view class="cv-radio-group-wrap">
3
- <radio-group @change="radioChange" class="cv-radio-group__box">
3
+ <radio-group @change="radioChange" class="cv-radio-group__box" :style="localStyle">
4
4
  <slot>
5
5
  <cv-radio-opt-base
6
6
  v-if="type == 'base'"
@@ -41,14 +41,21 @@ export default {
41
41
  cvRadioOptTag
42
42
  },
43
43
  props: {
44
+ value: {
45
+ type: [Number, String],
46
+ default: ''
47
+ },
48
+ modelValue: {
49
+ type: [Number, String],
50
+ default: ''
51
+ },
44
52
  type: {
45
53
  type: [String],
46
54
  default: 'base'
47
55
  },
48
- //默认内容
49
- value: {
50
- type: [String, Number],
51
- default: ''
56
+ align: {
57
+ type: [String],
58
+ default: 'left'
52
59
  },
53
60
  dataType: {
54
61
  type: String,
@@ -56,7 +63,7 @@ export default {
56
63
  },
57
64
  //选项数组
58
65
  dataLists: {
59
- type: [Array, String],
66
+ type: [Array, String, Object],
60
67
  default: () => {
61
68
  return [];
62
69
  }
@@ -75,6 +82,8 @@ export default {
75
82
  data() {
76
83
  return {
77
84
  localVal: '',
85
+ localList: [],
86
+ localStyle: '',
78
87
  items: [],
79
88
  itemsValue: ''
80
89
  };
@@ -84,21 +93,36 @@ export default {
84
93
  this.localVal = newVal;
85
94
  this._dealValue();
86
95
  },
96
+ modelValue(newVal) {
97
+ this.localVal = newVal;
98
+ this._dealValue();
99
+ },
87
100
  dataLists(newVal) {
88
- this.dataLists = newVal;
101
+ this.localList = newVal || [];
89
102
  this.items = this.itemsSortOut();
90
103
  this._dealValue();
91
104
  }
92
105
  },
93
106
  created() {
94
- this.localVal = this.value;
107
+ this.localVal = this.doValueGet();
95
108
  if (this.dataLists) {
109
+ this.localList = this.dataLists || [];
96
110
  this.items = this.itemsSortOut();
97
111
  }
98
- //默认Value
112
+ // 默认Value
99
113
  this._dealValue();
114
+ this._dealStyle();
100
115
  },
101
116
  methods: {
117
+ doValueGet() {
118
+ if (this.value === '') return this.modelValue;
119
+ if (this.modelValue === '') return this.value;
120
+ return this.value;
121
+ },
122
+ _dealStyle() {
123
+ let alignStyle = this.align == 'right' ? 'flex-end' : 'flex-start';
124
+ this.localStyle = `justify-content:${alignStyle};`;
125
+ },
102
126
  _dealValue() {
103
127
  //默认Value
104
128
  let items = this.items;
@@ -114,12 +138,10 @@ export default {
114
138
  },
115
139
  itemsSortOut() {
116
140
  let original = [];
117
- original = this.dataLists || [];
118
-
141
+ original = this.localList || [];
119
142
  if (typeof original == 'string') {
120
143
  original = JSON.parse(original);
121
144
  }
122
-
123
145
  //整理数据
124
146
  let items = [];
125
147
  let dataValue = this.dataValue ? this.dataValue : 'value';
@@ -147,6 +169,7 @@ export default {
147
169
  }
148
170
  this.localVal = localVal;
149
171
  this.$emit('input', this.localVal);
172
+ this.$emit('update:modelValue', this.localVal);
150
173
  }
151
174
  }
152
175
  };
@@ -155,7 +178,6 @@ export default {
155
178
  <style>
156
179
  .cv-radio-group-wrap {
157
180
  min-height: 35px;
158
- float: left;
159
181
  }
160
182
  .cv-radio-group__box {
161
183
  display: flex;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view class="cv-radio-opt-base">
3
3
  <label class="cv-radio-opt__label">
4
- <radio :value="localVal" :checked="checked" style="transform: scale(0.7)" />
4
+ <radio :value="localVal" :checked="localChecked" style="transform: scale(0.7)" />
5
5
  <view>
6
6
  <slot>{{ label }}</slot>
7
7
  </view>
@@ -27,18 +27,52 @@ export default {
27
27
  },
28
28
  data() {
29
29
  return {
30
- localVal: ''
30
+ localVal: '',
31
+ localChecked: false,
32
+ parentObj: null
31
33
  };
32
34
  },
33
35
  watch: {
34
36
  value(newVal) {
35
37
  this.localVal = String(newVal);
38
+ },
39
+ checked(newVal) {
40
+ this.localChecked = newVal;
41
+ },
42
+ 'parentObj.localVal'(newVal) {
43
+ // console.log('----', newVal);
44
+ this.localChecked = newVal == this.value ? true : false;
36
45
  }
37
46
  },
38
47
  created() {
39
48
  this.localVal = String(this.value);
49
+ this.localChecked = this.checked;
50
+ },
51
+ mounted() {
52
+ this.parentObj = this.getParent();
40
53
  },
41
- methods: {}
54
+ methods: {
55
+ funcOnClick() {
56
+ // let parentObj = this.getParent();
57
+ // console.log(parentObj.$children);
58
+ // let { value } = parentObj;
59
+ // console.log(value, this.localVal);
60
+ // this.localChecked = newVal == this.value ? true : false;
61
+ },
62
+ /**
63
+ * 获取父元素实例
64
+ */
65
+ getParent(name = 'cvRadioGroup') {
66
+ let parent = this.$parent;
67
+ let parentName = parent.$options.name;
68
+ while (parentName !== name) {
69
+ parent = parent.$parent;
70
+ if (!parent) return false;
71
+ parentName = parent.$options.name;
72
+ }
73
+ return parent;
74
+ }
75
+ }
42
76
  };
43
77
  </script>
44
78
 
@@ -39,7 +39,7 @@ export default {
39
39
  checked(newVal) {
40
40
  this.localChecked = newVal;
41
41
  },
42
- 'parentObj.value'(newVal) {
42
+ 'parentObj.localVal'(newVal) {
43
43
  // console.log('----', newVal);
44
44
  this.localChecked = newVal == this.value ? true : false;
45
45
  }
@@ -4,7 +4,7 @@
4
4
  class="cv-rate-item"
5
5
  v-for="i in parseInt(max)"
6
6
  :key="i"
7
- v-bind:style="i <= locaValue ? starSelected : starStyle"
7
+ :style="i <= locaValue ? starSelected : starStyle"
8
8
  :data-value="i"
9
9
  @tap="click_star"
10
10
  >
@@ -17,14 +17,16 @@
17
17
  <script>
18
18
  export default {
19
19
  name: 'cvRate',
20
- inject: {
21
- cvFormGroup: {
22
- default() {
23
- return null;
24
- }
25
- }
26
- },
27
20
  props: {
21
+ // 当前评分
22
+ value: {
23
+ type: [Number, String],
24
+ default: 0
25
+ },
26
+ modelValue: {
27
+ type: [Number, String],
28
+ default: 0
29
+ },
28
30
  isFill: {
29
31
  // 星星的类型,是否镂空
30
32
  type: [Boolean, String],
@@ -45,11 +47,6 @@ export default {
45
47
  type: [Number, String],
46
48
  default: 24
47
49
  },
48
- value: {
49
- // 当前评分
50
- type: [Number, String],
51
- default: 1
52
- },
53
50
  max: {
54
51
  // 最大评分
55
52
  type: [Number, String],
@@ -74,13 +71,24 @@ export default {
74
71
  };
75
72
  },
76
73
  watch: {
77
- value(newVal) {}
74
+ value(newVal) {
75
+ this.locaValue = newVal;
76
+ },
77
+ modelValue(newVal) {
78
+ this.locaValue = newVal;
79
+ }
78
80
  },
79
81
  created() {
80
- this.locaValue = this.value || 1;
82
+ this.locaValue = this.doValueGet();
83
+ console.log(this.locaValue);
81
84
  this._dealStyle();
82
85
  },
83
86
  methods: {
87
+ doValueGet() {
88
+ if (this.value === 0) return this.modelValue;
89
+ if (this.modelValue === 0) return this.value;
90
+ return this.value;
91
+ },
84
92
  _dealStyle() {
85
93
  if (this.color) {
86
94
  let starStyle = 'font-size:' + this.size + 'px;';
@@ -97,6 +105,7 @@ export default {
97
105
  let value = e.target.dataset.value;
98
106
  this.locaValue = value;
99
107
  this.$emit('input', value);
108
+ this.$emit('update:modelValue', value);
100
109
  }
101
110
  }
102
111
  };
@@ -39,7 +39,11 @@ export default {
39
39
  },
40
40
  props: {
41
41
  value: {
42
- type: String,
42
+ type: [Number, String],
43
+ default: ''
44
+ },
45
+ modelValue: {
46
+ type: [Number, String],
43
47
  default: ''
44
48
  },
45
49
  placeholder: {
@@ -72,6 +76,7 @@ export default {
72
76
  /* 判断是否禁止实时更新父级数据 */
73
77
  if (this.disableRealTime === false) {
74
78
  this.$emit('input', this.localVal);
79
+ this.$emit('update:modelValue', this.localVal);
75
80
  }
76
81
  },
77
82
  onEmpty() {
@@ -81,6 +86,7 @@ export default {
81
86
  onSearch() {
82
87
  this.$emit('search', this.localVal);
83
88
  this.$emit('input', this.localVal);
89
+ this.$emit('update:modelValue', this.localVal);
84
90
  }
85
91
  }
86
92
  };
@@ -2,7 +2,7 @@
2
2
  <view class="cv-specs">
3
3
  <!-- 规格 -->
4
4
  <view class="cv-specs-area">
5
- <view class="cv-specs-sort-area" v-for="(item, index1) in spu" :key="index1">
5
+ <view class="cv-specs-sort-area" v-for="(item, index1) in localSpu" :key="index1">
6
6
  <!-- 规格类别名称 -->
7
7
  <view class="cv-specs-sort-name">
8
8
  <text>{{ item.name }}</text>
@@ -83,8 +83,8 @@ export default {
83
83
  },
84
84
  data() {
85
85
  return {
86
- spu: [], //spu规格列表
87
- sku: [], //sku列表
86
+ localSpu: [], //spu规格列表
87
+ localSku: [], //sku列表
88
88
  shopItemInfo: {}, //存放要和选中的值进行匹配的数据
89
89
  selectArr: [], //存放被选中的值
90
90
  subIndex: [], //是否选中 因为不确定是多规格还是但规格,所以这里定义数组来判断
@@ -101,14 +101,14 @@ export default {
101
101
  methods: {
102
102
  //初始化数据
103
103
  _dealData() {
104
- this.spu = this.specList.items; //spu规格列表
105
- this.sku = this.skuList.items; //sku列表
104
+ this.localSpu = this.specList.items; // spu规格列表
105
+ this.localSku = this.skuList.items; // sku列表
106
106
  this.shopItemInfo = {}; //存放要和选中的值进行匹配的数据
107
107
  this.selectArr = []; //存放被选中的值
108
108
  this.subIndex = []; //是否选中 因为不确定是多规格还是但规格,所以这里定义数组来判断
109
109
  this.selectshop = {}; //存放最后选中的商品
110
- if (this.spu && this.sku && this.spu.length > 0 && this.sku.length > 0) {
111
- this.spu.map((item) => {
110
+ if (this.localSpu && this.localSku && this.localSpu.length > 0 && this.localSku.length > 0) {
111
+ this.localSpu.map((item) => {
112
112
  this.selectArr.push('');
113
113
  this.subIndex.push(-1);
114
114
  });
@@ -141,29 +141,29 @@ export default {
141
141
  //循环所有属性判断哪些属性可选
142
142
  //当前选中的兄弟节点和已选中属性不需要循环
143
143
 
144
- for (let i = 0, len = this.spu.length; i < len; i++) {
144
+ for (let i = 0, len = this.localSpu.length; i < len; i++) {
145
145
  if (i == clickIndex) {
146
146
  continue;
147
147
  }
148
- let len2 = this.spu[i].items.length;
148
+ let len2 = this.localSpu[i].items.length;
149
149
  for (let j = 0; j < len2; j++) {
150
150
  if (this.subIndex[i] != -1 && j == this.subIndex[i]) {
151
151
  continue;
152
152
  }
153
153
  let choosed_copy = [...this.selectArr];
154
- this.$set(choosed_copy, i, this.spu[i].items[j].name);
154
+ this.$set(choosed_copy, i, this.localSpu[i].items[j].name);
155
155
  let choosed_copy2 = choosed_copy.filter((item) => item !== '' && typeof item !== 'undefined');
156
156
  if (this.shopItemInfo.hasOwnProperty(choosed_copy2)) {
157
- this.$set(this.spu[i].items[j], 'ishow', true);
157
+ this.$set(this.localSpu[i].items[j], 'ishow', true);
158
158
  } else {
159
- this.$set(this.spu[i].items[j], 'ishow', false);
159
+ this.$set(this.localSpu[i].items[j], 'ishow', false);
160
160
  }
161
161
  }
162
162
  }
163
163
  },
164
164
  checkItem() {
165
165
  //计算可选路径
166
- let result = this.sku.reduce(
166
+ let result = this.localSku.reduce(
167
167
  (arrs, items) => {
168
168
  return arrs.concat(
169
169
  items.sku.reduce(
@@ -5,22 +5,18 @@
5
5
  <script>
6
6
  export default {
7
7
  name: 'cvSwitch',
8
- inject: {
9
- cvFormGroup: {
10
- default() {
11
- return null;
12
- }
13
- }
14
- },
15
8
  props: {
9
+ value: {
10
+ type: [Number, String, Boolean],
11
+ default: 0
12
+ },
13
+ modelValue: {
14
+ type: [Number, String, Boolean],
15
+ default: 0
16
+ },
16
17
  disabled: {
17
18
  type: Boolean,
18
19
  default: false
19
- },
20
- //默认输入框内容
21
- value: {
22
- type: [String, Number, Boolean],
23
- default: 0
24
20
  }
25
21
  },
26
22
  data() {
@@ -33,29 +29,40 @@ export default {
33
29
  },
34
30
  watch: {
35
31
  value(newVal) {
32
+ this.localVal = newVal;
33
+ this._dealDataList();
34
+ },
35
+ modelValue(newVal) {
36
+ this.localVal = newVal;
36
37
  this._dealDataList();
37
38
  }
38
39
  },
39
40
  created() {
41
+ this.localVal = this.doValueGet();
40
42
  this._dealDataList();
41
43
  },
42
44
  methods: {
45
+ doValueGet() {
46
+ if (this.value === '') return this.modelValue;
47
+ if (this.modelValue === '') return this.value;
48
+ return this.value;
49
+ },
43
50
  /* 整理数据 */
44
51
  _dealDataList() {
45
- this.dataType = typeof this.value;
52
+ this.dataType = typeof this.localVal;
46
53
  switch (this.dataType) {
47
54
  case 'boolean':
48
- this.checked = this.value;
55
+ this.checked = this.localVal;
49
56
  break;
50
57
  case 'number':
51
- if (this.value === 1) {
58
+ if (this.localVal === 1) {
52
59
  this.checked = true;
53
60
  } else {
54
61
  this.checked = false;
55
62
  }
56
63
  break;
57
64
  case 'string':
58
- if (this.value === '1') {
65
+ if (this.localVal === '1') {
59
66
  this.checked = true;
60
67
  } else {
61
68
  this.checked = false;
@@ -88,6 +95,7 @@ export default {
88
95
  break;
89
96
  }
90
97
  this.$emit('input', this.localVal);
98
+ this.$emit('update:modelValue', this.localVal);
91
99
  }
92
100
  }
93
101
  };
@@ -24,26 +24,23 @@
24
24
  <script>
25
25
  export default {
26
26
  name: 'cvTextArea',
27
- inject: {
28
- cvFormGroup: {
29
- default() {
30
- return null;
31
- }
32
- }
33
- },
34
27
  props: {
35
28
  value: {
36
- type: String,
29
+ type: [Number, String],
37
30
  default: ''
38
31
  },
39
- maxlength: {
32
+ modelValue: {
40
33
  type: [Number, String],
41
- default: -1
34
+ default: ''
42
35
  },
43
36
  placeholder: {
44
37
  type: [String],
45
38
  default: '请输入文本'
46
39
  },
40
+ maxlength: {
41
+ type: [Number, String],
42
+ default: -1
43
+ },
47
44
  clearable: {
48
45
  type: Boolean,
49
46
  default: false
@@ -53,7 +50,6 @@ export default {
53
50
  default: true
54
51
  }
55
52
  },
56
-
57
53
  data() {
58
54
  return {
59
55
  localVal: '',
@@ -64,15 +60,25 @@ export default {
64
60
  value(newVal) {
65
61
  this.localVal = newVal;
66
62
  this.tempLength = this.localVal.length;
63
+ },
64
+ modelValue(newVal) {
65
+ this.localVal = newVal;
66
+ this.tempLength = this.localVal.length;
67
67
  }
68
68
  },
69
69
  created() {
70
- this.localVal = this.value;
70
+ this.localVal = this.doValueGet();
71
71
  },
72
72
  methods: {
73
+ doValueGet() {
74
+ if (this.value === '') return this.modelValue;
75
+ if (this.modelValue === '') return this.value;
76
+ return this.value;
77
+ },
73
78
  funcOnInput(e) {
74
79
  this.tempLength = this.localVal.length;
75
80
  this.$emit('input', this.localVal);
81
+ this.$emit('update:modelValue', this.localVal);
76
82
  },
77
83
  /* 监听自己清除按钮点击事件 */
78
84
  onEmpty() {