在职位管理和行业管理中,转为树形表格数据结构

This commit is contained in:
yy
2025-04-02 19:07:15 +08:00
parent b140dd9aae
commit 994ec60616
10 changed files with 442 additions and 254 deletions

View File

@@ -1,5 +1,13 @@
{
"extends": [
"development"
],
"hints": {
"no-inline-styles": "off"
},
"browserslist": [
"defaults",
"not ie 11",
"not ie <= 11"
]
}

View File

@@ -20,7 +20,15 @@ body,
.ant-pro-sider.ant-layout-sider.ant-pro-sider-fixed {
left: unset;
}
.ant-table-row {
&-level-1 .ant-table-cell:first-child {
padding-left: 24px !important;
}
&-level-2 .ant-table-cell:first-child {
padding-left: 48px !important;
}
// 可根据需要添加更多层级
}
canvas {
display: block;
}

View File

@@ -4,50 +4,56 @@ import {
ProForm,
ProFormDigit,
ProFormRadio,
ProFormSelect,
ProFormTreeSelect,
ProFormText,
ProDescriptions,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import { DictValueEnumObj } from '@/components/DictTag';
import { FormattedMessage } from '@@/exports';
import { getCmsIndustryTree } from '@/services/classify/industry';
import { values } from 'lodash';
import { getCmsIndustryTreeList } from '@/services/classify/industry'; // 修改导入为 getCmsIndustryTreeList
interface IndustryDetail extends API.ClassifyIndustry.IndustryRow {
parentName: string;
interface IndustryDetail {
id?: number;
industryName?: string;
orderNum?: number;
status?: string;
parentId?: number;
parentName?: string;
}
export type ListFormProps = {
onCancel: (flag?: boolean, formVars?: unknown) => void;
onSubmit: (values: API.ClassifyIndustry.IndustryRow) => Promise<void>;
onSubmit: (values: any) => Promise<void>;
open: boolean;
values?: Partial<API.ClassifyIndustry.IndustryRow>;
// industryStatusEnum: DictOptionType[];
values?: Partial<IndustryDetail>;
industryStatusEnum: DictValueEnumObj;
mode?: 'view' | 'edit' | 'create';
};
const listEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm();
const { industryStatusEnum, mode = props.values ? 'edit' : 'create',values } = props;
const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props;
useEffect(() => {
form.resetFields();
if (values) {
form.setFieldsValue(values);
form.setFieldsValue({
...values,
parentId: values?.parentId ?? 0
});
}
}, [form,values?.industryId]);
}, [form, values?.id]);
const getSafeDetailData = (
data?: Partial<API.ClassifyIndustry.IndustryRow>
): IndustryDetail => {
return{
industryId: data?.industryId ?? 0,
const getSafeDetailData = (data?: Partial<IndustryDetail>): IndustryDetail => {
return {
id: data?.id ?? 0,
industryName: data?.industryName ?? '',
orderNum: data?.orderNum ?? 0,
parentId: data?.parentId ?? 0,
parentName: (data as any)?.parentName ?? '', // 或通过 parentId 映射
status: data?.status ?? '0',}
parentName: data?.parentName ?? '顶级节点',
status: data?.status ?? '0',
};
};
const handleCancel = () => {
@@ -56,10 +62,27 @@ const listEdit: React.FC<ListFormProps> = (props) => {
};
const handleFinish = async (values: Record<string, any>) => {
props.onSubmit(values as API.ClassifyIndustry.IndustryRow);
const submitValues = {
...values,
parentId: values.parentId === 0 ? undefined : values.parentId
};
// check
if (mode === 'view') {
props.onSubmit(submitValues);
};
// 获取行业树数据
const fetchIndustryTree = async () => {
const res = await getCmsIndustryTreeList();
return [
{
id: 0,
label: '顶级节点',
value: 0,
children: res.data || []
}
];
};
if (mode === 'view') {
return (
<ModalForm
title="行业详情"
@@ -77,13 +100,13 @@ if (mode === 'view') {
dataSource={getSafeDetailData(values)}
loading={!values}
>
<ProDescriptions.Item label="行业ID" dataIndex="industryId" />
<ProDescriptions.Item label="行业ID" dataIndex="id" />
<ProDescriptions.Item label="行业名称" dataIndex="industryName" />
<ProDescriptions.Item label="显示顺序" dataIndex="orderNum" />
<ProDescriptions.Item
label="父行业"
dataIndex="parentName"
valueType="text"// 假设API返回中有parentName字段
renderText={(text, record) => record.parentId === 0 ? '顶级节点' : text}
/>
<ProDescriptions.Item
label="行业状态"
@@ -94,6 +117,7 @@ if (mode === 'view') {
</ModalForm>
);
}
return (
<ModalForm
title={`${values ? '编辑' : '新增'}行业`}
@@ -106,86 +130,56 @@ if (mode === 'view') {
}}
submitTimeout={2000}
onFinish={handleFinish}
// readonly
>
<ProFormDigit label="InputNumber" name="industryId" disabled hidden={true} />
<ProFormDigit name="id" disabled hidden={true} />
<ProForm.Group>
<ProFormText width="md" name="industryName" label="行业名称" placeholder="请输入行业名称" />
<ProFormText
width="md"
name="industryName"
label="行业名称"
placeholder="请输入行业名称"
rules={[{ required: true, message: '请输入行业名称' }]}
/>
<ProFormDigit
label="显示顺序"
name="orderNum"
width="md"
min={0}
placeholder="请输入显示顺序"
rules={[{ required: true, message: '请输入显示顺序' }]}
/>
</ProForm.Group>
<ProForm.Group>
{/* 多级 */}
{/*<ProFormTreeSelect*/}
{/* name="parentId"*/}
{/* label="父行业"*/}
{/* placeholder="请选择父行业"*/}
{/* allowClear*/}
{/* width="md"*/}
{/* request={async () => {*/}
{/* return getCmsIndustryTree().then((res) => {*/}
{/* return res.data;*/}
{/* });*/}
{/* }}*/}
{/* fieldProps={{*/}
{/* suffixIcon: null,*/}
{/* filterTreeNode: true,*/}
{/* showSearch: true,*/}
{/* popupMatchSelectWidth: false,*/}
{/* labelInValue: false,*/}
{/* autoClearSearchValue: true,*/}
{/* multiple: false,*/}
{/* treeNodeFilterProp: 'title',*/}
{/* fieldNames: {*/}
{/* label: 'label',*/}
{/* value: 'id',*/}
{/* children: 'children',*/}
{/* },*/}
{/* }}*/}
{/*/>*/}
{/* 2级 */}
<ProFormSelect
<ProFormTreeSelect
name="parentId"
label="父行业"
placeholder="请选择父行业"
allowClear
width="md"
placeholder="请选择父行业"
request={async () => {
return getCmsIndustryTree().then((res) => {
return res.data;
});
}}
colProps={{ md: 12, xl: 12 }}
rules={[{ required: true, message: '请选择父行业!' }]}
request={fetchIndustryTree}
fieldProps={{
suffixIcon: null,
treeDefaultExpandAll: true,
showSearch: true,
popupMatchSelectWidth: false,
labelInValue: false,
autoClearSearchValue: true,
filterTreeNode: true,
fieldNames: {
label: 'label',
value: 'id',
children: 'children',
},
dropdownStyle: {
maxHeight: 400,
overflow: 'auto',
},
}}
rules={[{ required: true, message: '请选择父行业' }]}
/>
<ProFormRadio.Group
valueEnum={industryStatusEnum}
name="status"
label="行业状态"
width="md"
placeholder="请输入状态"
rules={[
{
required: false,
message: <FormattedMessage id="请输入状态!" defaultMessage="请选择行业状态!" />,
},
]}
initialValue="0"
rules={[{ required: true, message: '请选择行业状态' }]}
/>
</ProForm.Group>
</ModalForm>

View File

@@ -8,17 +8,25 @@ import {
addCmsIndustryIndustryt,
delCmsIndustryList,
exportCmsIndustry,
getCmsIndustryList,
getCmsIndustryTreeList,
updateCmsIndustryIndustryt,
} from '@/services/classify/industry';
import { getDictValueEnum } from '@/services/system/dict';
import DictTag from '@/components/DictTag';
const handleRemoveOne = async (industryId: string) => {
// 定义行业数据类型替代API.ClassifyIndustry.IndustryRow
interface IndustryItem {
id: number;
industryName: string;
orderNum?: number;
status?: string;
children?: IndustryItem[];
}
const handleRemoveOne = async (id: string) => { // 参数改为id
const hide = message.loading('正在删除');
if (!industryId) return true;
try {
const resp = await delCmsIndustryList(industryId);
const resp = await delCmsIndustryList(id);
hide();
if (resp.code === 200) {
message.success('删除成功,即将刷新');
@@ -33,7 +41,7 @@ const handleRemoveOne = async (industryId: string) => {
}
};
const handleExport = async (values: API.ClassifyIndustry.Params) => {
const handleExport = async (values: any) => { // 简化类型定义
const hide = message.loading('正在导出');
try {
await exportCmsIndustry(values);
@@ -47,12 +55,24 @@ const handleExport = async (values: API.ClassifyIndustry.Params) => {
}
};
// 处理树形数据的函数(移到组件外部)
function processTreeData(data: any[]): IndustryItem[] {
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) : []
}));
}
function ManagementList() {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<API.ClassifyIndustry.IndustryRow>();
const [currentRow, setCurrentRow] = useState<IndustryItem>(); // 使用新类型
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [industryStatusEnum, setIndustryStatusEnum] = useState<any>([]);
@@ -62,9 +82,7 @@ function ManagementList() {
});
}, []);
const editSubmit = () => {};
const columns: ProColumns<API.ClassifyIndustry.IndustryRow>[] = [
const columns: ProColumns<IndustryItem>[] = [ // 使用新类型
{
title: '行业名称',
dataIndex: 'industryName',
@@ -92,9 +110,9 @@ function ManagementList() {
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'industryId',
dataIndex: 'id', // 改为id
width: 300,
render: (industryId, record) => [
render: (id, record) => [
<Button
type="link"
size="small"
@@ -132,15 +150,11 @@ function ManagementList() {
Modal.confirm({
title: '删除',
content: '确定删除该项吗?',
okText: '确认',
cancelText: '取消',
onOk: async () => {
const success = await handleRemoveOne(industryId as string);
if (success) {
if (actionRef.current) {
const success = await handleRemoveOne(id.toString());
if (success && actionRef.current) {
actionRef.current.reload();
}
}
},
});
}}
@@ -150,31 +164,37 @@ function ManagementList() {
],
},
];
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
<ProTable<API.ClassifyIndustry.IndustryRow>
<ProTable<IndustryItem>
actionRef={actionRef}
formRef={formTableRef}
rowKey="industryId"
key="index"
rowKey="id" // 改为id
columns={columns}
request={(params) =>
getCmsIndustryList({ ...params } as API.ClassifyIndustry.Params).then((res) => {
const result = {
data: res.rows,
total: res.total,
search={false}
defaultExpandAllRows={true}
childrenColumnName="children"
pagination={false}
request={async () => {
try {
const res = await getCmsIndustryTreeList();
return {
data: processTreeData(res.data || []),
success: true,
};
return result;
})
} catch (error) {
console.error('获取数据失败:', error);
return { data: [], success: false };
}
}}
toolBarRender={() => [
<Button
type="primary"
key="add"
hidden={!access.hasPerms('manage:List:add')}
onClick={async () => {
onClick={() => {
setCurrentRow(undefined);
setModalVisible(true);
}}
@@ -185,8 +205,8 @@ function ManagementList() {
key="export"
hidden={!access.hasPerms('system:user:export')}
onClick={async () => {
const searchVal = formTableRef.current && formTableRef.current.getFieldsValue();
handleExport(searchVal as API.ClassifyIndustry.Params);
const searchVal = formTableRef.current?.getFieldsValue();
handleExport(searchVal);
}}
>
<PlusOutlined />
@@ -195,11 +215,11 @@ function ManagementList() {
]}
/>
</div>
<EditCompanyListRow
<EditCompanyListRow
open={modalVisible}
onSubmit={async (values) => {
let resData;
if (values.industryId) {
if (values.id) { // 改为id
resData = await updateCmsIndustryIndustryt(values);
} else {
resData = await addCmsIndustryIndustryt(values);
@@ -207,14 +227,8 @@ function ManagementList() {
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
if (values.industryId) {
message.success('修改成功');
} else {
message.success('新增成功');
}
if (actionRef.current) {
actionRef.current.reload();
}
message.success(values.id ? '修改成功' : '新增成功');
actionRef.current?.reload();
}
}}
onCancel={() => {
@@ -224,11 +238,11 @@ function ManagementList() {
industryStatusEnum={industryStatusEnum}
values={currentRow}
mode={
currentRow?.industryId
currentRow?.id // 改为id
? access.hasPerms('area:business:List.update') ? 'edit' : 'view'
: 'create'
}
/>
/>
</Fragment>
);
}

View File

@@ -1,58 +1,100 @@
import { useEffect } from 'react';
import React,{ useEffect,useState } from 'react';
import {
ModalForm,
ProForm,
ProFormDigit,
ProFormText,
ProFormTextArea,
ProFormTreeSelect,
ProFormSelect
} from '@ant-design/pro-components';
import { Form } from 'antd';
import { getCmsJobTitleList } from '@/services/classify/jobs';
import { getDictValueEnum } from '@/services/system/dict';
// tree
type JobListParams = API.ClassifyJobs.Params;
export type ListFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.CompanyList.Company) => Promise<void>;
onSubmit: (values: any) => Promise<void>;
open: boolean;
values?: Partial<API.CompanyList.Company>;
values?: Partial<API.ClassifyJobs.Job>;
// jobGroupOptions: DictOptionType[];
// statusOptions: DictValueEnumObj;
};
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const listEdit: React.FC<ListFormProps> = (props) => {
const [form] = Form.useForm();
const [treeData, setTreeData] = useState<API.ClassifyJobs.Job[]>([]);
const [statusOptions, setStatusOptions] = useState<Record<string, any>>({});
const [loading, setLoading] = useState(false);
const buildTree = (data: API.ClassifyJobs.Job[], parentId: number = 0): API.ClassifyJobs.Job[] => {
return data
.filter(item => item.parentId === parentId)
.map(item => ({
...item,
children: buildTree(data, item.jobId),
}));
};
useEffect(() => {
form.resetFields();
const fetchData = async () => {
const res = await getCmsJobTitleList({
tree: false,
// 明确传递所有必要参数
pageSize: 1000, // 确保获取全部数据
current: 1
} as JobListParams);
setLoading(true);
try {
// 获取状态枚举
const statusData = await getDictValueEnum('sys_jobs_status', true);
setStatusOptions(statusData);
// 获取岗位数据
const res = await getCmsJobTitleList({ tree: false } as JobListParams);
console.log('原始数据:', res.rows);
const treeData = buildTree(res.rows || []);
console.log('转换后的树形数据:', treeData);
setTreeData(treeData);
// 设置表单初始值
if (props.values) {
form.setFieldsValue(props.values);
form.setFieldsValue({
...props.values,
parentId: props.values.parentId || undefined,
});
}
}, [form, props]);
} catch (error) {
console.error('数据加载失败:', error);
} finally {
setLoading(false);
}
};
fetchData();
}, []);
const handleCancel = () => {
props.onCancel();
form.resetFields();
};
const handleFinish = async (values: Record<string, any>) => {
props.onSubmit(values as API.CompanyList.Company);
await props.onSubmit(values);
};
return (
<ModalForm<{
name: string;
company: string;
}>
<ModalForm
title={`${props.values ? '编辑' : '新增'}企业`}
form={form}
autoFocusFirstInput
open={props.open}
width={600}
modalProps={{
destroyOnClose: true,
onCancel: () => handleCancel(),
@@ -60,10 +102,46 @@ const listEdit: React.FC<ListFormProps> = (props) => {
submitTimeout={2000}
onFinish={handleFinish}
>
<ProFormDigit label="InputNumber" name="companyId" disabled hidden={true} />
<ProFormDigit label="InputNumber" name="jobId" disabled hidden={true} />
{/* 新增:父级岗位选择 */}
<ProFormTreeSelect
name="parentId"
label="父级岗位"
width="md"
placeholder="请选择父级岗位"
allowClear
fieldProps={{
treeData,
fieldNames: { label: 'jobName', value: 'jobId', children: 'children' },
treeDefaultExpandAll: true,
showSearch: true,
variant:'outlined',
dropdownStyle: { maxHeight: 400, overflow: 'auto' },
filterTreeNode: (input, option) =>
String(option?.title ?? '').toLowerCase().includes(input.toLowerCase())
}}
/>
<ProForm.Group>
<ProFormText width="md" name="name" label="单位名称" placeholder="请输入单位名称" />
<ProFormText width="md" name="jobname" label="单位名称" placeholder="请输入单位名称" />
<ProFormDigit
width="md"
name="orderNum"
label="显示顺序"
placeholder="请输入显示顺序"
min={0}
fieldProps={{ precision: 0 }}
rules={[{ required: true, message: '请输入显示顺序' }]}
/>
</ProForm.Group>
<ProFormSelect
name="status"
label="状态"
width="md"
valueEnum={statusOptions}
placeholder="请选择状态"
/>
<ProForm.Group>
<ProFormText width="md" name="code" label="信用代码" placeholder="请输入信用代码" />
<ProFormText width="md" name="industry" label="主要行业" placeholder="请输入主要行业" />
@@ -76,3 +154,6 @@ const listEdit: React.FC<ListFormProps> = (props) => {
};
export default listEdit;

View File

@@ -2,12 +2,38 @@ import React, { Fragment, useEffect, useRef, useState } from 'react';
import { FormattedMessage, useAccess } from '@umijs/max';
import { Button, FormInstance, message, Modal } from 'antd';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import { DeleteOutlined, FormOutlined, 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 {
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('正在删除');
@@ -41,8 +67,17 @@ const handleExport = async (values: API.ClassifyJobs.Params) => {
return false;
}
};
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),
}));
};
function ManagementList() {
const ManagementList: React.FC = () => {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
@@ -53,9 +88,7 @@ function ManagementList() {
const [jobsStatusEnum, setJobsStatusEnum] = useState<any>([]);
useEffect(() => {
getDictValueEnum('sys_jobs_status', true).then((data) => {
setJobsStatusEnum(data);
});
getDictValueEnum('sys_jobs_status', true).then(setJobsStatusEnum);
}, []);
const editSubmit = () => {};
@@ -64,7 +97,19 @@ function ManagementList() {
{
title: '岗位名称',
dataIndex: 'jobName',
align: 'center',
render: (text, record) => (
<span style={{ paddingLeft: `${(record.depth || 0) * 20}px`,display:'inline-block' ,
width:'100%'}}>
{text}
</span>
),
},
{title: '父级岗位',
dataIndex: 'parentName',
valueType: 'text',
hideInSearch: true,
align: 'center',
},
{
@@ -88,48 +133,49 @@ function ManagementList() {
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'companyId',
dataIndex: 'jobId',
width: 300,
render: (companyId, record) => [
// <Button
// type="link"
// size="small"
// key="edit"
// icon={<FormOutlined />}
// hidden={!access.hasPerms('area:business:List.update')}
// onClick={() => {
// setModalVisible(true);
// setCurrentRow(record);
// }}
// >
// 编辑
// </Button>,
render: (_, record) => [
<Button
type="link"
size="small"
danger
key="batchRemove"
icon={<DeleteOutlined />}
hidden={!access.hasPerms('area:subway:List')}
onClick={async () => {
Modal.confirm({
title: '删除',
content: '确定删除该项吗?',
okText: '确认',
cancelText: '取消',
onOk: async () => {
const success = await handleRemoveOne(companyId as string);
if (success) {
if (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>,
],
},
];
@@ -144,28 +190,41 @@ function ManagementList() {
rowKey="jobId"
key="index"
columns={columns}
request={(params) =>
getCmsJobTitleList({ ...params } as API.ClassifyJobs.Params).then((res) => {
const result = {
data: res.rows,
search={{
labelWidth: 120,
}}
request={async (params) => {
const res = await getCmsJobTitleList({ ...params, tree: false ,
pageSize:1000
});
const treeData = buildTree(res.rows);
console.log('完整树形结构:', JSON.stringify(treeData, null, 2));
return {
data: treeData,
total: res.total,
success: true,
};
return result;
})
}
}}
pagination={false}
expandable={{
childrenColumnName: 'children',
defaultExpandAllRows: true,
indentSize:30,
rowExpandable: (record) => !!record.children?.length
}}
toolBarRender={() => [
// <Button
// type="primary"
// key="add"
// hidden={!access.hasPerms('manage:List:add')}
// onClick={async () => {
// setCurrentRow(undefined);
// setModalVisible(true);
// }}
// >
// <PlusOutlined /> 新建
// </Button>,
<Button
type="primary"
key="add"
hidden={!access.hasPerms('manage:List:add')}
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
}}
>
<PlusOutlined />
</Button>,
<Button
type="primary"
key="export"
@@ -185,7 +244,7 @@ function ManagementList() {
open={modalVisible}
onSubmit={async (values) => {
let resData;
if (values.companyId) {
if (values.jobId) {
resData = await putCmsCompanyList(values);
} else {
resData = await addCmsCompanyList(values);
@@ -193,7 +252,7 @@ function ManagementList() {
if (resData.code === 200) {
setModalVisible(false);
setCurrentRow(undefined);
if (values.companyId) {
if (values.jobId) {
message.success('修改成功');
} else {
message.success('新增成功');

View File

@@ -10,8 +10,7 @@ import {
} from '@ant-design/pro-components';
import { Form, Button, message, Modal, Descriptions } from 'antd';
import DictTag, { DictValueEnumObj } from '@/components/DictTag';
import { getCmsIndustryTree } from '@/services/classify/industry';
import { getCmsIndustryTreeList } from '@/services/classify/industry';
export type ListFormProps = {
onCancel: (flag?: boolean, formVals?: unknown) => void;
onSubmit: (values: API.CompanyList.Company) => Promise<void>;
@@ -78,7 +77,7 @@ const ListEdit: React.FC<ListFormProps> = (props) => {
allowClear
width="md"
request={async () => {
return getCmsIndustryTree().then((res) => {
return getCmsIndustryTreeList().then((res) => {
return res.data;
});
}}

View File

@@ -14,8 +14,8 @@ export async function delCmsIndustryList(industryId?: string) {
});
}
export async function getCmsIndustryTree() {
return request<API.ClassifyIndustry.IndustryTreeResult>(`/api/cms/industry/treeselect`, {
export async function getCmsIndustryTreeList() {
return request(`/api/cms/industry/treeselect`, {
method: 'GET',
});
}

View File

@@ -7,6 +7,7 @@ declare namespace API.ClassifyJobs {
}
export interface Jobs {
[x: string]: number;
createTime?: any;
jobId: number;
parentId: number;

24
src/typings.d.ts vendored
View File

@@ -18,3 +18,27 @@ declare module 'react-fittext';
declare module 'bizcharts-plugin-slider';
declare const REACT_APP_ENV: 'test' | 'dev' | 'pre' | false;
declare namespace API {
namespace ClassifyJobs {
interface Params {
tree?: boolean;
pageSize?: number;
current?: number;
jobName?: string;
status?: string;
[key: string]: any; // 允许其他未定义属性
}
// 表格和表单使用的职业数据
interface Job {
jobId: number;
parentId: number;
jobName: string;
orderNum?: number;
status?: string;
createTime?: string;
parentName?: string;
children?: Job[];
}
}
}