Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100. 管理后台表单提交:封装表单相关内容为 model #100

Open
ly525 opened this issue Jul 12, 2018 · 0 comments
Open

100. 管理后台表单提交:封装表单相关内容为 model #100

ly525 opened this issue Jul 12, 2018 · 0 comments

Comments

@ly525
Copy link
Owner

ly525 commented Jul 12, 2018

export default class User {
   constructor(form={}) {
      this.name = form.name
      this.age = form.age
      this.gender = form.gender
   }

   parse2Payload() {
      let payload = {
        name: this.name,
        age: this.age,
        gender: this.gender === 'boy' ? 0 : 1,       
      }

     return payload

   }

   static getValidateRules() {
      return {
        name: [
          { required: true, message: 'source is required', trigger: 'blur'}
        ],
        age: [
          { required: true, message: 'package is required', trigger: 'blur'}
        ],
        gender: [
          { required: true, message: 'source is required', trigger: 'blur'}
        ],
       }
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
0.0 业务场景总结
B端业务场景
Development

No branches or pull requests

1 participant