flat:商圈优化,导出文件优化
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
import React, {Fragment, useRef, useState} from "react";
|
||||
import { FormattedMessage, useAccess } from '@umijs/max';
|
||||
import { FormInstance, Button, message, Modal } from 'antd';
|
||||
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 { PlusOutlined, DeleteOutlined, FormOutlined, AlignLeftOutlined } from '@ant-design/icons';
|
||||
import { DeleteOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
getCmsAreaList,
|
||||
addCmsAreaListRow,
|
||||
updateCmsAreaListRow,
|
||||
deleteCmsAreaListRow,
|
||||
exportCmsAreaListRow
|
||||
} from "@/services/area/business";
|
||||
import BusinessEdit from "@/pages/Area/Business/edit";
|
||||
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.AreaBusiness.Circle) => {
|
||||
const handleRemoveOne = async (selectedRow: API.AreaRegional.RegionalRows) => {
|
||||
const hide = message.loading('正在删除');
|
||||
if (!selectedRow) return true;
|
||||
try {
|
||||
const resp = await deleteCmsAreaListRow(selectedRow.commercialAreaId);
|
||||
const resp = await deleteCmsRegionalData(selectedRow.regionalId);
|
||||
hide();
|
||||
if (resp.code === 200) {
|
||||
message.success('删除成功,即将刷新');
|
||||
@@ -32,60 +36,42 @@ const handleRemoveOne = async (selectedRow: API.AreaBusiness.Circle) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async (values: API.AreaBusiness.CircleEditParams) => {
|
||||
const hide = message.loading('正在导出');
|
||||
try {
|
||||
await exportCmsAreaListRow(values);
|
||||
hide();
|
||||
message.success('导出成功');
|
||||
return true;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('导出失败,请重试');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
function ManagementList() {
|
||||
const access = useAccess();
|
||||
|
||||
const formTableRef = useRef<FormInstance>();
|
||||
const actionRef = useRef<ActionType>();
|
||||
|
||||
const [currentRow, setCurrentRow] = useState<API.AreaBusiness.Circle>()
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false)
|
||||
const [currentRow, setCurrentRow] = useState<API.AreaSubWay.Line>();
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||
|
||||
const columns: ProColumns<API.AreaBusiness.Circle>[] = [
|
||||
const columns: ProColumns<API.AreaRegional.RegionalRows>[] = [
|
||||
{
|
||||
title: '商圈名称',
|
||||
dataIndex: 'commercialAreaName',
|
||||
valueType: 'text',
|
||||
title: '区域名称',
|
||||
dataIndex: 'regionalName',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
valueType: 'text',
|
||||
render: (dom, record) => (
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => history.push(`/area/updata-router/business/${record.regionalId}`)}
|
||||
block
|
||||
>
|
||||
{dom}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
width: 300,
|
||||
hideInSearch: true,
|
||||
render: (_, record) => [
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
key="detail"
|
||||
icon={<AlignLeftOutlined />}
|
||||
hidden={!access.hasPerms('area:business:List.detail')}
|
||||
onClick={() => {
|
||||
setModalVisible(true);
|
||||
setCurrentRow(record);
|
||||
}}
|
||||
>
|
||||
详细
|
||||
</Button>,
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
key="edit"
|
||||
icon = {<FormOutlined />}
|
||||
icon={<FormOutlined />}
|
||||
hidden={!access.hasPerms('area:business:List.update')}
|
||||
onClick={() => {
|
||||
setModalVisible(true);
|
||||
@@ -99,8 +85,8 @@ function ManagementList() {
|
||||
size="small"
|
||||
danger
|
||||
key="batchRemove"
|
||||
icon ={<DeleteOutlined/>}
|
||||
hidden={!access.hasPerms('area:business:List')}
|
||||
icon=<DeleteOutlined />
|
||||
hidden={!access.hasPerms('area:subway:List')}
|
||||
onClick={async () => {
|
||||
Modal.confirm({
|
||||
title: '删除',
|
||||
@@ -119,30 +105,33 @@ function ManagementList() {
|
||||
}}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
]
|
||||
}
|
||||
]
|
||||
</Button>,
|
||||
],
|
||||
},
|
||||
];
|
||||
return (
|
||||
<Fragment>
|
||||
<div style={{ width: '100%', float: 'right' }}>
|
||||
<ProTable<API.AreaBusiness.Circle>
|
||||
<ProTable<API.AreaSubWay.Line>
|
||||
// params 是需要自带的参数
|
||||
// 这个参数优先级更高,会覆盖查询表单的参数
|
||||
actionRef={actionRef}
|
||||
formRef={formTableRef}
|
||||
columns={columns}
|
||||
rowKey={"commercialAreaName"}
|
||||
key={"index"}
|
||||
request={(params) =>
|
||||
getCmsAreaList({ ...params } as API.AreaBusiness.CircleParams).then((res) => {
|
||||
return {
|
||||
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={() => [
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -155,50 +144,39 @@ function ManagementList() {
|
||||
>
|
||||
<PlusOutlined /> 新建
|
||||
</Button>,
|
||||
<Button
|
||||
type="primary"
|
||||
key="export"
|
||||
hidden={!access.hasPerms('system:user:export')}
|
||||
onClick={async () => {
|
||||
const searchVal = formTableRef.current && formTableRef.current.getFieldsValue();
|
||||
handleExport(searchVal);
|
||||
}}
|
||||
>
|
||||
<PlusOutlined />
|
||||
<FormattedMessage id="pages.searchTable.export" defaultMessage="导出" />
|
||||
</Button>,
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<BusinessEdit
|
||||
<SubWayEdit
|
||||
open={modalVisible}
|
||||
onSubmit={async (values) => {
|
||||
let resData
|
||||
if(values.commercialAreaId) {
|
||||
resData = await updateCmsAreaListRow(values)
|
||||
let resData;
|
||||
if (values.regionalId) {
|
||||
resData = await updateRegionalData(values);
|
||||
} else {
|
||||
resData = await addCmsAreaListRow(values)
|
||||
resData = await addCmsSaveRegionalData(values);
|
||||
}
|
||||
if (resData.code === 200) {
|
||||
setModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
if(values.commercialAreaId) {
|
||||
message.success('修改成功')
|
||||
if (values.regionalId) {
|
||||
message.success('修改成功');
|
||||
} else {
|
||||
message.success('新增成功')
|
||||
message.success('新增成功');
|
||||
}
|
||||
if (actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
}
|
||||
}}
|
||||
values={currentRow}
|
||||
onCancel={() => {
|
||||
setModalVisible(false);
|
||||
setCurrentRow(undefined)
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
></BusinessEdit>
|
||||
values={currentRow}
|
||||
></SubWayEdit>
|
||||
</Fragment>
|
||||
)
|
||||
);
|
||||
}
|
||||
export default ManagementList
|
||||
|
||||
export default ManagementList;
|
||||
|
||||
Reference in New Issue
Block a user