fix:修复控制台问题

This commit is contained in:
yy
2025-04-23 14:05:56 +08:00
parent 994ec60616
commit 2224e1acb4
8 changed files with 1197 additions and 1220 deletions

View File

@@ -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,

View File

@@ -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,
}));
}
@@ -72,7 +74,7 @@ function ManagementList() {
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<IndustryItem>(); // 使用新类型
const [currentRow, setCurrentRow] = useState<IndustryItem>(); // 使用新类型
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [industryStatusEnum, setIndustryStatusEnum] = useState<any>([]);
@@ -82,7 +84,8 @@ function ManagementList() {
});
}, []);
const columns: ProColumns<IndustryItem>[] = [ // 使用新类型
const columns: ProColumns<IndustryItem>[] = [
// 使用新类型
{
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) => [
<Button
@@ -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>,
],
},
];
@@ -171,7 +174,7 @@ function ManagementList() {
<ProTable<IndustryItem>
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'
}
/>

View File

@@ -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 => ({

View File

@@ -8,32 +8,7 @@ import { addCmsCompanyList, delCmsCompanyList, putCmsCompanyList } from '@/servi
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('正在删除');

View File

@@ -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}

View File

@@ -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;

View File

@@ -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
View File

@@ -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[];
}
}
}