|
|
@ -9,7 +9,8 @@ import { |
|
|
|
Row, |
|
|
|
Col, |
|
|
|
Divider, |
|
|
|
InputNumber |
|
|
|
InputNumber, |
|
|
|
message |
|
|
|
} from "antd"; |
|
|
|
import moment from "moment"; |
|
|
|
function TimePart(props) { |
|
|
@ -39,17 +40,49 @@ function TimePart(props) { |
|
|
|
"status": "disable", |
|
|
|
"key": "821170365" |
|
|
|
} |
|
|
|
useEffect(() => { |
|
|
|
console.log(43, form.getFieldsValue()) |
|
|
|
if (form.getFieldsValue().time_part == undefined) { |
|
|
|
timePart(false) |
|
|
|
} |
|
|
|
}, [form]) |
|
|
|
const countDown = (time) => { |
|
|
|
var s = 0; |
|
|
|
var hour = time.split(':')[0]; |
|
|
|
var min = time.split(':')[1]; |
|
|
|
var sec = time.split(':')[2]; |
|
|
|
s = Number(hour * 3600) + Number(min * 60) + Number(sec); |
|
|
|
return s; |
|
|
|
} |
|
|
|
const valueChange = (value, all) => { |
|
|
|
timePart(value) |
|
|
|
//timePart(value) |
|
|
|
console.log(value) |
|
|
|
if(value.limit){ |
|
|
|
form.validateFields(Object.keys(value)) |
|
|
|
} |
|
|
|
// if (value.limit) { |
|
|
|
// console.log(46) |
|
|
|
// //form.validateFields(Object.keys(value)) |
|
|
|
// form.validateFields() |
|
|
|
// .then(values => { console.log(values) }) |
|
|
|
// .catch(e => console.log(e)) |
|
|
|
// } |
|
|
|
form.validateFields().then((data) => { |
|
|
|
console.log(data) |
|
|
|
}).catch(err => { |
|
|
|
if (err.errorFields.length > 0) { |
|
|
|
console.log('不完整') |
|
|
|
timePart(false) |
|
|
|
} else { |
|
|
|
console.log('完整了',all, countDown(all.end) - countDown(all.start)<all.items[0].segment * 60 ) |
|
|
|
if ( countDown(all.end) - countDown(all.start) < all.items[0].segment * 60) { |
|
|
|
message.error("输入的分钟数要小于时间段时间") |
|
|
|
return |
|
|
|
} |
|
|
|
timePart(true) |
|
|
|
} |
|
|
|
}) |
|
|
|
all.key = itemKey; |
|
|
|
if (all.time_part) { |
|
|
|
all.start = moment(all.time_part[0]).format('HH:mm:ss') |
|
|
|
all.end = moment(all.time_part[1]).format('HH:mm:ss') |
|
|
|
delete all.time_part |
|
|
|
} |
|
|
|
if (all.type == 0) { |
|
|
|
all.items = [ |
|
|
@ -65,7 +98,7 @@ function TimePart(props) { |
|
|
|
"threshold": 0, |
|
|
|
"period": all.time_after_minute, |
|
|
|
"unit": all.time_after_money, |
|
|
|
"segment": all.time_before, |
|
|
|
"segment": all.time_part ? (moment(all.time_part[1]) - moment(all.time_part[0])) / 60000 - all.time_before : all.time_before, |
|
|
|
}, |
|
|
|
] |
|
|
|
delete all.type |
|
|
@ -99,7 +132,8 @@ function TimePart(props) { |
|
|
|
delete all.unit |
|
|
|
delete all.segment |
|
|
|
} |
|
|
|
console.log(66, all) |
|
|
|
delete all.time_part |
|
|
|
//console.log(66, all) |
|
|
|
onChange(all); |
|
|
|
}; |
|
|
|
useEffect(() => { |
|
|
@ -134,7 +168,6 @@ function TimePart(props) { |
|
|
|
}) |
|
|
|
} |
|
|
|
}, []) |
|
|
|
console.log(30, record) |
|
|
|
return ( |
|
|
|
<div className="timepart-box"> |
|
|
|
<Form |
|
|
@ -155,7 +188,7 @@ function TimePart(props) { |
|
|
|
> |
|
|
|
<Row gutter={[30]}> |
|
|
|
<Col span={16}> |
|
|
|
<Form.Item label={`时段${index}`} name="time_part"> |
|
|
|
<Form.Item label={`时段${index}`} name="time_part" rules={[{ required: true, message: '请选择时间段!' }]}> |
|
|
|
<TimePicker.RangePicker style={{ width: "50%" }} order={false} secondStep={60} /> |
|
|
|
</Form.Item> |
|
|
|
</Col> |
|
|
@ -199,11 +232,11 @@ function TimePart(props) { |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Input.Group compact> |
|
|
|
<Form.Item name="time_before" label="前:" rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_before" label="前:" rules={[{ required: true, message: '请输入内容!' }]} > |
|
|
|
<InputNumber min={0} precision={0} addonAfter={"分钟"} /> |
|
|
|
</Form.Item> |
|
|
|
<div className="wenzi">,</div> |
|
|
|
<Form.Item name="time_before_money" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_before_money" noStyle rules={[{ required: true, message: '' }]}> |
|
|
|
<InputNumber |
|
|
|
min={0} |
|
|
|
addonAfter={"元"} |
|
|
@ -211,7 +244,7 @@ function TimePart(props) { |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<div className="wenzi">/</div> |
|
|
|
<Form.Item name="time_before_minute" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_before_minute" noStyle rules={[{ required: true, message: '' }]}> |
|
|
|
<InputNumber |
|
|
|
min={1} |
|
|
|
precision={0} |
|
|
@ -221,11 +254,11 @@ function TimePart(props) { |
|
|
|
</Form.Item> |
|
|
|
</Input.Group> |
|
|
|
<Input.Group compact> |
|
|
|
<Form.Item name="time_before" label="满:" rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_before" label="满:" rules={[{ required: true, message: '请输入内容!' }]} > |
|
|
|
<InputNumber min={0} precision={0} addonAfter={"分钟"} disabled /> |
|
|
|
</Form.Item> |
|
|
|
<div className="wenzi">,</div> |
|
|
|
<Form.Item name="time_after_money" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_after_money" noStyle > |
|
|
|
<InputNumber |
|
|
|
min={0} |
|
|
|
addonAfter={"元"} |
|
|
@ -233,7 +266,7 @@ function TimePart(props) { |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
<div className="wenzi">/</div> |
|
|
|
<Form.Item name="time_after_minute" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="time_after_minute" noStyle rules={[{ required: true, message: '' }]}> |
|
|
|
<InputNumber |
|
|
|
min={1} |
|
|
|
precision={0} |
|
|
@ -247,11 +280,11 @@ function TimePart(props) { |
|
|
|
case 2: |
|
|
|
return ( |
|
|
|
<Input.Group compact> |
|
|
|
<Form.Item name="unit" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="unit" noStyle rules={[{ required: true, message: '请输入内容!' }]} > |
|
|
|
<InputNumber min={0} addonAfter={"元"} style={{ width: "20%" }} /> |
|
|
|
</Form.Item> |
|
|
|
<div className="wenzi">/</div> |
|
|
|
<Form.Item name="period" noStyle rules={[{ required: true }]}> |
|
|
|
<Form.Item name="period" noStyle rules={[{ required: true, message: '' }]} > |
|
|
|
<InputNumber min={1} precision={0} addonAfter={"分钟"} style={{ width: "20%" }} /> |
|
|
|
</Form.Item> |
|
|
|
</Input.Group> |
|
|
@ -259,7 +292,7 @@ function TimePart(props) { |
|
|
|
case 1: |
|
|
|
return ( |
|
|
|
<Form.Item name="unit"> |
|
|
|
<InputNumber min={0} addonAfter={"元/次"} style={{ width: "20%" }} /> |
|
|
|
<InputNumber min={0} addonAfter={"元/次"} style={{ width: "20%" }} rules={[{ required: true, message: '请输入内容!' }]} /> |
|
|
|
</Form.Item> |
|
|
|
); |
|
|
|
} |
|
|
@ -277,7 +310,7 @@ function TimePart(props) { |
|
|
|
<Form.Item |
|
|
|
label="时段最高收费金额" |
|
|
|
name="limit" |
|
|
|
rules={[{ required: true }]} |
|
|
|
rules={[{ required: true, message: '请输入内容!' }]} |
|
|
|
> |
|
|
|
<InputNumber min={0} addonAfter={"元"} /> |
|
|
|
</Form.Item> |
|
|
|