flat: 暂存
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
ModalForm,
|
||||
ProForm,
|
||||
ProFormDateRangePicker,
|
||||
ProFormSelect,
|
||||
ProFormDigit,
|
||||
ProFormText,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Button, Form, message } from 'antd';
|
||||
import { Form } from 'antd';
|
||||
import {DictOptionType, DictValueEnumObj} from "@/components/DictTag";
|
||||
|
||||
import {useEffect} from 'react'
|
||||
export type ListFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||
onSubmit: (values: API.AreaSubWay.Line) => Promise<void>;
|
||||
onCancel: (flag?: boolean, formVars?: unknown) => void;
|
||||
onSubmit: (values: API.AreaSubWay.LinePoint) => Promise<void>;
|
||||
open: boolean;
|
||||
values?: Partial<API.AreaSubWay.Line>;
|
||||
values?: Partial<API.AreaSubWay.LinePoint>;
|
||||
jobGroupOptions?: DictOptionType[];
|
||||
statusOptions?: DictValueEnumObj;
|
||||
};
|
||||
@@ -27,7 +25,19 @@ const waitTime = (time: number = 100) => {
|
||||
};
|
||||
|
||||
const SubWayEdit: React.FC<ListFormProps> = (props) => {
|
||||
const [form] = Form.useForm<{ name: string; company: string }>();
|
||||
const [form] = Form.useForm();
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if(props.values) {
|
||||
form.setFieldsValue({
|
||||
stationName: props.values.stationName,
|
||||
stationId: props.values.stationId,
|
||||
longitude: props.values.longitude,
|
||||
latitude: props.values.latitude,
|
||||
});
|
||||
}
|
||||
}, [form, props]);
|
||||
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
@@ -35,7 +45,7 @@ const SubWayEdit: React.FC<ListFormProps> = (props) => {
|
||||
};
|
||||
|
||||
const handleFinish = async (values: Record<string, any>) => {
|
||||
props.onSubmit(values as API.AreaSubWay.Line);
|
||||
props.onSubmit(values as API.AreaSubWay.LinePoint);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -43,7 +53,7 @@ const SubWayEdit: React.FC<ListFormProps> = (props) => {
|
||||
name: string;
|
||||
company: string;
|
||||
}>
|
||||
title="新增线路"
|
||||
title={`${props.values ? '编辑' : '新增'}站点`}
|
||||
form={form}
|
||||
// layout="inline"
|
||||
autoFocusFirstInput
|
||||
@@ -55,14 +65,53 @@ const SubWayEdit: React.FC<ListFormProps> = (props) => {
|
||||
submitTimeout={2000}
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
<ProFormDigit
|
||||
name="stationId"
|
||||
label={'字典主键'}
|
||||
placeholder="请输入字典主键"
|
||||
disabled
|
||||
hidden={true}
|
||||
/>
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
width="xl"
|
||||
name="lineName"
|
||||
label="线路名称:"
|
||||
width="md"
|
||||
name="stationName"
|
||||
label="站点名称:"
|
||||
placeholder="请输入名称"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProFormDigit
|
||||
label="纬度"
|
||||
placeholder="请输入纬度"
|
||||
name="latitude"
|
||||
width="md"
|
||||
min={-90}
|
||||
max={90}
|
||||
fieldProps={{ controls: false }}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: "请输入纬度!" ,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<ProFormDigit
|
||||
label="经度"
|
||||
placeholder="请输入经度"
|
||||
name="longitude"
|
||||
width="md"
|
||||
min={-180}
|
||||
max={180}
|
||||
fieldProps={{ controls: false }}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: "请输入经度!" ,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user