mfmf 3 лет назад
Родитель
Сommit
8b05272ce8
3 измененных файлов с 30 добавлено и 18 удалено
  1. 5 0
      src/common/common.less
  2. 1 1
      src/components/DocTemplate/index.js
  3. 24 17
      src/components/DutyRecord/index.js

+ 5 - 0
src/common/common.less

@@ -233,4 +233,9 @@ body {
 }
 .ant-picker-footer{
   display: none;
+}
+.times{
+  display: inline-block;
+  width: 120px;
+  margin-right: 0;
 }

+ 1 - 1
src/components/DocTemplate/index.js

@@ -177,7 +177,7 @@ function DocTemplate() {
 			footer={[<Button key={1} type="primary" onClick={()=>setVisible(false)}>
 			  关闭
 			</Button>]}
-			width="80%"
+			width="90%"
 			visible={visible}
 			onCancel={()=>setVisible(false)}
 		>

+ 24 - 17
src/components/DutyRecord/index.js

@@ -5,7 +5,7 @@ import apiObj from '@api/index';
 import moment from "moment";
 import "moment/locale/zh-cn"
 import { message } from "antd/lib/index";
-import { disabledDate } from '@utils/index'
+import { disabledDate,getDaysBetween } from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { RangePicker } = DatePicker;
 const { Option } = Select;
@@ -108,12 +108,11 @@ function DutyRecord() {
 		setSelectedRowKeys(selectedRowKeys);
 	};
 	const onFinish = (value) => {
-		if (value.changeTime) {
-			value.changeTimeStart = moment(value.changeTime[0]).format('YYYY-MM-DD 00:00:00')
-			value.changeTimeEnd = moment(value.changeTime[1]).format('YYYY-MM-DD 23:23:59')
-		}else{
-			value.changeTimeStart =lastmonthday+" 00:00:00"
-			value.changeTimeEnd =today+" 23:23:59"
+		value.changeTimeStart = moment(value.changeTimeStart).format('YYYY-MM-DD 00:00:00');
+		value.changeTimeEnd = moment(value.changeTimeEnd).format('YYYY-MM-DD 23:23:59');
+		if (value.changeTimeStart > value.changeTimeEnd) {
+		    message.warning('开始时间不能大于结束时间');
+		    return
 		}
 		const param = {
 			...data,
@@ -154,7 +153,7 @@ function DutyRecord() {
 					form={form}
 					name="normal_login"
 					onFinish={onFinish}
-					initialValues={{ type: '' }}
+					initialValues={{ type: '', changeTimeStart: moment(lastmonthday), changeTimeEnd: moment(today) }}
 				>
 					<Row gutter={24}>
 						<Col span={5} key={0}>
@@ -188,15 +187,23 @@ function DutyRecord() {
 								</Select>
 							</Form.Item>
 						</Col>
-						<Col span={7} key={5}>
-							<Form.Item label="变更时间" name="changeTime">
-								<RangePicker
-									defaultValue={[moment(lastmonthday), moment(today)]}
-									disabledDate={disabledDate}
-									placeholder={['开始时间', '结束时间']}
-									allowClear={false}
-									inputReadOnly={true}
-								/>
+						<Col span={8} key={5}>
+							<Form.Item label="变更时间">
+								<Form.Item name="changeTimeStart" className='times'>
+								    <DatePicker
+								        allowClear={false}
+								        disabledDate={disabledDate}
+								        placeholder="请选择开始日期"
+								    />
+								</Form.Item>
+								<span style={{ margin: '0 5px', position: 'relative', top: '2px' }}>-</span>
+								<Form.Item name="changeTimeEnd" className='times'>
+								    <DatePicker
+								        allowClear={false}
+								        disabledDate={disabledDate}
+								        placeholder="请选择结束日期"
+								    />
+								</Form.Item>
 							</Form.Item>
 						</Col>
 						<Col span={6} key={6}>