Commit 5a8fb662 authored by baixian's avatar baixian

ERP年龄计算优化

parent c2b662e1
...@@ -18,5 +18,5 @@ ...@@ -18,5 +18,5 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="text/javascript" src="https://cdn.s.shangjiadao.cn/qingxiao/biz/dist/main.d6563c.js"></script></body> <script type="text/javascript" src="https://cdn.s.shangjiadao.cn/qingxiao/biz/dist/main.4a8467.js"></script></body>
</html> </html>
...@@ -896,7 +896,7 @@ class StudentMgt extends React.Component { ...@@ -896,7 +896,7 @@ class StudentMgt extends React.Component {
return ( return (
<div> <div>
{/* { new Date(Date(record.birthday)).getFullYear()} */} {/* { new Date(Date(record.birthday)).getFullYear()} */}
{record.birthday ? `${(new Date().getFullYear() + 1) - new Date(record.birthday).getFullYear()}` : ''} {record.birthday ? `${((new Date().getFullYear()) - new Date(record.birthday).getFullYear()) == 0 ? 1 : ((new Date().getFullYear()) - new Date(record.birthday).getFullYear())}` : ''}
</div> </div>
); );
}, },
......
...@@ -96,15 +96,15 @@ class StudentAddForm extends React.Component { ...@@ -96,15 +96,15 @@ class StudentAddForm extends React.Component {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
let cAge = 0; let cAge = 0;
if (!selectYear == '') { if (!selectYear == '') {
const toyear = new Date().getFullYear() + 1; const toyear = new Date().getFullYear();
cAge = toyear - selectYear; cAge = ((toyear - selectYear) == 0) ? 1 : toyear - selectYear;
} else { } else {
if (!studentsdetail.birthday) { if (!studentsdetail.birthday) {
cAge = 0; cAge = 0;
} else { } else {
const year = new Date(studentsdetail.birthday.replace(/-/g, '-')).getFullYear(); const year = new Date(studentsdetail.birthday.replace(/-/g, '-')).getFullYear();
const toyear = new Date().getFullYear() + 1; const toyear = new Date().getFullYear();
cAge = toyear - year; cAge = ((toyear - year) == 0) ? 1 : toyear - year;
} }
} }
// const cage = toyear - Number(dateString ? dateString.format('YYYY') : 0); // const cage = toyear - Number(dateString ? dateString.format('YYYY') : 0);
......
...@@ -775,7 +775,7 @@ class StudentMgt extends React.Component { ...@@ -775,7 +775,7 @@ class StudentMgt extends React.Component {
</Descriptions> </Descriptions>
<Descriptions> <Descriptions>
<Descriptions.Item label="状态">{studentsdetail.student_courses && studentsdetail.student_courses.length == 0 ? '未在读' : '在读'}</Descriptions.Item> <Descriptions.Item label="状态">{studentsdetail.student_courses && studentsdetail.student_courses.length == 0 ? '未在读' : '在读'}</Descriptions.Item>
<Descriptions.Item label="年龄">{(new Date().getFullYear() + 1) - new Date(studentsdetail.birthday).getFullYear()}</Descriptions.Item> <Descriptions.Item label="年龄">{((new Date().getFullYear()) - new Date(studentsdetail.birthday).getFullYear() == 0 ? 1 : (new Date().getFullYear()) - new Date(studentsdetail.birthday).getFullYear())}</Descriptions.Item>
<Descriptions.Item label="备注">{studentsdetail.remark}</Descriptions.Item> <Descriptions.Item label="备注">{studentsdetail.remark}</Descriptions.Item>
</Descriptions> </Descriptions>
</Col> </Col>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment