Commit 76a9f7c5 authored by Bill's avatar Bill

fix: 活动页bug

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