Commit 85b7236f authored by Bill's avatar Bill

fix: 修改活动页以及导航页bug

parent 702a446b
......@@ -76,6 +76,7 @@
"babel-plugin-transform-remove-console": "^6.9.4",
"bignumber.js": "^9.0.1",
"bizcharts": "^4.1.10",
"braft-editor": "^2.3.9",
"copy-to-clipboard": "^3.3.1",
"crypto-js": "^4.0.0",
"god": "0.2.11",
......@@ -104,8 +105,7 @@
"typescript": "^3.9.7",
"umi": "~3.2.28",
"video-react": "^0.14.1",
"yorkie": "^2.0.0",
"braft-editor": "^2.3.9"
"yorkie": "^2.0.0"
},
"devDependencies": {
"@types/qrcode": "^1.3.4",
......@@ -133,4 +133,4 @@
"ssh2": "^0.8.9",
"util": "^0.12.3"
}
}
\ No newline at end of file
}
......@@ -63,19 +63,20 @@ const BranchList = (props) => {
setPageSize(pageSize || 10);
fetchData({
shopId: fixtureContext?.shopId.toString(),
categoryId: categoryId.toString,
customerCategoryId: categoryId.toString,
current: page.toString(),
pageSize: pageSize?.toString() || '10',
});
};
const onSubmit = (values) => {
console.log(values);
const withName = values.name ? { name: values.name } : {};
fetchData({
shopId: fixtureContext?.shopId.toString(),
customerCategoryId: categoryId.toString(),
current: current.toString(),
pageSize: pageSize.toString(),
...withName,
});
};
......
......@@ -31,7 +31,11 @@ const FormilyBrand: React.FC<Iprops> & { isFieldComponent: boolean } = (props: I
<div>
<Button onClick={() => setVisible(true)}>选择</Button>
<div style={{marginTop: '12px'}}>
<BrandItem {...value} />
{
value?.icon && (
<BrandItem {...value} />
)
}
</div>
<BranchList value={value} visible={visible} onCancel={onCancel} onConfirm={onConfirm} />
</div>
......
......@@ -6,6 +6,7 @@ import { Product } from '@/pages/transaction/marketingAbility/marketingActivitie
import ActivityProductDrawer from '@/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/ActivityAreaSetting/activityProductDrawer';
import { PublicApi } from '@/services/api';
import { GetMarketingAdornMerchantActivityListAdornRequest } from '@/services/MarketingApi';
import activityImage from '@/assets/activity/ActivityImage.svg';
interface Iprops {
value: {
......@@ -36,8 +37,7 @@ const FormilyActivityProduct: React.FC<Iprops> & { isFieldComponent: boolean } =
/** 1 级分类 id */
const { activeKey } = useSelector<any, "activeKey" >(['activeKey']);
const fixtureContext = useContext(context);
console.log(value);
const ignoresFilters = ['activityType'];
const componentProps = props.props?.['x-component-props'] || {} as { activityType?: number, isWithLabels: boolean };
const activityImage = "logo.png";
......@@ -80,6 +80,7 @@ const FormilyActivityProduct: React.FC<Iprops> & { isFieldComponent: boolean } =
<div style={{ position: 'relative' }}>
<Product activityImage={''} onEdit={onEdit} {...productProps} isWithLabels={componentProps.isWithLabels || false} />
<ActivityProductDrawer
ignoresFilters={ignoresFilters}
activityImage={activityImage}
products={cacheProductList}
onOk={onOk}
......
......@@ -275,25 +275,28 @@ function useGetLayout() {
};
const childNodesKeys: string[] = [];
if ( childrenData.length > 0 && _row.key !== 'suggestProduct') {
const formatedData = formatData[_row.key]?.(childrenData);
const requestData = await service[_row.key]?.(formatedData, { ctlType: 'none' });
const afterRequestFormatedData = afterRequestFormat[_row.key]?.(requestData);
afterRequestFormatedData?.forEach((_item, _index) => {
const keyNum = `${startKey}-${_index + 1}`;
childNodesKeys.push(keyNum);
const sonConfig = {
componentName: `${CHILD_COMPONENT_NAME[_row.key]}`,
title: _item?.productName || _item.name,
props: {
..._item,
},
otherProps: {
type: `${_row.key}Item`
},
childNodes: []
};
pageConfig[keyNum] = sonConfig;
});
const formatedData = formatData[_row.key]?.(childrenData.filter(Boolean));
const length = typeof formatedData.ids !== 'undefined' ? formatedData?.ids?.length : formatedData?.couponList.length;
if (length > 0) {
const requestData = await service[_row.key]?.(formatedData, { ctlType: 'none' });
const afterRequestFormatedData = afterRequestFormat[_row.key]?.(requestData);
afterRequestFormatedData?.forEach((_item, _index) => {
const keyNum = `${startKey}-${_index + 1}`;
childNodesKeys.push(keyNum);
const sonConfig = {
componentName: `${CHILD_COMPONENT_NAME[_row.key]}`,
title: _item?.productName || _item.name,
props: {
..._item,
},
otherProps: {
type: `${_row.key}Item`
},
childNodes: []
};
pageConfig[keyNum] = sonConfig;
});
}
} else if (_row.key === 'suggestProduct') {
// const suggestDataKeys: string[] = [];
let _index = 0;
......
......@@ -27,7 +27,7 @@
"specialOffer":{
"sort":5,
"props": {
"theme": 1,
"theme": 0,
"visible": true,
"title":"特价促销",
"childrenData": []
......@@ -36,7 +36,7 @@
"plummet":{
"sort":4,
"props": {
"theme":1,
"theme":0,
"visible": false,
"title":"直降促销",
"childrenData": []
......@@ -54,7 +54,7 @@
"fullQuantitySub":{
"sort":7,
"props": {
"theme":0,
"theme":1,
"visible": false,
"title":"满量促销--满量减",
"childrenData": []
......@@ -63,7 +63,7 @@
"fullQuantityDiscount":{
"sort":8,
"props": {
"theme":0,
"theme":1,
"visible": false,
"title":"满量促销--满量折",
"childrenData": []
......@@ -72,7 +72,7 @@
"fullMoneySub":{
"sort":9,
"props": {
"theme":0,
"theme":1,
"visible": false,
"title":"满额促销--满额减",
"childrenData": []
......@@ -81,7 +81,7 @@
"fullMoneyDiscount":{
"sort":10,
"props": {
"theme":0,
"theme":1,
"visible": false,
"title":"满额促销--满额折",
"childrenData": []
......
......@@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Drawer, Table, Button, Space, Pagination, Spin } from 'antd';
import NiceForm from '@/components/NiceForm';
import { createFormActions } from '@formily/antd';
import omit from 'lodash/omit';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
......@@ -13,6 +14,9 @@ import styles from './activityProductDrawer.less';
import ActivityItem from './activityItem';
import { GetMarketingAdornMerchantActivityListAdornResponseDetail } from '@/services/MarketingApi';
import differenceWith from 'lodash/differenceWith';
import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import moment from 'moment';
const actions = createFormActions();
......@@ -28,12 +32,18 @@ interface Iprops {
activityImage: string,
mode?: 'radio' | 'checked',
/** mode === 'radio'的时候, 禁用的的活动商品 [`${id}_${activityId}`] */
disabledList?: string[]
disabledList?: string[],
/** 去除某些高级筛选 */
ignoresFilters?: string[],
}
type SubmitType = {
id: number,
activityName: string,
activityType: number,
productName: string,
startTime: string,
endTime: string,
}
const columns: ColumnsType<GetMarketingAdornMerchantActivityListAdornResponseDetail["goodsList"][0]> = [
......@@ -93,7 +103,7 @@ const columns: ColumnsType<GetMarketingAdornMerchantActivityListAdornResponseDet
const ActivityProductDrawer: React.FC<Iprops> = (props: Iprops) => {
const { visible, onCancel, fetchData = null, onOk, products = [], activityImage, mode = 'checked', disabledList = [] } = props;
const { visible, onCancel, fetchData = null, onOk, products = [], activityImage, mode = 'checked', disabledList = [], ignoresFilters = [] } = props;
const [current, setPage] = useState<number>(1);
const [currentPageSize, setPageSize] = useState<number>(10);
const [dataSource, setDataSource] = useState<GetMarketingAdornMerchantActivityListAdornResponseDetail[]>([]);
......@@ -107,6 +117,11 @@ const ActivityProductDrawer: React.FC<Iprops> = (props: Iprops) => {
const selectedRowKeys = useMemo(() => checkedProduct.map((_item) => `${_item.activityId!}-${_item.id!}`), [checkedProduct]);
const ignoredSchema = useMemo(() => {
const ignoreData = ignoresFilters.map((_item) => `properties.megaLayout.properties.FORM_FILTER_PATH.properties.${_item}`);
return omit(schema, ignoreData);
}, [ignoresFilters]);
const fetchList = useCallback(async (params: any) => {
if (fetchData === null) {
return;
......@@ -133,8 +148,16 @@ const ActivityProductDrawer: React.FC<Iprops> = (props: Iprops) => {
}, [current, currentPageSize, visible,]);
const onSubmit = (value: SubmitType) => {
console.log(value);
fetchList({ current, pageSize: currentPageSize, ...value });
const { startTime, endTime, ...rest } = value;
const time = startTime ? {
startTime: moment(startTime).valueOf(),
endTime: moment(endTime).valueOf(),
} : {};
const postData = {
...time,
...rest,
};
fetchList({ current, pageSize: currentPageSize, ...postData });
};
const onReset = () => {
......@@ -164,6 +187,14 @@ const ActivityProductDrawer: React.FC<Iprops> = (props: Iprops) => {
onOk?.(checkedProduct);
};
const fetchPrimaryOption = async () => {
const { data, code } = await PublicApi.getMarketingPlatformActivityGetActivityTypeList();
if (code !== 1000) {
return [];
}
return data;
};
const handleRowSelect = (record: GetMarketingAdornMerchantActivityListAdornResponseDetail["goodsList"][0], selected: boolean, selectedRows: GetMarketingAdornMerchantActivityListAdornResponseDetail["goodsList"]) => {
if (mode === 'checked') {
if (selected) {
......@@ -226,12 +257,13 @@ const ActivityProductDrawer: React.FC<Iprops> = (props: Iprops) => {
<div className={styles.container}>
<div className={styles.form}>
<NiceForm
schema={schema}
schema={ignoredSchema}
actions={actions}
onReset={onReset}
onSubmit={onSubmit}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'id', FORM_FILTER_PATH);
useAsyncSelect('activityType', fetchPrimaryOption, ["name", "status"]);
}}
></NiceForm>
</div>
......
......@@ -45,19 +45,14 @@ const schema: ISchema = {
},
type: 'daterange',
'x-component-props': {
placeholder: ['活动开始时间', "活动结束时间"]
placeholder: ['活动开始时间', "活动结束时间"],
showTime: true,
}
},
product: {
productName: {
type: 'string',
"x-component-props": {
placeholder: '活动名称'
}
},
merchantName: {
type: 'string',
"x-component-props": {
placeholder: '商家名称'
placeholder: '商品名称'
}
},
submit: {
......
......@@ -40,9 +40,9 @@ const FormilyActivityProduct: React.FC<Iprops> & { isFieldComponent: boolean } =
const { value, mutators } = props;
const { shopId } = useContext(ShopContext) || {};
const componentProps = props.props?.['x-component-props'] || {} as Iprops['props']['x-component-props'];
const activityImage = componentProps.activityImage || activityImageSvg;
const disabledKeys = componentProps.disabledKeys || [];
const ignoresFilters = componentProps?.activityType ? ['activityType'] : [];
const { state: productVisible, toggle: setProductVisible } = useToggle();
const cacheProductList = useMemo(() => [{ ...value }], [value]);
......@@ -99,6 +99,7 @@ const FormilyActivityProduct: React.FC<Iprops> & { isFieldComponent: boolean } =
onLabelChange={onLabelChange}
/>
<ActivityProductDrawer
ignoresFilters={ignoresFilters}
activityImage={activityImage}
products={cacheProductList}
onOk={onOk}
......
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