import React, { Fragment, useRef, useState } from 'react'; import { history, useAccess } from '@umijs/max'; 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 { addCmsLineSubWay, deleteCmsLineSubWay, getCmsLineList, putCmsLineSubWay, } from '@/services/area/subway'; import SubWayEdit from '@/pages/Area/Business/edit'; import { addCmsSaveRegionalData, deleteCmsRegionalData, getCmsRegionalList, updateRegionalData, } from '@/services/area/business'; const handleRemoveOne = async (selectedRow: API.AreaRegional.RegionalRows) => { const hide = message.loading('正在删除'); if (!selectedRow) return true; try { const resp = await deleteCmsRegionalData(selectedRow.regionalId); hide(); if (resp.code === 200) { message.success('删除成功,即将刷新'); } else { message.error(resp.msg); } return true; } catch (error) { hide(); message.error('删除失败,请重试'); return false; } }; function ManagementList() { const access = useAccess(); const formTableRef = useRef(); const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [modalVisible, setModalVisible] = useState(false); const columns: ProColumns[] = [ { title: '区域名称', dataIndex: 'regionalName', align: 'center', valueType: 'text', render: (dom, record) => ( ), }, { title: '操作', hideInSearch: true, align: 'center', width: 300, render: (_, record) => [ , , ], }, ]; return (
// params 是需要自带的参数 // 这个参数优先级更高,会覆盖查询表单的参数 actionRef={actionRef} formRef={formTableRef} columns={columns} headerTitle="信息" rowKey="regionalId" key="lineIdList" request={(params) => { return getCmsRegionalList(params as API.AreaRegional.RegionalParams).then((res) => { console.log(params); const result = { data: res.rows, total: res.total, success: true, }; return result; }); }} toolBarRender={() => [ , ]} />
{ let resData; if (values.regionalId) { resData = await updateRegionalData(values); } else { resData = await addCmsSaveRegionalData(values); } if (resData.code === 200) { setModalVisible(false); setCurrentRow(undefined); if (values.regionalId) { message.success('修改成功'); } else { message.success('新增成功'); } if (actionRef.current) { actionRef.current.reload(); } } }} onCancel={() => { setModalVisible(false); setCurrentRow(undefined); }} values={currentRow} >
); } export default ManagementList;