|
|
@@ -0,0 +1,40 @@
|
|
|
+Ext.define('school.view.basic.student.StudentDetailModel', {
|
|
|
+ extend: 'school.view.core.form.FormPanelModel',
|
|
|
+ alias: 'viewmodel.basic-student-studentdetail',
|
|
|
+
|
|
|
+ formulas: {
|
|
|
+ stu_birthday_change: {
|
|
|
+ bind: '{stu_birthday}',
|
|
|
+ get: function(v) {
|
|
|
+ var val = new Date(v);
|
|
|
+ var now = new Date();
|
|
|
+ var nYear = now.getFullYear();
|
|
|
+ var nMonth = now.getMonth() + 1;
|
|
|
+ var nDay = now.getDate();
|
|
|
+
|
|
|
+ var vYear = val.getFullYear();
|
|
|
+ var vMonth = val.getMonth() + 1;
|
|
|
+ var vDay = val.getDate();
|
|
|
+
|
|
|
+ var age = 0;
|
|
|
+
|
|
|
+ if(nYear < vYear) {
|
|
|
+ age = nYear - vYear;
|
|
|
+ }else {
|
|
|
+ age = nYear - vYear;
|
|
|
+ if(nMonth < vMonth) {
|
|
|
+ age--;
|
|
|
+ }else if(nMonth == vMonth){
|
|
|
+ if(nDay < vDay) {
|
|
|
+ age--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ this.set('stu_age', age);
|
|
|
+ return v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|