Commit 391363ed authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

feat(商家营销活动): 搭配商品选择

parent bbbe6d01
import React, { Fragment, useEffect, useState } from 'react'; import React, { Fragment } from 'react';
import { Form, Input, Row, Col, Image, Space } from 'antd'; import { Form, Input, Row, Col, Image } from 'antd';
import { DeleteOutlined } from '@ant-design/icons'; import { DeleteOutlined } from '@ant-design/icons';
import { FormInstance } from 'antd/es/form/Form';
import style from '../../index.less'; import style from '../../index.less';
type ListProps = { type ListProps = {
...@@ -40,6 +41,8 @@ type RemindLayoutProps = { ...@@ -40,6 +41,8 @@ type RemindLayoutProps = {
} }
export interface ProductLayoutProps { export interface ProductLayoutProps {
/** FormInstance */
form?: FormInstance,
/** message */ /** message */
remind?: RemindLayoutProps, remind?: RemindLayoutProps,
/** 最外层标号 */ /** 最外层标号 */
...@@ -53,7 +56,7 @@ export interface ProductLayoutProps { ...@@ -53,7 +56,7 @@ export interface ProductLayoutProps {
} }
const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => { const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
const { remind, index, list, onDeletion, onEntry } = props; const { form, remind, index, list, onDeletion, onEntry } = props;
const handleChange = (e, name, _index?) => { const handleChange = (e, name, _index?) => {
onEntry(name, Number(e.target.value), _index) onEntry(name, Number(e.target.value), _index)
...@@ -97,8 +100,6 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => { ...@@ -97,8 +100,6 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
</div> </div>
<div className={style.productLayout_item_info}>品类:{_item.category}</div> <div className={style.productLayout_item_info}>品类:{_item.category}</div>
<div className={style.productLayout_item_info}>品牌:{_item.brand}L</div> <div className={style.productLayout_item_info}>品牌:{_item.brand}L</div>
{/* <div className={style.productLayout_item_info}>品类:成品皮--&gt;牛皮--&gt;黄牛皮</div> */}
{/* <div className={style.productLayout_item_info}>品牌:{_item.brand} 颜色:红色 规格:XXL</div> */}
</Col> </Col>
</Row> </Row>
</div> </div>
......
...@@ -19,9 +19,9 @@ type RemindLayoutProps = { ...@@ -19,9 +19,9 @@ type RemindLayoutProps = {
/** 列表标题 */ /** 列表标题 */
listTitle?: string listTitle?: string
/** 列表label */ /** 列表label */
label?: {[key: number]: string}, label?: { [key: number]: string },
/** 提醒 */ /** 提醒 */
message?: {[key: number]: string}, message?: { [key: number]: string },
} }
interface ListModalLayoutProps { interface ListModalLayoutProps {
...@@ -45,6 +45,8 @@ interface ListModalLayoutProps { ...@@ -45,6 +45,8 @@ interface ListModalLayoutProps {
type ListProps = { type ListProps = {
/** id */ /** id */
id?: number, id?: number,
/** skuid */
skuId?: number,
/** 商品id */ /** 商品id */
productId: number, productId: number,
/** 商品名称 */ /** 商品名称 */
...@@ -94,7 +96,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => { ...@@ -94,7 +96,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
if (isArray(selectRowRecord)) { if (isArray(selectRowRecord)) {
fields[idx].list = [...fields[idx].list, ...selectRowRecord.map((item: any) => { fields[idx].list = [...fields[idx].list, ...selectRowRecord.map((item: any) => {
return { return {
id: item.id, skuId: item.skuId,
productId: item.productId, productId: item.productId,
productName: item.productName, productName: item.productName,
category: item.category, category: item.category,
...@@ -173,8 +175,19 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => { ...@@ -173,8 +175,19 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
} }
/** 选择搭配商品 */ /** 选择搭配商品 */
const handleCollocation = (_index: number) => { const handleCollocation = (_idx: number) => {
setIdx(_index); const fields = [...dataSource];
form.resetFields()
fields.forEach((item, _index) => {
item.list.forEach((_item, __index) => {
form.setFieldsValue({
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
})
})
})
setIdx(_idx);
toggle(true) toggle(true)
} }
...@@ -209,7 +222,6 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => { ...@@ -209,7 +222,6 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
} }
useEffect(() => { useEffect(() => {
console.log(value, 10086)
const fields = [...value]; const fields = [...value];
fields.forEach((item, _index) => { fields.forEach((item, _index) => {
item.list.forEach((_item, __index) => { item.list.forEach((_item, __index) => {
...@@ -249,6 +261,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => { ...@@ -249,6 +261,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
> >
{!isEmpty(item.list) && ( {!isEmpty(item.list) && (
<ProductLayout <ProductLayout
form={form}
index={index} index={index}
remind={remind} remind={remind}
list={item.list} list={item.list}
...@@ -257,9 +270,16 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => { ...@@ -257,9 +270,16 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
/> />
)} )}
{/* 选择搭配商品 */} {/* 选择搭配商品 */}
{remind.name !== 'swapValue' && (
<Button type="dashed" block icon={<PlusOutlined />} onClick={() => handleCollocation(index)}>
{remind.buttonTitle}
</Button>
)}
{(remind.name === 'swapValue' && item.list.length === 0) && (
<Button type="dashed" block icon={<PlusOutlined />} onClick={() => handleCollocation(index)}> <Button type="dashed" block icon={<PlusOutlined />} onClick={() => handleCollocation(index)}>
{remind.buttonTitle} {remind.buttonTitle}
</Button> </Button>
)}
</CollapseLayout> </CollapseLayout>
</Form.Item> </Form.Item>
))} ))}
......
...@@ -17,6 +17,7 @@ export const remindLayout = (int, giveType?, giftType?) => { ...@@ -17,6 +17,7 @@ export const remindLayout = (int, giveType?, giftType?) => {
switch(int) { switch(int) {
case 6: case 6:
return { return {
name: 'giveValue',
type: 'limitValue', type: 'limitValue',
modalTitle: `设置赠品-${give}${gift}`, modalTitle: `设置赠品-${give}${gift}`,
buttonTitle: `添加赠送${gift}`, buttonTitle: `添加赠送${gift}`,
...@@ -39,6 +40,7 @@ export const remindLayout = (int, giveType?, giftType?) => { ...@@ -39,6 +40,7 @@ export const remindLayout = (int, giveType?, giftType?) => {
} }
case 13: { case 13: {
return { return {
name: 'swapValue',
type: 'limitValue', type: 'limitValue',
modalTitle: `设置换购商品-${give}换购商品`, modalTitle: `设置换购商品-${give}换购商品`,
buttonTitle: '添加换购商品', buttonTitle: '添加换购商品',
...@@ -62,6 +64,7 @@ export const remindLayout = (int, giveType?, giftType?) => { ...@@ -62,6 +64,7 @@ export const remindLayout = (int, giveType?, giftType?) => {
} }
case 15: case 15:
return { return {
name: 'groupValue',
type: 'groupPrice', type: 'groupPrice',
modalTitle: '设置搭配商品', modalTitle: '设置搭配商品',
buttonTitle: '选择搭配商品', buttonTitle: '选择搭配商品',
......
...@@ -16,11 +16,25 @@ const { onFormMount$ } = FormEffectHooks; ...@@ -16,11 +16,25 @@ const { onFormMount$ } = FormEffectHooks;
const ReadyExamineOne = () => { const ReadyExamineOne = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]); const [rowkeys, setRowKeys] = useState<Array<number>>([]);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const fetchSubmitBatch = async () => {
setSubmitLoading(true)
await PublicApi.postMarketingMerchantActivityExamineStep1Batch({ ids: rowkeys }).then(res => {
if (res.code !== 1000) {
setSubmitLoading(false)
return
}
ref.current.reload();
setRowKeys([])
}).catch(_e => { setSubmitLoading(false) })
}
const controllerBtns = ( const controllerBtns = (
<Row> <Row>
<Col span={6}> <Col span={6}>
<Button <Button
loading={submitLoading}
onClick={fetchSubmitBatch}
disabled={rowkeys.length === 0} disabled={rowkeys.length === 0}
> >
批量提交审核 批量提交审核
......
...@@ -15,11 +15,26 @@ const { onFormMount$ } = FormEffectHooks; ...@@ -15,11 +15,26 @@ const { onFormMount$ } = FormEffectHooks;
const ReadyExamineTwo = () => { const ReadyExamineTwo = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]); const [rowkeys, setRowKeys] = useState<Array<number>>([]);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const fetchSubmitBatch = async () => {
setSubmitLoading(true)
await PublicApi.postMarketingMerchantActivityExamineStep2Batch({ ids: rowkeys }).then(res => {
if (res.code !== 1000) {
setSubmitLoading(false)
return
}
ref.current.reload();
setRowKeys([])
}).catch(_e => {setSubmitLoading(false)})
}
const controllerBtns = ( const controllerBtns = (
<Row> <Row>
<Col span={6}> <Col span={6}>
<Button <Button
loading={submitLoading}
onClick={fetchSubmitBatch}
disabled={rowkeys.length === 0} disabled={rowkeys.length === 0}
> >
批量提交审核 批量提交审核
......
import React, { useRef, useState } from 'react'; import React, { Fragment, useRef, useState } from 'react';
import { Button, Row, Col } from 'antd' import { Button, Row, Col, Popconfirm } from 'antd'
import TableLayout from '@/pages/transaction/components/tableLayout' import TableLayout from '@/pages/transaction/components/tableLayout'
import { ColumnType } from 'antd/lib/table'; import { ColumnType } from 'antd/lib/table';
import EyePreview from '@/components/EyePreview'; import EyePreview from '@/components/EyePreview';
...@@ -14,11 +14,31 @@ const { onFormMount$ } = FormEffectHooks; ...@@ -14,11 +14,31 @@ const { onFormMount$ } = FormEffectHooks;
const ReadyLive = () => { const ReadyLive = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]); const [rowkeys, setRowKeys] = useState<Array<number>>([]);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const fetchSubmitBatch = async (id?: number) => {
let res: any = null;
if (id) {
res = await PublicApi.postMarketingMerchantActivityOnline({ id: Number(id) })
} else {
res = await PublicApi.postMarketingMerchantActivityOnlineBatch({ ids: rowkeys });
}
setSubmitLoading(true)
if (res.code !== 1000) {
setSubmitLoading(false)
return
}
setSubmitLoading(false)
ref.current.reload();
setRowKeys([])
}
const controllerBtns = ( const controllerBtns = (
<Row> <Row>
<Col span={6}> <Col span={6}>
<Button <Button
loading={submitLoading}
onClick={() => fetchSubmitBatch()}
disabled={rowkeys.length === 0} disabled={rowkeys.length === 0}
> >
批量上线活动 批量上线活动
...@@ -77,6 +97,17 @@ const ReadyLive = () => { ...@@ -77,6 +97,17 @@ const ReadyLive = () => {
title: '操作', title: '操作',
key: 'state', key: 'state',
dataIndex: 'state', dataIndex: 'state',
render: (_text, _record) => (
<Fragment>
{_record.online && (
<Popconfirm okButtonProps={{ loading: submitLoading }} title="确定要上线活动吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(_record.id)}>
<Button type='link'>
上线活动
</Button>
</Popconfirm>
)}
</Fragment>
)
} }
] ]
......
...@@ -14,6 +14,24 @@ const { onFormMount$ } = FormEffectHooks; ...@@ -14,6 +14,24 @@ const { onFormMount$ } = FormEffectHooks;
const ReadySubmit = () => { const ReadySubmit = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]); const [rowkeys, setRowKeys] = useState<Array<number>>([]);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const fetchSubmitBatch = async (id?: number) => {
let res: any = null;
if (id) {
res = await PublicApi.postMarketingMerchantActivitySubmit({ id: Number(id) })
} else {
res = await PublicApi.postMarketingMerchantActivitySubmitBatch({ ids: rowkeys });
}
setSubmitLoading(true)
if (res.code !== 1000) {
setSubmitLoading(false)
return
}
setSubmitLoading(false)
ref.current.reload();
setRowKeys([])
}
const controllerBtns = ( const controllerBtns = (
<Row> <Row>
...@@ -27,19 +45,6 @@ const ReadySubmit = () => { ...@@ -27,19 +45,6 @@ const ReadySubmit = () => {
</Row> </Row>
) )
const fetchSubmitBatch = async (id?: number) => {
let res: any = null;
if (id) {
res = await PublicApi.postMarketingMerchantActivitySubmit({ id: Number(id) })
} else {
// res = await PublicApi.postPurchasePurchaseInquirySubmitBatch({ ids: rowkeys });
}
if (res.code === 1000) {
ref.current.reload();
setRowKeys([])
}
}
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ {
title: '活动ID', title: '活动ID',
...@@ -93,7 +98,7 @@ const ReadySubmit = () => { ...@@ -93,7 +98,7 @@ const ReadySubmit = () => {
render: (_text, _record) => ( render: (_text, _record) => (
<Fragment> <Fragment>
{_record.submit && ( {_record.submit && (
<Popconfirm title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(_record.id)}> <Popconfirm okButtonProps={{ loading: submitLoading }} title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(_record.id)}>
<Button type='link'> <Button type='link'>
提交 提交
</Button> </Button>
......
...@@ -38,7 +38,7 @@ const avtivityTypes = [ ...@@ -38,7 +38,7 @@ const avtivityTypes = [
] ]
const AddedMarketing = () => { const AddedMarketing = () => {
const { query: { id, signUpId }, pathname } = history.location; const { query: { id }, pathname } = history.location;
const [path] = useState(pathname.split('/')[pathname.split('/').length - 1]); const [path] = useState(pathname.split('/')[pathname.split('/').length - 1]);
const focus$ = useEventEmitter(); const focus$ = useEventEmitter();
const [form] = Form.useForm(); const [form] = Form.useForm();
......
import React from 'react'; import React from 'react';
import { Image, Form, Input, Popconfirm } from 'antd'; import { Image, Form, Input, Popconfirm, Button } from 'antd';
const columns_4 = ({ const columns_4 = ({
dataSource, dataSource,
setDataSource, setDataSource,
handleDelete, handleDelete,
form, form,
handlCollocation,
value,
}) => { }) => {
/** 输入 */ /** 输入 */
const handleInputChange = (e, name, index) => { const handleInputChange = (e, name, index) => {
...@@ -128,12 +130,23 @@ const columns_4 = ({ ...@@ -128,12 +130,23 @@ const columns_4 = ({
key: 'operation', key: 'operation',
dataIndex: 'operation', dataIndex: 'operation',
render: (_text, _record) => ( render: (_text, _record) => (
<>
<Popconfirm <Popconfirm
title="是否删除?" title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)} onConfirm={() => handleDelete(_record.skuId)}
> >
<a>删除</a> <a>删除</a>
</Popconfirm> </Popconfirm>
{(value === 6) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置赠品</Button>
)}
{(value === 13) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置换购商品</Button>
)}
{(value === 15) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置搭配商品</Button>
)}
</>
) )
}, },
] ]
......
import React from 'react'; import React from 'react';
import { Tooltip, Image } from 'antd'; import { Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { ColumnType } from 'antd/lib/table';
interface ColumnTypes<T> extends ColumnType<any> { const columns_8 = ({
/** dataSource,
* 可编辑 setDataSource,
*/ handleDelete,
editable?: boolean, form,
/** }) => {
* 操作 /** 输入 */
*/ const handleInputChange = (e, name, index) => {
operation?: boolean, const { value } = e.target;
} const params = [...dataSource];
const newData = params.map((_item, _i) => {
const columns_8 = () => { if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return ( return (
[ [
{ {
...@@ -57,34 +67,89 @@ const columns_8 = () => { ...@@ -57,34 +67,89 @@ const columns_8 = () => {
{ {
title: '预售价格', title: '预售价格',
key: 'activityPrice', key: 'activityPrice',
dataIndex: 'activityPrice' dataIndex: 'activityPrice',
}, },
{ {
title: '单位定金', title: '单位定金',
key: 'activityPrice', key: 'activityPrice',
dataIndex: 'activityPrice' dataIndex: 'activityPrice',
}, },
{ {
title: '定金抵扣单价', title: '定金抵扣单价',
key: 'activityPrice', key: 'activityPrice',
dataIndex: 'activityPrice' dataIndex: 'activityPrice',
}, },
{ {
title: '个人限购数量', title: '个人限购数量',
key: 'restrictNum', key: 'restrictNum',
dataIndex: 'restrictNum', dataIndex: 'restrictNum',
editable: true, render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ 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('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
}, },
{ {
title: '活动限购总数量', title: '活动限购总数量',
key: 'restrictTotalNum', key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum', dataIndex: 'restrictTotalNum',
editable: true, render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`restrictTotalNum_${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: '操作', title: '操作',
key: '', key: 'operation',
dataIndex: '' dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
}, },
] ]
) )
......
...@@ -7,6 +7,8 @@ import { PlusOutlined } from '@ant-design/icons'; ...@@ -7,6 +7,8 @@ import { PlusOutlined } from '@ant-design/icons';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import CollocationLayout from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/collocationLayout'; import CollocationLayout from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/collocationLayout';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import ListModalLayout from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/listModalLayout';
import { remindLayout, RemindLayoutProps } from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/productListLayout/remind';
type optionProps = { type optionProps = {
/** key */ /** key */
...@@ -34,6 +36,9 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -34,6 +36,9 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
const [listModalVisible, setListModalVisible] = useState<boolean>(false); const [listModalVisible, setListModalVisible] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<any[]>([]); const [dataSource, setDataSource] = useState<any[]>([]);
const [idNotInList, setIdNotInList] = useState<number[]>([]); // 排除的id集合 ,Long const [idNotInList, setIdNotInList] = useState<number[]>([]); // 排除的id集合 ,Long
const [skuId, setSkuId] = useState<number>(0); // 当前设置商品的id
const [remind, setRemind] = useState<RemindLayoutProps>({});
const [collocation, setCollocation] = useState<any[]>([]);
const handlesStFieldsValue = () => { const handlesStFieldsValue = () => {
const params = [...dataSource]; const params = [...dataSource];
...@@ -62,15 +67,50 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -62,15 +67,50 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
setDataSource(newData.filter(item => item.skuId !== key)) setDataSource(newData.filter(item => item.skuId !== key))
} }
/** 设置搭配 */
const handlCollocation = (record: any) => {
const tableRecord: any = {...record}
if (tableRecord.goodsSubsidiaryGroupList !== undefined) {
setCollocation(tableRecord.goodsSubsidiaryGroupList)
} else {
setCollocation([])
}
setSkuId(tableRecord.skuId)
setListModalVisible(true);
console.log(record)
}
const columns = useMemo(() => { const columns = useMemo(() => {
return Columns[value]?.({ dataSource, setDataSource, handleDelete, form, setIdNotInList }) return Columns[value]?.({ dataSource, setDataSource, handleDelete, form, setIdNotInList, handlCollocation, value })
}, [value, dataSource]) }, [value, dataSource])
const toggle = (flag: boolean) => { const toggle = (flag: boolean) => {
const activityDefinedBO = form.getFieldValue('activityDefinedBO');
if (isEmpty(shopIdList)) { if (isEmpty(shopIdList)) {
message.warning('请选择适用商城!') message.warning('请选择适用商城!');
return return
} }
if ((value === 6 || value === 13) && isEmpty(activityDefinedBO)) {
message.warning('请选择活动规则!');
return
}
if ((value === 6) && !isEmpty(activityDefinedBO) && (!activityDefinedBO.giveType || !activityDefinedBO.giftType)) {
message.warning('请选择赠送促销类型和赠品类型!');
return
}
if ((value === 13) && !isEmpty(activityDefinedBO) && !activityDefinedBO.swapType) {
message.warning('请选择换购类型!');
return
}
if (value === 6) {
setRemind(remindLayout(value, activityDefinedBO.giveType, activityDefinedBO.giftType));
}
if (value === 13) {
setRemind(remindLayout(value, activityDefinedBO.swapType));
}
if (value === 15) {
setRemind(remindLayout(value));
}
setProductVisible(flag) setProductVisible(flag)
} }
...@@ -82,10 +122,20 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -82,10 +122,20 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
useEffect(() => { useEffect(() => {
if (activityId) { if (activityId) {
PublicApi.getMarketingMerchantActivityDetailGoodsPage({ current: '1', pageSize: '999', activityId}).then(res => { PublicApi.getMarketingMerchantActivityDetailGoodsPage({ current: '1', pageSize: '999', activityId }).then(res => {
if (res.code !== 1000) { if (res.code !== 1000) {
return return
} }
const activityDefinedBO = form.getFieldValue('activityDefinedBO');
if (value === 6) {
setRemind(remindLayout(value, activityDefinedBO.giveType, activityDefinedBO.giftType));
}
if (value === 13) {
setRemind(remindLayout(value, activityDefinedBO.swapType));
}
if (value === 15) {
setRemind(remindLayout(value));
}
form.setFieldsValue({ form.setFieldsValue({
'productList': res.data.data 'productList': res.data.data
}) })
...@@ -99,6 +149,17 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -99,6 +149,17 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
handlesStFieldsValue() handlesStFieldsValue()
}, [dataSource]) }, [dataSource])
const handleConfirm = (params: any) => {
const fields = [...dataSource];
fields.forEach(item => {
if (item.skuId === skuId) {
item.goodsSubsidiaryGroupList = [...params]
}
})
setListModalVisible(false)
setDataSource(fields)
}
return ( return (
<CardLayout <CardLayout
id="productListLayout" id="productListLayout"
...@@ -110,7 +171,7 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -110,7 +171,7 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
rules={[{ required: true, message: '请选择活动商品' }]} rules={[{ required: true, message: '请选择活动商品' }]}
> >
<Table <Table
rowKey={(record) => record.id} rowKey={(record) => record.skuId}
columns={columns} columns={columns}
dataSource={dataSource} dataSource={dataSource}
pagination={{ pagination={{
...@@ -125,6 +186,19 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => { ...@@ -125,6 +186,19 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
toggle={toggle} toggle={toggle}
onConfirm={handleSelectActiveProducts} onConfirm={handleSelectActiveProducts}
/> />
{/* 设置搭配商品 */}
{!isEmpty(remind) && (
<ListModalLayout
title={remind.modalTitle}
remind={remind}
idNotInList={[skuId]}
shopIdList={shopIdList}
visible={listModalVisible}
onClose={() => setListModalVisible(false)}
onConfirm={handleConfirm}
value={collocation}
/>
)}
</Form.Item> </Form.Item>
</CardLayout> </CardLayout>
) )
......
...@@ -28,7 +28,7 @@ type optionProps = { ...@@ -28,7 +28,7 @@ type optionProps = {
const RulesLayout: React.FC<RulesLayoutProps> = (props: any) => { const RulesLayout: React.FC<RulesLayoutProps> = (props: any) => {
const { focus$, form } = props; const { focus$, form } = props;
const [option, setOption] = useState<optionProps>(); const [option, setOption] = useState<optionProps>();
const [ladderType, setLadderType] = useState<number>(1) const [ladderType, setLadderType] = useState<number>(1);
const handleActivityDefinedBO = (e) => { const handleActivityDefinedBO = (e) => {
const { value } = e.target const { value } = e.target
......
...@@ -20,20 +20,25 @@ import { ...@@ -20,20 +20,25 @@ import {
const ReadySubmitExamine = () => { const ReadySubmitExamine = () => {
const ref = useRef<any>({}); const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]); const [rowkeys, setRowKeys] = useState<Array<number>>([]);
const [loading, setLoading] = useState<boolean>(false) const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const fetchSubmitBatch = async (id?: number) => { const fetchSubmitBatch = async (id?: number) => {
let res: any = null; let res: any = null;
if (id) { if (id) {
res = await PublicApi.postMarketingMerchantActivitySubmitExamine({ id: Number(id) }) res = await PublicApi.postMarketingMerchantActivitySubmitExamine({ id: Number(id) })
} else { } else {
// res = await PublicApi.postPurchasePurchaseInquirySubmitBatch({ ids: rowkeys }); res = await PublicApi.postMarketingMerchantActivitySubmitExamineBatch({ ids: rowkeys });
} }
if (res.code === 1000) { setSubmitLoading(true)
if (res.code !== 1000) {
setSubmitLoading(false)
return
}
setSubmitLoading(false)
ref.current.reload(); ref.current.reload();
setRowKeys([]) setRowKeys([])
} }
}
const fetchDeleteBatch = async (id?: number) => { const fetchDeleteBatch = async (id?: number) => {
let res: any = null; let res: any = null;
...@@ -42,12 +47,12 @@ const ReadySubmitExamine = () => { ...@@ -42,12 +47,12 @@ const ReadySubmitExamine = () => {
} else { } else {
res = await PublicApi.postMarketingMerchantActivityDeleteBatch({ ids: rowkeys }); res = await PublicApi.postMarketingMerchantActivityDeleteBatch({ ids: rowkeys });
} }
setLoading(true) setDeleteLoading(true)
if (res.code !== 1000) { if (res.code !== 1000) {
setLoading(false) setDeleteLoading(false)
return return
} }
setLoading(false) setDeleteLoading(false)
ref.current.reload(); ref.current.reload();
setRowKeys([]) setRowKeys([])
} }
...@@ -105,7 +110,7 @@ const ReadySubmitExamine = () => { ...@@ -105,7 +110,7 @@ const ReadySubmitExamine = () => {
render: (_text, _record) => ( render: (_text, _record) => (
<Fragment> <Fragment>
{_record.submit && ( {_record.submit && (
<Popconfirm title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(_record.id)}> <Popconfirm okButtonProps={{ loading: submitLoading }} title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(_record.id)}>
<Button type='link'> <Button type='link'>
提交 提交
</Button> </Button>
...@@ -113,7 +118,7 @@ const ReadySubmitExamine = () => { ...@@ -113,7 +118,7 @@ const ReadySubmitExamine = () => {
)} )}
{_record.update && (<Button type='link' onClick={() => history.push(`/memberCenter/marketingAbility/selfManagement/readySubmitExamine/edit?id=${_record.id}`)}>修改</Button>)} {_record.update && (<Button type='link' onClick={() => history.push(`/memberCenter/marketingAbility/selfManagement/readySubmitExamine/edit?id=${_record.id}`)}>修改</Button>)}
{_record.delete && ( {_record.delete && (
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => fetchDeleteBatch(_record.id)}> <Popconfirm okButtonProps={{ loading: deleteLoading }} title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => fetchDeleteBatch(_record.id)}>
<Button type='link'> <Button type='link'>
删除 删除
</Button> </Button>
...@@ -248,13 +253,15 @@ const ReadySubmitExamine = () => { ...@@ -248,13 +253,15 @@ const ReadySubmitExamine = () => {
</Button> </Button>
<Button <Button
icon={<DeleteOutlined />} icon={<DeleteOutlined />}
loading={loading} loading={deleteLoading}
onClick={() => fetchDeleteBatch()}
disabled={rowkeys.length === 0} disabled={rowkeys.length === 0}
> >
批量删除 批量删除
</Button> </Button>
<Button <Button
loading={loading} loading={submitLoading}
onClick={() => fetchSubmitBatch()}
disabled={rowkeys.length === 0} disabled={rowkeys.length === 0}
> >
批量提交审核 批量提交审核
......
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