提交 794a651d 作者: 龚洪江

修复:飞手培训选点编辑

上级 f0dfbf16
import { Button, Form, Input, Radio, Select } from 'antd';
import { Button, Col, Form, Input, Radio, Row, Select } from 'antd';
import { Uploader } from '~/components/uploader';
import { EnvironmentOutlined, UploadOutlined } from '@ant-design/icons';
import './index.scss';
......@@ -19,6 +19,7 @@ type insertOrgParametersType = Omit<InterReqType<insertOrgType>, 'trainingProgra
const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
const [baseInfoForm] = Form.useForm<insertOrgParametersType>();
const [isEditAddress, setIsEditAddress] = useState<boolean>(false);
//地图地点选择
const [selectMapShow, setSelectMapShow] = useState<boolean>(false);
// 位置信息
......@@ -62,6 +63,7 @@ const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
setMainImgList,
setSubImgList,
setVideoList,
setIsEditAddress,
}),
getPosition: () => position,
}));
......@@ -101,21 +103,19 @@ const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
baseInfoForm.setFieldValue('video', undefined);
};
//地图选点
const showSelectMap = () => [setSelectMapShow(true)];
const showSelectMap = () => {
setSelectMapShow(true);
};
const selectMapSubmit = (value: {
lat: number;
lon: number;
address: string;
adCode: number;
}) => {
baseInfoForm.setFieldsValue({
region: [
value.adCode.toString().substring(0, 2) + '0000',
value.adCode.toString().substring(0, 4) + '00',
].join(','),
});
setPosition(value);
baseInfoForm.setFieldValue('region', value.address || undefined);
setSelectMapShow(false);
setIsEditAddress(true);
};
const selectMapClose = () => {
setSelectMapShow(false);
......@@ -126,6 +126,13 @@ const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
setScaleList(result || []);
});
};
//地址输入监听
const inputChangeEvent = (e: any) => {
if (position) {
position.address = e.target.value;
setPosition({ ...position });
}
};
useEffect(() => {
getLicenceScaleList();
......@@ -209,14 +216,26 @@ const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
name='region'
rules={[{ required: true, message: '请选择机构地区' }]}
>
<div className='region-info'>
{position?.address ? <div>{position?.address}</div> : ''}
<Row justify='space-between'>
{isEditAddress ? (
<Col span={22}>
<Input
placeholder='请输入机构地区'
value={position?.address || ''}
onChange={inputChangeEvent}
/>
</Col>
) : (
''
)}
<Col span={1}>
<Button
icon={<EnvironmentOutlined />}
type='primary'
onClick={showSelectMap}
></Button>
</div>
</Col>
</Row>
</Form.Item>
<Form.Item label='考点机构' name='testCenter'>
<Radio.Group>
......
......@@ -155,7 +155,6 @@ const SkuInfo: FC<selfProps> = forwardRef((_props, ref) => {
...col,
onCell: (record: any) => ({
record,
editable: col.editable,
dataIndex: col.dataIndex,
title: col.title,
editing: true,
......
......@@ -65,6 +65,10 @@ const AddOrEditInstitution = () => {
}, []);
PilotTrainAPI[institutionId ? 'updateOrg' : 'insertOrg']({
...value[0],
region: [
baseRef.current.getPosition().adCode.toString().substring(0, 2) + '0000',
baseRef.current.getPosition().adCode.toString().substring(0, 4) + '00',
].join(','),
trainingProgramsVOS: skuReqData,
detail: introduceInfo,
longitude: baseRef.current.getPosition().lon,
......@@ -109,7 +113,7 @@ const AddOrEditInstitution = () => {
auxiliaryPicture: institutionDetail.auxiliaryPicture || undefined,
video: institutionDetail.video,
name: institutionDetail.name,
region: institutionDetail.region,
region: institutionDetail.detailedAddress,
testCenter: institutionDetail.testCenter,
scaleId: institutionDetail.scaleId || undefined,
description: institutionDetail.description || undefined,
......@@ -120,6 +124,7 @@ const AddOrEditInstitution = () => {
address: institutionDetail.detailedAddress,
adCode: institutionDetail.region.split(',')[1],
});
baseRef.current.getDefaultDataEvent().setIsEditAddress(true);
baseRef.current.getDefaultDataEvent().setMainImgList([
{
id: Math.random(),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论