sadais-piui 1.2.7-beta1 → 1.2.7-beta4

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.
@@ -184,6 +184,8 @@ export default {
184
184
  })
185
185
  this.val = vals
186
186
  this.handleEmitChange()
187
+ this.dispatch('PiForm', 'form-change', this.val)
188
+ this.dispatch('PiFormItem', 'form-change', this.val)
187
189
  }
188
190
  }
189
191
  }
@@ -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
- rules: {}
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.rules = rules
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 ? 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
  },
@@ -449,7 +449,10 @@ export default {
449
449
  resolve(_getResolve())
450
450
  })
451
451
  .catch(({ errors, fields }) => {
452
- console.log(TAG, '表单校验失败', this.prop, errors, fields)
452
+ console.log(TAG, '表单校验失败', `字段名:${this.prop},字段值:${fieldValue}`)
453
+ console.log(TAG, '字段值:', fieldValue)
454
+ console.log(TAG, '错误信息', errors)
455
+ console.log(TAG, '校验规则', fields)
453
456
  // 记录状态和报错信息
454
457
  this.validateState = 'error'
455
458
  this.validateMessage = errors ? errors[0].message : ''
@@ -328,8 +328,8 @@ export default {
328
328
  handleChange(value) {
329
329
  this.val = value
330
330
  this.handleEmitChange()
331
- this.dispatch('PiForm', 'form-change', value)
332
- this.dispatch('PiFormItem', 'form-change', value)
331
+ this.dispatch('PiForm', 'form-change', this.val)
332
+ this.dispatch('PiFormItem', 'form-change', this.val)
333
333
  }
334
334
  }
335
335
  }
@@ -181,6 +181,8 @@ export default {
181
181
  this.val = childName
182
182
  }
183
183
  this.handleEmitChange()
184
+ this.dispatch('PiForm', 'form-change', this.val)
185
+ this.dispatch('PiFormItem', 'form-change', this.val)
184
186
  }
185
187
  }
186
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7beta1",
3
+ "version": "1.2.7beta4",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {