Commit 8982efb4 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 3b0b4785 8d98d4ea
......@@ -15,6 +15,7 @@ const Roles: React.FC = () => {
useEffect(() => {
const userInfo = getAuth() || {};
console.log(userInfo, 10086)
setRoles(userInfo.roles || []);
if (userInfo.roles && userInfo.roles.length) {
......
......@@ -19,7 +19,7 @@ export interface ListLayoutIProps {
/** 是否不发送请求 */
done?: boolean,
/** 展示的数据 */
data?: [],
data?: any[],
/** ids */
ids?: Object,
}
......
import React from 'react';
import { Tooltip, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const levelList = {
1: '一等奖',
2: '二等奖',
3: '二等奖',
4: '四等奖',
5: '五等奖',
6: '六等奖'
}
const typeList = {
1: '商品',
2: '优惠卷',
3: '现金',
4: '积分',
5: '谢谢参与',
}
const columns_9 = () => {
return (
[
{
title: '奖项等级',
key: 'level',
dataIndex: 'level',
width: 240,
render: (_text) => <Typography.Text>{levelList[_text]}</Typography.Text>
},
{
title: '奖品类别',
key: 'type',
dataIndex: 'type',
width: 240,
render: (_text) => <Typography.Text>{typeList[_text]}</Typography.Text>
},
{
title: <Tooltip placement="top" title="中奖概率为当前奖项等级的中奖概率,如设置一等奖的中奖概率为10%,则表示用户抽中一等奖的概率是10%">
中奖概率 <QuestionCircleOutlined />
</Tooltip>,
key: 'probability',
dataIndex: 'probability',
width: 176,
render: (_text) => <Typography.Text>{_text}&nbsp;%</Typography.Text>
},
{
title: '奖品',
key: 'prize',
dataIndex: 'prize',
render: (_text, record) => (
<>
{
record.type === 3 ? <Typography.Text>{Number(_text).toFixed(2)}&nbsp;</Typography.Text> :
record.type === 4 ? <Typography.Text>{_text}&nbsp;积分</Typography.Text> :
record.type === 5 ? '无' :
<Typography.Text>{_text}</Typography.Text>
}
</>
)
},
]
)
}
export default columns_9
......@@ -7,6 +7,7 @@ import columns_6 from './columns_4';
import columns_7 from './columns_4';
import columns_8 from './columns_4';
import columns_9 from './columns_5';
import columns_10 from './columns_9';
import columns_11 from './columns_6';
import columns_12 from './columns_7';
import columns_13 from './columns_4';
......@@ -24,6 +25,7 @@ export const Columns = {
7: columns_7,
8: columns_8,
9: columns_9,
10: columns_10,
11: columns_11,
12: columns_12,
13: columns_13,
......
import React from 'react';
import { Space, Tooltip } from 'antd';
import { Space, Tooltip, Typography } from 'antd';
import StatusTag from '@/components/StatusTag';
import { format } from '@/pages/transaction/common/dateFormat';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -261,7 +261,14 @@ export const GeneralEffect = (int, data) => {
return [
{
col: [
{ label: '抽奖类型', extra: '' },
{
label: '抽奖类型', extra: <Space direction='vertical'>
{data.lotteryType === 1 && (<><StatusTag type="default" title='订单抽奖' /><Typography.Text>订单金额满 {data.orderPrice.toFixed(2)} 元且支付成功后参与抽奖</Typography.Text></>)}
{data.lotteryType === 2 && (<><StatusTag type="default" title='积分抽奖' /><Typography.Text>每次抽奖消耗 {data.integral} 积分</Typography.Text></>)}
{data.lotteryType === 3 && (<><StatusTag type="default" title='行为抽奖' /><Typography.Text>用户完成 “{data.behavior === 1 ? '申请会员' : '签到'}” 时参与抽奖</Typography.Text></>)}
{data.lotteryType === 4 && <StatusTag type="default" title='活动抽奖' />}
</Space>
},
{ label: '抽奖次数', extra: `${lotteryNumType[data.lotteryNumType]}限制${data.lotteryNum}次` },
{ label: '活动描述', extra: data.describe }
]
......@@ -286,7 +293,7 @@ export const GeneralEffect = (int, data) => {
return [
{
col: [
{ label: '每日秒杀时间段', extra: <>{format(data.startTime, 'HH:mm:ss')}~{format(data.endTime, 'HH:mm:ss')}</>},
{ label: '每日秒杀时间段', extra: <>{format(data.startTime, 'HH:mm:ss')}~{format(data.endTime, 'HH:mm:ss')}</> },
{ label: '活动描述', extra: data.describe }
]
},
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_1 = ({
......@@ -30,9 +30,10 @@ const columns_1 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_2 = ({
......@@ -41,9 +41,10 @@ const columns_2 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_3 = ({
......@@ -38,9 +38,10 @@ const columns_3 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Image, Form, Input, Popconfirm, Button } from 'antd';
import { Image, Form, Input, Popconfirm, Button, Typography } from 'antd';
const columns_4 = ({
dataSource,
......@@ -30,9 +30,10 @@ const columns_4 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Image, Form, Input, Popconfirm } from 'antd';
import { Image, Form, Input, Popconfirm, Typography } from 'antd';
const columns_5 = ({
dataSource,
......@@ -28,9 +28,10 @@ const columns_5 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_6 = ({
......@@ -29,9 +29,10 @@ const columns_6 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_7 = ({
......@@ -30,9 +30,10 @@ const columns_7 = ({
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
title: '商品ID',
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: '商品图片',
......
......@@ -68,16 +68,88 @@ const columns_8 = ({
title: '预售价格',
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${index}`}
rules={[{
required: true,
message: '请输入预售价格'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '单位定金',
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${index}`}
rules={[{
required: true,
message: '请输入单位定金'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'activityPrice', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '定金抵扣单价',
key: 'activityPrice',
dataIndex: 'activityPrice',
key: 'deductionPrice',
dataIndex: 'deductionPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`deductionPrice_${index}`}
rules={[{
required: true,
message: '请输入定金抵扣单价'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'deductionPrice', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '个人限购数量',
......
......@@ -3,32 +3,24 @@ import { Button } from 'antd';
import { history } from 'umi';
import { Context } from '@/pages/transaction/components/detailLayout/components/context';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
import { _data } from './data';
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import moment from 'moment';
import { useEffect } from 'react';
import { ACTIVITYTYPENAME, GeneralEffect } from './constants';
import { ACTIVITYTYPENAME, GeneralEffect } from '../../common/constants';
import ActivityUserLayout from '../../components/activityUserLayout';
import DemandLayout from '../../components/demandLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import { Columns } from './columns';
import { Columns } from '../../common/columns';
import { PublicApi } from '@/services/api';
import { isEmpty } from 'lodash';
import { CheckCircleOutlined } from '@ant-design/icons';
import ModalOperate from '@/pages/transaction/components/modalOperate';
const TABLINK = [
{ id: 'progressLayout', title: '流转进度' },
{ id: 'basicLayout', title: '基本信息' },
{ id: 'activityRuleLayout', title: '活动规则' },
{ id: 'activityProductLayout', title: '活动商品' },
{ id: 'activityUserLayout', title: '活动用户' },
{ id: 'applyMallLayout', title: '适用商城' },
{ id: 'recordLyout', title: '流转记录' },
]
import { remindLayout, RemindLayoutProps } from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/productListLayout/remind';
import ListModalLayout from '../../components/listModalLayout';
import CouponsListLayout from '../../components/couponsListLayout';
const DetialLayout = () => {
const { query: { activityId, signUpId }, pathname } = history.location;
......@@ -41,7 +33,10 @@ const DetialLayout = () => {
const [dataSource, setDataSource] = useState<any>({});
const [basicEffect, setBasicEffect] = useState<any>([]);
const [generalEffect, setGeneralEffect] = useState<any>([]);
const [value, setValue] = useState<number>(1);
const [collocation, setCollocation] = useState<any[]>([]);
const [listModalVisible, setListModalVisible] = useState<boolean>(false);
const [remind, setRemind] = useState<RemindLayoutProps>({});
const handleBasicEffect = (data: any) => {
setBasicEffect([
......@@ -92,20 +87,34 @@ const DetialLayout = () => {
})
})
data.externalLogStates = externalLogStates;
if (data.activityType === 6) {
setRemind(remindLayout(data.activityType, data.activityDefined.giveType, data.activityDefined.giftType));
}
if (data.activityType === 13) {
setRemind(remindLayout(data.activityType, data.activityDefined.swapType));
}
if (data.activityType === 15) {
setRemind(remindLayout(data.activityType));
}
setDataSource(data);
handleBasicEffect(data)
handleGeneralEffect(data.activityDefinedBO, data.activityType)
handleBasicEffect(data);
setValue(data.activityType);
handleGeneralEffect(data.activityDefined, data.activityType);
}).catch(() => { })
}, [])
useEffect(() => {
fetchDataSource();
// handleGeneralEffect(_data);
}, [])
const handlCollocation = (val) => {
setCollocation(val.goodsSubsidiaryGroupList);
setListModalVisible(true)
}
const columns = useMemo(() => {
return Columns(dataSource.activityType || 1)
}, [dataSource.activityType])
return Columns[value]?.({ value, handlCollocation })
}, [value])
const fetchLink = () => {
let fetchSoure: any = null;
......@@ -125,7 +134,15 @@ const DetialLayout = () => {
<PeripheralLayout
no={dataSource.activityId}
detail={dataSource.activityName}
tabLink={TABLINK}
tabLink={[
{ id: 'progressLayout', title: '流转进度' },
{ id: 'basicLayout', title: '基本信息' },
{ id: 'activityRuleLayout', title: '活动规则' },
{ id: 'activityProductLayout', title: '活动商品' },
{ id: 'activityUserLayout', title: '活动用户' },
{ id: 'applyMallLayout', title: '适用商城' },
{ id: 'recordLyout', title: '流转记录' },
]}
effect={
<>
{path === 'detail'
......@@ -173,6 +190,28 @@ const DetialLayout = () => {
onCancel={() => setVisible(false)}
onOk={() => history.goBack()}
/>
{/* 查看搭配商品 */}
{(!isEmpty(remind) && remind.value === 1) && (
<ListModalLayout
title={remind.modalTitle}
remind={remind}
visible={listModalVisible}
value={collocation}
isPreview
onClose={() => setListModalVisible(false)}
/>
)}
{/* 查看优惠券 */}
{(!isEmpty(remind) && remind.value !== 1) && (
<CouponsListLayout
title={remind.modalTitle}
remind={remind}
visible={listModalVisible}
value={collocation}
isPreview
onClose={() => setListModalVisible(false)}
/>
)}
</Context.Provider>
)
}
......
import React, { useCallback, useState } from 'react';
import React, { useState } from 'react';
import { Button, Form } from 'antd';
import { history, Prompt } from 'umi';
import { useEventEmitter } from '@umijs/hooks';
import { Context } from '@/pages/transaction/components/detailLayout/components/context';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
......@@ -31,7 +30,7 @@ const TABLINK = [
const DetialLayout = () => {
const { query: { activityId, signUpId }, pathname } = history.location;
const [path] = useState(pathname.split('/')[pathname.split('/').length - 1]);
const focus$ = useEventEmitter();
const [value, setValue] = useState<number>(1);
const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(false)
const [unsaved, setUnsaved] = useState<boolean>(false);
......@@ -95,8 +94,7 @@ const DetialLayout = () => {
})
})
data.externalLogStates = externalLogStates;
const option: any = { value: data.activityType };
focus$.emit(option)
setValue(data.activityType)
setDataSource(data);
handleBasicEffect(data);
setShopIdList(data.shopList.map(item => { return item.shopId }));
......@@ -185,7 +183,7 @@ const DetialLayout = () => {
anchor="activityRuleLayout"
effect={generalEffect}
/>
<ProductListLayout getActivityDefinedBO={activityDefinedBO} activityId={signUpIds && { signUpId: signUpIds }} form={form} focus$={focus$} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingPlatformActivitySignupDetailGoodsPage} />
<ProductListLayout getActivityDefinedBO={activityDefinedBO} activityId={signUpIds && { signUpId: signUpIds }} form={form} focus$={value} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingPlatformActivitySignupDetailGoodsPage} />
<ActivityUserLayout dataScoure={dataSource} />
<DemandLayout storeList={dataSource.shopList} />
<RecordLyout />
......
......@@ -9,7 +9,7 @@ import RecordLyout from '@/pages/transaction/components/detailLayout/components/
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import moment from 'moment';
import { useEffect } from 'react';
import { ACTIVITYTYPENAME, GeneralEffect } from './constants';
import { ACTIVITYTYPENAME, GeneralEffect } from '../../common/constants';
import ActivityUserLayout from '../../components/activityUserLayout';
import DemandLayout from '../../components/demandLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
......@@ -21,16 +21,7 @@ import ModalOperate from '@/pages/transaction/components/modalOperate';
import ListModalLayout from '../../components/listModalLayout';
import CouponsListLayout from '../../components/couponsListLayout';
import { remindLayout, RemindLayoutProps } from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/productListLayout/remind';
const TABLINK = [
{ id: 'progressLayout', title: '流转进度' },
{ id: 'basicLayout', title: '基本信息' },
{ id: 'activityRuleLayout', title: '活动规则' },
{ id: 'activityProductLayout', title: '活动商品' },
{ id: 'activityUserLayout', title: '活动用户' },
{ id: 'applyMallLayout', title: '适用商城' },
{ id: 'recordLyout', title: '流转记录' },
]
import PrizeList from './prizeList';
const DetialLayout = () => {
const { query: { id }, pathname } = history.location;
......@@ -48,6 +39,7 @@ const DetialLayout = () => {
const [remind, setRemind] = useState<RemindLayoutProps>({});
const [collocation, setCollocation] = useState<any[]>([]);
const [listModalVisible, setListModalVisible] = useState<boolean>(false);
const [prizeList, setPrizeList] = useState<any[]>([]);
const handleBasicEffect = (data: any) => {
setBasicEffect([
......@@ -170,10 +162,10 @@ const DetialLayout = () => {
}
])
if (data.activityType === 6) {
setRemind(remindLayout(data.activityType, data.activityDefinedBO.giveType, data.activityDefinedBO.giftType));
setRemind(remindLayout(data.activityType, data.activityDefined.giveType, data.activityDefined.giftType));
}
if (data.activityType === 13) {
setRemind(remindLayout(data.activityType, data.activityDefinedBO.swapType));
setRemind(remindLayout(data.activityType, data.activityDefined.swapType));
}
if (data.activityType === 15) {
setRemind(remindLayout(data.activityType));
......@@ -181,7 +173,10 @@ const DetialLayout = () => {
setDataSource(data);
handleBasicEffect(data)
setValue(data.activityType)
handleGeneralEffect(data.activityDefinedBO, data.activityType)
if (data.activityDefined?.prizeList) {
setPrizeList(data.activityDefined.prizeList)
}
handleGeneralEffect(data.activityDefined, data.activityType)
}).catch(() => { })
}, [])
......@@ -216,7 +211,15 @@ const DetialLayout = () => {
<PeripheralLayout
no={dataSource.activityId}
detail={dataSource.activityName}
tabLink={TABLINK}
tabLink={[
{ id: 'progressLayout', title: '流转进度' },
{ id: 'basicLayout', title: '基本信息' },
{ id: 'activityRuleLayout', title: '活动规则' },
{ id: 'activityProductLayout', title: value === 10 ? '奖品' : '活动商品' },
{ id: 'activityUserLayout', title: '活动用户' },
{ id: 'applyMallLayout', title: '适用商城' },
{ id: 'recordLyout', title: '流转记录' },
]}
effect={
<>
{path === 'detail'
......@@ -235,19 +238,9 @@ const DetialLayout = () => {
<Fragment>
<ProgressLayout />
<BasicLayout effect={basicEffect} />
<GeneralLayout
visible
title={`活动规则-${ACTIVITYTYPENAME[dataSource.activityType]}`}
anchor="activityRuleLayout"
effect={generalEffect}
/>
<ListLayout
anchor="activityProductLayout"
ids={id !== 'null' && { activityId: id }}
title="活动商品"
fetch={PublicApi.getMarketingMerchantActivityDetailGoodsPage}
columns={columns}
/>
<GeneralLayout visible title={`活动规则-${ACTIVITYTYPENAME[dataSource.activityType]}`} anchor="activityRuleLayout" effect={generalEffect} />
{value !== 10 && (<ListLayout anchor="activityProductLayout" ids={id !== 'null' && { activityId: id }} title='活动商品' fetch={PublicApi.getMarketingMerchantActivityDetailGoodsPage} columns={columns} />)}
{value === 10 && (<PrizeList columns={columns} dataSource={prizeList} />)}
<ActivityUserLayout dataScoure={dataSource} allUsers={allUsers} />
<DemandLayout storeList={dataSource.shopList} />
<RecordLyout />
......
import React, { useState, useEffect } from 'react';
import { Table } from 'antd';
import CardLayout from '../readySubmitExamine/components/card';
import { isEmpty } from '@antv/util';
interface PrizeListProps {
/** columns */
columns?: any[],
/** 回显数据 */
dataSource?: any[],
}
const PrizeList: React.FC<PrizeListProps> = (props: any) => {
const { columns, dataSource } = props;
const [data, setData] = useState<any[]>([])
useEffect(() => {
if (!isEmpty(dataSource)) {
setData(dataSource)
}
}, [dataSource])
return (
<CardLayout
id='activityProductLayout'
title='奖品'
weight
>
<Table
rowKey={(record) => record.level}
columns={columns}
dataSource={data}
pagination={{
size: 'small'
}}
/>
</CardLayout>
)
}
export default PrizeList;
......@@ -89,7 +89,7 @@ const AddedMarketing = () => {
form.validateFields().then(res => {
const params: any = {
activityType: res.activityType,
activityDefinedBO: res.activityDefinedBO,
activityDefined: res.activityDefined,
activityName: res.activityName,
startTime: Number(moment(res.startTime).format('x')),
endTime: Number(moment(res.endTime).format('x')),
......@@ -121,20 +121,20 @@ const AddedMarketing = () => {
return item
})
}
if (res['activityDefinedBO']['assembleTime']) {
params['activityDefinedBO'].assembleTime = Number(moment(res['activityDefinedBO']['assembleTime']).format('x'));
if (res['activityDefined']['assembleTime']) {
params['activityDefined'].assembleTime = Number(moment(res['activityDefined']['assembleTime']).format('x'));
}
if (res['activityDefinedBO']['startTime']) {
params['activityDefinedBO']['startTime'] = Number(moment(res['activityDefinedBO']['startTime']).format('x'));
if (res['activityDefined']['startTime']) {
params['activityDefined']['startTime'] = Number(moment(res['activityDefined']['startTime']).format('x'));
}
if (res['activityDefinedBO']['endTime']) {
params['activityDefinedBO']['endTime'] = Number(moment(res['activityDefinedBO']['endTime']).format('x'));
if (res['activityDefined']['endTime']) {
params['activityDefined']['endTime'] = Number(moment(res['activityDefined']['endTime']).format('x'));
}
if (res['activityDefinedBO']['extractAttemptUserTime']) {
params['activityDefinedBO']['extractAttemptUserTime'] = Number(moment(res['activityDefinedBO']['extractAttemptUserTime']).format('x'));
if (res['activityDefined']['extractAttemptUserTime']) {
params['activityDefined']['extractAttemptUserTime'] = Number(moment(res['activityDefined']['extractAttemptUserTime']).format('x'));
}
if (res['activityDefinedBO']['attemptEndTime']) {
params['activityDefinedBO']['attemptEndTime'] = Number(moment(res['activityDefinedBO']['attemptEndTime']).format('x'));
if (res['activityDefined']['attemptEndTime']) {
params['activityDefined']['attemptEndTime'] = Number(moment(res['activityDefined']['attemptEndTime']).format('x'));
}
setLoading(true)
path !== 'add' && (params.id = id);
......@@ -164,27 +164,27 @@ const AddedMarketing = () => {
}
})[0]
focus$.emit(option)
if (data['activityDefinedBO']['assembleTime']) {
data['activityDefinedBO']['assembleTime'] = moment(data['activityDefinedBO']['assembleTime']);
if (data['activityDefined']['assembleTime']) {
data['activityDefined']['assembleTime'] = moment(data['activityDefined']['assembleTime']);
}
if (data['activityDefinedBO']['startTime']) {
data['activityDefinedBO']['startTime'] = moment(data['activityDefinedBO']['startTime']);
if (data['activityDefined']['startTime']) {
data['activityDefined']['startTime'] = moment(data['activityDefined']['startTime']);
}
if (data['activityDefinedBO']['endTime']) {
data['activityDefinedBO']['endTime'] = moment(data['activityDefinedBO']['endTime']);
if (data['activityDefined']['endTime']) {
data['activityDefined']['endTime'] = moment(data['activityDefined']['endTime']);
}
if (data['activityDefinedBO']['extractAttemptUserTime']) {
data['activityDefinedBO']['extractAttemptUserTime'] = moment(data['activityDefinedBO']['extractAttemptUserTime']);
if (data['activityDefined']['extractAttemptUserTime']) {
data['activityDefined']['extractAttemptUserTime'] = moment(data['activityDefined']['extractAttemptUserTime']);
}
if (data['activityDefinedBO']['attemptEndTime']) {
data['activityDefinedBO']['attemptEndTime'] = moment(data['activityDefinedBO']['attemptEndTime']);
if (data['activityDefined']['attemptEndTime']) {
data['activityDefined']['attemptEndTime'] = moment(data['activityDefined']['attemptEndTime']);
}
if (data['activityDefinedBO']['prizeBOList']) {
setPrizeList(data['activityDefinedBO']['prizeBOList'])
if (data['activityDefined']['prizeList']) {
setPrizeList(data['activityDefined']['prizeList'])
}
form.setFieldsValue({
allUser: [data.newUser && 1, data.oldUser && 2, data.newMember && 3, data.oldMember && 4],
activityDefinedBO: data.activityDefinedBO,
activityDefined: data.activityDefined,
activityName: data.activityName,
activityType: data.activityType,
shopList: data.shopList,
......@@ -202,7 +202,7 @@ const AddedMarketing = () => {
focus$.useSubscription((val: any) => {
setValue(val.value)
form.resetFields(['activityDefinedBO']);
form.resetFields(['activityDefined']);
});
return (
......@@ -237,7 +237,7 @@ const AddedMarketing = () => {
}
}}
>
<BasicInfoLayout form={form} focus$={focus$} />
<BasicInfoLayout form={form} focus$={focus$} isEdit={path==='edit' ? true : false} />
<ShopLayout onGetShopList={handleGetShopList} onSetShopList={shopList} />
<RulesLayout form={form} focus$={focus$} />
{value !== 10 && (<ProductListLayout activityId={activityId && { activityId: activityId }} form={form} focus$={value} shopIdList={shopIdList} fieldApi={PublicApi.getMarketingMerchantActivityDetailGoodsPage} />)}
......
......@@ -9,6 +9,8 @@ interface BasicInfoProps {
focus$?: EventEmitter<void>,
/** FormInstance */
form?: FormInstance,
/** 是否编辑 */
isEdit?: boolean,
}
const avtivityTypes = [
......@@ -31,7 +33,7 @@ const avtivityTypes = [
]
const BasicInfoLayout: React.FC<BasicInfoProps> = (props: any) => {
const { focus$, form } = props;
const { focus$, form, isEdit } = props;
const startTimeDisabled = (current, name) => {
const _endTime = form.getFieldValue(name);
if (_endTime) {
......@@ -88,9 +90,9 @@ const BasicInfoLayout: React.FC<BasicInfoProps> = (props: any) => {
label="活动类型"
name="activityType"
initialValue={1}
rules={[{ required: true, message: '请输入活动名称' }]}
rules={[{ required: true, message: '请选择活动类型' }]}
>
<Select onChange={handleChange}>
<Select onChange={handleChange} disabled={isEdit}>
{avtivityTypes.map((item) => <Select.Option key={'ACTIVITY_TYPE' + item.value} value={item.value}>{item.lable}</Select.Option>)}
</Select>
</Form.Item>
......
......@@ -3,6 +3,7 @@
align-items: center;
:global {
.ant-radio-wrapper {width: 100%;}
.ant-checkbox+span,
.ant-radio+span {
flex: 1;
......
......@@ -130,9 +130,21 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
useEffect(() => {
if (!isEmpty(value)) {
const newChekedId = value.list.map((_item: any) => _item.id);
setCheckedId(newChekedId)
setSelectCouponList(value.list)
if (mode === 'checkbox') {
const newChekedId = value.list.map((_item: any) => _item.id);
setCheckedId(newChekedId)
setSelectCouponList(value.list)
} else {
if (value.coupon !== undefined) {
setCheckedId([value.coupon.id])
setSelectCouponList([value.coupon])
form.setFieldsValue({'radio': value.coupon.id })
} else {
setCheckedId([])
setSelectCouponList([])
form.setFieldsValue({'radio': undefined })
}
}
}
}, [value])
......@@ -208,19 +220,24 @@ const CouponsLayout: React.FC<CouponsLayoutProps> = (props: any) => {
</>
)}
{mode === 'radio' && (
<Radio.Group style={{ flex: 1 }} onChange={(_e) => _setRadioList(_e)}>
{couponList.map((item: any, index: number) => {
return (
<Col span={22} key={`Col_${index}`} style={{ marginBottom: 24 }}>
<Radio checked={chekedId.includes(item.id)} value={item.id} data-item={item} className={styles.customsCheckbox}>
<CouponItem
fieldListData={item}
/>
</Radio>
</Col>
)
})}
</Radio.Group>
<Form.Item
style={{ margin: 0, flex: 1 }}
name='radio'
>
<Radio.Group style={{ width: '100%' }} onChange={(_e) => _setRadioList(_e)}>
{couponList.map((item: any, index: number) => {
return (
<Col span={22} key={`Col_${index}`} style={{ marginBottom: 24 }}>
<Radio checked={chekedId.includes(item.id)} value={item.id} data-item={item} className={styles.customsCheckbox}>
<CouponItem
fieldListData={item}
/>
</Radio>
</Col>
)
})}
</Radio.Group>
</Form.Item>
)}
<Col span={24} style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Pagination size="small" total={total} current={params.current} onChange={handlePagination} />
......
import React, { useEffect, useState } from 'react';
import { Form, Table, Tooltip, Button, Select, Input, Popconfirm } from 'antd';
import { Form, Table, Tooltip, Button, Select, Input, Popconfirm, Typography } from 'antd';
import { ColumnType } from 'antd/lib/table';
import { EditOutlined, PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import CardLayout from '../card';
......@@ -7,6 +7,7 @@ import { FormInstance } from 'antd/es/form/Form';
import { isEmpty } from '@antv/util';
import CouponsLayout from '../couponsLayout';
import { PublicApi } from '@/services/api';
import moment from 'moment';
const levelList = [
{ value: 1, name: '一等奖' },
......@@ -36,13 +37,19 @@ interface PrizeListProps {
const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
const { form, prizeList, focus$ } = props;
const format = (text, fmt?: string) => {
return <>{moment(text).format(fmt || "YYYY-MM-DD HH:mm:ss")}</>
}
const [dataSource, setDataSource] = useState<any[]>([]);
const [levelIds, setLevelIds] = useState<number[]>([]);
const [tableModalVisible, setTableModalVisible] = useState<boolean>(false);
const [_type, setType] = useState<number>();
const [_index_, setIndex] = useState<number>();
const [coupon, setCoupon] = useState<any>({});
const toggle = (flag: boolean) => {
if (!flag) { setCoupon({}) }
setTableModalVisible(flag)
};
......@@ -136,11 +143,11 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
}
/** 选择优惠券 */
const handleClickButton = (value, _index) => {
const handleClickButton = (value, _index, _record) => {
setCoupon(_record)
setType(value);
setIndex(_index)
toggle(true);
}
const columns: ColumnType<any>[] = [
......@@ -228,7 +235,8 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
name={`prize_${_index}`}
rules={[{ required: true, message: '请输选择商品' }]}
>
<Button icon={<EditOutlined />} type='text' onClick={() => handleClickButton(getFieldValue([`type_${_index}`]), _index)}>选择0元购买抵扣劵</Button>
{!isEmpty(_record.coupon) && (<Typography.Text>{_record.coupon.id}/{_record.coupon.typeName}/有效期:{format(_record.coupon.effectiveTimeStart)}{format(_record.coupon.effectiveTimeEnd)}/适用商品:{_record.coupon.suitableProduct?.productId}/{_record.coupon.suitableProduct?.productName}</Typography.Text>)}
<Button icon={<EditOutlined />} type='text' onClick={() => handleClickButton(getFieldValue([`type_${_index}`]), _index, _record)}>{!_record.coupon && '选择0元购买抵扣劵'}</Button>
</Form.Item>
) : getFieldValue([`type_${_index}`]) === 2 ? (
<Form.Item
......@@ -236,7 +244,8 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
name={`prize_${_index}`}
rules={[{ required: true, message: '请输选择优惠券' }]}
>
<Button icon={<EditOutlined />} type='text' onClick={() => handleClickButton(getFieldValue([`type_${_index}`]), _index)}>选择优惠券</Button>
{!isEmpty(_record.coupon) && (<Typography.Text>{_record.coupon.id}/{_record.coupon.typeName}/¥{Number(_record.coupon.useConditionMoney).toFixed(2)}/有效期:{format(_record.coupon.effectiveTimeStart)}{format(_record.coupon.effectiveTimeEnd)}</Typography.Text>)}
<Button icon={<EditOutlined />} type='text' onClick={() => handleClickButton(getFieldValue([`type_${_index}`]), _index, _record)}>{!_record.coupon && '选择优惠券'}</Button>
</Form.Item>
) : getFieldValue([`type_${_index}`]) === 3 ? (
<Form.Item
......@@ -313,8 +322,8 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
useEffect(() => {
form.setFieldsValue({
'activityDefinedBO': {
'prizeBOList': dataSource
'activityDefined': {
'prizeList': dataSource
}
})
}, [dataSource])
......@@ -330,7 +339,20 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
}, [prizeList])
const handleCouponSubmit = (selectRowRecord: any) => {
console.log(selectRowRecord)
const fields = [...dataSource];
const prize = selectRowRecord[0].id
const newData = fields.map((_item, _i) => {
if (_i === _index_) {
return {
..._item,
prize,
coupon: selectRowRecord[0],
}
}
return _item
})
handleSetFieldsValue(newData)
setDataSource(newData)
toggle(false);
}
......@@ -348,7 +370,7 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
weight
>
<Form.Item
name={['activityDefinedBO', 'prizeBOList']}
name={['activityDefined', 'prizeList']}
rules={[{ required: true, message: '请选择奖品设置!' }]}
>
<Table
......@@ -366,6 +388,7 @@ const PrizeListLayout: React.FC<PrizeListProps> = (props: any) => {
visible={tableModalVisible}
onClose={() => toggle(false)}
onSubmit={handleCouponSubmit}
value={coupon}
/>
</CardLayout>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment