flat: 合并
This commit is contained in:
@@ -20,14 +20,27 @@ body,
|
||||
.ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed {
|
||||
left: unset;
|
||||
}
|
||||
.ant-table-cell .ant-table-row-expand-icon {
|
||||
vertical-align: middle;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.ant-table-row {
|
||||
&-level-0 .ant-table-cell:first-child {
|
||||
padding-left: 16px !important;
|
||||
}
|
||||
&-level-1 .ant-table-cell:first-child {
|
||||
padding-left: 24px !important;
|
||||
padding-left: 40px !important;
|
||||
}
|
||||
&-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 {
|
||||
display: block;
|
||||
|
||||
@@ -32,7 +32,7 @@ export type ListFormProps = {
|
||||
};
|
||||
|
||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
const [form] = Form.useForm();
|
||||
const [form] = Form.useForm<IndustryDetail>();
|
||||
const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -158,6 +158,7 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
width="md"
|
||||
request={fetchIndustryTree}
|
||||
fieldProps={{
|
||||
virtual:true,
|
||||
treeDefaultExpandAll: true,
|
||||
showSearch: true,
|
||||
filterTreeNode: true,
|
||||
|
||||
@@ -21,18 +21,18 @@ export type ListFormProps = {
|
||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||
onSubmit: (values: any) => Promise<void>;
|
||||
open: boolean;
|
||||
values?: Partial<API.ClassifyJobs.Job>;
|
||||
values?: Partial<API.ClassifyJobs.Jobs>;
|
||||
// jobGroupOptions: DictOptionType[];
|
||||
// statusOptions: DictValueEnumObj;
|
||||
};
|
||||
|
||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
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 [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
|
||||
.filter(item => item.parentId === parentId)
|
||||
.map(item => ({
|
||||
|
||||
@@ -9,34 +9,6 @@ import { exportCmsJobTitleList, getCmsJobTitleList } from '@/services/classify/j
|
||||
import { getDictValueEnum } from '@/services/system/dict';
|
||||
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 hide = message.loading('正在删除');
|
||||
if (!jobId) return true;
|
||||
@@ -74,16 +46,14 @@ const buildTree = (
|
||||
parentId: number = 0,
|
||||
depth = 0,
|
||||
): API.ClassifyJobs.Jobs[] => {
|
||||
return data
|
||||
const children = data
|
||||
.filter((item) => item.parentId === parentId)
|
||||
.map((item) => {
|
||||
const child = buildTree(data, item.jobId, depth + 1);
|
||||
return {
|
||||
...item,
|
||||
depth,
|
||||
children: child.length ? child : undefined,
|
||||
};
|
||||
});
|
||||
.map((item) => ({
|
||||
...item,
|
||||
depth,
|
||||
children: buildTree(data, item.jobId, depth + 1),
|
||||
}));
|
||||
return children || [];
|
||||
};
|
||||
|
||||
const ManagementList: React.FC = () => {
|
||||
@@ -107,13 +77,12 @@ const ManagementList: React.FC = () => {
|
||||
title: '岗位名称',
|
||||
dataIndex: 'jobName',
|
||||
|
||||
align: 'center',
|
||||
align: 'left',
|
||||
render: (text, record) => (
|
||||
<span
|
||||
style={{
|
||||
paddingLeft: `${(record.depth || 0) * 20}px`,
|
||||
display: 'inline-block',
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{text}
|
||||
@@ -144,67 +113,22 @@ const ManagementList: React.FC = () => {
|
||||
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 (
|
||||
<Fragment>
|
||||
<div style={{ width: '100%', float: 'right' }}>
|
||||
<ProTable<API.ClassifyJobs.Jobs>
|
||||
// params 是需要自带的参数
|
||||
// 这个参数优先级更高,会覆盖查询表单的参数
|
||||
actionRef={actionRef}
|
||||
formRef={formTableRef}
|
||||
rowKey="jobId"
|
||||
key="index"
|
||||
columns={columns}
|
||||
expandable={{
|
||||
childrenColumnName: 'children',
|
||||
defaultExpandAllRows: true,
|
||||
indentSize: 24,
|
||||
rowExpandable: (record) => Array.isArray(record.children) && record.children.length > 0,
|
||||
}}
|
||||
search={{
|
||||
labelWidth: 120,
|
||||
}}
|
||||
@@ -215,7 +139,6 @@ const ManagementList: React.FC = () => {
|
||||
pageSize: 1000,
|
||||
});
|
||||
const treeData = buildTree(res.rows);
|
||||
console.log('完整树形结构:', JSON.stringify(treeData, null, 2));
|
||||
return {
|
||||
data: treeData,
|
||||
total: res.total,
|
||||
@@ -223,12 +146,6 @@ const ManagementList: React.FC = () => {
|
||||
};
|
||||
}}
|
||||
pagination={false}
|
||||
expandable={{
|
||||
childrenColumnName: 'children',
|
||||
defaultExpandAllRows: true,
|
||||
indentSize: 30,
|
||||
rowExpandable: (record) => !!record.children?.length,
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<Button
|
||||
type="primary"
|
||||
|
||||
@@ -32,18 +32,20 @@ const waitTime = (time: number = 100) => {
|
||||
};
|
||||
|
||||
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 { mode = props.values ? 'edit' : 'create' } = props;
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if(props.open){
|
||||
form.resetFields();
|
||||
if (props.values) {
|
||||
form.setFieldsValue({
|
||||
...props.values,
|
||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||
});
|
||||
}
|
||||
}, [form, props.values?.jobID]);
|
||||
}
|
||||
}, [form, props.values?.jobId,props.open]);
|
||||
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
@@ -105,11 +107,9 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ModalForm<{
|
||||
name: string;
|
||||
company: string;
|
||||
}>
|
||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||
<ModalForm<API.ManagementList.Manage>
|
||||
|
||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||
form={form}
|
||||
autoFocusFirstInput
|
||||
open={props.open}
|
||||
|
||||
44
src/types/Management/list.d.ts
vendored
44
src/types/Management/list.d.ts
vendored
@@ -1,26 +1,26 @@
|
||||
declare namespace API.ManagementList {
|
||||
export interface Manage {
|
||||
applyNum: number;
|
||||
companyId: number;
|
||||
companyName: string;
|
||||
education: string;
|
||||
experience: string;
|
||||
isApply: number;
|
||||
isCollection: number;
|
||||
isHot: number;
|
||||
jobId: number;
|
||||
jobLocation: string;
|
||||
jobLocationAreaCode: number;
|
||||
jobTitle: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
maxSalary: number;
|
||||
minSalary: number;
|
||||
postingDate: string;
|
||||
vacancies: number;
|
||||
view: number;
|
||||
release: number;
|
||||
isPublish: number;
|
||||
applyNum?: number;
|
||||
companyId?: number;
|
||||
companyName?: string;
|
||||
education?: string;
|
||||
experience?: string;
|
||||
isApply?: number;
|
||||
isCollection?: number;
|
||||
isHot?: number;
|
||||
jobId?: number;
|
||||
jobLocation?: string;
|
||||
jobLocationAreaCode?: string;
|
||||
jobTitle?: string;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
maxSalary?: number;
|
||||
minSalary?: number;
|
||||
postingDate?: string;
|
||||
vacancies?: number;
|
||||
view?: number;
|
||||
release?: number;
|
||||
isPublish?: number;
|
||||
}
|
||||
|
||||
export interface AddParams {
|
||||
@@ -34,7 +34,7 @@ declare namespace API.ManagementList {
|
||||
isHot?: number;
|
||||
jobId?: number;
|
||||
jobLocation?: string;
|
||||
jobLocationAreaCode?: number;
|
||||
jobLocationAreaCode?: string;
|
||||
jobTitle?: string;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
|
||||
11
src/types/classify/jobs.d.ts
vendored
11
src/types/classify/jobs.d.ts
vendored
@@ -7,13 +7,19 @@ declare namespace API.ClassifyJobs {
|
||||
}
|
||||
|
||||
export interface Jobs {
|
||||
[x: string]: number;
|
||||
createTime?: any;
|
||||
createTime?: string;
|
||||
jobId: number;
|
||||
parentId: number;
|
||||
jobName: string;
|
||||
orderNum: number;
|
||||
status: string;
|
||||
children?:Jobs[];
|
||||
depth?: number;
|
||||
parentName?: string;
|
||||
}
|
||||
export interface JobTreeNode extends Jobs {
|
||||
children: JobTreeNode[];
|
||||
depth: number;
|
||||
}
|
||||
|
||||
export interface Params {
|
||||
@@ -22,5 +28,6 @@ declare namespace API.ClassifyJobs {
|
||||
jobName?: string;
|
||||
orderNum?: number;
|
||||
status?: string;
|
||||
tree?:boolean;
|
||||
}
|
||||
}
|
||||
|
||||
12
src/typings.d.ts
vendored
12
src/typings.d.ts
vendored
@@ -28,17 +28,5 @@ declare namespace API {
|
||||
status?: string;
|
||||
[key: string]: any; // 允许其他未定义属性
|
||||
}
|
||||
|
||||
// 表格和表单使用的职业数据
|
||||
interface Job {
|
||||
jobId: number;
|
||||
parentId: number;
|
||||
jobName: string;
|
||||
orderNum?: number;
|
||||
status?: string;
|
||||
createTime?: string;
|
||||
parentName?: string;
|
||||
children?: Job[];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user