提交 e298070c 作者: ZhangLingKun

功能:业务案例联调

上级 58189b84
...@@ -132,3 +132,59 @@ export type industryNewsDetailType = InterFunction< ...@@ -132,3 +132,59 @@ export type industryNewsDetailType = InterFunction<
surfaceImg: string; surfaceImg: string;
} }
>; >;
// 案例列表
export type industryCaseListCasePage = InterListFunction<
{
cityCode?: number;
date?: string;
districtCode?: number;
keyword?: string;
provinceCode?: number;
requirementTypeId?: number;
},
{
caseAuthor: string;
caseContents: string;
caseTitle: string;
createTime: string;
id: number;
origin: string;
surfaceImg: null;
updateTime: string;
userAccountId: number;
}
>;
// 添加业务案例
export type industryCaseAddCase = InterFunction<
{
caseAuthor?: string;
caseContents?: string;
caseTitle?: string;
createTime?: string;
id?: number;
origin?: string;
surfaceImg?: string;
updateTime?: string;
userAccountId?: number;
},
NonNullable<unknown>
>;
// 修改业务案例
export type industryCaseUpdateCase = InterFunction<
{
caseAuthor?: string;
caseContents?: string;
caseTitle?: string;
createTime?: string;
id?: number;
origin?: string;
surfaceImg?: string;
updateTime?: string;
userAccountId?: number;
},
NonNullable<unknown>
>;
// 删除业务案例
export type industryCaseDeleteDetails = InterFunction<{ id: number }, NonNullable<unknown>>;
...@@ -12,6 +12,10 @@ import { ...@@ -12,6 +12,10 @@ import {
industryNewsListType, industryNewsListType,
editIndustryNews, editIndustryNews,
industryNewsDetailType, industryNewsDetailType,
industryCaseListCasePage,
industryCaseAddCase,
industryCaseUpdateCase,
industryCaseDeleteDetails,
} from '~/api/interface/resourceManageType'; } from '~/api/interface/resourceManageType';
import axios from '../request'; import axios from '../request';
...@@ -62,4 +66,20 @@ export class ResourceManageAPI { ...@@ -62,4 +66,20 @@ export class ResourceManageAPI {
// 行业新闻-详情 // 行业新闻-详情
static getIndustryNewsDetail: industryNewsDetailType = (params) => static getIndustryNewsDetail: industryNewsDetailType = (params) =>
axios.get('/release/industry-news/details', { params }); axios.get('/release/industry-news/details', { params });
// 案例列表
static industryCaseListCasePage: industryCaseListCasePage = (params) =>
axios.post('/release/industry-case/listCasePage', params);
// 添加业务案例
static industryCaseAddCase: industryCaseAddCase = (params) =>
axios.post('/release/industry-case/addCase', params);
// 修改业务案例
static industryCaseUpdateCase: industryCaseUpdateCase = (params) =>
axios.post('/release/industry-case/updateCase', params);
// 删除业务案例
static industryCaseDeleteDetails: industryCaseDeleteDetails = (params) =>
axios.get('/release/industry-case/deleteDetails', { params });
} }
...@@ -6,13 +6,17 @@ import { CommonAPI } from '~/api'; ...@@ -6,13 +6,17 @@ import { CommonAPI } from '~/api';
let editor: any = null; let editor: any = null;
interface PropsType { interface PropsType {
onChange: (html?: string) => void; onChange?: (html?: string) => void;
value: string | undefined; value: string | undefined;
// eslint-disable-next-line react/require-default-props // eslint-disable-next-line react/require-default-props
isDetail?: boolean; isDetail?: boolean;
height?: number; height?: number;
} }
const RichText: React.FC<PropsType> = ({ onChange, value, isDetail, height }) => { const RichText: React.FC<PropsType> = ({ onChange, value, isDetail, height }) => {
RichText.defaultProps = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
onChange: () => {},
};
useEffect(() => { useEffect(() => {
// 注:class写法需要在componentDidMount 创建编辑器 // 注:class写法需要在componentDidMount 创建编辑器
editor = new E('.edit'); editor = new E('.edit');
...@@ -38,9 +42,9 @@ const RichText: React.FC<PropsType> = ({ onChange, value, isDetail, height }) => ...@@ -38,9 +42,9 @@ const RichText: React.FC<PropsType> = ({ onChange, value, isDetail, height }) =>
}; };
editor.config.onchange = (newHtml: string) => { editor.config.onchange = (newHtml: string) => {
if (newHtml) { if (newHtml) {
onChange(newHtml); onChange?.(newHtml);
} else { } else {
onChange(undefined); onChange?.(undefined);
} }
}; };
......
import { FC, useEffect } from 'react';
import { Form, Input, message, Modal } from 'antd';
import { InterListType, InterReqType } from '~/api/interface';
import { industryCaseAddCase, industryCaseListCasePage } from '~/api/interface/resourceManageType';
import { ResourceManageAPI } from '~/api';
import RichText from '~/components/richText';
// 列表的类型
type TableType = InterListType<industryCaseListCasePage>;
// 请求的表单类型
type ReqType = InterReqType<industryCaseAddCase>;
// 传参类型
interface propType {
title: string;
open: boolean;
closed: any;
data?: TableType[0];
}
const AddEditModal: FC<propType> = (props) => {
AddEditModal.defaultProps = {
data: undefined,
};
// 参数
const { title, open, closed, data } = props;
// 表单钩子
const [form] = Form.useForm<ReqType>();
// 关闭弹窗
const handleCancel = () => {
form.resetFields();
closed();
};
// 确认事件
const handleOk = () => {
form
.validateFields()
.then(async (values) => {
await handleSubmit(values as ReqType & { file: any[] });
})
.catch((err) => {
message
.warning({
content: err.errorFields[0].errors[0],
})
.then();
});
};
// 提交事件
const handleSubmit = async (values: ReqType) => {
const res = await ResourceManageAPI[
data?.id ? 'industryCaseUpdateCase' : 'industryCaseAddCase'
]({
...values,
id: data?.id ? Number(data?.id) : undefined,
});
if (res && res.code === '200') {
message.success('操作成功');
handleCancel();
}
};
// componentDidMount
useEffect(() => {
if (!open) return;
if (!data) return;
form.setFieldsValue(data);
// console.log('data --->', data);
}, [open]);
return (
<Modal
open={open}
title={title}
onCancel={handleCancel}
onOk={handleOk}
destroyOnClose
width={768}
>
<Form
name='Form'
form={form}
labelAlign='right'
labelCol={{ span: 3 }}
wrapperCol={{ span: 20 }}
>
<Form.Item
label='文章标题'
name='caseTitle'
rules={[{ required: true, message: '请输入文章标题' }]}
>
<Input placeholder={'请输入文章标题'} maxLength={50} allowClear />
</Form.Item>
<Form.Item
label='文章来源'
name='origin'
rules={[{ required: true, message: '请输入文章来源' }]}
>
<Input placeholder={'请输入文章来源'} maxLength={50} allowClear />
</Form.Item>
<Form.Item
label='文章详情'
name='caseContents'
rules={[{ required: true, message: '请输入文章详情' }]}
>
<RichText
value={form.getFieldValue('caseContents')}
onChange={(e) => form.setFieldValue('caseContents', e)}
height={250}
/>
</Form.Item>
</Form>
</Modal>
);
};
export default AddEditModal;
import { FC, useEffect } from 'react';
import { Modal } from 'antd';
import { InterListType } from '~/api/interface';
import { industryCaseListCasePage } from '~/api/interface/resourceManageType';
import RichText from '~/components/richText';
// 列表的类型
type TableType = InterListType<industryCaseListCasePage>;
// 传参类型
interface propType {
title: string;
open: boolean;
closed: any;
data?: TableType[0];
}
const PreviewModal: FC<propType> = (props) => {
PreviewModal.defaultProps = {
data: undefined,
};
// 参数
const { title, open, closed, data } = props;
// 关闭弹窗
const handleCancel = () => {
closed();
};
// componentDidMount
useEffect(() => {
if (!open) return;
if (!data) return;
// console.log('data --->', data);
}, [open]);
return (
<Modal
open={open}
title={title}
onCancel={handleCancel}
destroyOnClose
width={768}
footer={null}
>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'flex-start',
flexDirection: 'column',
}}
>
<div style={{ fontSize: '20px', fontWeight: 'bold' }}>{data?.caseTitle}</div>
<div style={{ fontSize: '15px', marginBottom: '10px' }}>{data?.createTime}</div>
</div>
<RichText value={data?.caseContents} height={350} isDetail={true} />
</Modal>
);
};
export default PreviewModal;
import { useEffect, useState } from 'react';
import SearchBox from '~/components/search-box';
import { Button, message, Modal, Table } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { InterListType, InterReqListType } from '~/api/interface';
import { ResourceManageAPI } from '~/api';
import { industryCaseListCasePage } from '~/api/interface/resourceManageType';
import { ColumnsType } from 'antd/es/table';
import AddEditModal from '~/pages/resourceManage/businessCaseManage/comp/addEditModal';
import PreviewModal from '~/pages/resourceManage/businessCaseManage/comp/previewModal';
// 列表类型
type TableType = InterListType<industryCaseListCasePage>;
// 请求的参数
type ReqType = InterReqListType<industryCaseListCasePage>;
// 搜索表单的数据
let query: ReqType = {};
const BusinessCaseManage = () => {
const { confirm } = Modal;
// 新增弹窗
const [addModalVisible, setAddModalVisible] = useState<boolean>(false);
// 预览弹窗
const [previewVisible, setPreviewVisible] = useState<boolean>(false);
// 需要编辑的数据
const [editData, setEditData] = useState<TableType[0]>();
// 表格数据
const [tableData, setTableData] = useState<TableType>([]);
// 表格分页配置
const [pagination, setPagination] = useState({
total: 0,
pageSize: 10,
current: 1,
totalPage: 0,
});
// 加载列表
const getTableList = async (value = {}) => {
// 只需要修改这个地方的接口即可
const res = await ResourceManageAPI.industryCaseListCasePage({
pageNo: pagination.current,
pageSize: pagination.pageSize,
...value,
...query,
});
if (res && res.code === '200') {
const { list, pageNo, totalCount, pageSize, totalPage } = res.result; // 解构
setPagination({
total: totalCount,
current: pageNo,
pageSize,
totalPage,
});
setTableData(list);
}
};
// 翻页
const paginationChange = (pageNo: number, pageSize: number) => {
getTableList({ pageNo, pageSize }).then();
};
// 表单提交
const onFinish = (data: ReqType) => {
pagination.current = 1;
query = data;
getTableList(data).then();
};
// 删除数据
const handleDelete = (record: TableType[0]) => {
confirm({
title: '提示',
content: '是否删除该记录?',
onOk: async () => {
const res = await ResourceManageAPI.industryCaseDeleteDetails({ id: record.id });
if (res && res.code === '200') {
message.success('删除成功');
paginationChange(
tableData.length === 1 ? pagination.current - 1 : pagination.current,
pagination.pageSize,
);
}
},
});
};
// componentDidMount
useEffect(() => {
query = {};
getTableList().then();
}, []);
// 表格结构
const columns: ColumnsType<TableType[0]> = [
{
title: '序号',
dataIndex: 'accountNo',
align: 'center',
width: '50px',
render: (_text, _record, index) => (pagination.current - 1) * pagination.pageSize + index + 1,
},
{
title: '文章名称',
dataIndex: 'caseTitle',
align: 'center',
ellipsis: true,
},
{
title: '发布时间',
dataIndex: 'updateTime',
align: 'center',
render: (text, record) => text || record.createTime,
},
{
title: '来源',
dataIndex: 'origin',
align: 'center',
},
{
title: '操作',
dataIndex: 'action',
align: 'center',
width: '150px',
fixed: 'right',
render: (_text, record) => (
<>
<Button
type={'link'}
onClick={() => {
setEditData(JSON.parse(JSON.stringify(record)));
setAddModalVisible(true);
}}
>
编辑
</Button>
<Button
type={'link'}
onClick={() => {
setEditData(JSON.parse(JSON.stringify(record)));
setPreviewVisible(true);
}}
>
预览
</Button>
<Button type={'link'} danger onClick={() => handleDelete(record)}>
删除
</Button>
</>
),
},
];
return (
<>
<SearchBox
search={[
{ name: 'keyword', label: '文章名称', type: 'input', placeholder: '请输入文章名称' },
]}
child={
<>
<Button
type={'primary'}
icon={<PlusOutlined />}
onClick={() => {
setAddModalVisible(true);
}}
>
新增
</Button>
</>
}
searchData={onFinish}
/>
<Table
size='small'
dataSource={tableData}
columns={columns}
rowKey='id'
// scroll={{ x: 1500 }}
bordered
pagination={{
total: pagination.total,
pageSize: pagination.pageSize,
current: pagination.current,
showSizeChanger: true,
showQuickJumper: true,
onChange: (page: number, pageSize: number) => paginationChange(page, pageSize),
showTotal: (total, range) => `当前 ${range[0]}-${range[1]} 条记录 / 共 ${total} 条数据`,
}}
/>
<AddEditModal
open={addModalVisible}
title={editData?.id ? '编辑' : '新增'}
data={editData}
closed={() => {
setAddModalVisible(false);
setEditData(undefined);
paginationChange(pagination.current, pagination.pageSize);
}}
/>
<PreviewModal
open={previewVisible}
title={editData?.id ? '预览' : '新增'}
data={editData}
closed={() => {
setPreviewVisible(false);
setEditData(undefined);
paginationChange(pagination.current, pagination.pageSize);
}}
/>
</>
);
};
export default BusinessCaseManage;
...@@ -78,8 +78,8 @@ const AddEditDetailModal: React.FC<propType> = (props) => { ...@@ -78,8 +78,8 @@ const AddEditDetailModal: React.FC<propType> = (props) => {
name='Form' name='Form'
form={form} form={form}
labelAlign='right' labelAlign='right'
labelCol={{ span: 4 }} labelCol={{ span: 2 }}
wrapperCol={{ span: 20 }} wrapperCol={{ span: 21 }}
> >
<Form.Item <Form.Item
label='标题' label='标题'
......
...@@ -153,7 +153,7 @@ const TenderManageView = () => { ...@@ -153,7 +153,7 @@ const TenderManageView = () => {
<> <>
<SearchBox <SearchBox
search={[ search={[
{ name: 'keywords', label: '名称', type: 'input', placeholder: '请输入招标快讯名称' }, { name: 'tenderName', label: '名称', type: 'input', placeholder: '请输入招标快讯名称' },
{ {
name: 'rangeTime', name: 'rangeTime',
label: '发布时间', label: '发布时间',
......
...@@ -3,10 +3,7 @@ import { Navigate, RouteObject } from 'react-router-dom'; ...@@ -3,10 +3,7 @@ import { Navigate, RouteObject } from 'react-router-dom';
import ErrorPage from '~/pages/common/error'; import ErrorPage from '~/pages/common/error';
import LayoutView from '~/components/layout'; import LayoutView from '~/components/layout';
import { import {
// AccountBookOutlined,
MacCommandOutlined, MacCommandOutlined,
// GiftOutlined,
// PayCircleOutlined,
BarsOutlined, BarsOutlined,
ShoppingOutlined, ShoppingOutlined,
ShopOutlined, ShopOutlined,
...@@ -28,6 +25,7 @@ import { ...@@ -28,6 +25,7 @@ import {
SketchOutlined, SketchOutlined,
DribbbleOutlined, DribbbleOutlined,
MessageOutlined, MessageOutlined,
AliwangwangOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
...@@ -101,6 +99,7 @@ import AccountManageView from '~/pages/systemManage/accountManage'; ...@@ -101,6 +99,7 @@ import AccountManageView from '~/pages/systemManage/accountManage';
import TenderManageView from '~/pages/resourceManage/tenderManage'; import TenderManageView from '~/pages/resourceManage/tenderManage';
import TenderManageDetail from '~/pages/resourceManage/tenderManage/detail'; import TenderManageDetail from '~/pages/resourceManage/tenderManage/detail';
import TenderManageFeedback from '~/pages/resourceManage/tenderManage/feedback'; import TenderManageFeedback from '~/pages/resourceManage/tenderManage/feedback';
import BusinessCaseManage from '~/pages/resourceManage/businessCaseManage';
// const IndustryListView = React.lazy(() => import('~/pages/mallManage/industryManage/industryList')); //行业列表 // const IndustryListView = React.lazy(() => import('~/pages/mallManage/industryManage/industryList')); //行业列表
// const IndustryDetailView = React.lazy( // const IndustryDetailView = React.lazy(
...@@ -277,7 +276,7 @@ export const routerList: Array<RouteObjectType> = [ ...@@ -277,7 +276,7 @@ export const routerList: Array<RouteObjectType> = [
path: '/resourceManage/tenderManage/detail', path: '/resourceManage/tenderManage/detail',
element: withLoadingComponent(<TenderManageDetail />), element: withLoadingComponent(<TenderManageDetail />),
meta: { meta: {
id: 30200, id: 30500,
title: '招标快讯详情', title: '招标快讯详情',
icon: <CoffeeOutlined />, icon: <CoffeeOutlined />,
hidden: true, hidden: true,
...@@ -287,12 +286,21 @@ export const routerList: Array<RouteObjectType> = [ ...@@ -287,12 +286,21 @@ export const routerList: Array<RouteObjectType> = [
path: '/resourceManage/tenderManage/feedback', path: '/resourceManage/tenderManage/feedback',
element: withLoadingComponent(<TenderManageFeedback />), element: withLoadingComponent(<TenderManageFeedback />),
meta: { meta: {
id: 30200, id: 30500,
title: '用户反馈', title: '用户反馈',
icon: <CoffeeOutlined />, icon: <CoffeeOutlined />,
hidden: true, hidden: true,
}, },
}, },
{
path: '/resourceManage/businessCaseManage',
element: withLoadingComponent(<BusinessCaseManage />),
meta: {
id: 30600,
title: '业务案例',
icon: <AliwangwangOutlined />,
},
},
], ],
}, },
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论