提交 5ee04d42 作者: ZhangLingKun

功能:宣传中心新增有效期限

上级 b28bc339
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Form, Input, message, Modal, Select } from 'antd'; import { DatePicker, Form, Input, message, Modal, Select, Space } from 'antd';
import { InterListType, InterReqType } from '~/api/interface'; import { InterListType, InterReqType } from '~/api/interface';
import { insertBannerInfo, listBannerInfoPage } from '~/api/interface/commonType'; import { insertBannerInfo, listBannerInfoPage } from '~/api/interface/commonType';
import { CommonAPI } from '~/api'; import { CommonAPI } from '~/api';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { Uploader } from '~/components/uploader'; import { Uploader } from '~/components/uploader';
import RichText from '~/components/richText'; import RichText from '~/components/richText';
import dayjs from 'dayjs';
// 列表的类型 // 列表的类型
type TableType = InterListType<listBannerInfoPage>; type TableType = InterListType<listBannerInfoPage>;
...@@ -45,6 +46,8 @@ const AddEditModal: React.FC<propType> = (props) => { ...@@ -45,6 +46,8 @@ const AddEditModal: React.FC<propType> = (props) => {
const [form] = Form.useForm<ReqType>(); const [form] = Form.useForm<ReqType>();
// 上传图片 // 上传图片
const [bannerTypeValue, setBannerTypeValue] = useState(0); const [bannerTypeValue, setBannerTypeValue] = useState(0);
// 是否有效
const [validTime, setValidTime] = useState<number>(0);
// 关闭弹窗 // 关闭弹窗
const handleCancel = () => { const handleCancel = () => {
setBannerTypeValue(0); setBannerTypeValue(0);
...@@ -56,7 +59,7 @@ const AddEditModal: React.FC<propType> = (props) => { ...@@ -56,7 +59,7 @@ const AddEditModal: React.FC<propType> = (props) => {
form form
.validateFields() .validateFields()
.then(async (values) => { .then(async (values) => {
await handleSubmit(values); await handleSubmit(values as ReqType & { timeRange: string[] });
}) })
.catch((err) => { .catch((err) => {
message message
...@@ -67,9 +70,15 @@ const AddEditModal: React.FC<propType> = (props) => { ...@@ -67,9 +70,15 @@ const AddEditModal: React.FC<propType> = (props) => {
}); });
}; };
// 提交事件 // 提交事件
const handleSubmit = async (values: ReqType) => { const handleSubmit = async (values: ReqType & { timeRange: string[] }) => {
const res = await CommonAPI[data?.id ? 'updateBannerInfo' : 'insertBannerInfo']({ const res = await CommonAPI[data?.id ? 'updateBannerInfo' : 'insertBannerInfo']({
...values, ...values,
startTime: values.timeRange
? dayjs(values.timeRange[0]).format('YYYY-MM-DD HH:mm:ss')
: undefined,
endTime: values.timeRange
? dayjs(values.timeRange[1]).format('YYYY-MM-DD HH:mm:ss')
: undefined,
moduleId, moduleId,
id: data?.id, id: data?.id,
}); });
...@@ -112,6 +121,39 @@ const AddEditModal: React.FC<propType> = (props) => { ...@@ -112,6 +121,39 @@ const AddEditModal: React.FC<propType> = (props) => {
allowClear allowClear
/> />
</Form.Item> </Form.Item>
<Form.Item label='有效时间' required wrapperCol={{ span: 18 }}>
<Space.Compact>
<Form.Item
name={'validTime'}
noStyle
rules={[{ required: true, message: '请选择是否有效' }]}
initialValue={0}
>
<Select
placeholder='请选择是否有效'
options={[
{ label: '永久有效', value: 0 },
{ label: '有效期限', value: 1 },
]}
style={{ width: '30%' }}
value={validTime}
onChange={(e) => {
setValidTime(e);
}}
/>
</Form.Item>
<Form.Item
name={'timeRange'}
noStyle
rules={[{ required: validTime === 1, message: '请选择有效期限' }]}
>
<DatePicker.RangePicker
showTime={{ format: 'HH:mm:ss' }}
format='YYYY-MM-DD HH:mm:ss'
/>
</Form.Item>
</Space.Compact>
</Form.Item>
<Form.Item <Form.Item
label='封面图' label='封面图'
name='bannerImg' name='bannerImg'
......
...@@ -17,10 +17,11 @@ interface propType { ...@@ -17,10 +17,11 @@ interface propType {
} }
// 所属产品 // 所属产品
const moduleType = [ const moduleType = [
{ label: '云享飞', value: 0 }, { label: '云享飞Pro', value: 0 },
{ label: '云飞手', value: 1 }, { label: '云享飞Web', value: 1 },
{ label: '云仓', value: 2 }, // { label: '云飞手', value: 1 },
{ label: '无人机城', value: 3 }, // { label: '云仓', value: 2 },
// { label: '无人机城', value: 3 },
]; ];
const AddModuleModal: React.FC<propType> = (props) => { const AddModuleModal: React.FC<propType> = (props) => {
......
...@@ -17,10 +17,11 @@ type ReqType = InterReqListType<listBannerInfoPage>; ...@@ -17,10 +17,11 @@ type ReqType = InterReqListType<listBannerInfoPage>;
let query: ReqType = {}; let query: ReqType = {};
// 所属产品 // 所属产品
const moduleType = [ const moduleType = [
{ label: '云享飞', value: '0' }, { label: '云享飞Pro', value: 0 },
{ label: '云飞手', value: '1' }, { label: '云享飞Web', value: 1 },
{ label: '云仓', value: '2' }, // { label: '云飞手', value: '1' },
{ label: '无人机城', value: '3' }, // { label: '云仓', value: '2' },
// { label: '无人机城', value: '3' },
]; ];
// 详情类型 // 详情类型
const bannerType = [ const bannerType = [
...@@ -254,6 +255,23 @@ const MaterielManageDetail = () => { ...@@ -254,6 +255,23 @@ const MaterielManageDetail = () => {
render: (text) => (text === 1 ? '上架' : '下架'), render: (text) => (text === 1 ? '上架' : '下架'),
}, },
{ {
title: '有效时间',
dataIndex: 'createTime',
align: 'center',
width: '120px',
ellipsis: true,
render: (_text, record) =>
record.startTime && record.endTime ? (
<>
<div>{record?.startTime}</div>
<div></div>
<div>{record?.endTime}</div>
</>
) : (
'永久'
),
},
{
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
align: 'center', align: 'center',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论