Skip to content

Commit 8232cdf

Browse files
committed
1 parent a26674b commit 8232cdf

File tree

7 files changed

+30
-23
lines changed

7 files changed

+30
-23
lines changed

components/uni-data-checkbox/uni-data-checkbox.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,18 @@
157157
},
158158
value(newVal) {
159159
this.dataList = this.getDataList(newVal)
160-
this.formItem && this.formItem.setValue(newVal)
160+
// fix by mehaotian is_reset 在 uni-forms 中定义
161+
if (!this.is_reset) {
162+
this.is_reset = false
163+
this.formItem && this.formItem.setValue(newVal)
164+
}
161165
},
162166
modelValue(newVal) {
163167
this.dataList = this.getDataList(newVal);
164-
this.formItem && this.formItem.setValue(newVal);
168+
if (!this.is_reset) {
169+
this.is_reset = false
170+
this.formItem && this.formItem.setValue(newVal)
171+
}
165172
}
166173
},
167174
data() {

components/uni-easyinput/uni-easyinput.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,17 @@
173173
value(newVal) {
174174
if (this.errMsg) this.errMsg = ''
175175
this.val = newVal
176-
if (this.form && this.formItem) {
176+
// fix by mehaotian is_reset 在 uni-forms 中定义
177+
if (this.form && this.formItem && !this.is_reset) {
178+
this.is_reset = false
177179
this.formItem.setValue(newVal)
178180
}
179181
},
180182
modelValue(newVal) {
181183
if (this.errMsg) this.errMsg = ''
182184
this.val = newVal
183-
if (this.form && this.formItem) {
185+
if (this.form && this.formItem && !this.is_reset) {
186+
this.is_reset = false
184187
this.formItem.setValue(newVal)
185188
}
186189
},

components/uni-file-picker/uni-file-picker.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@
269269
this.localValue = newVal
270270
this.formItem && this.formItem.setValue(this.localValue)
271271
this.files = [].concat(newVal || [])
272+
let filesData = Object.keys(newVal).length > 0 ? newVal : []
273+
this.files = [].concat(filesData)
272274
},
273275
274276
/**

components/uni-forms-item/uni-forms-item.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
<view class="uni-forms-item__inner" :class="['is-direction-' + labelPos]">
55
<view class="uni-forms-item__label" :style="{ width: labelWid , justifyContent: justifyContent }">
66
<slot name="left">
7+
<text v-if="required" class="is-required">*</text>
78
<uni-icons v-if="leftIcon" class="label-icon" size="16" :type="leftIcon" :color="iconColor" />
89
<text class="label-text">{{ label }}</text>
9-
<text v-if="required" class="is-required">*</text>
10+
1011
<view v-if="label" class="label-seat"></view>
1112
</slot>
1213
</view>
@@ -230,18 +231,16 @@
230231
this.border = this.form.border;
231232
this.showMsg = errShowType;
232233
let name = this.isArray ? this.arrayField : this.name;
233-
if (formRules) {
234+
if (!name) return
235+
if (formRules && this.rules.length > 0) {
234236
if (!formRules[name]) {
235237
formRules[name] = {
236238
rules: this.rules
237239
}
238240
}
239-
this.formRules = formRules[name];
240-
}
241-
if (this.rules.length > 0) {
242241
validator.updateSchema(formRules);
243242
}
244-
243+
this.formRules = formRules[name] || {};
245244
this.validator = validator;
246245
} else {
247246
this.labelPos = this.labelPosition || 'left';
@@ -301,7 +300,8 @@
301300
async triggerCheck(value, formTrigger) {
302301
let promise = null;
303302
this.errMsg = '';
304-
if (!this.validator) return;
303+
// fix by mehaotian 解决没有检验规则的情况下,抛出错误的问题
304+
if (!this.validator || Object.keys(this.formRules).length === 0) return;
305305
const isNoField = this.isRequired(this.formRules.rules || []);
306306
let isTrigger = this.isTrigger(this.formRules.validateTrigger, this.validateTrigger, this.form.validateTrigger);
307307
let result = null;
@@ -449,7 +449,8 @@
449449
}
450450
451451
.is-required {
452-
color: #dd524d;
452+
color: #f00;
453+
font-weight: bold;
453454
}
454455
455456
.uni-error-message {

components/uni-forms/uni-forms.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@
5656
export default {
5757
name: 'uniForms',
5858
components: {},
59-
model: {
60-
prop: 'modelValue',
61-
event: 'update:modelValue'
62-
},
63-
emits: ['update:modelValue', 'input', 'reset', 'validate', 'submit'],
59+
emits: ['input', 'reset', 'validate', 'submit'],
6460
props: {
6561
// 即将弃用
6662
value: {
@@ -236,8 +232,6 @@
236232
value = this._getValue(example.name, value);
237233
this.formData[name] = value;
238234
example.val = value;
239-
this.$emit('input', Object.assign({}, this.value, this.formData));
240-
this.$emit('update:modelValue', Object.assign({}, this.value, this.formData));
241235
return example.triggerCheck(value, callback);
242236
},
243237
@@ -251,6 +245,8 @@
251245
const inputComp = this.inputChildrens.find(child => child.rename === item.name);
252246
if (inputComp) {
253247
inputComp.errMsg = '';
248+
// fix by mehaotian 不触发其他组件的 setValue
249+
inputComp.is_reset = true
254250
inputComp.$emit('input', inputComp.multiple ? [] : '');
255251
inputComp.$emit('update:modelValue', inputComp.multiple ? [] : '');
256252
}
@@ -262,8 +258,6 @@
262258
}
263259
});
264260
265-
this.$emit('input', this.formData);
266-
this.$emit('update:modelValue', this.formData);
267261
this.$emit('reset', event);
268262
},
269263

components/uni-tag/uni-tag.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
isTrue(circle) ? 'uni-tag--circle' : '',
9090
isTrue(mark) ? 'uni-tag--mark' : '',
9191
'uni-tag--' + size,
92-
type === 'default' ? 'uni-tag--default' : 'uni-tag-text',
92+
// type === 'default' ? 'uni-tag--default' : 'uni-tag-text',
9393
isTrue(inverted) ? 'uni-tag-text--' + type : '',
9494
size === 'small' ? 'uni-tag-text--small' : ''
9595
]

pages/extUI/forms/forms.nvue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<uni-easyinput type="textarea" v-model="baseFormData.introduction" placeholder="请输入自我介绍" />
2222
</uni-forms-item>
2323
<uni-forms-item label="日期时间">
24-
<uni-datetime-picker type="datetime" return-type="timestamp" v-model="baseFormData.datetimesingle" @change="changeLog" />
24+
<uni-datetime-picker type="datetime" return-type="timestamp" v-model="baseFormData.datetimesingle" />
2525
</uni-forms-item>
2626
</uni-forms>
2727
</view>

0 commit comments

Comments
 (0)