6 changed files with 296 additions and 16 deletions
-
5src/components/TableModule/index.jsx
-
9src/pages/OffPeak/OffPeakShareRecords/ShareParkMgm/index.scss
-
123src/pages/OffPeak/OffPeakShareRecords/ShareParkMgm/infoModal/index.jsx
-
32src/pages/OffPeak/OffPeakShareRecords/ShareParkMgm/infoModal/index.scss
-
115src/pages/OffPeak/OffPeakShareRecords/ShareParkMgm/loadable.jsx
-
28src/services/OffPeak/index.js
@ -0,0 +1,123 @@ |
|||
import React, {useState, useEffect} from 'react' |
|||
import { Modal, Form, Input, DatePicker, TreeSelect, Button, Col, Row, Select } from 'antd' |
|||
import { SearchableTreeSelect } from '@/components' |
|||
import moment from 'moment' |
|||
import './index.scss' |
|||
|
|||
function InfoModal (props) { |
|||
const { |
|||
visible, |
|||
isEdit=false, |
|||
isDetail=false, |
|||
onCancel, |
|||
timeRulesData=[], |
|||
data={}, |
|||
onOk |
|||
} = props |
|||
|
|||
const [baseForm] = Form.useForm() |
|||
|
|||
const rules = [ |
|||
{ |
|||
required: true, |
|||
message: "此为必填字段", |
|||
}, |
|||
] |
|||
|
|||
const handleSave = () => { |
|||
baseForm.validateFields().then((data) => { |
|||
onOk({...data}) |
|||
}).catch(err => { |
|||
console.error(err) |
|||
}) |
|||
} |
|||
|
|||
const validateCws = (_, value) => { |
|||
const total = baseForm.getFieldValue('total'); |
|||
if (value > total) { |
|||
return Promise.reject(new Error('可预约车位数大于总数')); |
|||
} |
|||
return Promise.resolve(); |
|||
} |
|||
|
|||
useEffect(() => { |
|||
if (visible) { |
|||
baseForm.setFieldsValue({...data}) |
|||
console.log(data) |
|||
} else { |
|||
baseForm.resetFields() |
|||
} |
|||
}, [visible]) |
|||
|
|||
return ( |
|||
<Modal |
|||
open={visible} |
|||
onCancel={onCancel} |
|||
footer={null} |
|||
width={600} |
|||
className="yisa-modal modal-conf" |
|||
title={isEdit ? '错峰修改' : '错峰新增'} |
|||
> |
|||
<div className="conf-form-container"> |
|||
<Form |
|||
form={baseForm} |
|||
> |
|||
|
|||
|
|||
<Row> |
|||
<Col span={11}> |
|||
<Form.Item label="车场名称" name="park_name" rules={rules}> |
|||
<Input></Input> |
|||
</Form.Item> |
|||
</Col> |
|||
<Col span={2}></Col> |
|||
<Col span={11}> |
|||
<Form.Item label="总车位数" name="total" rules={rules}> |
|||
<Input type='number'></Input> |
|||
</Form.Item> |
|||
</Col> |
|||
</Row> |
|||
<Row> |
|||
<Col span={11}> |
|||
<Form.Item label="可预约车位数" name="kyycws" rules={[{required: true, message: '此为必填字段'}, {validator: validateCws}]}> |
|||
<Input type='number'></Input> |
|||
</Form.Item> |
|||
</Col> |
|||
<Col span={2}></Col> |
|||
<Col span={11}> |
|||
<Form.Item label="时间规则" name="time_rules_id" rules={rules}> |
|||
<Select |
|||
options={timeRulesData} |
|||
/> |
|||
</Form.Item> |
|||
</Col> |
|||
</Row> |
|||
|
|||
|
|||
<Form.Item name="id" hidden></Form.Item> |
|||
</Form> |
|||
</div> |
|||
|
|||
<div className="conf-form-btn"> |
|||
{ |
|||
isDetail ? ( |
|||
<Button onClick={onCancel}>关闭</Button> |
|||
) : ( |
|||
<> |
|||
<Button type="" onClick={onCancel}>取消</Button> |
|||
{ |
|||
(data.id) ? ( |
|||
<Button type="primary" onClick={handleSave}>修改</Button> |
|||
) : ( |
|||
<Button type="primary" onClick={handleSave}>添加</Button> |
|||
) |
|||
} |
|||
</> |
|||
) |
|||
} |
|||
</div> |
|||
</Modal> |
|||
) |
|||
} |
|||
|
|||
export default InfoModal |
@ -0,0 +1,32 @@ |
|||
@import "@/assets/css/mixin.scss"; |
|||
|
|||
.modal-conf { |
|||
.conf-form-btn { |
|||
margin-top: 20px; |
|||
display: flex; |
|||
justify-content: center; |
|||
button { |
|||
margin: 0 10px; |
|||
&:first-child { |
|||
background: var(--button-default-bg); |
|||
} |
|||
} |
|||
} |
|||
.conf-detail-title { |
|||
font-size: 18px; |
|||
font-weight: 700; |
|||
} |
|||
.conf-detail-textarea { |
|||
min-height: 200px; |
|||
border: 1px solid #666d7d; |
|||
padding: 10px; |
|||
border-radius: 4px; |
|||
} |
|||
.conf-detail-info { |
|||
&.person-info-container { |
|||
max-height: 184px; |
|||
overflow: auto; |
|||
@include scrollBar(var(--color-user-list-bg), #3B97FF); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue