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