From 203b7d4ef76e710a87262a3546010162c34db905 Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Thu, 30 Oct 2025 10:54:08 +0800 Subject: [PATCH] =?UTF-8?q?flat:=E5=95=86=E5=9C=88=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E5=87=BA=E6=96=87=E4=BB=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Area/Business/UpLine/index.tsx | 63 ++++++++-- src/pages/Area/Business/index.tsx | 6 +- src/pages/Management/List/index.tsx | 150 ++++++++++++----------- src/services/area/business.ts | 12 +- 4 files changed, 140 insertions(+), 91 deletions(-) diff --git a/src/pages/Area/Business/UpLine/index.tsx b/src/pages/Area/Business/UpLine/index.tsx index 274efff..211ea64 100644 --- a/src/pages/Area/Business/UpLine/index.tsx +++ b/src/pages/Area/Business/UpLine/index.tsx @@ -4,7 +4,13 @@ import { Button, FormInstance, message, Modal } from 'antd'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { DeleteOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons'; import UpStationEdit from '@/pages/Area/Business/UpLine/edit'; -import { addCmsAreaListRow, deleteCmsAreaListRow, getCmsAreaList } from '@/services/area/business'; +import { + addCmsAreaListRow, + deleteCmsAreaListRow, + getCmsAreaList, + updateCmsAreaListRow, +} from '@/services/area/business'; +import { useLocation } from '@@/exports'; const handleRemoveOne = async (selectedRow: API.AreaSubWay.LinePoint) => { const hide = message.loading('正在删除'); @@ -30,16 +36,23 @@ function ManagementList() { const formTableRef = useRef(); const actionRef = useRef(); + const location = useLocation(); + const params = useParams(); + + const searchParams = new URLSearchParams(location.search); + const name = searchParams.get('name'); + const id = params.id || '0'; + const [regionalId, setRegionalId] = useState(); + const [regionalName, setRegionalName] = useState(); const [currentRow, setCurrentRow] = useState(); const [modalVisible, setModalVisible] = useState(false); const [page, setPage] = useState({}); - const params = useParams(); - const id = params.id || '0'; useEffect(() => { if (regionalId !== id) { setRegionalId(id); + setRegionalName(name); } }, [regionalId, params]); @@ -157,17 +170,43 @@ function ManagementList() { setCurrentRow(undefined); }} onSubmit={async (values) => { - // values.regionalId = - // values.lineName = - const resData = await addCmsAreaListRow(values); - if (resData.code === 200) { - setModalVisible(false); - setCurrentRow(undefined); - message.success('添加成功'); - if (actionRef.current) { - actionRef.current.reload(); + if (values.commercialAreaId) { + const resData = await updateCmsAreaListRow(values); + if (resData.code === 200) { + setModalVisible(false); + setCurrentRow(undefined); + message.success('添加成功'); + if (actionRef.current) { + actionRef.current.reload(); + } + } + } else { + let params = { + regionalName, + regionalId, + ...values, + }; + const resData = await addCmsAreaListRow(params); + if (resData.code === 200) { + setModalVisible(false); + setCurrentRow(undefined); + message.success('添加成功'); + if (actionRef.current) { + actionRef.current.reload(); + } } } + // values.regionalId = + // values.lineName = + // const resData = await addCmsAreaListRow(values); + // if (resData.code === 200) { + // setModalVisible(false); + // setCurrentRow(undefined); + // message.success('添加成功'); + // if (actionRef.current) { + // actionRef.current.reload(); + // } + // } }} values={currentRow} > diff --git a/src/pages/Area/Business/index.tsx b/src/pages/Area/Business/index.tsx index fec8f91..f3f40e2 100644 --- a/src/pages/Area/Business/index.tsx +++ b/src/pages/Area/Business/index.tsx @@ -54,7 +54,11 @@ function ManagementList() { render: (dom, record) => ( - + + , -
- - + -
+ }, + }); + }} + > + 删除 + + , ], }, ]; diff --git a/src/services/area/business.ts b/src/services/area/business.ts index 8aa445d..9282b8a 100644 --- a/src/services/area/business.ts +++ b/src/services/area/business.ts @@ -1,22 +1,22 @@ import { request } from '@umijs/max'; import { getDateTimeForFilename } from '@/utils/tools'; -export async function getCmsAreaList(params?: API.BusinessParams.BusinessParams) { +export async function getCmsAreaList(params?: API.AreaRegional.BusinessParams) { return request(`/api/cms/area/list`, { method: 'GET', params: params, }); } -export async function addCmsAreaListRow(params?: API.BusinessParams.BusinessParams) { - return request(`/api/cms/area`, { +export async function addCmsAreaListRow(params?: API.AreaRegional.BusinessParams) { + return request(`/api/cms/area`, { method: 'post', data: params, }); } -export async function updateCmsAreaListRow(params?: API.BusinessParams.BusinessParams) { - return request(`/api/cms/area`, { +export async function updateCmsAreaListRow(params?: API.AreaRegional.BusinessParams) { + return request(`/api/cms/area`, { method: 'put', data: params, }); @@ -28,7 +28,7 @@ export async function deleteCmsAreaListRow(ids: number) { }); } -export async function exportCmsAreaListRow(params?: API.BusinessParams.BusinessParams) { +export async function exportCmsAreaListRow(params?: API.AreaRegional.BusinessParams) { return downLoadXlsx(`/api/cms/area/export`, { params }, `区域_${getDateTimeForFilename()}.xlsx`); }