sadais-piui 1.2.6 → 1.2.7-beta3
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.
|
@@ -218,17 +218,33 @@ export default {
|
|
|
218
218
|
default() {
|
|
219
219
|
return form.rightIcon
|
|
220
220
|
}
|
|
221
|
+
},
|
|
222
|
+
// 表单校验规则
|
|
223
|
+
rules: {
|
|
224
|
+
type: Object,
|
|
225
|
+
default() {
|
|
226
|
+
return {}
|
|
227
|
+
}
|
|
221
228
|
}
|
|
222
229
|
},
|
|
223
230
|
data() {
|
|
224
231
|
return {
|
|
225
|
-
|
|
232
|
+
validRules: {}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
watch: {
|
|
236
|
+
rules: {
|
|
237
|
+
deep: true,
|
|
238
|
+
immediate: true,
|
|
239
|
+
handler(value) {
|
|
240
|
+
this.setRules(value)
|
|
241
|
+
}
|
|
226
242
|
}
|
|
227
243
|
},
|
|
228
244
|
methods: {
|
|
229
245
|
// 由于跨平台限制,无法通过props传递方法,通过refs方式在onReady生命周期设置校验规则
|
|
230
246
|
setRules(rules) {
|
|
231
|
-
this.
|
|
247
|
+
this.validRules = rules
|
|
232
248
|
},
|
|
233
249
|
// 校验数据
|
|
234
250
|
async validation() {
|
|
@@ -400,7 +400,7 @@ export default {
|
|
|
400
400
|
// 从pi-form的rules属性中,取出当前pi-form-item的校验规则
|
|
401
401
|
getRules() {
|
|
402
402
|
// 父组件的所有规则
|
|
403
|
-
const parentRules = this._parent
|
|
403
|
+
const parentRules = this._parent && (this._parent.validRules || this._parent.rules)
|
|
404
404
|
const rules = parentRules ? parentRules[this.prop] : []
|
|
405
405
|
return [].concat(rules || [])
|
|
406
406
|
},
|
package/package.json
CHANGED