flat: 添加来源监测相关
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled

This commit is contained in:
Apcallover
2026-04-27 09:13:30 +08:00
parent a67946a1cb
commit b7d7437c21
18 changed files with 1696 additions and 2 deletions

View File

@@ -0,0 +1,125 @@
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProDescriptions,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
import DictTag from '@/components/DictTag';
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';
isActiveEnum: any;
};
const WebsiteEdit: React.FC<WebsiteFormProps> = (props) => {
const [form] = Form.useForm<API.Website.WebsiteItem>();
const { mode = props.values ? 'edit' : 'create', isActiveEnum } = 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} bordered 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="是否启用"
render={(text) => <DictTag enums={isActiveEnum} value={text as string} />}
/>
</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={isActiveEnum}
placeholder="请选择状态"
rules={[{ required: true, message: '请选择是否启用!' }]}
/>
</ProForm.Group>
</ModalForm>
);
};
export default WebsiteEdit;

View File

@@ -0,0 +1,278 @@
import React, { Fragment, useRef, useState, useEffect } from 'react';
import { useAccess } from '@umijs/max';
import {
getWebsiteList,
getWebsiteSingle,
saveWebsite,
updateWebsite,
deleteWebsite,
} from '@/services/recruitmentDataCollection/sourceManager';
import { getDictValueEnum } from '@/services/system/dict';
import { Button, FormInstance, message, Modal } from 'antd';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import DictTag from '@/components/DictTag';
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 [isActiveEnum, setIsActiveEnum] = useState<any>([]);
useEffect(() => {
getDictValueEnum('enable_status', true).then((data) => {
setIsActiveEnum(data);
});
}, []);
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: isActiveEnum,
fieldProps: {
allowClear: false,
defaultValue: '1',
},
render: (_, record) => {
return <DictTag enums={isActiveEnum} value={record.isActive} />;
},
},
{
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('recruitmentDataCollection:sourceManager:view')}
onClick={() => handleViewDetail(websiteId)}
>
</Button>
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined />}
loading={loading}
hidden={!access.hasPerms('recruitmentDataCollection:sourceManager:edit')}
onClick={() => handleEdit(websiteId)}
>
</Button>
<Button
type="link"
size="small"
danger
key="delete"
icon={<DeleteOutlined />}
hidden={!access.hasPerms('recruitmentDataCollection:sourceManager: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 || '1', //默认查询启用
};
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('recruitmentDataCollection:sourceManager:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
setMode('create');
}}
>
<PlusOutlined />
</Button>,
]}
/>
</div>
<EditWebsiteRow
open={modalVisible}
mode={mode}
isActiveEnum={isActiveEnum}
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;