diff --git a/src/pages/Classify/Industry/index.tsx b/src/pages/Classify/Industry/index.tsx index bbdd68d..d88e8bd 100644 --- a/src/pages/Classify/Industry/index.tsx +++ b/src/pages/Classify/Industry/index.tsx @@ -1,14 +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 { AlignLeftOutlined, DeleteOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons'; +import { AlignLeftOutlined, FormOutlined, PlusOutlined } from '@ant-design/icons'; import EditCompanyListRow from './edit'; import { addCmsIndustryIndustryt, delCmsIndustryList, exportCmsIndustry, - getCmsIndustryTreeList, + getCmsIndustryTreeList, updateCmsIndustryIndustryt, } from '@/services/classify/industry'; import { getDictValueEnum } from '@/services/system/dict'; @@ -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, })); } @@ -72,7 +74,7 @@ function ManagementList() { const formTableRef = useRef(); const actionRef = useRef(); - const [currentRow, setCurrentRow] = useState(); // 使用新类型 + const [currentRow, setCurrentRow] = useState(); // 使用新类型 const [modalVisible, setModalVisible] = useState(false); const [industryStatusEnum, setIndustryStatusEnum] = useState([]); @@ -82,7 +84,8 @@ function ManagementList() { }); }, []); - const columns: ProColumns[] = [ // 使用新类型 + const columns: ProColumns[] = [ + // 使用新类型 { title: '行业名称', dataIndex: 'industryName', @@ -110,7 +113,7 @@ function ManagementList() { title: '操作', hideInSearch: true, align: 'center', - dataIndex: 'id', // 改为id + dataIndex: 'id', // 改为id width: 300, render: (id, record) => [ , - , + // , ], }, ]; @@ -171,7 +174,7 @@ function ManagementList() { actionRef={actionRef} formRef={formTableRef} - rowKey="id" // 改为id + rowKey="id" // 改为id columns={columns} search={false} defaultExpandAllRows={true} @@ -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); @@ -238,8 +242,10 @@ function ManagementList() { industryStatusEnum={industryStatusEnum} values={currentRow} mode={ - currentRow?.id // 改为id - ? access.hasPerms('area:business:List.update') ? 'edit' : 'view' + currentRow?.id // 改为id + ? access.hasPerms('area:business:List.update') + ? 'edit' + : 'view' : 'create' } /> @@ -247,4 +253,4 @@ function ManagementList() { ); } -export default ManagementList; \ No newline at end of file +export default ManagementList; diff --git a/src/pages/Classify/Jobs/index.tsx b/src/pages/Classify/Jobs/index.tsx index 2bb56bc..a85a6cc 100644 --- a/src/pages/Classify/Jobs/index.tsx +++ b/src/pages/Classify/Jobs/index.tsx @@ -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; @@ -25,14 +27,14 @@ declare namespace API { status?: string; createTime?: string; parentName?: string; - children?: Jobs[]; + children?: Jobs[]; depth?: number; // 添加这行 } } } // params类型 type JobListParams = API.ClassifyJobs.Params & { - tree?:boolean; + tree?: boolean; }; const handleRemoveOne = async (jobId: string) => { @@ -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 => ({ - ...item, - depth, - children: buildTree(data, item.jobId,depth + 1), - })); + .filter((item) => item.parentId === parentId) + .map((item) => { + const child = buildTree(data, item.jobId, depth + 1); + return { + ...item, + depth, + children: child.length ? child : undefined, + }; + }); }; const ManagementList: React.FC = () => { @@ -97,16 +106,22 @@ const ManagementList: React.FC = () => { { title: '岗位名称', dataIndex: 'jobName', - + align: 'center', render: (text, record) => ( - + {text} ), }, - {title: '父级岗位', + { + title: '父级岗位', dataIndex: 'parentName', valueType: 'text', hideInSearch: true, @@ -129,55 +144,55 @@ const ManagementList: React.FC = () => { return ; }, }, - { - title: '操作', - hideInSearch: true, - align: 'center', - dataIndex: 'jobId', - width: 300, - render: (_, record) => [ - , - // , - ], - }, + // { + // title: '操作', + // hideInSearch: true, + // align: 'center', + // dataIndex: 'jobId', + // width: 300, + // render: (_, record) => [ + // , + // // , + // ], + // }, ]; return ( @@ -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)); @@ -209,10 +226,9 @@ const ManagementList: React.FC = () => { expandable={{ childrenColumnName: 'children', defaultExpandAllRows: true, - indentSize:30, - rowExpandable: (record) => !!record.children?.length + indentSize: 30, + rowExpandable: (record) => !!record.children?.length, }} - toolBarRender={() => [