flat: 暂存
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import React, { Fragment, useEffect, useRef, useState } from 'react';
|
import React, { Fragment, useEffect, useRef, useState } from 'react';
|
||||||
import { FormattedMessage, useAccess } from '@umijs/max';
|
import { FormattedMessage, useAccess } from '@umijs/max';
|
||||||
import { Button, FormInstance, message, Modal } from 'antd';
|
import { Button, FormInstance, message } from 'antd';
|
||||||
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||||
import { AlignLeftOutlined, DeleteOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons';
|
import { AlignLeftOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import EditCompanyListRow from './edit';
|
import EditCompanyListRow from './edit';
|
||||||
import {
|
import {
|
||||||
addCmsIndustryIndustryt,
|
addCmsIndustryIndustryt,
|
||||||
@@ -23,7 +23,8 @@ interface IndustryItem {
|
|||||||
children?: IndustryItem[];
|
children?: IndustryItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRemoveOne = async (id: string) => { // 参数改为id
|
const handleRemoveOne = async (id: string) => {
|
||||||
|
// 参数改为id
|
||||||
const hide = message.loading('正在删除');
|
const hide = message.loading('正在删除');
|
||||||
try {
|
try {
|
||||||
const resp = await delCmsIndustryList(id);
|
const resp = await delCmsIndustryList(id);
|
||||||
@@ -41,7 +42,8 @@ const handleRemoveOne = async (id: string) => { // 参数改为id
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExport = async (values: any) => { // 简化类型定义
|
const handleExport = async (values: any) => {
|
||||||
|
// 简化类型定义
|
||||||
const hide = message.loading('正在导出');
|
const hide = message.loading('正在导出');
|
||||||
try {
|
try {
|
||||||
await exportCmsIndustry(values);
|
await exportCmsIndustry(values);
|
||||||
@@ -57,13 +59,13 @@ const handleExport = async (values: any) => { // 简化类型定义
|
|||||||
|
|
||||||
// 处理树形数据的函数(移到组件外部)
|
// 处理树形数据的函数(移到组件外部)
|
||||||
function processTreeData(data: any[]): IndustryItem[] {
|
function processTreeData(data: any[]): IndustryItem[] {
|
||||||
return data.map(item => ({
|
return data.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
industryName: item.label,
|
industryName: item.label,
|
||||||
orderNum: item.sort || 0,
|
orderNum: item.sort || 0,
|
||||||
status: item.status || '0',
|
status: item.status || '0',
|
||||||
key: item.id, // ProTable需要的唯一key
|
key: item.id, // ProTable需要的唯一key
|
||||||
children: item.children ? processTreeData(item.children) : []
|
children: item.children ? processTreeData(item.children) : undefined,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +84,8 @@ function ManagementList() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ProColumns<IndustryItem>[] = [ // 使用新类型
|
const columns: ProColumns<IndustryItem>[] = [
|
||||||
|
// 使用新类型
|
||||||
{
|
{
|
||||||
title: '行业名称',
|
title: '行业名称',
|
||||||
dataIndex: 'industryName',
|
dataIndex: 'industryName',
|
||||||
@@ -139,28 +142,28 @@ function ManagementList() {
|
|||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
// <Button
|
||||||
type="link"
|
// type="link"
|
||||||
size="small"
|
// size="small"
|
||||||
danger
|
// danger
|
||||||
key="batchRemove"
|
// key="batchRemove"
|
||||||
icon={<DeleteOutlined />}
|
// icon={<DeleteOutlined />}
|
||||||
hidden={!access.hasPerms('area:subway:List')}
|
// hidden={!access.hasPerms('area:subway:List')}
|
||||||
onClick={async () => {
|
// onClick={async () => {
|
||||||
Modal.confirm({
|
// Modal.confirm({
|
||||||
title: '删除',
|
// title: '删除',
|
||||||
content: '确定删除该项吗?',
|
// content: '确定删除该项吗?',
|
||||||
onOk: async () => {
|
// onOk: async () => {
|
||||||
const success = await handleRemoveOne(id.toString());
|
// const success = await handleRemoveOne(id.toString());
|
||||||
if (success && actionRef.current) {
|
// if (success && actionRef.current) {
|
||||||
actionRef.current.reload();
|
// actionRef.current.reload();
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}}
|
// }}
|
||||||
>
|
// >
|
||||||
删除
|
// 删除
|
||||||
</Button>,
|
// </Button>,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -219,7 +222,8 @@ function ManagementList() {
|
|||||||
open={modalVisible}
|
open={modalVisible}
|
||||||
onSubmit={async (values) => {
|
onSubmit={async (values) => {
|
||||||
let resData;
|
let resData;
|
||||||
if (values.id) { // 改为id
|
if (values.id) {
|
||||||
|
// 改为id
|
||||||
resData = await updateCmsIndustryIndustryt(values);
|
resData = await updateCmsIndustryIndustryt(values);
|
||||||
} else {
|
} else {
|
||||||
resData = await addCmsIndustryIndustryt(values);
|
resData = await addCmsIndustryIndustryt(values);
|
||||||
@@ -239,7 +243,9 @@ function ManagementList() {
|
|||||||
values={currentRow}
|
values={currentRow}
|
||||||
mode={
|
mode={
|
||||||
currentRow?.id // 改为id
|
currentRow?.id // 改为id
|
||||||
? access.hasPerms('area:business:List.update') ? 'edit' : 'view'
|
? access.hasPerms('area:business:List.update')
|
||||||
|
? 'edit'
|
||||||
|
: 'view'
|
||||||
: 'create'
|
: 'create'
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import React, { Fragment, useEffect, useRef, useState } from 'react';
|
import React, { Fragment, useEffect, useRef, useState } from 'react';
|
||||||
import { FormattedMessage, useAccess } from '@umijs/max';
|
import { FormattedMessage, useAccess } from '@umijs/max';
|
||||||
import { Button, FormInstance, message, Modal } from 'antd';
|
import { Button, FormInstance, message } from 'antd';
|
||||||
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||||
import { DeleteOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import EditCompanyListRow from './edit';
|
import EditCompanyListRow from './edit';
|
||||||
import { addCmsCompanyList, delCmsCompanyList, putCmsCompanyList } from '@/services/company/list';
|
import { addCmsCompanyList, delCmsCompanyList, putCmsCompanyList } from '@/services/company/list';
|
||||||
import { exportCmsJobTitleList, getCmsJobTitleList } from '@/services/classify/jobs';
|
import { exportCmsJobTitleList, getCmsJobTitleList } from '@/services/classify/jobs';
|
||||||
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 {
|
declare namespace API {
|
||||||
namespace ClassifyJobs {
|
namespace ClassifyJobs {
|
||||||
interface Params {
|
interface Params {
|
||||||
@@ -17,6 +18,7 @@ declare namespace API {
|
|||||||
jobName?: string;
|
jobName?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Jobs {
|
interface Jobs {
|
||||||
jobId: number;
|
jobId: number;
|
||||||
parentId: number;
|
parentId: number;
|
||||||
@@ -32,7 +34,7 @@ declare namespace API {
|
|||||||
}
|
}
|
||||||
// params类型
|
// params类型
|
||||||
type JobListParams = API.ClassifyJobs.Params & {
|
type JobListParams = API.ClassifyJobs.Params & {
|
||||||
tree?:boolean;
|
tree?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveOne = async (jobId: string) => {
|
const handleRemoveOne = async (jobId: string) => {
|
||||||
@@ -67,14 +69,21 @@ const handleExport = async (values: API.ClassifyJobs.Params) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const buildTree = (data: API.ClassifyJobs.Jobs[], parentId: number = 0,depth = 0): API.ClassifyJobs.Jobs[] => {
|
const buildTree = (
|
||||||
|
data: API.ClassifyJobs.Jobs[],
|
||||||
|
parentId: number = 0,
|
||||||
|
depth = 0,
|
||||||
|
): API.ClassifyJobs.Jobs[] => {
|
||||||
return data
|
return data
|
||||||
.filter(item => item.parentId === parentId)
|
.filter((item) => item.parentId === parentId)
|
||||||
.map(item => ({
|
.map((item) => {
|
||||||
|
const child = buildTree(data, item.jobId, depth + 1);
|
||||||
|
return {
|
||||||
...item,
|
...item,
|
||||||
depth,
|
depth,
|
||||||
children: buildTree(data, item.jobId,depth + 1),
|
children: child.length ? child : undefined,
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const ManagementList: React.FC = () => {
|
const ManagementList: React.FC = () => {
|
||||||
@@ -100,13 +109,19 @@ const ManagementList: React.FC = () => {
|
|||||||
|
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<span style={{ paddingLeft: `${(record.depth || 0) * 20}px`,display:'inline-block' ,
|
<span
|
||||||
width:'100%'}}>
|
style={{
|
||||||
|
paddingLeft: `${(record.depth || 0) * 20}px`,
|
||||||
|
display: 'inline-block',
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{text}
|
{text}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{title: '父级岗位',
|
{
|
||||||
|
title: '父级岗位',
|
||||||
dataIndex: 'parentName',
|
dataIndex: 'parentName',
|
||||||
valueType: 'text',
|
valueType: 'text',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
@@ -129,55 +144,55 @@ const ManagementList: React.FC = () => {
|
|||||||
return <DictTag enums={jobsStatusEnum} value={record.status} />;
|
return <DictTag enums={jobsStatusEnum} value={record.status} />;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: '操作',
|
// title: '操作',
|
||||||
hideInSearch: true,
|
// hideInSearch: true,
|
||||||
align: 'center',
|
// align: 'center',
|
||||||
dataIndex: 'jobId',
|
// dataIndex: 'jobId',
|
||||||
width: 300,
|
// width: 300,
|
||||||
render: (_, record) => [
|
// render: (_, record) => [
|
||||||
<Button
|
|
||||||
type="link"
|
|
||||||
size="small"
|
|
||||||
key="edit"
|
|
||||||
icon={<FormOutlined />}
|
|
||||||
hidden={!access.hasPerms('system:job:edit')}
|
|
||||||
onClick={() => {
|
|
||||||
setModalVisible(true);
|
|
||||||
setCurrentRow(record);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</Button>,
|
|
||||||
// <Button
|
// <Button
|
||||||
// type="link"
|
// type="link"
|
||||||
// size="small"
|
// size="small"
|
||||||
// danger
|
// key="edit"
|
||||||
// key="delete"
|
// icon={<FormOutlined />}
|
||||||
// icon={<DeleteOutlined />}
|
// hidden={!access.hasPerms('system:job:edit')}
|
||||||
// hidden={!access.hasPerms('system:job:remove')}
|
// onClick={() => {
|
||||||
// onClick={async () => {
|
// setModalVisible(true);
|
||||||
// Modal.confirm({
|
// setCurrentRow(record);
|
||||||
// title: '删除',
|
|
||||||
// content: '确定删除该项吗?',
|
|
||||||
// okText: '确认',
|
|
||||||
// cancelText: '取消',
|
|
||||||
// onOk: async () => {
|
|
||||||
// if(record.jobId){
|
|
||||||
// const success = await handleRemoveOne(record.jobId.toString());
|
|
||||||
|
|
||||||
// if (success && actionRef.current) {
|
|
||||||
// actionRef.current.reload();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// }}
|
// }}
|
||||||
// >
|
// >
|
||||||
// 删除
|
// 编辑
|
||||||
// </Button>,
|
// </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>
|
||||||
@@ -194,8 +209,10 @@ const ManagementList: React.FC = () => {
|
|||||||
labelWidth: 120,
|
labelWidth: 120,
|
||||||
}}
|
}}
|
||||||
request={async (params) => {
|
request={async (params) => {
|
||||||
const res = await getCmsJobTitleList({ ...params, tree: false ,
|
const res = await getCmsJobTitleList({
|
||||||
pageSize:1000
|
...params,
|
||||||
|
tree: false,
|
||||||
|
pageSize: 1000,
|
||||||
});
|
});
|
||||||
const treeData = buildTree(res.rows);
|
const treeData = buildTree(res.rows);
|
||||||
console.log('完整树形结构:', JSON.stringify(treeData, null, 2));
|
console.log('完整树形结构:', JSON.stringify(treeData, null, 2));
|
||||||
@@ -209,10 +226,9 @@ const ManagementList: React.FC = () => {
|
|||||||
expandable={{
|
expandable={{
|
||||||
childrenColumnName: 'children',
|
childrenColumnName: 'children',
|
||||||
defaultExpandAllRows: true,
|
defaultExpandAllRows: true,
|
||||||
indentSize:30,
|
indentSize: 30,
|
||||||
rowExpandable: (record) => !!record.children?.length
|
rowExpandable: (record) => !!record.children?.length,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
toolBarRender={() => [
|
toolBarRender={() => [
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -270,6 +286,6 @@ const ManagementList: React.FC = () => {
|
|||||||
></EditCompanyListRow>
|
></EditCompanyListRow>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ManagementList;
|
export default ManagementList;
|
||||||
|
|||||||
Reference in New Issue
Block a user