227 lines
6.4 KiB
TypeScript
227 lines
6.4 KiB
TypeScript
|
|
import React, {Fragment, useRef, useState, useEffect} from "react";
|
||
|
|
import { useIntl, FormattedMessage, useAccess, history } from '@umijs/max';
|
||
|
|
import {delCmsJobIds, getCmsJobList} from "@/services/Management/list";
|
||
|
|
import { Dropdown, FormInstance, Space, Button, message, Modal } from 'antd';
|
||
|
|
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
|
||
|
|
import { PlusOutlined, DeleteOutlined, FormOutlined, DownOutlined, EditOutlined } from '@ant-design/icons';
|
||
|
|
import EditCompanyListRow from './edit'
|
||
|
|
import {
|
||
|
|
addCmsFairList,
|
||
|
|
delCmsFairList,
|
||
|
|
exportCmsFairList,
|
||
|
|
getCmsFairList,
|
||
|
|
putCmsFairList
|
||
|
|
} from "@/services/jobfair/list";
|
||
|
|
import {getDictValueEnum} from "@/services/system/dict";
|
||
|
|
import DictTag from "@/components/DictTag";
|
||
|
|
|
||
|
|
const handleRemoveOne = async (jobFairId: string) => {
|
||
|
|
const hide = message.loading('正在删除');
|
||
|
|
if (!jobFairId) return true;
|
||
|
|
try {
|
||
|
|
const resp = await delCmsFairList(jobFairId);
|
||
|
|
hide();
|
||
|
|
if (resp.code === 200) {
|
||
|
|
message.success('删除成功,即将刷新');
|
||
|
|
} else {
|
||
|
|
message.error(resp.msg);
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
} catch (error) {
|
||
|
|
hide();
|
||
|
|
message.error('删除失败,请重试');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleExport = async (values: API.JobFairList.Params) => {
|
||
|
|
const hide = message.loading('正在导出');
|
||
|
|
try {
|
||
|
|
await exportCmsFairList(values);
|
||
|
|
hide();
|
||
|
|
message.success('导出成功');
|
||
|
|
return true;
|
||
|
|
} catch (error) {
|
||
|
|
hide();
|
||
|
|
message.error('导出失败,请重试');
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
function ManagementList() {
|
||
|
|
const access = useAccess();
|
||
|
|
|
||
|
|
const formTableRef = useRef<FormInstance>();
|
||
|
|
const actionRef = useRef<ActionType>();
|
||
|
|
|
||
|
|
const [currentRow, setCurrentRow] = useState<API.JobFairList.JobFairListRows>()
|
||
|
|
const [modalVisible, setModalVisible] = useState<boolean>(false)
|
||
|
|
const [jobFairType, setJobFairTypeEnum] = useState<any>([])
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
getDictValueEnum('job_fair_type', true).then((data) => {
|
||
|
|
setJobFairTypeEnum(data)
|
||
|
|
});
|
||
|
|
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
const editSubmit = () => {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
const columns: ProColumns<API.JobFairList.JobFairListRows>[] = [
|
||
|
|
{
|
||
|
|
title: '招聘会名称',
|
||
|
|
dataIndex: 'name',
|
||
|
|
valueType: 'text',
|
||
|
|
hideInSearch: true,
|
||
|
|
align: 'center',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
title: '类型',
|
||
|
|
dataIndex: 'jobFairType',
|
||
|
|
valueType: 'select',
|
||
|
|
align: 'center',
|
||
|
|
valueEnum: jobFairType,
|
||
|
|
render: (_, record) => {
|
||
|
|
return (<DictTag enums={jobFairType} value={record.jobFairType} />);
|
||
|
|
},
|
||
|
|
},
|
||
|
|
{
|
||
|
|
title: '位置',
|
||
|
|
dataIndex: 'location',
|
||
|
|
valueType: 'text',
|
||
|
|
hideInSearch: true,
|
||
|
|
align: 'center',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
title: '操作',
|
||
|
|
hideInSearch: true,
|
||
|
|
align: 'center',
|
||
|
|
dataIndex: 'jobFairId',
|
||
|
|
width: 300,
|
||
|
|
render: (jobFairId, 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(jobFairId as string);
|
||
|
|
if (success) {
|
||
|
|
if (actionRef.current) {
|
||
|
|
actionRef.current.reload();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
});
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
删除
|
||
|
|
</Button>
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
return (
|
||
|
|
<Fragment>
|
||
|
|
<div style={{ width: '100%', float: 'right' }}>
|
||
|
|
<ProTable<API.JobFairList.JobFairListRows>
|
||
|
|
// params 是需要自带的参数
|
||
|
|
// 这个参数优先级更高,会覆盖查询表单的参数
|
||
|
|
actionRef={actionRef}
|
||
|
|
formRef={formTableRef}
|
||
|
|
rowKey="companyId"
|
||
|
|
key="index"
|
||
|
|
columns={columns}
|
||
|
|
request={(params) =>
|
||
|
|
getCmsFairList({ ...params } as API.JobFairList.Params).then((res) => {
|
||
|
|
const result = {
|
||
|
|
data: res.rows,
|
||
|
|
total: res.total,
|
||
|
|
success: true,
|
||
|
|
};
|
||
|
|
return result;
|
||
|
|
})
|
||
|
|
}
|
||
|
|
toolBarRender={() => [
|
||
|
|
<Button
|
||
|
|
type="primary"
|
||
|
|
key="add"
|
||
|
|
hidden={!access.hasPerms('manage:List:add')}
|
||
|
|
onClick={async () => {
|
||
|
|
setCurrentRow(undefined);
|
||
|
|
setModalVisible(true);
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
<PlusOutlined /> 新建
|
||
|
|
</Button>,
|
||
|
|
<Button
|
||
|
|
type="primary"
|
||
|
|
key="export"
|
||
|
|
hidden={!access.hasPerms('system:user:export')}
|
||
|
|
onClick={async () => {
|
||
|
|
const searchVal = formTableRef.current && formTableRef.current.getFieldsValue();
|
||
|
|
handleExport(searchVal as API.JobFairList.Params);
|
||
|
|
}}
|
||
|
|
>
|
||
|
|
<PlusOutlined />
|
||
|
|
<FormattedMessage id="pages.searchTable.export" defaultMessage="导出" />
|
||
|
|
</Button>,
|
||
|
|
]}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<EditCompanyListRow
|
||
|
|
open={modalVisible}
|
||
|
|
onSubmit={async (values) => {
|
||
|
|
let resData;
|
||
|
|
if (values.jobFairId) {
|
||
|
|
resData = await putCmsFairList(values)
|
||
|
|
} else {
|
||
|
|
resData = await addCmsFairList(values)
|
||
|
|
}
|
||
|
|
if (resData.code === 200) {
|
||
|
|
setModalVisible(false);
|
||
|
|
setCurrentRow(undefined);
|
||
|
|
if(values.jobFairId) {
|
||
|
|
message.success('修改成功')
|
||
|
|
} else {
|
||
|
|
message.success('新增成功')
|
||
|
|
}
|
||
|
|
if (actionRef.current) {
|
||
|
|
actionRef.current.reload();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}}
|
||
|
|
onCancel={() => {
|
||
|
|
setModalVisible(false);
|
||
|
|
setCurrentRow(undefined);
|
||
|
|
}}
|
||
|
|
jobFairType={jobFairType || {}}
|
||
|
|
values={currentRow}
|
||
|
|
></EditCompanyListRow>
|
||
|
|
</Fragment>
|
||
|
|
)
|
||
|
|
}
|
||
|
|
export default ManagementList
|