Commit 618dc361 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

fix: 修改新增营销活动规格改变重新选则商品

parent 2f363a17
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -11,7 +11,7 @@ const columns_1 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......@@ -25,45 +25,45 @@ const columns_1 = ({
return (
[
{
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinID'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinID' })}`,
key: 'productId',
dataIndex: 'productId',
render: (text) => <Typography.Link target="_blank" href={`/memberCenter/commodityAbility/commodity/products/detail?id=${text}`}>{text}</Typography.Link>
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.shangpintupian'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.shangpintupian' })}`,
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinmingcheng'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinmingcheng' })}`,
key: 'productName',
dataIndex: 'productName'
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.pinlei'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.pinlei' })}`,
key: 'category',
dataIndex: 'category'
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.pinpai'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.pinpai' })}`,
key: 'brand',
dataIndex: 'brand'
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.danwei'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.danwei' })}`,
key: 'unit',
dataIndex: 'unit'
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinjiage'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.shangpinjiage' })}`,
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title={intl.formatMessage({ id: 'marketingAbility.huodongjiagebiaoshishangchengzhijieyigaishangpindehuodongjiagejinxingxiaoshou'})}>{ intl.formatMessage({ id: 'marketingAbility.huodongjiage'}) }<QuestionCircleOutlined />
title: <Tooltip placement="top" title={intl.formatMessage({ id: 'marketingAbility.huodongjiagebiaoshishangchengzhijieyigaishangpindehuodongjiagejinxingxiaoshou' })}>{intl.formatMessage({ id: 'marketingAbility.huodongjiage' })}<QuestionCircleOutlined />
</Tooltip>,
key: 'activityPrice',
dataIndex: 'activityPrice',
......@@ -78,10 +78,10 @@ const columns_1 = ({
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!value) {
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.qingshuruhuodongjiage'})}`));
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.qingshuruhuodongjiage' })}`));
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiexiaoyushangpinjiage'})}`));
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiexiaoyushangpinjiage' })}`));
}
return Promise.resolve();
}
......@@ -93,7 +93,7 @@ const columns_1 = ({
}
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.gerenxiangoushuliang'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.gerenxiangoushuliang' })}`,
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => {
......@@ -107,14 +107,14 @@ const columns_1 = ({
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: `${intl.formatMessage({ id: 'marketingAbility.qingshurugerenxiangoushuliang'})}`
message: `${intl.formatMessage({ id: 'marketingAbility.qingshurugerenxiangoushuliang' })}`
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiexiaoyuhuodongxiangouzongshuliang'})}`));
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiexiaoyuhuodongxiangouzongshuliang' })}`));
}
return Promise.resolve();
},
......@@ -127,7 +127,7 @@ const columns_1 = ({
}
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.huodongxiangouzongshuliang'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.huodongxiangouzongshuliang' })}`,
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => {
......@@ -140,14 +140,14 @@ const columns_1 = ({
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: `${intl.formatMessage({ id: 'marketingAbility.qingshuruhuodongxiangouzongshuliang'})}`
message: `${intl.formatMessage({ id: 'marketingAbility.qingshuruhuodongxiangouzongshuliang' })}`
},
({ 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(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiedayugerenxiangoushuliang'})}`));
return Promise.reject(new Error(`${intl.formatMessage({ id: 'marketingAbility.bixudayu0qiedayugerenxiangoushuliang' })}`));
}
return Promise.resolve();
}
......@@ -160,15 +160,15 @@ const columns_1 = ({
}
},
{
title: `${intl.formatMessage({ id: 'marketingAbility.caozuo'})}`,
title: `${intl.formatMessage({ id: 'marketingAbility.caozuo' })}`,
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title={intl.formatMessage({ id: 'marketingAbility.shifoushanchu?'})}
title={intl.formatMessage({ id: 'marketingAbility.shifoushanchu?' })}
onConfirm={() => handleDelete(_record.skuId)}
>
<a>{ intl.formatMessage({ id: 'marketingAbility.shanchu'}) }</a>
<a>{intl.formatMessage({ id: 'marketingAbility.shanchu' })}</a>
</Popconfirm>
)
},
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -10,7 +10,7 @@ const columns_2 = ({
form,
current
}) => {
const intl = useIntl();
const intl = getIntl();
const sumTotal = (price, num) => {
return (Number(price) - Number(num))
}
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -11,7 +11,7 @@ const columns_3 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Image, Form, Input, Popconfirm, Button, Typography } from 'antd';
......@@ -12,7 +12,7 @@ const columns_4 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Image, Form, Input, Popconfirm, Typography } from 'antd';
......@@ -10,7 +10,7 @@ const columns_5 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -11,7 +11,7 @@ const columns_6 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm, Typography } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
......@@ -11,7 +11,7 @@ const columns_7 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
import { useIntl } from 'umi';
import { getIntl } from 'umi';
import React from 'react';
import { Image, Form, Input, Popconfirm } from 'antd';
......@@ -10,7 +10,7 @@ const columns_8 = ({
current
}) => {
/** 输入 */
const intl = useIntl();
const intl = getIntl();
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
......
......@@ -37,11 +37,13 @@ interface ProductListProps {
filterSkuId?: number[],
/** 是否商家自建营销活动 */
itrue?: boolean,
/** 活动规则改变 */
refresh?: boolean
}
const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
const intl = getIntl();
const { activityId, form, focus$, shopIdList, fieldApi, getActivityDefinedBO, filterSkuId, itrue } = props;
const { activityId, form, focus$, shopIdList, fieldApi, getActivityDefinedBO, filterSkuId, itrue, refresh } = props;
const [value, setValue] = useState<number>(1);
const [productVisible, setProductVisible] = useState<boolean>(false);
const [listModalVisible, setListModalVisible] = useState<boolean>(false);
......@@ -109,19 +111,19 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
const toggle = (flag: boolean) => {
const activityDefined = form.getFieldValue('activityDefined') || getActivityDefinedBO;
if (isEmpty(shopIdList)) {
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzeshiyongshangcheng!'})}`);
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzeshiyongshangcheng!' })}`);
return
}
if ((value === 6 || value === 13) && isEmpty(activityDefined)) {
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuodongguize!'})}`);
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuodongguize!' })}`);
return
}
if ((value === 6) && !isEmpty(activityDefined) && (!activityDefined.giveType || !activityDefined.giftType)) {
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzezengsongcuxiaoleixinghezengpinleixing!'})}`);
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzezengsongcuxiaoleixinghezengpinleixing!' })}`);
return
}
if ((value === 13) && !isEmpty(activityDefined) && !activityDefined.swapType) {
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuangouleixing!'})}`);
message.warning(`${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuangouleixing!' })}`);
return
}
if (value === 6) {
......@@ -149,7 +151,7 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
setProductVisible(flag)
})
} else {
message.warn(`${intl.formatMessage({ id: 'marketingAbility.qingxianwanshanhuodongshijianhehuodongguize!'})}`)
message.warn(`${intl.formatMessage({ id: 'marketingAbility.qingxianwanshanhuodongshijianhehuodongguize!' })}`)
}
} else {
setProductVisible(flag)
......@@ -223,15 +225,21 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
}
}, [!isEmpty(filterSkuId)])
useEffect(() => {
setIdNots([]);
setDataSource([])
setIdNotInList([])
}, [refresh])
return (
<CardLayout
id="productListLayout"
title={intl.formatMessage({ id: 'marketingAbility.huodongshangpin'})}
title={intl.formatMessage({ id: 'marketingAbility.huodongshangpin' })}
>
<Button style={{ marginBottom: '16px' }} block type="dashed" icon={<PlusOutlined />} onClick={() => toggle(true)} >{ intl.formatMessage({ id: 'marketingAbility.xuanzehuodongshangpin'}) }</Button>
<Button style={{ marginBottom: '16px' }} block type="dashed" icon={<PlusOutlined />} onClick={() => toggle(true)} >{intl.formatMessage({ id: 'marketingAbility.xuanzehuodongshangpin' })}</Button>
<Form.Item
name='productList'
rules={[{ required: true, message: `${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuodongshangpin'})}` }]}
rules={[{ required: true, message: `${intl.formatMessage({ id: 'marketingAbility.qingxuanzehuodongshangpin' })}` }]}
>
<Table
rowKey={(record) => record.skuId}
......
......@@ -40,7 +40,8 @@ const AddedMarketing = () => {
const [activityId, setActivityId] = useState<number>();
const [value, setValue] = useState<number>();
const [prizeList, setPrizeList] = useState<any[]>([]);
const [avtivityTypes, setAvtivityTypes] = useState<objType[]>([])
const [avtivityTypes, setAvtivityTypes] = useState<objType[]>([]);
const [refresh, setRefresh] = useState<boolean>(false)
const handleGetShopList = (mall) => {
......@@ -243,6 +244,11 @@ const AddedMarketing = () => {
})
}, [])
const handleGetRule = () => {
console.log(!refresh)
setRefresh(!refresh)
}
return (
<Fragment>
<PeripheralLayout
......@@ -275,8 +281,8 @@ const AddedMarketing = () => {
>
<BasicInfoLayout form={form} focus$={focus$} isEdit={path === 'edit' ? true : false} />
<ShopLayout onGetShopList={handleGetShopList} onSetShopList={shopList} />
<RulesLayout form={form} focus$={focus$} />
{value !== 10 && (<ProductListLayout itrue activityId={activityId && { activityId: activityId }} form={form} focus$={value} shopIdList={shopIdList} fieldApi={getMarketingMerchantActivityDetailGoodsPage} />)}
<RulesLayout form={form} focus$={focus$} getRule={handleGetRule} />
{value !== 10 && (<ProductListLayout refresh={refresh} itrue activityId={activityId && { activityId: activityId }} form={form} focus$={value} shopIdList={shopIdList} fieldApi={getMarketingMerchantActivityDetailGoodsPage} />)}
{value === 10 && (<PrizeListLayout form={form} prizeList={prizeList} focus$={value} />)}
<PartakeUserLayout onGetLevel={handleGetLevel} onSetLevel={memberLevelList} setMemberType={memberType} />
</Form>
......
......@@ -16,7 +16,7 @@ export interface cardProps {
}
const CardLayout: React.FC<cardProps> = (props: any) => {
const { id, title, weight, children, bodyStyle, classNames } = props;
const { id, title, weight, children, bodyStyle, classNames, click } = props;
return (
<div id={id} className={cx(style.cardLayout, classNames && classNames)}>
{title && (
......
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