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

feat(平台营销活动): 新增接口接入

parent 427792c6
......@@ -34,6 +34,7 @@
// import purchaseBidRoute from './purchaseBidRoute'; // 采购竞价单审核
// import seoSettingRoutes from './seoSettingRoutes'; // seo优化
import marketingRoutes from './marketingRoutes'; // 营销
import merchantMarketingRoute from './merchantMarketingRoute'; // 商家营销活动设审核
//@ts-ignore
import asyncRoutes from '../router.config.json'
......@@ -104,6 +105,7 @@ const router = [
// icon: 'BarChartOutlined'
// },
// ...routeList,
merchantMarketingRoute,
marketingRoutes,
...asyncRoutes,
// purchaseBidRoute,
......
......@@ -25,6 +25,14 @@ const marketingRoutes = {
component: '@/pages/marketing/waitAddedMarketing/add',
},
{
/** 编辑平台营销活动 - edit */
path: '/marketing/waitAddedMarketing/edit',
name: '编辑平台营销活动',
hidePageHeader: true,
hideInMenu: true,
component: '@/pages/marketing/waitAddedMarketing/add',
},
{
/** 待审核报名 - waitAuditApply */
path: '/marketing/waitAuditApply',
name: '待审核报名',
......
const merchantMarketing = {
path: '/merchantMarketing',
name: '商家营销活动审核',
routes: [
{
/** 商家营销活动查询 - merchantMarketingSearch */
path: '/merchantMarketing/merchantMarketingSearch',
name: '商家营销活动查询',
hidePageHeader: true,
component: '@/pages/merchantMarketing/merchantMarketingSearch',
},
{
/** 待审核商家营销活动 - waitAuditMerchantMarketing */
path: '/merchantMarketing/waitAuditMerchantMarketing',
name: '待审核商家营销活动',
hidePageHeader: true,
component: '@/pages/merchantMarketing/waitAuditMerchantMarketing',
},
]
}
export default merchantMarketing;
/** 新增平台营销活动 */
import React, { useState } from 'react';
import React, { Fragment, useEffect, useState } from 'react';
import { history, Prompt } from 'umi';
import { Form, Button } from 'antd';
import { ACTIVITYTYPEARRAY } from './components/constants';
import PeripheralLayout from '@/components/DetailLayout';
import BasicInfoLayout from './components/basicLayout';
import RulesLayout from './components/rulesLayout';
import { SaveOutlined } from '@ant-design/icons';
import PartakeUserLayout from './components/partakeUserLayout';
import ShopLayout from './components/shopLayout';
import moment from 'moment';
import ApplyMemberLayout from './components/applyMember';
import { PublicApi } from '@/services/api';
const layout: any = {
colon: false,
......@@ -12,50 +19,137 @@ const layout: any = {
labelAlign: "left"
};
const AddedMarketing = (props: any) => {
const { id }: any = history.location.query;
const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(false)
const [unsaved, setUnsaved] = useState<boolean>(false);
const [shopList, setShopList] = useState<any[]>([]);
/** 活动类型 */
const [option, setOption] = useState<any>({});
const handleGetAcType = (_e?: number, option?: any) => {
setOption(option)
}
const handleSubmit = () => {
form.validateFields().then(res => {
console.log(res, 10086)
setLoading(true)
const params: any = {
newUser: (res.allUser.includes(2) || res.allUser.includes(1)) ? 1 : 0,
oldUser: (res.allUser.includes(3) || res.allUser.includes(1)) ? 1 : 0,
newMember: (res.allMember.includes(2) || res.allMember.includes(1)) ? 1 : 0,
oldMember: (res.allMember.includes(3) || res.allMember.includes(1)) ? 1 : 0,
activityDefinedBO: res.activityDefinedBO,
activityName: res.activityName,
activitySignUpType: res.activitySignUpType,
activityType: res.activityType,
shopList: res.shopList,
startTime: Number(moment(res.startTime).format('x')),
endTime: Number(moment(res.endTime).format('x')),
signUpStartTime: Number(moment(res.signUpStartTime).format('x')),
signUpEndTime: Number(moment(res.signUpEndTime).format('x')),
inviteType: res.inviteType,
}
id && (params.id = Number(id));
PublicApi.postMarketingPlatformActivitySave(params).then(resolve => {
if (resolve.code !== 1000) {
setLoading(false);
return
}
setUnsaved(false);
setLoading(false);
history.goBack();
}).catch(_e => {
setLoading(false);
})
}).catch(_e => {
setLoading(false);
})
}
const handleGetShopList = (mall) => {
console.log(mall, 10086)
const shopList = mall.filter(item => item.checked)
form.setFieldsValue({
"shopList": shopList.map(item => {
return {
shopId: item.id,
shopName: item.name,
logo: item.logoUrl,
}
})
})
}
useEffect(() => {
if (id) {
PublicApi.getMarketingPlatformActivityDetail({ id }).then((res: any) => {
if (res.code !== 1000) {
return
}
const { data } = res;
form.setFieldsValue({
allUser: (data.newUser && data.oldUser) ? [1] : [data.newUser && 2, data.oldUser && 3],
allMember: (data.newMember && data.oldMember) ? [1] : [data.newMember && 2, data.oldMember && 3],
activityDefinedBO: data.activityDefinedBO,
activityName: data.activityName,
activitySignUpType: data.activitySignUpType,
activityType: data.activityType,
shopList: data.shopList,
startTime: moment(data.startTime),
endTime: moment(data.endTime),
signUpStartTime: moment(data.signUpStartTime),
signUpEndTime: moment(data.signUpEndTime),
inviteType: data.inviteType,
})
setShopList(data.shopList)
setOption(ACTIVITYTYPEARRAY.filter(item => item.value === data.activityType).map(v => {
return {
value: v.value,
children: v.lable,
}
})[0])
}).catch(_e => {})
}
}, [id])
return (
<PeripheralLayout
detail="新增平台营销活动"
tabLink={[
{ id: 'basicInfoLayout', title: '基本信息' },
{ id: 'rulesLayout', title: '活动规则' },
{ id: 'goodsLayout', title: '活动商品' },
{ id: 'usersLayout', title: '参与用户' },
{ id: 'shopsLayout', title: '适用商城' },
]}
hideBreak
effect={
<Button
icon={<SaveOutlined />}
type="primary"
onClick={handleSubmit}
>
保存
</Button>
}
components={
<Form
form={form}
{...layout}
>
<BasicInfoLayout onChange={handleGetAcType} />
<RulesLayout option={option} />
</Form>
}
/>
<Fragment>
<PeripheralLayout
detail="新增平台营销活动"
tabLink={[
{ id: 'basicInfoLayout', title: '基本信息' },
{ id: 'rulesLayout', title: '活动规则' },
{ id: 'partakeUserLayout', title: '参与用户' },
{ id: 'shopLayout', title: '适用商城' },
{ id: 'applyMemberLayout', title: '适用会员' },
]}
hideBreak
effect={
<Button
loading={loading}
icon={<SaveOutlined />}
type="primary"
onClick={handleSubmit}
>
保存
</Button>
}
components={
<Form
form={form}
{...layout}
>
<BasicInfoLayout onChange={handleGetAcType} />
<RulesLayout option={option} />
<PartakeUserLayout />
<ShopLayout onGetShopList={handleGetShopList} onSetShopList={shopList} />
<ApplyMemberLayout />
</Form>
}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Fragment>
)
}
export default AddedMarketing;
import React, { useState } from 'react';
import { Form, Radio, Button, Table } from 'antd'
import CardLayout from '../card';
import { PlusSquareOutlined } from '@ant-design/icons';
import { ColumnType } from 'antd/lib/table';
const ApplyMemberLayout = () => {
const [inviteType, setInviteType] = useState<boolean>(true)
const columns: ColumnType<any>[] = [
{
title: "会员ID",
key: "",
dataIndex: "",
},
{
title: "会员名称",
key: "",
dataIndex: "",
},
{
title: "会员类型",
key: "",
dataIndex: "",
},
{
title: "会员角色",
key: "",
dataIndex: "",
},
{
title: "会员等级",
key: "",
dataIndex: "",
},
{
title: "操作",
key: "",
dataIndex: "",
},
]
const handleOnChange = (e) => {
setInviteType(e.target.value)
}
return (
<CardLayout
id="applyMemberLayout"
title="适用会员"
weight
>
<Form.Item
name="inviteType"
label="选择会员"
rules={[{ required: true, message: "请选择适用会员" }]}
initialValue={true}
>
<Radio.Group onChange={handleOnChange}>
<Radio value={true}>所有会员共享(默认)</Radio>
<Radio value={false}>指定会员</Radio>
</Radio.Group>
</Form.Item>
{!inviteType && (
<Form.Item
name="inviteList"
rules={[{ required: true, message: "请选择适用会员" }]}
>
<Button
type="dashed"
block
icon={<PlusSquareOutlined />}
style={{ marginBottom: '24px' }}
>
选择
</Button>
<Table
columns={columns}
/>
</Form.Item>
)}
</CardLayout>
)
}
export default ApplyMemberLayout;
......@@ -31,10 +31,10 @@ export const OVERLAYACTIVITYTYPE = (int) => {
case 2:
case 3:
return [
{ label: '满量促销', value: 1 },
{ label: '满额促销', value: 2 },
{ label: '赠送促销', value: 3 },
{ label: '换购', value: 4 },
{ label: '满量促销', value: 4 },
{ label: '满额促销', value: 5 },
{ label: '赠送促销', value: 6 },
{ label: '换购', value: 13 },
]
case 4:
case 5:
......@@ -42,8 +42,8 @@ export const OVERLAYACTIVITYTYPE = (int) => {
{ label: '特价促销', value: 1 },
{ label: '直降促销', value: 2 },
{ label: '折扣促销', value: 3 },
{ label: '赠送促销', value: 4 },
{ label: '换购', value: 5 },
{ label: '赠送促销', value: 6 },
{ label: '换购', value:13 },
]
case 6:
return [
......@@ -52,15 +52,15 @@ export const OVERLAYACTIVITYTYPE = (int) => {
{ label: '折扣促销', value: 3 },
{ label: '满量促销', value: 4 },
{ label: '满额促销', value: 5 },
{ label: '多件促销', value: 6 },
{ label: '组合促销', value: 7 },
{ label: '换购', value: 8 },
{ label: '多件促销', value: 7 },
{ label: '组合促销', value: 8 },
{ label: '换购', value: 13 },
]
case 7:
case 8:
return [
{ label: '赠送促销', value: 1 },
{ label: '换购', value: 2 },
{ label: '赠送促销', value: 6 },
{ label: '换购', value: 13 },
]
case 13:
return [
......
.rulesLayout {
:global {
.ant-checkbox {
display: none;
}
.ant-checkbox-wrapper {
min-width: 56px;
text-align: center;
color: rgba(0, 0, 0, 0.85);
font-weight: 400;
padding: 5.6px 0px;
border: 1px solid transparent;
box-shadow: 0 2px 0 rgb(0 0 0 / 2%);
border-color: #d9d9d9;
}
.ant-checkbox-wrapper-checked {
color: @main-color;
border-color: @main-color;
}
}
}
import React from 'react';
import { Form, Checkbox } from 'antd';
import CardLayout from '../card';
import style from './index.less';
const PartakeUserLayout = () => {
return (
<CardLayout
id="partakeUserLayout"
title="参与用户"
weight
>
<Form.Item
name="allUser"
label="适用新老会员"
tooltip="当天平台审核通过的平台会员为新会员,非当天审核通过的平台会员为老会员"
rules={[{required: true, message: '请选择适用新老会员'}]}
className={style.rulesLayout}
>
<Checkbox.Group>
<Checkbox value={1}>全部</Checkbox>
<Checkbox value={2}>新会员(平台会员)</Checkbox>
<Checkbox value={3}>老会员(平台会员)</Checkbox>
</Checkbox.Group>
</Form.Item>
<Form.Item
name="allMember"
label="适用会员类型"
rules={[{required: true, message: '请选择适用会员类型'}]}
className={style.rulesLayout}
>
<Checkbox.Group>
<Checkbox value={1}>全部</Checkbox>
<Checkbox value={2}>企业会员</Checkbox>
<Checkbox value={3}>个人会员</Checkbox>
</Checkbox.Group>
</Form.Item>
</CardLayout>
)
}
export default PartakeUserLayout;
......@@ -14,6 +14,7 @@ interface RulesLayoutProps {
const RulesLayout: React.FC<RulesLayoutProps> = (props: any) => {
const { option } = props;
const [data, setData] = useState<any>({});
console.log(data)
/** 叠加活动类型 */
const allowActivity = (int) => {
switch (int) {
......
.shopListLayout {
display: flex;
align-items: center;
border: 1px solid transparent;
border-color: #5C626A;
padding: 8px 16px;
cursor: pointer;
.shopListLogo {
width: 32px;
height: 32px;
border-radius: 50%;
overflow: hidden;
}
.shopListName {
color: #5C626A;
margin-left: 10px;
}
}
.shopListLayoutChecked {
border-color: @main-color;
.shopListName {
color: @main-color;
}
}
import React, { useEffect, useState } from 'react';
import { Form, Row, Col, Image } from 'antd';
import cx from 'classnames';
import CardLayout from '../card';
import { GlobalConfig } from '@/global/config'
import style from './index.less';
import { isEmpty } from '@/components/NiceForm/components/AntUpload/shared';
type ShopItem = {
describe?: string
environment?: number,
id?: number,
isDefault?: number,
logoUrl?: string,
name?: string
state?: number,
type?: number,
url?: string,
checked?: boolean,
}
interface shopListProps {
/** 返回选择商城 */
onGetShopList?: (e: any) => void,
/** 回显数据 */
onSetShopList?: any[],
}
const ShopLayout: React.FC<shopListProps> = (props: any) => {
const { onGetShopList, onSetShopList } = props;
const [mallList, setMallList] = useState<ShopItem[]>([]);
useEffect(() => {
let shopInfo = GlobalConfig.web.shopInfo.filter(v => v.type == 1).map(
v => v
)
setMallList(shopInfo)
}, [])
const handleShopList = (index) => {
let mall = [...mallList]
mall[index].checked = !mall[index].checked;
setMallList(mall)
onGetShopList(mall)
}
useEffect(() => {
if (!isEmpty(onSetShopList)) {
mallList.forEach(item => {
onSetShopList.filter(_item => _item.shopId === item.id).forEach(v => {
if (v.shopId === item.id) {
item.checked = true
}
})
})
console.log(mallList, 962039)
setMallList([...mallList]);
onGetShopList([...mallList])
}
}, [onSetShopList])
return (
<CardLayout
id="shopLayout"
title="适用商城"
weight
>
<Form.Item
name="shopList"
>
<Row gutter={[16, 16]}>
{mallList.map((item: ShopItem, index: number ) => (
<Col span={6} key={item.id}>
<div className={cx(style.shopListLayout, item.checked && style.shopListLayoutChecked)} onClick={() => handleShopList(index)}>
<div className={style.shopListLogo}>
<Image width={32} height={32} src={item.logoUrl} preview={false} />
</div>
<span className={style.shopListName}>{item.name}</span>
</div>
</Col>
))}
</Row>
</Form.Item>
</CardLayout>
)
}
export default ShopLayout
/** 待新增平台营销活动 */
import React from 'react';
import { Button, Row, Col, Space } from 'antd';
import React, { useRef, useState } from 'react';
import { history } from 'umi';
import { Button, Row, Col, Space, Popconfirm } from 'antd';
import TableLayout from '@/components/TableLayout';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ColumnType } from 'antd/lib/table/interface';
......@@ -14,6 +15,39 @@ import { PlusOutlined } from '@ant-design/icons';
const { onFormMount$ } = FormEffectHooks;
const WaitAddedMarketing = () => {
const ref = useRef<any>({});
const [rowkeys, setRowKeys] = useState<Array<number>>([]);
/** 批量审核 */
const fetchSubmitBatch = async (id?: number) => {
let res: any = null;
if (id) {
res = await PublicApi.postMarketingPlatformActivitySubmit({ id: Number(id) })
} else {
// res = await PublicApi.postPurchasePurchaseInquirySubmitBatch({ ids: rowkeys });
}
if (res.code === 1000) {
ref.current.reload();
setRowKeys([])
}
}
/**
* 删除或批量删除
* @type: 1: 单个删除, 2: 批量删除
* */
const fetchDeleteBatch = async (id?: number) => {
let res: any = null;
if (id) {
// res = await PublicApi.postPurchasePurchaseInquiryDelete({ id });
} else {
// res = await PublicApi.postPurchasePurchaseInquiryDeleteBatch({ ids: rowkeys });
}
if (res.code === 1000) {
ref.current.reload();
setRowKeys([])
}
}
const columns: ColumnType<any>[] = [
{
title: '活动ID',
......@@ -78,9 +112,17 @@ const WaitAddedMarketing = () => {
dataIndex: 'state',
render: (text, record) => (
<>
<Button type='link'>提交</Button>
<Button type='link'>修改</Button>
<Button type='link'>删除</Button>
<Popconfirm title="确定要提交吗?" okText="是" cancelText="否" onConfirm={() => fetchSubmitBatch(record.id)}>
<Button type='link'>
提交
</Button>
</Popconfirm>
<Button type='link' onClick={() => history.push(`/marketing/waitAddedMarketing/edit?id=${record.id}`)}>修改</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => fetchDeleteBatch(record.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
)
}
......@@ -102,8 +144,10 @@ const WaitAddedMarketing = () => {
return (
<TableLayout
selectedRow
reload={ref}
columns={columns}
effects="id"
fetchRowkeys={(e) => setRowKeys(e)}
fetch={PublicApi.getMarketingPlatformActivityPageTobeAdd}
useStateEffects={useStateEffects}
schema={{
......@@ -202,6 +246,7 @@ const WaitAddedMarketing = () => {
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => history.push(`/marketing/waitAddedMarketing/add`)}
>
新增
</Button>
......@@ -215,7 +260,6 @@ const WaitAddedMarketing = () => {
</Col>
</Row>
}
fetchRowkeys={(e) => console.log(e)}
/>
)
}
......
import React from 'react';
const MerchantMarketingSearch = () => {
return (
<div>123</div>
)
}
export default MerchantMarketingSearch
import React from 'react';
const WaitAuditMerchantMarketing = () => {
return (
<div>123</div>
)
}
export default WaitAuditMerchantMarketing
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