diff --git a/src/pages/activity/activityStart/components/CouponDelivery/index.jsx b/src/pages/activity/activityStart/components/CouponDelivery/index.jsx index 8182e83..66c2489 100644 --- a/src/pages/activity/activityStart/components/CouponDelivery/index.jsx +++ b/src/pages/activity/activityStart/components/CouponDelivery/index.jsx @@ -434,8 +434,8 @@ const CouponDelivery = () => { diff --git a/src/pages/activity/activityStart/components/FreeCouponMoney/index.jsx b/src/pages/activity/activityStart/components/FreeCouponMoney/index.jsx index 7245163..e6776fa 100644 --- a/src/pages/activity/activityStart/components/FreeCouponMoney/index.jsx +++ b/src/pages/activity/activityStart/components/FreeCouponMoney/index.jsx @@ -415,8 +415,8 @@ const FreeCouponMoney = () => { - 点击参与(需要用户主动点击) - 自动参与(满足特定条件自动参与) + 点击参与(需要用户主动点击) + 自动参与(满足特定条件自动参与) diff --git a/src/pages/activity/activityStart/components/FreeGoodsMoney/index.jsx b/src/pages/activity/activityStart/components/FreeGoodsMoney/index.jsx index bc448b9..d8a5812 100644 --- a/src/pages/activity/activityStart/components/FreeGoodsMoney/index.jsx +++ b/src/pages/activity/activityStart/components/FreeGoodsMoney/index.jsx @@ -404,8 +404,8 @@ const FreeGoodsMoney = () => { diff --git a/src/pages/activity/activityStart/components/FullDecrement/index.jsx b/src/pages/activity/activityStart/components/FullDecrement/index.jsx index ca8f296..a378ec3 100644 --- a/src/pages/activity/activityStart/components/FullDecrement/index.jsx +++ b/src/pages/activity/activityStart/components/FullDecrement/index.jsx @@ -376,8 +376,8 @@ const FullDecrement = () => { diff --git a/src/pages/activity/activityStart/components/LadderExchange/index.jsx b/src/pages/activity/activityStart/components/LadderExchange/index.jsx index c3562a9..308a3e3 100644 --- a/src/pages/activity/activityStart/components/LadderExchange/index.jsx +++ b/src/pages/activity/activityStart/components/LadderExchange/index.jsx @@ -1,19 +1,193 @@ -import React, { useState } from "react"; -import { Form, Button, Input, Image, Select, DatePicker, Upload, InputNumber } from 'antd'; +import React, { useState, useEffect } from "react"; +import { Form, Button, Input, Image, Select, DatePicker, Upload, InputNumber, Modal, message, Checkbox, Row, Col } from 'antd'; import styles from "../../index.less"; -import { MinusCircleOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons'; +import { MinusCircleOutlined, PlusOutlined, UploadOutlined, PlusCircleOutlined } from '@ant-design/icons'; import startAPI from "../../service"; import axios from 'axios'; +const key = 'coupon'; +import moment from "moment"; + +const activityConfigArray = [ + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "2B0F88D6-EDA0-4AAC-BB0B-DD34F3245C17", + "configurationName": "日参与次数限制", + "configurationRule": "每日参与次数", + "valueType": 1, + "configurationValueCount": 1 + }, + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "8AC2A2BA-BB6E-4566-B147-ACF798146BBD", + "configurationName": "星期限制", + "configurationRule": "包含的星期", + "valueType": 2, + "configurationValueCount": 1 + }, + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "9620CCF9-679E-44B1-B8FF-9B6F511208FA", + "configurationName": "消费金额", + "configurationRule": "单笔订单消费金额", + "valueType": 1, + "configurationValueCount": 1 + }, + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "AF62B336-15A6-453B-AD4A-61EB7D43B99B", + "configurationName": "商品种类限制", + "configurationRule": "包含的商品种类", + "valueType": 2, + "configurationValueCount": 1 + }, + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "ECBACC1C-6BA8-498E-BDE4-6A012881E0E7", + "configurationName": "门店限制", + "configurationRule": "包含的门店", + "valueType": 2, + "configurationValueCount": 1 + }, + { + "configId": null, + "operator": null, + "value1": [], + "value2": null, + "activity_Id": null, + "configuration_Id": "F06DEAD8-DDB8-4B27-94E9-389DE9AC155D", + "configurationName": "总参与次数限制", + "configurationRule": "总参与次数", + "valueType": 1, + "configurationValueCount": 1 + } +] + +const formItemLayout = { + labelCol: { + sm: { span: 4 }, + }, + wrapperCol: {}, +}; + +const tailFormItemLayout = { + wrapperCol: { + sm: { + span: 500, + offset: 1, + }, + }, +}; + /** * 阶梯消费换购 * @returns */ -const LadderExchange = () => { +const LadderExchange = (props) => { const [couponInfo, SetCouponInfo] = useState([]); + /** + * 获取优惠券列表 + */ + const onFetchCouponList = async () => { + const response = await startAPI.GetCouponCanUseCountAndLimit(); + if (response.succeeded) { + SetCouponInfo(response.data); + } + } const [couponForm] = Form.useForm(); const [imgurl, setimgUrl] = useState(null); + /** 新建/更新窗口的弹窗 */ + const [createModalVisible, handleModalVisible] = useState(false); + const [form] = Form.useForm(); + + /** 优惠券类型 */ + const [couponType, setcouponType] = useState([]); + + /** 适用商品范围 */ + const [applyGood, setApplyGood] = useState([]); + + /** + * 获取商品 + */ + const onFetchGoods = async (goodsType = -1) => { + const response = await startAPI.GetGoodsById(goodsType); + if (response.statusCode === 200) { + const array = []; + Object.keys(response.data).forEach(item => { + array.push({ + id: item, + name: response.data[item] + }) + }); + setApplyGood(array) + } + } + + /** + * 获取适用店铺 + */ + const GetStores = async () => { + const response = await startAPI.GetStores(); + if (response.statusCode === 200) { + setApplicableStore(response.data); + } + } + + /** + * 获取消费券类型 + */ + const GetCouponStatusOrType = async () => { + await startAPI.GetCouponStatusOrType(2).then((r) => { + if (r.succeeded) { + setcouponType(r.data); + } + }); + } + + /** 适用门店范围 */ + const [applicableStore, setApplicableStore] = useState([]); + + /** 适用商品类型范围 */ + const [applyGoodType, setApplyGoodType] = useState([]); + + /** + * 适用商品范围 + */ + const onFetchGoodsType = async () => { + const response = await startAPI.GetGoodsType(); + if (response.statusCode === 200) { + const array = []; + Object.keys(response.data).forEach(item => { + array.push({ + id: item, + name: response.data[item] + }) + }) + setApplyGoodType(array); + } + } + const uploadProp = { name: 'file', showUploadList: false, @@ -73,6 +247,122 @@ const LadderExchange = () => { }, }; + //新增 + const handleAddCoupon = async (fields) => { + fields.RangeType = 1; + message.loading('正在添加...', key); + try { + if (fields.validEndTime < fields.validStartTime) { + message.error('开始时间不能大于结束时间'); + } + await startAPI.Addcoupon(JSON.stringify(fields)).then((r) => { + message.destroy(key); + if (r.data) { + message.success('添加成功'); + onFetchCouponList(); + handleModalVisible(false); + } else { + message.error('添加失败请重试!'); + } + }); + } catch (error) { + message.destroy(key); + message.error('添加失败请重试!'); + } + }; + + const hander = async (value) => { + var res = (await startAPI.GetSelectedConfig(value)).data; + var arr = []; + for (let k in res) { + arr.push({ + id: k.toString(), + name: res[k.toString()], + }); + } + setApplicableStore(data); + form.setFieldsValue({ Relation: [] }); + }; + + /** + * 提交 + * @param {*} values + */ + const onSubmitActivity = async (values) => { + values.activityType = props.currentActivityType; + values.activityRewards.forEach(item => { + item.id = ""; + item.activityInfo_Id = ""; + }) + values.activityStartTime = moment(values.activityStartAndEndTime[0]).format('YYYY-MM-DD'); + values.activityEndTime = moment(values.activityStartAndEndTime[1]).format('YYYY-MM-DD'); + values.status = 0; + values.isShow = 1; + values.isDeleted = 0; + values.activityConfiguration = []; + values.activityConfig.forEach(config => { + const findConfig = activityConfigArray.find(item => item.configuration_Id === config); + if (findConfig) { + findConfig.configId = [findConfig.configuration_Id]; + if (findConfig.configurationName === '日参与次数限制') { + findConfig.operator = values.dayOperator; + findConfig.value1 = values.dayValue; + } else if (findConfig.configurationName === '星期限制') { + findConfig.operator = values.weekOperator; + findConfig.value1 = values.weekValue; + } else if (findConfig.configurationName === '消费金额') { + findConfig.operator = values.amountOperator; + findConfig.value1 = values.amountValue; + } else if (findConfig.configurationName === '商品种类限制') { + findConfig.operator = values.goodsTypeOperator; + findConfig.value1 = values.goodsTypeValue; + } else if (findConfig.configurationName === '门店限制') { + findConfig.operator = values.storeOperator; + findConfig.value1 = values.storeValue; + } else if (findConfig.configurationName === '总参与次数限制') { + findConfig.operator = values.totalOperator; + findConfig.value1 = values.totalValue; + } + values.activityConfiguration.push(findConfig); + } + }); + delete values.activityConfig; + delete values.activityStartAndEndTime; + + delete values.amountOperator; + delete values.amountValue; + + delete values.dayOperator; + delete values.dayValue; + + delete values.goodsTypeOperator; + delete values.goodsTypeValue; + + delete values.storeOperator; + delete values.storeValue; + + delete values.totalOperator; + delete values.totalValue; + + delete values.weekOperator; + delete values.weekValue; + const response = await startAPI.FastAddActivity(values); + if (response.statusCode === 200) { + message.success('新建活动成功!'); + couponForm.resetFields(); + } else { + message.error(response.errors || '创建失败 请重试!'); + } + } + + useEffect(() => { + GetCouponStatusOrType(); + onFetchCouponList(); + onFetchGoodsType(); + GetStores(); + onFetchGoods(); + }, []); + return
{ remember: true, }} onFinish={(values) => { - console.log('values', values); + onSubmitActivity(values); }} layout="vertical" autoComplete="off" @@ -169,15 +459,15 @@ const LadderExchange = () => { fieldKey={[fieldKey, 'rewardValue']} rules={[{ required: true, message: '请输入消费次数' }]} > - +
赠送优惠券:
+ handleModalVisible(true)} style={{ margin: '0 10px', flexShrink: 0, marginBottom: '24px', fontSize: '25px', color: '#F84352' }} /> + remove(name)} />
))} - + + { + handleModalVisible(false); + }} + //关闭时销毁 Modal 里的子元素 + destroyOnClose + > +
{ + handleAddCoupon(values) + }} + > + + + + + + + + + + + + + + + + + + + + + + + 0 为不限制 + + + + + + + prevValues.timeType !== currentValues.timeType + } + > + {({ getFieldValue }) => + getFieldValue('timeType') == '2' ? ( + + + + + + ) : ( + + + + + + + + + ) + } + + + + + + + + + + + 注: 多条规则请用  ;  隔开。    如:1.xxxxxx; 2.xxxxxx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
} diff --git a/src/pages/activity/activityStart/components/PriceIncrease/index.jsx b/src/pages/activity/activityStart/components/PriceIncrease/index.jsx index 8e6f763..b39fd5f 100644 --- a/src/pages/activity/activityStart/components/PriceIncrease/index.jsx +++ b/src/pages/activity/activityStart/components/PriceIncrease/index.jsx @@ -398,8 +398,8 @@ const PriceIncrease = () => { diff --git a/src/pages/activity/activityStart/components/SpecialOffer/index.jsx b/src/pages/activity/activityStart/components/SpecialOffer/index.jsx index 31470a2..75f87a8 100644 --- a/src/pages/activity/activityStart/components/SpecialOffer/index.jsx +++ b/src/pages/activity/activityStart/components/SpecialOffer/index.jsx @@ -297,6 +297,13 @@ const SpecialOffer = () => { + + + + { - { currentActivityType === 1 && } - { currentActivityType === 2 && } - { currentActivityType === 3 && } - { currentActivityType === 4 && } - { currentActivityType === 5 && } - { (currentActivityType === 6 || currentActivityType === 7) && } - { currentActivityType === 8 && } + {currentActivityType === 1 && } + {currentActivityType === 2 && } + {currentActivityType === 3 && } + {currentActivityType === 4 && } + {currentActivityType === 5 && } + {currentActivityType === 6 && } + {currentActivityType === 7 && } + {currentActivityType === 8 && } }