sadais-piui 1.2.7-beta1 → 1.2.7-beta2

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,32 @@ 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
- rules: {}
232
+ validRules: {}
233
+ }
234
+ },
235
+ watch: {
236
+ rules: {
237
+ handler(val) {
238
+ this.validRules = val
239
+ },
240
+ deep: true
226
241
  }
227
242
  },
228
243
  methods: {
229
244
  // 由于跨平台限制,无法通过props传递方法,通过refs方式在onReady生命周期设置校验规则
230
245
  setRules(rules) {
231
- this.rules = rules
246
+ this.validRules = rules
232
247
  },
233
248
  // 校验数据
234
249
  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 ? this._parent.rules : undefined
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7beta1",
3
+ "version": "1.2.7beta2",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {