flat: 合并

This commit is contained in:
史典卓
2025-04-23 15:47:46 +08:00
8 changed files with 784 additions and 858 deletions

View File

@@ -20,14 +20,27 @@ body,
.ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed { .ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed {
left: unset; left: unset;
} }
.ant-table-cell .ant-table-row-expand-icon {
vertical-align: middle;
margin-right: 8px;
}
.ant-table-row { .ant-table-row {
&-level-0 .ant-table-cell:first-child {
padding-left: 16px !important;
}
&-level-1 .ant-table-cell:first-child { &-level-1 .ant-table-cell:first-child {
padding-left: 24px !important; padding-left: 40px !important;
} }
&-level-2 .ant-table-cell:first-child { &-level-2 .ant-table-cell:first-child {
padding-left: 48px !important; padding-left: 64px !important;
} }
// 可根据需要添加更多层级 }
.ant-table-row .ant-table-cell:first-child {
display: flex;
align-items: center;
}
.ant-table-row-level-2 .ant-table-row-expand-icon {
display: none;
} }
canvas { canvas {
display: block; display: block;

View File

@@ -32,7 +32,7 @@ export type ListFormProps = {
}; };
const listEdit: React.FC<ListFormProps> = (props) => { const listEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm(); const [form] = Form.useForm<IndustryDetail>();
const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props; const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props;
useEffect(() => { useEffect(() => {
@@ -158,6 +158,7 @@ const listEdit: React.FC<ListFormProps> = (props) => {
width="md" width="md"
request={fetchIndustryTree} request={fetchIndustryTree}
fieldProps={{ fieldProps={{
virtual:true,
treeDefaultExpandAll: true, treeDefaultExpandAll: true,
showSearch: true, showSearch: true,
filterTreeNode: true, filterTreeNode: true,

View File

@@ -21,18 +21,18 @@ export type ListFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void; onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: any) => Promise<void>; onSubmit: (values: any) => Promise<void>;
open: boolean; open: boolean;
values?: Partial<API.ClassifyJobs.Job>; values?: Partial<API.ClassifyJobs.Jobs>;
// jobGroupOptions: DictOptionType[]; // jobGroupOptions: DictOptionType[];
// statusOptions: DictValueEnumObj; // statusOptions: DictValueEnumObj;
}; };
const listEdit: React.FC<ListFormProps> = (props) => { const listEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [treeData, setTreeData] = useState<API.ClassifyJobs.Job[]>([]); const [treeData, setTreeData] = useState<API.ClassifyJobs.Jobs[]>([]);
const [statusOptions, setStatusOptions] = useState<Record<string, any>>({}); const [statusOptions, setStatusOptions] = useState<Record<string, any>>({});
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const buildTree = (data: API.ClassifyJobs.Job[], parentId: number = 0): API.ClassifyJobs.Job[] => { const buildTree = (data: API.ClassifyJobs.Jobs[], parentId: number = 0): API.ClassifyJobs.Jobs[] => {
return data return data
.filter(item => item.parentId === parentId) .filter(item => item.parentId === parentId)
.map(item => ({ .map(item => ({

View File

@@ -9,34 +9,6 @@ import { exportCmsJobTitleList, getCmsJobTitleList } from '@/services/classify/j
import { getDictValueEnum } from '@/services/system/dict'; import { getDictValueEnum } from '@/services/system/dict';
import DictTag from '@/components/DictTag'; import DictTag from '@/components/DictTag';
declare namespace API {
namespace ClassifyJobs {
interface Params {
tree?: boolean;
pageSize?: number;
current?: number;
jobName?: string;
status?: string;
}
interface Jobs {
jobId: number;
parentId: number;
jobName: string;
orderNum?: number;
status?: string;
createTime?: string;
parentName?: string;
children?: Jobs[];
depth?: number; // 添加这行
}
}
}
// params类型
type JobListParams = API.ClassifyJobs.Params & {
tree?: boolean;
};
const handleRemoveOne = async (jobId: string) => { const handleRemoveOne = async (jobId: string) => {
const hide = message.loading('正在删除'); const hide = message.loading('正在删除');
if (!jobId) return true; if (!jobId) return true;
@@ -74,16 +46,14 @@ const buildTree = (
parentId: number = 0, parentId: number = 0,
depth = 0, depth = 0,
): API.ClassifyJobs.Jobs[] => { ): API.ClassifyJobs.Jobs[] => {
return data const children = data
.filter((item) => item.parentId === parentId) .filter((item) => item.parentId === parentId)
.map((item) => { .map((item) => ({
const child = buildTree(data, item.jobId, depth + 1); ...item,
return { depth,
...item, children: buildTree(data, item.jobId, depth + 1),
depth, }));
children: child.length ? child : undefined, return children || [];
};
});
}; };
const ManagementList: React.FC = () => { const ManagementList: React.FC = () => {
@@ -107,13 +77,12 @@ const ManagementList: React.FC = () => {
title: '岗位名称', title: '岗位名称',
dataIndex: 'jobName', dataIndex: 'jobName',
align: 'center', align: 'left',
render: (text, record) => ( render: (text, record) => (
<span <span
style={{ style={{
paddingLeft: `${(record.depth || 0) * 20}px`, display: 'flex',
display: 'inline-block', alignItems: 'center',
width: '100%',
}} }}
> >
{text} {text}
@@ -144,67 +113,22 @@ const ManagementList: React.FC = () => {
return <DictTag enums={jobsStatusEnum} value={record.status} />; return <DictTag enums={jobsStatusEnum} value={record.status} />;
}, },
}, },
// {
// title: '操作',
// hideInSearch: true,
// align: 'center',
// dataIndex: 'jobId',
// width: 300,
// render: (_, record) => [
// <Button
// type="link"
// size="small"
// key="edit"
// icon={<FormOutlined />}
// hidden={!access.hasPerms('system:job:edit')}
// onClick={() => {
// setModalVisible(true);
// setCurrentRow(record);
// }}
// >
// 编辑
// </Button>,
// // <Button
// // type="link"
// // size="small"
// // danger
// // key="delete"
// // icon={<DeleteOutlined />}
// // hidden={!access.hasPerms('system:job:remove')}
// // onClick={async () => {
// // Modal.confirm({
// // title: '删除',
// // content: '确定删除该项吗?',
// // okText: '确认',
// // cancelText: '取消',
// // onOk: async () => {
// // if(record.jobId){
// // const success = await handleRemoveOne(record.jobId.toString());
//
// // if (success && actionRef.current) {
// // actionRef.current.reload();
// // }
// // }
// // },
// // });
// // }}
// // >
// // 删除
// // </Button>,
// ],
// },
]; ];
return ( return (
<Fragment> <Fragment>
<div style={{ width: '100%', float: 'right' }}> <div style={{ width: '100%', float: 'right' }}>
<ProTable<API.ClassifyJobs.Jobs> <ProTable<API.ClassifyJobs.Jobs>
// params 是需要自带的参数
// 这个参数优先级更高,会覆盖查询表单的参数
actionRef={actionRef} actionRef={actionRef}
formRef={formTableRef} formRef={formTableRef}
rowKey="jobId" rowKey="jobId"
key="index" key="index"
columns={columns} columns={columns}
expandable={{
childrenColumnName: 'children',
defaultExpandAllRows: true,
indentSize: 24,
rowExpandable: (record) => Array.isArray(record.children) && record.children.length > 0,
}}
search={{ search={{
labelWidth: 120, labelWidth: 120,
}} }}
@@ -215,7 +139,6 @@ const ManagementList: React.FC = () => {
pageSize: 1000, pageSize: 1000,
}); });
const treeData = buildTree(res.rows); const treeData = buildTree(res.rows);
console.log('完整树形结构:', JSON.stringify(treeData, null, 2));
return { return {
data: treeData, data: treeData,
total: res.total, total: res.total,
@@ -223,12 +146,6 @@ const ManagementList: React.FC = () => {
}; };
}} }}
pagination={false} pagination={false}
expandable={{
childrenColumnName: 'children',
defaultExpandAllRows: true,
indentSize: 30,
rowExpandable: (record) => !!record.children?.length,
}}
toolBarRender={() => [ toolBarRender={() => [
<Button <Button
type="primary" type="primary"

View File

@@ -32,18 +32,20 @@ const waitTime = (time: number = 100) => {
}; };
const listEdit: React.FC<ListFormProps> = (props) => { const listEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm<{ name: string; company: string; companyName: number }>(); const [form] = Form.useForm<API.ManagementList.Manage>();
const { educationEnum, experienceEnum, areaEnum } = props; const { educationEnum, experienceEnum, areaEnum } = props;
const { mode = props.values ? 'edit' : 'create' } = props; const { mode = props.values ? 'edit' : 'create' } = props;
useEffect(() => { useEffect(() => {
form.resetFields(); if(props.open){
form.resetFields();
if (props.values) { if (props.values) {
form.setFieldsValue({ form.setFieldsValue({
...props.values, ...props.values,
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''), jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
}); });
} }
}, [form, props.values?.jobID]); }
}, [form, props.values?.jobId,props.open]);
const handleCancel = () => { const handleCancel = () => {
props.onCancel(); props.onCancel();
@@ -105,11 +107,9 @@ const listEdit: React.FC<ListFormProps> = (props) => {
); );
} }
return ( return (
<ModalForm<{ <ModalForm<API.ManagementList.Manage>
name: string;
company: string; title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
}>
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
form={form} form={form}
autoFocusFirstInput autoFocusFirstInput
open={props.open} open={props.open}

View File

@@ -1,26 +1,26 @@
declare namespace API.ManagementList { declare namespace API.ManagementList {
export interface Manage { export interface Manage {
applyNum: number; applyNum?: number;
companyId: number; companyId?: number;
companyName: string; companyName?: string;
education: string; education?: string;
experience: string; experience?: string;
isApply: number; isApply?: number;
isCollection: number; isCollection?: number;
isHot: number; isHot?: number;
jobId: number; jobId?: number;
jobLocation: string; jobLocation?: string;
jobLocationAreaCode: number; jobLocationAreaCode?: string;
jobTitle: string; jobTitle?: string;
latitude: number; latitude?: number;
longitude: number; longitude?: number;
maxSalary: number; maxSalary?: number;
minSalary: number; minSalary?: number;
postingDate: string; postingDate?: string;
vacancies: number; vacancies?: number;
view: number; view?: number;
release: number; release?: number;
isPublish: number; isPublish?: number;
} }
export interface AddParams { export interface AddParams {
@@ -34,7 +34,7 @@ declare namespace API.ManagementList {
isHot?: number; isHot?: number;
jobId?: number; jobId?: number;
jobLocation?: string; jobLocation?: string;
jobLocationAreaCode?: number; jobLocationAreaCode?: string;
jobTitle?: string; jobTitle?: string;
latitude?: number; latitude?: number;
longitude?: number; longitude?: number;

View File

@@ -7,13 +7,19 @@ declare namespace API.ClassifyJobs {
} }
export interface Jobs { export interface Jobs {
[x: string]: number; createTime?: string;
createTime?: any;
jobId: number; jobId: number;
parentId: number; parentId: number;
jobName: string; jobName: string;
orderNum: number; orderNum: number;
status: string; status: string;
children?:Jobs[];
depth?: number;
parentName?: string;
}
export interface JobTreeNode extends Jobs {
children: JobTreeNode[];
depth: number;
} }
export interface Params { export interface Params {
@@ -22,5 +28,6 @@ declare namespace API.ClassifyJobs {
jobName?: string; jobName?: string;
orderNum?: number; orderNum?: number;
status?: string; status?: string;
tree?:boolean;
} }
} }

12
src/typings.d.ts vendored
View File

@@ -28,17 +28,5 @@ declare namespace API {
status?: string; status?: string;
[key: string]: any; // 允许其他未定义属性 [key: string]: any; // 允许其他未定义属性
} }
// 表格和表单使用的职业数据
interface Job {
jobId: number;
parentId: number;
jobName: string;
orderNum?: number;
status?: string;
createTime?: string;
parentName?: string;
children?: Job[];
}
} }
} }