Commit 76a9f7c5 authored by Bill's avatar Bill

fix: 活动页bug

parent 618cd1a4
......@@ -108,7 +108,7 @@ const router = [
// },
// ...routeList,
// merchantMarketingRoute,
// marketingRoutes,
marketingRoutes,
// platformCouponManageRoute,
...asyncRoutes,
// purchaseBidRoute,
......
/** 1.WEB 2.H5 3.小程序 4.APP */
/** WEB */
export const WEB = 1;
/** h5 */
export const H5 = 2;
/** 小程序 */
export const APPLETS = 3;
/** APP */
export const APP = 4;
export const enumName = {
[WEB]: 'WEB',
[H5]: 'H5',
[APPLETS]: '小程序',
[APP]: 'APP'
};
......@@ -2,9 +2,9 @@ import React, { useEffect, useMemo, useState } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import NiceForm from '@/components/NiceForm';
import RangeTime from '@/components/RangeTime/FormilyRangeTime';
import { Button, Space } from 'antd';
import { Button, Space, message } from 'antd';
import ReutrnEle from '@/components/ReturnEle';
import { history } from 'umi';
import { history , useLocation } from 'umi';
import { BgColorsOutlined, SaveOutlined } from '@ant-design/icons';
import { FormEffectHooks, createFormActions, FormPath } from '@formily/antd';
import { PublicApi } from '@/services/api';
......@@ -14,7 +14,7 @@ import { usePageStatus } from '@/hooks/usePageStatus';
import schema from './schema';
import styles from './index.less';
import FormilyTemplateDrawer from '../components/TemplateDrawer/formilyTemplateDrawer';
import { useLocation } from 'umi';
const actions = createFormActions();
......@@ -41,7 +41,7 @@ type SubmitType = {
}
const Add = () => {
const { id, ...rest } = usePageStatus();
const { id, } = usePageStatus();
const { pathname } = useLocation();
const isEdit = useMemo(() => id !== '' && pathname.includes("edit"), [id]);
const isView = useMemo(() => id !== '' && pathname.includes("view"), [id]);
......@@ -51,6 +51,10 @@ const Add = () => {
const onSubmit = async (values: SubmitType) => {
const { template, startTime, endTime, ...rest } = values;
if (!template?.templateId) {
message.error("请填写活动模板");
return;
}
const startTimeStamp = moment(startTime, 'YYYY-MM-DD HH:mm:ss').valueOf();
const endTimeStamp = moment(endTime, 'YYYY-MM-DD HH:mm:ss').valueOf();
setLoading(true);
......@@ -177,10 +181,8 @@ const Add = () => {
linkage.loading('shopId');
fetchMallData({environment: value.toString(), shopType: '1'} as any)
.then((data) => {
formAction.setFieldState("shopId", state => {
state.originAsyncData = data;
state.value = "";
});
formAction.setFieldValue("shopId", "");
formAction.setFieldValue('template', {});
linkage.loaded("shopId");
linkage.enum("shopId", data);
});
......
......@@ -57,7 +57,7 @@ const schema: ISchema = {
]
},
template: {
type: 'object',
type: 'string',
"x-component": 'FormilyTemplateDrawer',
"x-component-props": {},
title: '活动模板',
......
......@@ -4,6 +4,7 @@ import { DeleteOutlined, EditOutlined, PlayCircleOutlined } from '@ant-design/ic
import { Button, Space, Popconfirm } from 'antd';
import moment from 'moment';
import { Link } from 'umi';
import { enumName } from '@/constants/const/environment';
import styles from './index.less';
interface Iprops {
......@@ -15,7 +16,7 @@ interface Iprops {
endTime: string,
statusName: string,
id: number,
/** */
/** 1.WEB 2.H5 3.小程序 4.APP */
environment: 1 | 2 | 3 | 4 | number,
onRemove?: ((id: number) => void )| null,
/** 1.待上线, 2已上线, 3进行中 4已下线 5已结束 */
......@@ -33,7 +34,7 @@ const END = 5;
const format = 'YYYY-MM-DD HH:mm:ss';
const ActiveItem: React.FC<Iprops> = (props: Iprops) => {
const { title, templateName, shopName, startTime, endTime, statusName, templatePicUrl, id, onRemove, status, onChangeStatus } = props;
const { title, templateName, shopName, startTime, endTime, statusName, templatePicUrl, id, onRemove, status, onChangeStatus, environment } = props;
const handleRemove = () => {
onRemove?.(id);
......@@ -60,7 +61,7 @@ const ActiveItem: React.FC<Iprops> = (props: Iprops) => {
<div className={styles.tags}>
<Space>
<StatusTag type="default" title={templateName} />
<StatusTag type="warnning" title={"web"} />
<StatusTag type="warnning" title={enumName[environment] || ''} />
</Space>
</div>
<div className={styles.mall}>
......
import React from 'react';
import StatusTag from '@/components/StatusTag';
import { Checkbox } from 'antd';
import { enumName } from '@/constants/const/environment';
import styles from './index.less';
interface Iprops {
checked: boolean
onSelect?: ((selected: boolean, postData: any) => void) | null,
......@@ -13,13 +15,6 @@ interface Iprops {
}
}
const ENVIRONMENT_MAP = {
'1': 'WEB',
'2': 'H5',
'3': 'APP',
'4': '小程序'
};
const ActivityTemplateItem: React.FC<Iprops> = (props: Iprops) => {
const { checked, onSelect = null, dataSource } = props;
const onChange = (selected: boolean) => {
......@@ -39,7 +34,7 @@ const ActivityTemplateItem: React.FC<Iprops> = (props: Iprops) => {
<p>{dataSource.templateDescribe}</p>
</div>
<div className={styles.tag}>
<StatusTag type="primary" title={ENVIRONMENT_MAP[dataSource.environment]} />
<StatusTag type="primary" title={enumName[dataSource.environment]} />
</div>
</div>
</div>
......
......@@ -36,7 +36,6 @@ const FormilyTemplateDrawer: React.FC<Iprops> & { isFieldComponent: boolean } =
templateName: record.templateName,
templatePicUrl: record.templatePicUrl,
};
console.log(data);
mutators.change(data);
setVisible(false);
};
......
......@@ -2,6 +2,7 @@
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
.image {
width: 32px;
......
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import mock from '../mock/index.json';
function getData(): Promise<any> {
......@@ -21,6 +21,10 @@ function useGetData() {
fetchData();
}, []);
const adapter = useMemo(() => {
}, [dataSource]);
return { dataSource, };
}
......
{
"top":{
"sort":1,
"style":0,
"status":true,
"details":"https://shushangyun-lingxi.oss-cn-shenzhen.aliyuncs.com/4f0f6362b2a348b993cc3139030356021611023985966.png"
"sort":1,
"style":0,
"status":true,
"details":"https://shushangyun-lingxi.oss-cn-shenzhen.aliyuncs.com/4f0f6362b2a348b993cc3139030356021611023985966.png"
},
"coupon":{
"sort":2,
"style":0,
"status":true,
"details":[
{"id":1, "type":1},
{"id":2, "type":1},
{"id":1, "type":2},
{"id":2, "type":2}
]
},
"coupon":{
"sort":2,
"style":0,
"status":true,
"details":[
{"id":1, "type":1},
{"id":2, "type":1},
{"id":1, "type":2},
{"id":2, "type":2}
]
},
"hot":{
"sort":3,
"style":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