Files
shihezi-admin/src/pages/Management/List/index.tsx

227 lines
6.3 KiB
TypeScript
Raw Normal View History

2025-01-20 17:42:05 +08:00
import React, {Fragment, useRef, useState, useEffect} from "react";
2024-11-26 16:43:31 +08:00
import { useIntl, FormattedMessage, useAccess, history } from '@umijs/max';
2025-01-20 17:42:05 +08:00
import {delCmsJobIds, getCmsJobList} from "@/services/Management/list";
2024-11-26 16:43:31 +08:00
import { Dropdown, FormInstance, Space, Button, message, Modal } from 'antd';
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
2025-01-20 17:42:05 +08:00
import { PlusOutlined, DeleteOutlined, FormOutlined, DownOutlined, EditOutlined } from '@ant-design/icons';
2024-11-26 16:43:31 +08:00
import EditManageRow from './edit'
2025-01-20 17:42:05 +08:00
import {getDictValueEnum} from "@/services/system/dict";
import DictTag from "@/components/DictTag";
const handleRemoveOne = async (jobId: string) => {
const hide = message.loading('正在删除');
if (!jobId) return true;
try {
const resp = await delCmsJobIds(jobId);
hide();
if (resp.code === 200) {
message.success('删除成功,即将刷新');
} else {
message.error(resp.msg);
}
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
2024-11-26 16:43:31 +08:00
function ManagementList() {
const access = useAccess();
const formTableRef = useRef<FormInstance>();
const actionRef = useRef<ActionType>();
2025-01-20 17:42:05 +08:00
const [educationEnum, setEducationEnum] = useState<any>([])
const [experienceEnum, setExperienceEnum] = useState<any>([])
const [hotEnum, setHotEnum] = useState<any>([])
const [currentRow, setCurrentRow] = useState<API.ManagementList.Manage>()
2024-11-26 16:43:31 +08:00
const [modalVisible, setModalVisible] = useState<boolean>(false)
2025-01-20 17:42:05 +08:00
useEffect(() => {
getDictValueEnum('education',true).then((data) => {
setEducationEnum(data)
})
getDictValueEnum('experience',true).then((data) => {
setExperienceEnum(data)
})
// getDictValueEnum('job_hot',true).then((data) => {
// setHotEnum(data)
// })
}, [])
const columns: ProColumns<API.ManagementList.Manage>[] = [
2024-11-26 16:43:31 +08:00
{
2025-01-20 17:42:05 +08:00
title: '岗位名称',
dataIndex: 'jobTitle',
valueType: 'text',
align: 'center',
},{
title: '最大最小薪资',
dataIndex: 'maxSalary',
valueType: 'text',
hideInSearch: true,
align: 'center',
render: (_, record) => <>{record.minSalary}-{record.maxSalary}</>
},
{
title: '单位名称',
dataIndex: 'companyName',
valueType: 'text',
align: 'center',
},
{
title: '学历要求',
dataIndex: 'education',
valueType: 'select',
align: 'center',
valueEnum: educationEnum,
render: (_, record) => {
return (<DictTag enums={educationEnum} value={record.education} />);
},
},
{
title: '经验要求',
dataIndex: 'experience',
hideInSearch: true,
valueType: 'select',
align: 'center',
valueEnum: experienceEnum,
render: (_, record) => {
return (<DictTag enums={experienceEnum} value={record.experience} />);
},
},
// {
// title: '是否热门',
// dataIndex: 'isHot',
// valueType: 'select',
// align: 'center',
// valueEnum: hotEnum,
// render: (_, record) => {
// return (<DictTag enums={hotEnum} value={record.isHot} />);
// },
// },
{
title: '发布时间',
dataIndex: 'postingDate',
valueType: 'text',
hideInSearch: true,
align: 'center',
},
{
title: '招聘人数',
dataIndex: 'vacancies',
2024-11-26 16:43:31 +08:00
valueType: 'text',
2025-01-20 17:42:05 +08:00
align: 'center',
2024-11-26 16:43:31 +08:00
hideInSearch: true,
},
2025-01-20 17:42:05 +08:00
{
title: '浏览量',
dataIndex: 'view',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: '操作',
hideInSearch: true,
align: 'center',
dataIndex: 'jobId',
width: 300,
render: (jobId, record) => [
<Button
type="link"
size="small"
key="edit"
icon={<FormOutlined/>}
hidden={!access.hasPerms('area:business:List.update')}
onClick={() => {
setModalVisible(true);
setCurrentRow(record);
}}
>
</Button>,
<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(jobId as string);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
},
});
}}
>
</Button>
]
}
2024-11-26 16:43:31 +08:00
]
return (
<Fragment>
<div style={{ width: '100%', float: 'right' }}>
2025-01-20 17:42:05 +08:00
<ProTable<API.ManagementList.Manage>
2024-11-26 16:43:31 +08:00
// params 是需要自带的参数
// 这个参数优先级更高,会覆盖查询表单的参数
actionRef={actionRef}
formRef={formTableRef}
2025-01-20 17:42:05 +08:00
rowKey="jobId"
key="index"
2024-11-26 16:43:31 +08:00
columns={columns}
request={(params) =>
2025-01-20 17:42:05 +08:00
getCmsJobList({ ...params } as API.ManagementList.ListParams).then((res) => {
console.log(params)
2024-11-26 16:43:31 +08:00
const result = {
data: res.rows,
total: res.total,
success: true,
};
return result;
})
}
toolBarRender={() => [
<Button
type="primary"
key="add"
2025-01-20 17:42:05 +08:00
hidden={!access.hasPerms('manage:List:add')}
2024-11-26 16:43:31 +08:00
onClick={async () => {
setCurrentRow(undefined);
setModalVisible(true);
}}
>
<PlusOutlined />
</Button>,
]}
/>
</div>
<EditManageRow
open={modalVisible}
onSubmit={(values) => {
console.log(values)
2024-12-05 16:32:02 +08:00
return Promise.resolve()
2024-11-26 16:43:31 +08:00
}}
onCancel={() => {
setModalVisible(false);
setCurrentRow(undefined);
}}
></EditManageRow>
</Fragment>
)
}
export default ManagementList