feat : 新增岗位数据入库监测、岗位信息来源管理、岗位信息指标管理 三个列表页面

This commit is contained in:
bin
2025-11-06 16:07:12 +08:00
parent 7cdaedcaa7
commit 89f97b0a4b
12 changed files with 1331 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
import {
ModalForm,
ProForm,
ProFormDatePicker,
ProFormDigit,
ProFormText,
ProFormTextArea,
ProDescriptions,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
export type StorageFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.StorageDetection.StorageItem) => Promise<void>;
open: boolean;
values?: Partial<API.StorageDetection.StorageItem>;
mode?: 'view' | 'edit' | 'create';
};
const StorageEdit: React.FC<StorageFormProps> = (props) => {
const [form] = Form.useForm<API.StorageDetection.StorageItem>();
const { mode = props.values ? 'edit' : 'create' } = props;
useEffect(() => {
if (props.open) {
form.resetFields();
if (props.values) {
form.setFieldsValue(props.values);
}
}
}, [form, props.values?.detectionId, props.open]);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
props.onSubmit(values as API.StorageDetection.StorageItem);
};
if (mode === 'view') {
return (
<ModalForm
title="入库监测详情"
open={props.open}
width={800}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
footer: null,
}}
submitter={false}
>
<ProDescriptions<API.StorageDetection.StorageItem>
column={2}
dataSource={props.values || {}}
>
<ProDescriptions.Item dataIndex="detectionId" label="监测ID" />
<ProDescriptions.Item dataIndex="storageDate" label="采集入库日期" />
<ProDescriptions.Item dataIndex="storageNumber" label="采集入库数量" />
<ProDescriptions.Item dataIndex="storageResult" label="采集入库结果" />
<ProDescriptions.Item dataIndex="storageDetail" label="入库数据详情" span={2} />
</ProDescriptions>
</ModalForm>
);
}
return (
<ModalForm<API.StorageDetection.StorageItem>
title={mode === 'edit' ? '编辑入库监测' : '新建入库监测'}
form={form}
autoFocusFirstInput
open={props.open}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
}}
submitTimeout={2000}
onFinish={handleFinish}
>
<ProForm.Group>
<ProFormText width="md" hidden name="detectionId" />
<ProFormDatePicker
width="md"
name="storageDate"
label="采集入库日期"
placeholder="请选择采集入库日期"
rules={[{ required: true, message: '请选择采集入库日期!' }]}
fieldProps={{
format: 'YYYY-MM-DD',
}}
/>
<ProFormDigit
name="storageNumber"
width="md"
min={0}
label="采集入库数量"
placeholder="请输入采集入库数量"
rules={[{ required: true, message: '请输入采集入库数量!' }]}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="storageResult"
label="采集入库结果"
placeholder="请输入采集入库结果"
rules={[{ required: true, message: '请输入采集入库结果!' }]}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
width="lg"
name="storageDetail"
label="入库数据详情"
placeholder="请输入入库数据详情"
rules={[{ required: true, message: '请输入入库数据详情!' }]}
/>
</ProForm.Group>
</ModalForm>
);
};
export default StorageEdit;

View File

@@ -0,0 +1,190 @@
import React, { Fragment, useRef, useState } from 'react';
import { useAccess } from '@umijs/max';
import {
getStorageDetectionList,
getStorageDetectionSingle,
saveStorageDetection,
} from '@/services/recruitmentDataCollection/jobMonitor';
import { Button, FormInstance, message } from 'antd';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { FormOutlined, EyeOutlined } from '@ant-design/icons';
import EditStorageRow from './edit';
function StorageDetectionList() {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<API.StorageDetection.StorageItem>();
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [mode, setMode] = useState<'view' | 'edit'>('view');
const [loading, setLoading] = useState<boolean>(false);
// 查看详情
const handleViewDetail = async (detectionId: any) => {
setLoading(true);
try {
const res = await getStorageDetectionSingle(detectionId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('view');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取详情失败');
} finally {
setLoading(false);
}
};
// 编辑
const handleEdit = async (detectionId: any) => {
setLoading(true);
try {
const res = await getStorageDetectionSingle(detectionId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('edit');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取编辑数据失败');
} finally {
setLoading(false);
}
};
const columns: ProColumns<API.StorageDetection.StorageItem>[] = [
{
title: '监测ID',
dataIndex: 'detectionId',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '采集入库日期',
dataIndex: 'storageDate',
valueType: 'date',
align: 'center',
},
{
title: '采集入库数量',
dataIndex: 'storageNumber',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '采集入库结果',
dataIndex: 'storageResult',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '入库数据详情',
dataIndex: 'storageDetail',
valueType: 'text',
align: 'center',
hideInSearch: true,
ellipsis: true,
},
{
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'detectionId',
width: 200,
render: (detectionId, record) => (
<div style={{ display: 'flex', justifyContent: 'center', gap: 8 }}>
<Button
type="link"
size="small"
key="view"
icon={<EyeOutlined />}
loading={loading}
hidden={!access.hasPerms('storage:detection:view')}
onClick={() => handleViewDetail(detectionId)}
>
</Button>
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined />}
loading={loading}
hidden={!access.hasPerms('storage:detection:update')}
onClick={() => handleEdit(detectionId)}
>
</Button>
</div>
),
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
<ProTable<API.StorageDetection.StorageItem>
actionRef={actionRef}
formRef={formTableRef}
rowKey="detectionId"
key="storageDetectionIndex"
columns={columns}
search={{ labelWidth: 'auto' }}
request={async (
params: API.StorageDetection.ListParams & {
pageSize?: number;
current?: number;
},
) => {
const res = await getStorageDetectionList({
...params,
} as API.StorageDetection.ListParams);
return {
data: res.rows,
total: res.total,
success: true,
};
}}
/>
</div>
<EditStorageRow
open={modalVisible}
mode={mode}
onSubmit={async (values: API.StorageDetection.StorageItem) => {
try {
const resData = await saveStorageDetection(values);
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
message.success('保存成功');
if (actionRef.current) {
actionRef.current.reload();
}
} else {
message.error(resData.msg || '保存失败');
}
} catch (error) {
message.error('保存失败');
}
}}
values={currentRow}
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
}}
/>
</Fragment>
);
}
export default StorageDetectionList;

View File

@@ -0,0 +1,122 @@
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
ProDescriptions,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
export type JobIndexFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.JobIndex.JobIndexItem) => Promise<void>;
open: boolean;
values?: Partial<API.JobIndex.JobIndexItem>;
mode?: 'view' | 'edit' | 'create';
};
const JobIndexEdit: React.FC<JobIndexFormProps> = (props) => {
const [form] = Form.useForm<API.JobIndex.JobIndexItem>();
const { mode = props.values ? 'edit' : 'create' } = props;
useEffect(() => {
if (props.open) {
form.resetFields();
if (props.values) {
form.setFieldsValue(props.values);
}
}
}, [form, props.values?.indexId, props.open]);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
await props.onSubmit(values as API.JobIndex.JobIndexItem);
};
if (mode === 'view') {
return (
<ModalForm
title="指标信息详情"
open={props.open}
width={800}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
footer: null,
}}
submitter={false}
>
<ProDescriptions<API.JobIndex.JobIndexItem> column={2} dataSource={props.values || {}}>
<ProDescriptions.Item dataIndex="indexId" label="指标ID" />
<ProDescriptions.Item dataIndex="indexName" label="指标名称" />
<ProDescriptions.Item dataIndex="indexDesc" label="指标描述" span={2} />
<ProDescriptions.Item
dataIndex="isActive"
label="是否启用"
valueEnum={{
'0': { text: '启用' },
'2': { text: '未启用' },
}}
/>
</ProDescriptions>
</ModalForm>
);
}
return (
<ModalForm<API.JobIndex.JobIndexItem>
title={mode === 'edit' ? '编辑指标信息' : '新建指标信息'}
form={form}
autoFocusFirstInput
open={props.open}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
}}
submitTimeout={2000}
onFinish={handleFinish}
>
<ProForm.Group>
<ProFormText width="md" hidden name="indexId" />
<ProFormText
width="md"
name="indexName"
label="指标名称"
placeholder="请输入指标名称"
rules={[{ required: true, message: '请输入指标名称!' }]}
/>
<ProFormSelect
width="md"
name="isActive"
label="是否启用"
valueEnum={{
'0': '启用',
'2': '未启用',
}}
placeholder="请选择状态"
rules={[{ required: true, message: '请选择是否启用!' }]}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
width="lg"
name="indexDesc"
label="指标描述"
placeholder="请输入指标描述"
rules={[{ required: true, message: '请输入指标描述!' }]}
fieldProps={{
rows: 4,
}}
/>
</ProForm.Group>
</ModalForm>
);
};
export default JobIndexEdit;

View File

@@ -0,0 +1,267 @@
import React, { Fragment, useRef, useState } from 'react';
import { useAccess } from '@umijs/max';
import {
getJobIndexList,
getJobIndexSingle,
saveJobIndex,
updateJobIndex,
deleteJobIndex,
} from '@/services/recruitmentDataCollection/metricAdmin';
import { Button, FormInstance, message, Modal } from 'antd';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { DeleteOutlined, FormOutlined, PlusOutlined, EyeOutlined } from '@ant-design/icons';
import EditJobIndexRow from './edit';
function JobIndexList() {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<API.JobIndex.JobIndexItem>();
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [mode, setMode] = useState<'view' | 'edit' | 'create'>('create');
const [loading, setLoading] = useState<boolean>(false);
// 删除处理
const handleRemoveOne = async (indexId: any) => {
const hide = message.loading('正在删除');
if (!indexId) return true;
try {
const resp = await deleteJobIndex({ indexId });
hide();
if (resp.code === 200) {
message.success('删除成功,即将刷新');
} else {
message.error(resp.msg);
}
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
// 查看详情
const handleViewDetail = async (indexId: any) => {
setLoading(true);
try {
const res = await getJobIndexSingle(indexId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('view');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取详情失败');
} finally {
setLoading(false);
}
};
// 编辑
const handleEdit = async (indexId: any) => {
setLoading(true);
try {
const res = await getJobIndexSingle(indexId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('edit');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取编辑数据失败');
} finally {
setLoading(false);
}
};
const columns: ProColumns<API.JobIndex.JobIndexItem>[] = [
{
title: '指标ID',
dataIndex: 'indexId',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '指标名称',
dataIndex: 'indexName',
valueType: 'text',
align: 'center',
},
{
title: '指标描述',
dataIndex: 'indexDesc',
valueType: 'text',
align: 'center',
},
{
title: '是否启用',
dataIndex: 'isActive',
valueType: 'select',
align: 'center',
valueEnum: {
'0': { text: '启用' },
'2': { text: '未启用' },
},
fieldProps: {
options: [
{ label: '启用', value: '0' },
{ label: '未启用', value: '2' },
],
defaultValue: '0',
allowClear: false,
},
},
{
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'indexId',
width: 300,
render: (indexId, record) => (
<div style={{ display: 'flex', justifyContent: 'center', gap: 8 }}>
<Button
type="link"
size="small"
key="view"
icon={<EyeOutlined />}
loading={loading}
hidden={!access.hasPerms('jobIndex:view')}
onClick={() => handleViewDetail(indexId)}
>
</Button>
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined />}
loading={loading}
hidden={!access.hasPerms('jobIndex:update')}
onClick={() => handleEdit(indexId)}
>
</Button>
<Button
type="link"
size="small"
danger
key="delete"
icon={<DeleteOutlined />}
hidden={!access.hasPerms('jobIndex:delete')}
onClick={async () => {
Modal.confirm({
title: '删除',
content: '确定删除该指标吗?',
okText: '确认',
cancelText: '取消',
onOk: async () => {
const success = await handleRemoveOne(indexId);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
},
});
}}
>
</Button>
</div>
),
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
<ProTable<API.JobIndex.JobIndexItem>
actionRef={actionRef}
formRef={formTableRef}
rowKey="indexId"
key="jobIndexIndex"
columns={columns}
search={{
labelWidth: 'auto',
}}
request={async (
params: API.JobIndex.ListParams & {
pageSize?: number;
current?: number;
},
) => {
const queryParams = {
...params,
isActive: params.isActive || '0', //默认查询启用
};
const res = await getJobIndexList({ ...queryParams } as API.JobIndex.ListParams);
return {
data: res.rows,
total: res.total,
success: true,
};
}}
toolBarRender={() => [
<Button
type="primary"
key="add"
hidden={!access.hasPerms('jobIndex:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
setMode('create');
}}
>
<PlusOutlined />
</Button>,
]}
/>
</div>
<EditJobIndexRow
open={modalVisible}
mode={mode}
onSubmit={async (values: API.JobIndex.JobIndexItem) => {
try {
let resData;
if (values.indexId) {
resData = await updateJobIndex(values as API.JobIndex.UpdateParams);
} else {
resData = await saveJobIndex(values as API.JobIndex.AddParams);
}
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
if (values.indexId) {
message.success('修改成功');
} else {
message.success('新增成功');
}
if (actionRef.current) {
actionRef.current.reload();
}
} else {
message.error(resData.msg || '操作失败');
}
} catch (error) {
message.error('操作失败');
}
}}
values={currentRow}
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
}}
/>
</Fragment>
);
}
export default JobIndexList;

View File

@@ -0,0 +1,129 @@
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProDescriptions,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
export type WebsiteFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.Website.WebsiteItem) => Promise<void>;
open: boolean;
values?: Partial<API.Website.WebsiteItem>;
mode?: 'view' | 'edit' | 'create';
};
const WebsiteEdit: React.FC<WebsiteFormProps> = (props) => {
const [form] = Form.useForm<API.Website.WebsiteItem>();
const { mode = props.values ? 'edit' : 'create' } = props;
useEffect(() => {
if (props.open) {
form.resetFields();
if (props.values) {
form.setFieldsValue(props.values);
}
}
}, [form, props.values?.websiteId, props.open]);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
await props.onSubmit(values as API.Website.WebsiteItem);
};
if (mode === 'view') {
return (
<ModalForm
title="网站信息详情"
open={props.open}
width={800}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
footer: null,
}}
submitter={false}
>
<ProDescriptions<API.Website.WebsiteItem> column={2} dataSource={props.values || {}}>
<ProDescriptions.Item dataIndex="websiteId" label="网站ID" />
<ProDescriptions.Item dataIndex="websiteName" label="网站名称" />
<ProDescriptions.Item dataIndex="websiteUrl" label="网站地址" />
<ProDescriptions.Item dataIndex="websiteOwnerCompany" label="归属单位公司" />
<ProDescriptions.Item
dataIndex="isActive"
label="是否启用"
valueEnum={{
'0': { text: '启用' },
'2': { text: '未启用' },
}}
/>
</ProDescriptions>
</ModalForm>
);
}
return (
<ModalForm<API.Website.WebsiteItem>
title={mode === 'edit' ? '编辑网站信息' : '新建网站信息'}
form={form}
autoFocusFirstInput
open={props.open}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
}}
submitTimeout={2000}
onFinish={handleFinish}
>
<ProForm.Group>
<ProFormText width="md" hidden name="websiteId" />
<ProFormText
width="md"
name="websiteName"
label="网站名称"
placeholder="请输入网站名称"
rules={[{ required: true, message: '请输入网站名称!' }]}
/>
<ProFormText
width="md"
name="websiteUrl"
label="网站地址"
placeholder="请输入网站地址"
rules={[
{ required: true, message: '请输入网站地址!' },
{ type: 'url', message: '请输入有效的网址!' },
]}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="websiteOwnerCompany"
label="归属单位公司"
placeholder="请输入归属单位公司"
rules={[{ required: true, message: '请输入归属单位公司!' }]}
/>
<ProFormSelect
width="md"
name="isActive"
label="是否启用"
valueEnum={{
'0': '启用',
'2': '未启用',
}}
placeholder="请选择状态"
rules={[{ required: true, message: '请选择是否启用!' }]}
/>
</ProForm.Group>
</ModalForm>
);
};
export default WebsiteEdit;

View File

@@ -0,0 +1,272 @@
import React, { Fragment, useRef, useState } from 'react';
import { useAccess } from '@umijs/max';
import {
getWebsiteList,
getWebsiteSingle,
saveWebsite,
updateWebsite,
deleteWebsite,
} from '@/services/recruitmentDataCollection/sourceManager';
import { Button, FormInstance, message, Modal } from 'antd';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { DeleteOutlined, FormOutlined, PlusOutlined, EyeOutlined } from '@ant-design/icons';
import EditWebsiteRow from './edit';
function WebsiteList() {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<API.Website.WebsiteItem>();
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [mode, setMode] = useState<'view' | 'edit' | 'create'>('create');
const [loading, setLoading] = useState<boolean>(false);
// 删除处理
const handleRemoveOne = async (websiteId: any) => {
const hide = message.loading('正在删除');
if (!websiteId) return true;
try {
const resp = await deleteWebsite({ websiteId });
hide();
if (resp.code === 200) {
message.success('删除成功,即将刷新');
} else {
message.error(resp.msg);
}
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
// 查看详情
const handleViewDetail = async (websiteId: any) => {
setLoading(true);
try {
const res = await getWebsiteSingle(websiteId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('view');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取详情失败');
} finally {
setLoading(false);
}
};
// 编辑
const handleEdit = async (websiteId: any) => {
setLoading(true);
try {
const res = await getWebsiteSingle(websiteId);
if (res.code === 200) {
setCurrentRow(res.data);
setModalVisible(true);
setMode('edit');
} else {
message.error(res.msg);
}
} catch (error) {
message.error('获取编辑数据失败');
} finally {
setLoading(false);
}
};
const columns: ProColumns<API.Website.WebsiteItem>[] = [
{
title: '网站ID',
dataIndex: 'websiteId',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '网站名称',
dataIndex: 'websiteName',
valueType: 'text',
align: 'center',
},
{
title: '网站地址',
dataIndex: 'websiteUrl',
valueType: 'text',
align: 'center',
},
{
title: '归属单位公司',
dataIndex: 'websiteOwnerCompany',
valueType: 'text', // 改为文本输入
align: 'center',
},
{
title: '是否启用',
dataIndex: 'isActive',
valueType: 'select',
align: 'center',
valueEnum: {
'0': { text: '启用' },
'2': { text: '未启用' },
},
fieldProps: {
options: [
{ label: '启用', value: '0' },
{ label: '未启用', value: '2' },
],
allowClear: false,
},
},
{
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'websiteId',
width: 300,
render: (websiteId, record) => (
<div style={{ display: 'flex', justifyContent: 'center', gap: 8 }}>
<Button
type="link"
size="small"
key="view"
icon={<EyeOutlined />}
loading={loading}
hidden={!access.hasPerms('website:view')}
onClick={() => handleViewDetail(websiteId)}
>
</Button>
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined />}
loading={loading}
hidden={!access.hasPerms('website:update')}
onClick={() => handleEdit(websiteId)}
>
</Button>
<Button
type="link"
size="small"
danger
key="delete"
icon={<DeleteOutlined />}
hidden={!access.hasPerms('website:delete')}
onClick={async () => {
Modal.confirm({
title: '删除',
content: '确定删除该网站信息吗?',
okText: '确认',
cancelText: '取消',
onOk: async () => {
const success = await handleRemoveOne(websiteId);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
},
});
}}
>
</Button>
</div>
),
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
<ProTable<API.Website.WebsiteItem>
actionRef={actionRef}
formRef={formTableRef}
rowKey="websiteId"
key="websiteIndex"
columns={columns}
search={{
labelWidth: 'auto',
}}
request={async (
params: API.Website.ListParams & {
pageSize?: number;
current?: number;
},
) => {
const queryParams = {
...params,
isActive: params.isActive || '0', //默认查询启用
};
const res = await getWebsiteList({ ...queryParams } as API.Website.ListParams);
return {
data: res.rows,
total: res.total,
success: true,
};
}}
toolBarRender={() => [
<Button
type="primary"
key="add"
hidden={!access.hasPerms('website:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
setMode('create');
}}
>
<PlusOutlined />
</Button>,
]}
/>
</div>
<EditWebsiteRow
open={modalVisible}
mode={mode}
onSubmit={async (values: API.Website.WebsiteItem) => {
try {
let resData;
if (values.websiteId) {
resData = await updateWebsite(values as API.Website.UpdateParams);
} else {
resData = await saveWebsite(values as API.Website.AddParams);
}
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
if (values.websiteId) {
message.success('修改成功');
} else {
message.success('新增成功');
}
if (actionRef.current) {
actionRef.current.reload();
}
} else {
message.error(resData.msg || '操作失败');
}
} catch (error) {
message.error('操作失败');
}
}}
values={currentRow}
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
}}
/>
</Fragment>
);
}
export default WebsiteList;