flat:商圈优化,导出文件优化

This commit is contained in:
Apcallover
2025-10-29 17:34:55 +08:00
parent d2cfb609d7
commit de7cf14248
19 changed files with 943 additions and 628 deletions

View File

@@ -0,0 +1,172 @@
import { ModalForm, ProForm, ProFormDigit, ProFormText } from '@ant-design/pro-components';
import { Button, Form } from 'antd';
import { DictOptionType, DictValueEnumObj } from '@/components/DictTag';
import { useEffect, useState } from 'react';
import ProFromMap from '@/components/ProFromMap';
export type ListFormProps = {
onCancel: (flag?: boolean, formVars?: unknown) => void;
onSubmit: (values: API.AreaSubWay.LinePoint) => Promise<void>;
open: boolean;
values?: Partial<API.AreaSubWay.LinePoint>;
jobGroupOptions?: DictOptionType[];
statusOptions?: DictValueEnumObj;
};
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const SubWayEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm();
const [open, setOpen] = useState<boolean>(false);
const [viewInfo, setViewInfo] = useState<any>({});
useEffect(() => {
form.resetFields();
if (props.values) {
form.setFieldsValue(props.values);
setViewInfo(props.values);
}
}, [form, props]);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
props.onSubmit(values as API.AreaSubWay.LinePoint);
};
const select = (result) => {
if (result.location) {
const { lat, lng } = result.location;
form.setFieldValue('latitude', lat);
form.setFieldValue('longitude', lng);
form.setFieldValue('address', result.address);
const obj = {
latitude: lat,
longitude: lng,
address: result.address,
};
setViewInfo(obj);
setOpen(false);
}
};
const cancel = () => {
setOpen(false);
};
return (
<ModalForm<{
name: string;
company: string;
stationOrder: number;
}>
title={`${props.values ? '编辑' : '新增'}站点`}
form={form}
// layout="inline"
autoFocusFirstInput
open={props.open}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
}}
initialValues={{
sort: 0,
}}
submitTimeout={2000}
onFinish={handleFinish}
>
<ProFormDigit
name="commercialAreaId"
label={'字典主键'}
placeholder="请输入字典主键"
disabled
hidden={true}
/>
<ProForm.Group>
<ProFormText
width="md"
name="commercialAreaName"
label="商业区名称"
placeholder="请输入名称"
rules={[
{
required: true,
message: '请输入名称!',
},
]}
/>
</ProForm.Group>
<ProForm.Group>
<div>
<Button onClick={() => setOpen(true)}></Button>
<div style={{ margin: '10px 0 0 0' }}>
{viewInfo.address ? (
<span style={{ padding: '0 0 0 16px' }}>{viewInfo.address}</span>
) : null}
{viewInfo.latitude ? (
<span style={{ padding: '0 0 0 16px' }}>
{viewInfo.latitude},{viewInfo.longitude}
</span>
) : (
<span style={{ padding: '0 0 0 16px', color: 'red' }}>!</span>
)}
</div>
</div>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="address"
label="地理位置"
hidden={true}
placeholder="请输入地理位置"
/>
<ProFormDigit
label="纬度"
placeholder="请输入纬度"
name="latitude"
width="md"
hidden={true}
min={-90}
max={90}
fieldProps={{ controls: false }}
rules={[
{
required: true,
message: '请输入纬度!',
},
]}
/>
<ProFormDigit
label="经度"
placeholder="请输入经度"
name="longitude"
width="md"
min={-180}
hidden={true}
max={180}
fieldProps={{ controls: false }}
rules={[
{
required: true,
message: '请输入经度!',
},
]}
/>
</ProForm.Group>
<ProFromMap open={open} onSelect={select} onCancel={cancel}></ProFromMap>
</ModalForm>
);
};
export default SubWayEdit;

View File

@@ -0,0 +1,178 @@
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react';
import { useAccess, useParams } 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 UpStationEdit from '@/pages/Area/Business/UpLine/edit';
import { addCmsAreaListRow, deleteCmsAreaListRow, getCmsAreaList } from '@/services/area/business';
const handleRemoveOne = async (selectedRow: API.AreaSubWay.LinePoint) => {
const hide = message.loading('正在删除');
if (!selectedRow) return true;
try {
const resp = await deleteCmsAreaListRow(selectedRow.commercialAreaId);
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<FormInstance>();
const actionRef = useRef<ActionType>();
const [regionalId, setRegionalId] = useState<string>();
const [currentRow, setCurrentRow] = useState<API.AreaPlatForm.LinePoint>();
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [page, setPage] = useState<API.AreaPlatForm.LineParams>({});
const params = useParams();
const id = params.id || '0';
useEffect(() => {
if (regionalId !== id) {
setRegionalId(id);
}
}, [regionalId, params]);
const getStationInfo = useCallback(async () => {
// const resData = await getCmsLineSubWay()
}, []);
const columns: ProColumns<API.AreaSubWay.LinePoint>[] = [
{
title: '商业区名称',
dataIndex: 'commercialAreaName',
align: 'center',
valueType: 'text',
},
{
title: '商业区地址',
dataIndex: 'address',
hideInSearch: true,
align: 'center',
valueType: 'text',
},
{
title: '操作',
hideInSearch: true,
align: 'center',
width: 300,
render: (_, record) => [
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined />}
hidden={!access.hasPerms('area:business:List.update')}
onClick={() => {
setModalVisible(true);
setCurrentRow(record);
}}
>
</Button>,
<Button
type="link"
size="small"
danger
key="batchRemove"
icon={<DeleteOutlined />}
hidden={!access.hasPerms('area:subway:List')}
onClick={async () => {
Modal.confirm({
title: '删除',
content: '确定删除该项吗?',
okText: '确认',
cancelText: '取消',
onOk: async () => {
const success = await handleRemoveOne(record);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
},
});
}}
>
</Button>,
],
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
<ProTable<API.AreaPlatForm.Line>
// params 是需要自带的参数
// 这个参数优先级更高,会覆盖查询表单的参数
actionRef={actionRef}
formRef={formTableRef}
columns={columns}
headerTitle="信息"
rowKey="stationId"
key="stationId"
request={(params) => {
return getCmsAreaList({
regionalId,
...params,
} as API.AreaPlatForm.LineParams).then((res) => {
setPage(params as API.AreaPlatForm.LineParams);
const result = {
data: res.rows,
total: res.total,
success: true,
};
return result;
});
}}
toolBarRender={() => [
<Button
type="primary"
key="add"
hidden={!access.hasPerms('manage:List:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
}}
>
<PlusOutlined />
</Button>,
]}
/>
</div>
<UpStationEdit
open={modalVisible}
onCancel={() => {
setModalVisible(false);
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();
}
}
}}
values={currentRow}
></UpStationEdit>
</Fragment>
);
}
export default ManagementList;

View File

@@ -1,14 +1,13 @@
import { ModalForm, ProForm, ProFormDigit, ProFormText } from '@ant-design/pro-components';
import React, { useEffect, useState } from 'react';
import { Button, Form } from 'antd';
import { Form } from 'antd';
import { DictOptionType, DictValueEnumObj } from '@/components/DictTag';
import ProFromMap from '@/components/ProFromMap';
import { useEffect } from 'react';
export type ListFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.AreaBusiness.CircleEditParams) => Promise<void>;
onSubmit: (values: API.AreaSubWay.Line) => Promise<void>;
open: boolean;
values?: Partial<API.AreaBusiness.CircleEditParams>;
values?: Partial<API.AreaSubWay.Line>;
jobGroupOptions?: DictOptionType[];
statusOptions?: DictValueEnumObj;
};
@@ -24,57 +23,31 @@ const waitTime = (time: number = 100) => {
const SubWayEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm();
const [open, setOpen] = useState<boolean>(false);
const [viewInfo, setViewInfo] = useState<any>({});
useEffect(() => {
form.resetFields();
if (props.values) {
const obj = {
commercialAreaId: props.values.commercialAreaId,
commercialAreaName: props.values.commercialAreaName,
latitude: props.values.latitude,
longitude: props.values.longitude,
address: props.values.address,
};
form.setFieldsValue(obj);
setViewInfo(obj);
} else {
setViewInfo({});
form.setFieldsValue({
regionalId: props.values.regionalId,
regionalName: props.values.regionalName,
});
}
}, [form, props]);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
props.onSubmit(values as API.AreaBusiness.CircleEditParams);
};
const select = (result) => {
if (result.location) {
const { lat, lng } = result.location;
form.setFieldValue('latitude', lat);
form.setFieldValue('longitude', lng);
form.setFieldValue('address', result.address);
const obj = {
latitude: lat,
longitude: lng,
address: result.address,
};
setViewInfo(obj);
setOpen(false);
}
};
const cancel = () => {
setOpen(false);
props.onSubmit(values as API.AreaSubWay.Line);
};
return (
<ModalForm<API.AreaBusiness.CircleParams>
title={`${props.values ? '编辑' : '新增'}商圈`}
<ModalForm<{
name: string;
company: string;
}>
title={`${props.values ? '编辑' : '新增'}线路`}
form={form}
// layout="inline"
autoFocusFirstInput
@@ -87,85 +60,15 @@ const SubWayEdit: React.FC<ListFormProps> = (props) => {
onFinish={handleFinish}
>
<ProFormDigit
name="commercialAreaId"
name="regionalId"
label={'字典主键'}
placeholder="请输入字典主键"
disabled
hidden={true}
/>
<ProForm.Group>
<ProFormText
width="md"
name="commercialAreaName"
label="商圈名称"
placeholder="请输入名称"
rules={[
{
required: true,
message: '请输入商圈名称!',
},
]}
/>
<ProFormText width="xl" name="regionalName" label="区域名称:" placeholder="请输入名称" />
</ProForm.Group>
<ProForm.Group>
<div>
<Button onClick={() => setOpen(true)}></Button>
<div style={{ margin: '10px 0 0 0' }}>
{viewInfo.address ? (
<span style={{ padding: '0 0 0 16px' }}>{viewInfo.address}</span>
) : null}
{viewInfo.latitude ? (
<span style={{ padding: '0 0 0 16px' }}>
{viewInfo.latitude},{viewInfo.longitude}
</span>
) : (
<span style={{ padding: '0 0 0 16px', color: 'red' }}>!</span>
)}
</div>
</div>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="address"
label="地理位置"
hidden={true}
placeholder="请输入地理位置"
/>
<ProFormDigit
label="纬度"
placeholder="请输入纬度"
name="latitude"
width="md"
min={-90}
max={90}
hidden={true}
fieldProps={{ controls: false }}
rules={[
{
required: true,
message: '请输入纬度!',
},
]}
/>
<ProFormDigit
label="经度"
placeholder="请输入经度"
name="longitude"
width="md"
min={-180}
hidden={true}
max={180}
fieldProps={{ controls: false }}
rules={[
{
required: true,
message: '请输入经度!',
},
]}
/>
</ProForm.Group>
<ProFromMap open={open} onSelect={select} onCancel={cancel}></ProFromMap>
</ModalForm>
);
};

View File

@@ -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;

View File

@@ -1,20 +1,19 @@
import React, {Fragment, useRef, useState, useEffect} from "react";
import { useIntl, FormattedMessage, useAccess, history } from '@umijs/max';
import {delCmsJobIds, getCmsJobList} from "@/services/Management/list";
import { Dropdown, FormInstance, Space, Button, message, Modal } from 'antd';
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { PlusOutlined, DeleteOutlined, FormOutlined, DownOutlined, EditOutlined } from '@ant-design/icons';
import EditCompanyListRow from './edit'
import React, { Fragment, useEffect, useRef, useState } from 'react';
import { FormattedMessage, 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 EditCompanyListRow from './edit';
import {
addCmsFairList,
delCmsFairList,
exportCmsFairList,
getCmsFairId,
getCmsFairList,
putCmsFairList,
getCmsFairId, getCmstitilelist
} from "@/services/jobfair/list";
import {getDictValueEnum} from "@/services/system/dict";
import DictTag from "@/components/DictTag";
} from '@/services/jobfair/list';
import { getDictValueEnum } from '@/services/system/dict';
import DictTag from '@/components/DictTag';
const handleRemoveOne = async (jobFairId: string) => {
const hide = message.loading('正在删除');
@@ -55,20 +54,17 @@ function ManagementList() {
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<API.JobFairList.JobFairListRows>()
const [modalVisible, setModalVisible] = useState<boolean>(false)
const [jobFairType, setJobFairTypeEnum] = useState<any>([])
const [currentRow, setCurrentRow] = useState<API.JobFairList.JobFairListRows>();
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [jobFairType, setJobFairTypeEnum] = useState<any>([]);
useEffect(() => {
getDictValueEnum('job_fair_type', true).then((data) => {
setJobFairTypeEnum(data)
setJobFairTypeEnum(data);
});
}, []);
const editSubmit = () => {
}
const editSubmit = () => {};
const columns: ProColumns<API.JobFairList.JobFairListRows>[] = [
{
@@ -84,7 +80,7 @@ function ManagementList() {
align: 'center',
valueEnum: jobFairType,
render: (_, record) => {
return (<DictTag enums={jobFairType} value={record.jobFairType} />);
return <DictTag enums={jobFairType} value={record.jobFairType} />;
},
},
{
@@ -105,10 +101,10 @@ function ManagementList() {
type="link"
size="small"
key="edit"
icon={<FormOutlined/>}
icon={<FormOutlined />}
hidden={!access.hasPerms('area:business:List.update')}
onClick={async () => {
let resData = await getCmsFairId(jobFairId as string)
let resData = await getCmsFairId(jobFairId as string);
setModalVisible(true);
setCurrentRow(resData.data);
}}
@@ -120,7 +116,7 @@ function ManagementList() {
size="small"
danger
key="batchRemove"
icon ={<DeleteOutlined/>}
icon={<DeleteOutlined />}
hidden={!access.hasPerms('area:subway:List')}
onClick={async () => {
Modal.confirm({
@@ -140,10 +136,10 @@ function ManagementList() {
}}
>
</Button>
]
}
]
</Button>,
],
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
@@ -166,17 +162,17 @@ function ManagementList() {
})
}
toolBarRender={() => [
<Button
type="primary"
key="add"
hidden={!access.hasPerms('manage:List:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
}}
>
<PlusOutlined />
</Button>,
// <Button
// type="primary"
// key="add"
// hidden={!access.hasPerms('manage:List:add')}
// onClick={async () => {
// setCurrentRow(undefined);
// setModalVisible(true);
// }}
// >
// <PlusOutlined /> 新建
// </Button>,
<Button
type="primary"
key="export"
@@ -197,17 +193,17 @@ function ManagementList() {
onSubmit={async (values) => {
let resData;
if (values.jobFairId) {
resData = await putCmsFairList(values)
resData = await putCmsFairList(values);
} else {
resData = await addCmsFairList(values)
resData = await addCmsFairList(values);
}
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
if(values.jobFairId) {
message.success('修改成功')
if (values.jobFairId) {
message.success('修改成功');
} else {
message.success('新增成功')
message.success('新增成功');
}
if (actionRef.current) {
actionRef.current.reload();
@@ -222,6 +218,7 @@ function ManagementList() {
values={currentRow}
></EditCompanyListRow>
</Fragment>
)
);
}
export default ManagementList
export default ManagementList;

View File

@@ -1,20 +1,20 @@
import React, { useState, useRef, useEffect, useMemo } from 'react';
import React, { useEffect, useMemo, useRef, useState } from 'react';
import {
addMobilelog,
exportMobilelog,
getMobileLogList,
removeMobilelog,
updateMobilelog
} from "@/services/logs/mobilelog";
updateMobilelog,
} from '@/services/logs/mobilelog';
import type { FormInstance } from 'antd';
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { Button, message, Modal } from 'antd';
import DictTag from "@/components/DictTag";
import {getDictValueEnum} from "@/services/system/dict";
import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { FormattedMessage, useAccess } from '@umijs/max';
import { DeleteOutlined, ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons';
import DictTag from '@/components/DictTag';
import { getDictValueEnum } from '@/services/system/dict';
import UpdateForm from './detail';
import {addOperlog, exportOperlog, removeOperlog, updateOperlog} from "@/services/logs/operlog";
/**
* 添加节点
*
@@ -102,14 +102,13 @@ const handleExport = async () => {
}
};
const MobileLog: React.FC = () => {
const MobileLog: React.FC = () => {
// ref
const formTableRef = useRef<FormInstance>();
const access = useAccess();
const actionRef = useRef<ActionType>();
// status
const [params, useParams] = useState({})
const [params, useParams] = useState({});
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [currentRow, setCurrentRow] = useState<API.Logs.Mobilelog>();
const [selectedRows, setSelectedRows] = useState<API.Logs.Mobilelog[]>([]);
@@ -131,200 +130,203 @@ const MobileLog: React.FC = () => {
});
}, []);
const columns: ProColumns<API.Logs.Mobilelog>[] = useMemo(
() => [
{
title: '日志主键',
dataIndex: 'operId',
valueType: 'text',
hideInSearch: true,
},
{
title: '操作模块',
dataIndex: 'title',
valueType: 'text',
},
{
title: '业务类型',
dataIndex: 'businessType',
valueType: 'select',
valueEnum: businessTypeOptions,
render: (_, record) => {
return <DictTag enums={businessTypeOptions} value={record.businessType} />;
},
},
{
title: '请求方式',
dataIndex: 'requestMethod',
valueType: 'text',
},
// {
// title: "操作类别",
// dataIndex: 'operatorType',
// valueType: 'select',
// valueEnum: operatorTypeOptions,
// render: (_, record) => {
// return (<DictTag enums={operatorTypeOptions} value={record.operatorType} />);
// },
// },
{
title: '操作人员',
dataIndex: 'operName',
valueType: 'text',
},
{
title: '主机地址',
dataIndex: 'operIp',
valueType: 'text',
},
{
title: '操作地点',
dataIndex: 'operLocation',
valueType: 'text',
},
{
title: '操作状态',
dataIndex: 'status',
valueType: 'select',
valueEnum: statusOptions,
render: (_, record) => {
return <DictTag key="status" enums={statusOptions} value={record.status} />;
},
},
{
title: '操作时间',
dataIndex: 'operTime',
valueType: 'dateTime',
},
{
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
dataIndex: 'option',
width: '120px',
valueType: 'option',
render: (_, record) => [
<Button
type="link"
size="small"
key="edit"
hidden={!access.hasPerms('logs:mobilelog:edit.tsx')}
onClick={() => {
setModalVisible(true);
setCurrentRow(record);
}}
>
</Button>,
],
},
],
[businessTypeOptions, operatorTypeOptions, statusOptions],
);
const columns: ProColumns<API.Logs.Mobilelog>[] = useMemo(() => [
{
title: '日志主键',
dataIndex: 'operId',
valueType: 'text',
hideInSearch: true,
},
{
title: "操作模块",
dataIndex: 'title',
valueType: 'text',
},
{
title: "业务类型",
dataIndex: 'businessType',
valueType: 'select',
valueEnum: businessTypeOptions,
render: (_, record) => {
return (<DictTag enums={businessTypeOptions} value={record.businessType} />);
},
},
{
title: "请求方式",
dataIndex: 'requestMethod',
valueType: 'text',
},
{
title: "操作类别",
dataIndex: 'operatorType',
valueType: 'select',
valueEnum: operatorTypeOptions,
render: (_, record) => {
return (<DictTag enums={operatorTypeOptions} value={record.operatorType} />);
},
},
{
title: "操作人员",
dataIndex: 'operName',
valueType: 'text',
},
{
title: "主机地址",
dataIndex: 'operIp',
valueType: 'text',
},
{
title: "操作地点",
dataIndex: 'operLocation',
valueType: 'text',
},
{
title: "操作状态",
dataIndex: 'status',
valueType: 'select',
valueEnum: statusOptions,
render: (_, record) => {
return (<DictTag key="status" enums={statusOptions} value={record.status} />);
},
},
{
title: "操作时间",
dataIndex: 'operTime',
valueType: 'dateTime',
},
{
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
dataIndex: 'option',
width: '120px',
valueType: 'option',
render: (_, record) => [
<Button
type="link"
size="small"
key="edit"
hidden={!access.hasPerms('logs:mobilelog:edit.tsx')}
onClick={() => {
setModalVisible(true);
setCurrentRow(record);
return (
<>
<PageContainer>
<div style={{ width: '100%', float: 'right' }}>
<ProTable
// params 是需要自带的参数
// 这个参数优先级更高,会覆盖查询表单的参数
actionRef={actionRef}
formRef={formTableRef}
rowKey="operId"
columns={columns}
search={{
labelWidth: 120,
}}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
request={(params) =>
getMobileLogList({ ...params } as API.Logs.MobilelogListParams).then((res) => {
const result = {
data: res.rows,
total: res.total,
success: true,
};
return result;
})
}
toolBarRender={() => [
// <Button
// type="primary"
// key="add"
// hidden={!access.hasPerms('logs:mobilelog:add')}
// onClick={async () => {
// setCurrentRow(undefined);
// setModalVisible(true);
// }}
// >
// <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
// </Button>,
<Button
type="primary"
key="remove"
danger
hidden={selectedRows?.length === 0 || !access.hasPerms('logs:mobilelog:remove')}
onClick={async () => {
Modal.confirm({
title: '是否确认删除所选数据项?',
icon: <ExclamationCircleOutlined />,
content: '请谨慎操作',
async onOk() {
const success = await handleRemove(selectedRows);
if (success) {
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}
},
onCancel() {},
});
}}
>
<DeleteOutlined />
<FormattedMessage id="pages.searchTable.delete" defaultMessage="删除" />
</Button>,
<Button
type="primary"
key="export"
hidden={!access.hasPerms('logs:mobilelog:export')}
onClick={async () => {
handleExport();
}}
>
<PlusOutlined />
<FormattedMessage id="pages.searchTable.export" defaultMessage="导出" />
</Button>,
]}
/>
</div>
<UpdateForm
onSubmit={async (values) => {
let success = false;
if (values.operId) {
success = await handleUpdate({ ...values } as API.Logs.Mobilelog);
} else {
success = await handleAdd({ ...values } as API.Logs.Mobilelog);
}
if (success) {
setModalVisible(false);
setCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
>
</Button>,
],
},
], [businessTypeOptions, operatorTypeOptions, statusOptions])
return <>
<PageContainer>
<div style={{ width: '100%', float: 'right' }}>
<ProTable
// params 是需要自带的参数
// 这个参数优先级更高,会覆盖查询表单的参数
actionRef={actionRef}
formRef={formTableRef}
rowKey="operId"
columns={columns}
search={{
labelWidth: 120,
}}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
request={(params) =>
getMobileLogList({ ...params } as API.Logs.MobilelogListParams).then((res) => {
const result = {
data: res.rows,
total: res.total,
success: true,
};
return result;
})
}
toolBarRender={() => [
// <Button
// type="primary"
// key="add"
// hidden={!access.hasPerms('logs:mobilelog:add')}
// onClick={async () => {
// setCurrentRow(undefined);
// setModalVisible(true);
// }}
// >
// <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="新建" />
// </Button>,
<Button
type="primary"
key="remove"
danger
hidden={selectedRows?.length === 0 || !access.hasPerms('logs:mobilelog:remove')}
onClick={async () => {
Modal.confirm({
title: '是否确认删除所选数据项?',
icon: <ExclamationCircleOutlined />,
content: '请谨慎操作',
async onOk() {
const success = await handleRemove(selectedRows);
if (success) {
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}
},
onCancel() { },
});
}}
>
<DeleteOutlined />
<FormattedMessage id="pages.searchTable.delete" defaultMessage="删除" />
</Button>,
<Button
type="primary"
key="export"
hidden={!access.hasPerms('logs:mobilelog:export')}
onClick={async () => {
handleExport();
}}
>
<PlusOutlined />
<FormattedMessage id="pages.searchTable.export" defaultMessage="导出" />
</Button>,
]}
/>
</div>
<UpdateForm
onSubmit={async (values) => {
let success = false;
if (values.operId) {
success = await handleUpdate({ ...values } as API.Logs.Mobilelog);
} else {
success = await handleAdd({ ...values } as API.Logs.Mobilelog);
}
if (success) {
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
}}
open={modalVisible}
values={currentRow || {}}
businessTypeOptions={businessTypeOptions}
operatorTypeOptions={operatorTypeOptions}
statusOptions={statusOptions}
/>
</PageContainer>
</>
}}
open={modalVisible}
values={currentRow || {}}
businessTypeOptions={businessTypeOptions}
operatorTypeOptions={operatorTypeOptions}
statusOptions={statusOptions}
/>
</PageContainer>
</>
);
};
export default MobileLog
export default MobileLog;

View File

@@ -222,13 +222,13 @@ const Login: React.FC = () => {
defaultMessage: '账户密码登录',
}),
},
{
key: 'mobile',
label: intl.formatMessage({
id: 'pages.login.phoneLogin.tab',
defaultMessage: '手机号登录',
}),
},
// {
// key: 'mobile',
// label: intl.formatMessage({
// id: 'pages.login.phoneLogin.tab',
// defaultMessage: '手机号登录',
// }),
// },
]}
/>