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