StudentDetailModel.js 1012 B

123456789101112131415161718192021222324252627282930313233
  1. Ext.define('school.view.basic.student.StudentDetailModel', {
  2. extend: 'school.view.core.form.FormPanelModel',
  3. alias: 'viewmodel.basic-student-studentdetail',
  4. formulas: {
  5. stu_birthday_change: {
  6. bind: '{stu_birthday}',
  7. get: function(v) {
  8. var val = new Date(v);
  9. var now = new Date();
  10. var nYear = now.getFullYear();
  11. var nMonth = now.getMonth() + 1;
  12. var nDay = now.getDate();
  13. var vYear = val.getFullYear();
  14. var vMonth = val.getMonth() + 1;
  15. var vDay = val.getDate();
  16. var age = 0;
  17. if(nYear > vYear) {
  18. age = nYear - vYear;
  19. if((nMonth < vMonth) || (nMonth == vMonth && nDay < vDay)) {
  20. age--;
  21. }
  22. }
  23. this.set('stu_age', age);
  24. return v;
  25. }
  26. }
  27. }
  28. });