fix:修复控制台问题
This commit is contained in:
@@ -32,7 +32,7 @@ export type ListFormProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm<IndustryDetail>();
|
||||||
const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props;
|
const { industryStatusEnum, mode = props.values ? 'edit' : 'create', values } = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -158,6 +158,7 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
|||||||
width="md"
|
width="md"
|
||||||
request={fetchIndustryTree}
|
request={fetchIndustryTree}
|
||||||
fieldProps={{
|
fieldProps={{
|
||||||
|
virtual:true,
|
||||||
treeDefaultExpandAll: true,
|
treeDefaultExpandAll: true,
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
filterTreeNode: true,
|
filterTreeNode: true,
|
||||||
|
|||||||
@@ -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,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ function ManagementList() {
|
|||||||
const formTableRef = useRef<FormInstance>();
|
const formTableRef = useRef<FormInstance>();
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
||||||
const [currentRow, setCurrentRow] = useState<IndustryItem>(); // 使用新类型
|
const [currentRow, setCurrentRow] = useState<IndustryItem>(); // 使用新类型
|
||||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||||
const [industryStatusEnum, setIndustryStatusEnum] = useState<any>([]);
|
const [industryStatusEnum, setIndustryStatusEnum] = useState<any>([]);
|
||||||
|
|
||||||
@@ -82,7 +84,8 @@ function ManagementList() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ProColumns<IndustryItem>[] = [ // 使用新类型
|
const columns: ProColumns<IndustryItem>[] = [
|
||||||
|
// 使用新类型
|
||||||
{
|
{
|
||||||
title: '行业名称',
|
title: '行业名称',
|
||||||
dataIndex: 'industryName',
|
dataIndex: 'industryName',
|
||||||
@@ -110,7 +113,7 @@ function ManagementList() {
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
dataIndex: 'id', // 改为id
|
dataIndex: 'id', // 改为id
|
||||||
width: 300,
|
width: 300,
|
||||||
render: (id, record) => [
|
render: (id, record) => [
|
||||||
<Button
|
<Button
|
||||||
@@ -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>,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -171,7 +174,7 @@ function ManagementList() {
|
|||||||
<ProTable<IndustryItem>
|
<ProTable<IndustryItem>
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
formRef={formTableRef}
|
formRef={formTableRef}
|
||||||
rowKey="id" // 改为id
|
rowKey="id" // 改为id
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
defaultExpandAllRows={true}
|
defaultExpandAllRows={true}
|
||||||
@@ -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);
|
||||||
@@ -238,8 +242,10 @@ function ManagementList() {
|
|||||||
industryStatusEnum={industryStatusEnum}
|
industryStatusEnum={industryStatusEnum}
|
||||||
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'
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -21,18 +21,18 @@ export type ListFormProps = {
|
|||||||
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
onCancel: (flag?: boolean, formVals?: unknown) => void;
|
||||||
onSubmit: (values: any) => Promise<void>;
|
onSubmit: (values: any) => Promise<void>;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
values?: Partial<API.ClassifyJobs.Job>;
|
values?: Partial<API.ClassifyJobs.Jobs>;
|
||||||
// jobGroupOptions: DictOptionType[];
|
// jobGroupOptions: DictOptionType[];
|
||||||
// statusOptions: DictValueEnumObj;
|
// statusOptions: DictValueEnumObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
const listEdit: React.FC<ListFormProps> = (props) => {
|
||||||
const [form] = Form.useForm();
|
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 [statusOptions, setStatusOptions] = useState<Record<string, any>>({});
|
||||||
const [loading, setLoading] = useState(false);
|
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
|
return data
|
||||||
.filter(item => item.parentId === parentId)
|
.filter(item => item.parentId === parentId)
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
|
|||||||
@@ -8,32 +8,7 @@ import { addCmsCompanyList, delCmsCompanyList, putCmsCompanyList } from '@/servi
|
|||||||
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 {
|
|
||||||
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 handleRemoveOne = async (jobId: string) => {
|
||||||
const hide = message.loading('正在删除');
|
const hide = message.loading('正在删除');
|
||||||
|
|||||||
@@ -32,18 +32,20 @@ const waitTime = (time: number = 100) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const listEdit: React.FC<ListFormProps> = (props) => {
|
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 { educationEnum, experienceEnum, areaEnum } = props;
|
||||||
const { mode = props.values ? 'edit' : 'create' } = props;
|
const { mode = props.values ? 'edit' : 'create' } = props;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.resetFields();
|
if(props.open){
|
||||||
|
form.resetFields();
|
||||||
if (props.values) {
|
if (props.values) {
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...props.values,
|
...props.values,
|
||||||
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
jobLocationAreaCode: String(props.values.jobLocationAreaCode || ''),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [form, props.values?.jobID]);
|
}
|
||||||
|
}, [form, props.values?.jobId,props.open]);
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
props.onCancel();
|
props.onCancel();
|
||||||
@@ -105,11 +107,9 @@ const listEdit: React.FC<ListFormProps> = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ModalForm<{
|
<ModalForm<API.ManagementList.Manage>
|
||||||
name: string;
|
|
||||||
company: string;
|
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
||||||
}>
|
|
||||||
title={mode === 'edit' ? '编辑岗位' : '新建岗位'}
|
|
||||||
form={form}
|
form={form}
|
||||||
autoFocusFirstInput
|
autoFocusFirstInput
|
||||||
open={props.open}
|
open={props.open}
|
||||||
|
|||||||
44
src/types/Management/list.d.ts
vendored
44
src/types/Management/list.d.ts
vendored
@@ -1,26 +1,26 @@
|
|||||||
declare namespace API.ManagementList {
|
declare namespace API.ManagementList {
|
||||||
export interface Manage {
|
export interface Manage {
|
||||||
applyNum: number;
|
applyNum?: number;
|
||||||
companyId: number;
|
companyId?: number;
|
||||||
companyName: string;
|
companyName?: string;
|
||||||
education: string;
|
education?: string;
|
||||||
experience: string;
|
experience?: string;
|
||||||
isApply: number;
|
isApply?: number;
|
||||||
isCollection: number;
|
isCollection?: number;
|
||||||
isHot: number;
|
isHot?: number;
|
||||||
jobId: number;
|
jobId?: number;
|
||||||
jobLocation: string;
|
jobLocation?: string;
|
||||||
jobLocationAreaCode: number;
|
jobLocationAreaCode?: string;
|
||||||
jobTitle: string;
|
jobTitle?: string;
|
||||||
latitude: number;
|
latitude?: number;
|
||||||
longitude: number;
|
longitude?: number;
|
||||||
maxSalary: number;
|
maxSalary?: number;
|
||||||
minSalary: number;
|
minSalary?: number;
|
||||||
postingDate: string;
|
postingDate?: string;
|
||||||
vacancies: number;
|
vacancies?: number;
|
||||||
view: number;
|
view?: number;
|
||||||
release: number;
|
release?: number;
|
||||||
isPublish: number;
|
isPublish?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddParams {
|
export interface AddParams {
|
||||||
@@ -34,7 +34,7 @@ declare namespace API.ManagementList {
|
|||||||
isHot?: number;
|
isHot?: number;
|
||||||
jobId?: number;
|
jobId?: number;
|
||||||
jobLocation?: string;
|
jobLocation?: string;
|
||||||
jobLocationAreaCode?: number;
|
jobLocationAreaCode?: string;
|
||||||
jobTitle?: string;
|
jobTitle?: string;
|
||||||
latitude?: number;
|
latitude?: number;
|
||||||
longitude?: number;
|
longitude?: number;
|
||||||
|
|||||||
11
src/types/classify/jobs.d.ts
vendored
11
src/types/classify/jobs.d.ts
vendored
@@ -7,13 +7,19 @@ declare namespace API.ClassifyJobs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Jobs {
|
export interface Jobs {
|
||||||
[x: string]: number;
|
createTime?: string;
|
||||||
createTime?: any;
|
|
||||||
jobId: number;
|
jobId: number;
|
||||||
parentId: number;
|
parentId: number;
|
||||||
jobName: string;
|
jobName: string;
|
||||||
orderNum: number;
|
orderNum: number;
|
||||||
status: string;
|
status: string;
|
||||||
|
children?:Jobs[];
|
||||||
|
depth?: number;
|
||||||
|
parentName?: string;
|
||||||
|
}
|
||||||
|
export interface JobTreeNode extends Jobs {
|
||||||
|
children: JobTreeNode[];
|
||||||
|
depth: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Params {
|
export interface Params {
|
||||||
@@ -22,5 +28,6 @@ declare namespace API.ClassifyJobs {
|
|||||||
jobName?: string;
|
jobName?: string;
|
||||||
orderNum?: number;
|
orderNum?: number;
|
||||||
status?: string;
|
status?: string;
|
||||||
|
tree?:boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/typings.d.ts
vendored
12
src/typings.d.ts
vendored
@@ -28,17 +28,5 @@ declare namespace API {
|
|||||||
status?: string;
|
status?: string;
|
||||||
[key: string]: any; // 允许其他未定义属性
|
[key: string]: any; // 允许其他未定义属性
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表格和表单使用的职业数据
|
|
||||||
interface Job {
|
|
||||||
jobId: number;
|
|
||||||
parentId: number;
|
|
||||||
jobName: string;
|
|
||||||
orderNum?: number;
|
|
||||||
status?: string;
|
|
||||||
createTime?: string;
|
|
||||||
parentName?: string;
|
|
||||||
children?: Job[];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user