Commit 090b9e46 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents e7230a6a f25f01f5
......@@ -8,6 +8,7 @@
*/
import { RouterChild } from '../utils/index';
const ShopRoute: RouterChild = {
path: '/memberCenter/channelAbility',
name: '渠道能力',
......@@ -33,6 +34,13 @@ const ShopRoute: RouterChild = {
component: '@/pages/channel/templateDetail',
},
{
path: `/memberCenter/channelAbility/template/categoryNavigation`,
name: '渠道品类导航页装修',
hideInMenu: true,
noLayout: true,
component: '@/pages/mobileTemplate/categoryNavigation',
},
{
path: '/memberCenter/channelAbility/channelSeo',
name: '店铺SEO设置',
component: '@/pages/channel/channelSeo',
......
......@@ -34,5 +34,8 @@ export interface RouterChild {
* @memberof RouterChild
*/
noMargin?: boolean
/** 是否使用上级路由布局 */
noLayout?: boolean
}
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-08-05 10:28:06
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-10 10:27:19
* @LastEditTime: 2021-09-17 15:48:16
* @Description: 地址选择 FormItem
*/
import React, { useState, useEffect, useMemo, useRef } from 'react';
......@@ -491,12 +491,12 @@ const AddressSelect: React.FC<IProps> = (props) => {
}, [list]);
if (!editable) {
const current = list.find((item) => item.id === value.id);
const current = list.find((item) => item.id === value?.id);
const full = current ? `${current.name} ${current.fullAddress} ${current.phone}` : null;
const isStr = typeof value === 'string';
return (
<div>{full || (!isStr ? `${value.name} ${value.fullAddress} ${value.phone}` : value)}</div>
<div>{full || (!isStr ? `${value?.name || ''} ${value?.fullAddress || ''} ${value?.phone || ''}` : value)}</div>
);
}
......
......@@ -59,3 +59,16 @@
.fileEmpty {
margin-bottom: 0;
}
.uploadContainer {
& > span {
width: 100%;
display: flex;
:global {
.ant-upload {
width: 100%;
}
}
}
}
import React, { useEffect, useState } from 'react';
import cx from 'classnames';
import { UploadProps, UploadChangeParam, UploadFile } from 'antd/lib/upload/interface';
import { UPLOAD_TYPE } from '@/constants';
import { Upload, Progress, Button, message } from 'antd';
import { CloudUploadOutlined, DeleteOutlined } from '@ant-design/icons';
import styles from './UploadFiles.less';
import { UPLOAD_TYPE } from '@/constants';
import pdfIcon from '@/assets/imgs/pdf_icon.png';
import { getAuth } from '@/utils/auth';
import styles from './UploadFiles.less';
type PickProps = "headers" | "action" | "accept" | "beforeUpload" | "onChange" | "fileList"
......@@ -24,7 +24,15 @@ interface PickUploadProps extends Pick<UploadProps, PickProps> {
customizeItemRender?: ((files: UploadFile[], handleRemove: (fileItem: UploadFile) => void) => React.ReactNode) | null,
onRemove?: ((fileItem: UploadFile) => void) | null,
/** 是否显示文件 */
showFiles?: boolean
showFiles?: boolean,
/**
* 上传最大数
*/
maxCount?: number,
/**
* 自定义渲染child
*/
renderUploadChild?: (fileList: any[]) => React.ReactNode,
}
const UploadFiles: React.FC<PickUploadProps> = (props: PickUploadProps) => {
......@@ -43,9 +51,12 @@ const UploadFiles: React.FC<PickUploadProps> = (props: PickUploadProps) => {
mode,
buttonText,
fileContainerClassName,
showFiles
showFiles,
renderUploadChild,
maxCount,
} = props;
const hasFileListProps = "fileList" in props;
const hasMaxCount = typeof maxCount !== 'undefined' ? { maxCount } : {};
const auth = getAuth();
const [files, setFiles] = useState<UploadFile[]>(() => props.fileList || []);
// const renderFiles = hasFileListProps ? props.fileList : files;
......@@ -61,23 +72,22 @@ const UploadFiles: React.FC<PickUploadProps> = (props: PickUploadProps) => {
}, styles.renderFileContainer, fileContainerClassName);
const uploadProps = {
disabled: disable,
name: 'file',
fileList: files,
accept: accept,
action: action,
headers: { ...headers, token: auth.token },
headers: { ...headers, token: auth?.token },
data: {
fileType: UPLOAD_TYPE
},
disabled: disable,
// disabled: loading || disabled,
showUploadList: false,
onChange(info: UploadChangeParam) {
console.log(info.file);
if (info.file.status === 'error' || (info.file.status === 'done' && info.file.response?.code !== 1000)) {
message.error(info.file.response?.message || "上传失败, 请检查上传接口");
return;
}
console.log(123123);
// 如果不存在fileList, 只存在onChange 那么也要改变组件的file
if (!("fileList" in props)) {
const fileList = info.fileList;
......@@ -97,9 +107,9 @@ const UploadFiles: React.FC<PickUploadProps> = (props: PickUploadProps) => {
if (onChange) {
onChange(info);
}
},
beforeUpload
beforeUpload,
...hasMaxCount
};
const handleRemove = (fileItem: UploadFile) => {
......@@ -168,10 +178,11 @@ const UploadFiles: React.FC<PickUploadProps> = (props: PickUploadProps) => {
}
{
!disable && (
<div style={{ order: uploadOrder }}>
<div style={{ order: uploadOrder }} className={styles.uploadContainer}>
<Upload {...uploadProps} >
{renderUploadChild?.(files)}
{
children || (
typeof children !== 'undefined' ? children : (
<Button type={mode} icon={<CloudUploadOutlined />}>
{buttonText}
</Button>
......@@ -201,7 +212,7 @@ UploadFiles.defaultProps = {
}
return true;
},
onChange: (file: UploadChangeParam) => { },
onChange: (file: UploadChangeParam) => {},
customizeItemRender: null,
onRemove: null,
disable: false,
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-05 17:36:45
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-16 10:31:19
* @LastEditTime: 2021-09-17 15:40:27
* @Description: 查看退货数量与退款金额 抽屉
*/
import React, { useEffect, useState } from 'react';
......@@ -203,7 +203,7 @@ const ReturnInfoDrawer: React.FC<ReturnInfoDrawerProps> = ({
setPayInfoLoading(true);
try {
// 编辑状态才请求支付信息,否则默认取申请信息里边的支付信息
if (isEdit && isMateriel) {
if (isEdit && !isMateriel) {
const res = await PublicApi.getOrderCommonAfterSalePaymentFind({
orderId: `${applyInfo.orderId}`,
});
......
......@@ -11,7 +11,6 @@ import { history } from 'umi';
import { PublicApi } from '@/services/api';
import {
GetAsReplaceGoodsGetDetailByConsumerResponse,
GetAsReplaceGoodsPageReturnedGoodsResponse,
} from '@/services/AfterServiceV2Api';
import {
EXCHANGE_OUTER_STATUS_FINISHED,
......@@ -88,8 +87,6 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
headExtra,
}) => {
const [detailInfo, setDetailInfo] = useState<DetailInfo>(null);
const [replaceGoodsList, setReplaceGoodsList] = useState<GetAsReplaceGoodsPageReturnedGoodsResponse>({ data: [], totalCount: 0 });
const [replaceGoodsLoading, setExchangeGoodsLoading] = useState(false);
const [infoLoading, setInfoloading] = useState(false);
const isPointsOrder = detailInfo?.orderType === ORDER_TYPE2_POINTS || detailInfo?.orderType === ORDER_TYPE2_CHANNEL_POINTS;
......@@ -227,30 +224,8 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
});
};
// 获取换货明细列表
const getReplaceGoods = () => {
if (!id) {
return;
}
setExchangeGoodsLoading(true);
PublicApi.getAsReplaceGoodsPageReturnedGoods({
replaceId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setReplaceGoodsList(res.data);
}
}).catch((err) => {
console.warn(err);
}).finally(() => {
setExchangeGoodsLoading(false);
});
};
useEffect(() => {
getDetailInfo();
getReplaceGoods();
}, []);
const handleReceivedConfirmReturnDeliver = (id): Promise<any> => {
......@@ -468,8 +443,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
title="换货商品"
rowKey="detailId"
columns={productColumns}
loading={replaceGoodsLoading}
dataSource={replaceGoodsList.data}
dataSource={detailInfo?.goodsDetailList}
id="goodsDetailList"
/>
</Suspense>
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-06 16:30:44
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-20 16:08:41
* @LastEditTime: 2021-09-16 15:17:24
* @Description: 待新增换货入库单
*/
import React, { useState, useRef } from 'react';
......@@ -44,7 +44,7 @@ const ExchangePrAddWarehousing: React.FC = () => {
confirm({
title: '确认审核操作',
icon: <ExclamationCircleOutlined />,
content: `是否确认审核换货收货单号为${record.replaceDeliveryNo}的换货收货单?`,
content: `是否确认审核换货收货单号为${record.replaceStorageNo}的换货收货单?`,
onOk() {
return new Promise((resolve, reject) => {
PublicApi.postAsReplaceGoodsVerifyReplaceGoodsStorage({
......
......@@ -288,8 +288,8 @@ const ExchangeForm: React.FC<BillsFormProps> = ({
},
{
title: !isPointsOrder ? '采购金额' : '所需积分小计',
dataIndex: 'paidAmount',
render: (text, record) => +text ? ${text}` : record.amount,
dataIndex: 'amount',
render: (text) => ${text}`,
},
{
title: '已换货数量',
......
import React, { Suspense, useEffect, useState } from 'react';
import {
PageHeader,
Descriptions,
Card,
Spin,
Button,
Row,
Col,
Badge,
......@@ -12,13 +8,11 @@ import {
Tooltip,
message,
} from 'antd';
import { FormOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { history } from 'umi';
import { PublicApi } from '@/services/api';
import {
GetAsReplaceGoodsGetDetailBySupplierResponse,
GetAsReplaceGoodsPageReturnedGoodsResponse,
} from '@/services/AfterServiceV2Api';
import {
EXCHANGE_OUTER_STATUS_FINISHED,
......@@ -44,7 +38,6 @@ import {
EXCHANGE_OUTER_STATUS_TAG_MAP,
EXCHANGE_INNER_STATUS_BADGE_MAP,
} from '../../../constants';
import styles from './index.less';
const ProductList = React.lazy(() => import('../../../components/ProductList'));
const ExchangeReceivedInfo = React.lazy(() => import('../../../components/ExchangeReceivedInfo'));
......@@ -101,9 +94,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
headExtra,
}) => {
const [detailInfo, setDetailInfo] = useState<DetailInfo>(null);
const [replaceGoodsList, setReplaceGoodsList] = useState<GetAsReplaceGoodsPageReturnedGoodsResponse>({ data: [], totalCount: 0 });
const [infoLoading, setInfoloading] = useState(false);
const [replaceGoodsLoading, setExchangeGoodsLoading] = useState(false);
const [exchangeAddress, setExchangeAddress] = useState<ExchangeAddressValues>(null);
const [returnAddress, setReturnAddress] = useState<ReturnAddressValues>(null);
......@@ -142,27 +133,6 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
});
};
// 获取换货明细列表
const getReplaceGoods = () => {
if (!id) {
return;
}
setExchangeGoodsLoading(true);
PublicApi.getAsReplaceGoodsPageReturnedGoods({
replaceId: id,
current: `${1}`,
pageSize: `${99999}`,
}).then(res => {
if (res.code === 1000) {
setReplaceGoodsList(res.data);
}
}).catch((err) => {
console.warn(err);
}).finally(() => {
setExchangeGoodsLoading(false);
});
};
const handleReturn = record => {
if (!isEditReturn || !id) {
return;
......@@ -177,7 +147,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
isNeed: record.isNeedReturn === 1 ? 0 : 1,
}).then(res => {
if (res.code === 1000) {
getReplaceGoods();
getDetailInfo();
}
}).finally(() => {
msg();
......@@ -295,7 +265,6 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
useEffect(() => {
getDetailInfo();
getReplaceGoods();
}, []);
const handleExchangeAddressSubmit = values => {
......@@ -521,8 +490,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
title="换货商品"
rowKey="detailId"
columns={productColumns}
loading={replaceGoodsLoading}
dataSource={replaceGoodsList.data}
dataSource={detailInfo?.goodsDetailList}
id="goodsDetailList"
/>
</Suspense>
......
......@@ -79,7 +79,7 @@ const ExchangePrDeliverVerify: React.FC = () => {
value={{
productList: (
info?.goodsDetailList
.filter((item) => item.isNeedReturn && item.deliveryCount > 0)
.filter((item) => item.deliveryCount > 0)
.map((item) => {
// 从换货统计里边找到对应的商品,
const current = info?.replaceStatisticsList.find((statisticsItem) => statisticsItem.productId === item.productId);
......
......@@ -119,6 +119,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
channelTxt: item.channelName,
})),
orderType: detailInfo?.orderType,
refundAmount: record.refundAmount,
});
setVisibleReturnInfo(true);
};
......
......@@ -291,8 +291,8 @@ const ReturnForm: React.FC<BillsFormProps> = ({
},
{
title: '金额',
dataIndex: 'paidAmount',
render: (text, record) => +text ? ${text}` : record.amount,
dataIndex: 'amount',
render: (text) => ${text}`,
},
{
title: '已退货数量',
......
......@@ -124,6 +124,7 @@ const DetailInfo: React.FC<DetailInfoProps> = ({
channelTxt: item.channelName,
})),
orderType: detailInfo?.orderType,
refundAmount: record.refundAmount,
});
setVisibleReturnInfo(true);
};
......
......@@ -84,6 +84,15 @@ const TemplateDetail: React.FC<TemplateDetailPropsType> = (props) => {
}
}
const handleJump = () => {
if (detailInfo?.environment !== 4) {
message.info("暂不支持该类型模板预览")
return;
}
window.location.href = `/memberCenter/channelAbility/template/categoryNavigation?id=${detailInfo.id}&template=${detailInfo.fileName}&type=${shopType}&shopId=${detailInfo.shopId}`
}
return (
<DetailPage
title="查看模板"
......@@ -127,7 +136,7 @@ const TemplateDetail: React.FC<TemplateDetailPropsType> = (props) => {
</div>
{
detailInfo?.environment === 4 && (
<div className={cx(styles.btn, styles.fit)}>
<div className={cx(styles.btn, styles.fit)} onClick={handleJump}>
<LayoutOutlined />
<label>渠道品类导航装修</label>
</div>
......
......@@ -27,11 +27,11 @@ interface PropsSettingsPropsType {
}
const PropsSettings: React.FC<PropsSettingsPropsType> = (props) => {
const { selectedInfo, pageConfig } = props
const { selectedInfo, shopId, pageConfig } = props
const renderSettingItem = () => {
const { props: initProps, propsConfig, parentKey } = selectedInfo || {};
const _props = { ...initProps, ...props, selectedKey: selectedInfo?.selectedKey }
const _props = { ...initProps, shopId, selectedKey: selectedInfo?.selectedKey }
const componentType = propsConfig?.componentType
if (componentType) {
......
......@@ -18,6 +18,7 @@ const getData = async () => {
function useGetLayout() {
const [info, setInfo] = useState<any>(null);
const { id } = usePageStatus();
const [dataSourceFromRequest, setDataSourceFromRequest] = useState<any>(null);
useEffect(() => {
if(!id) {
......@@ -29,9 +30,7 @@ function useGetLayout() {
templateId: id
});
if(code === 1000) {
// setInfo(data);
setInfo({});
console.log(data);
setInfo(data);
}
}
fetchData();
......@@ -40,7 +39,7 @@ function useGetLayout() {
if(info === null) {
return;
}
const dataFromRequest = {};
const { categoryAdornContent } = info;
const { category = [] } = categoryAdornContent || {};
const startKey = 7;
......@@ -66,6 +65,7 @@ function useGetLayout() {
category.forEach((_item, _index) => {
const tabName = "CustomizeTabs.TabItem";
const configKey = startKey + _index;
dataFromRequest[_item.id] = _item;
tabKeys.push(configKey.toString());
// const children = Object.keys(_item.children);
// console.log(children);
......@@ -123,11 +123,12 @@ function useGetLayout() {
...cloneconfig,
...config
};
setDataSourceFromRequest(dataFromRequest);
console.log("newConfig", newConfig);
updatePageConfig(newConfig);
}, [info]);
return { info };
return { info, dataSourceFromRequest };
}
export default useGetLayout;
......@@ -18,6 +18,7 @@ import FormilyUpload from '@/components/UploadFiles/FormilyUploadFiles';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { PublicApi } from '@/services/api';
import { getAuth } from '@/utils/auth';
type SettingPanelType = {
selectedInfo: SelectedInfoType,
......@@ -41,6 +42,7 @@ const ComponentSchema = {
const formActions = createFormActions();
const { onFieldInputChange$ } = FormEffectHooks;
const EditPanel = () => {
const userAuth = getAuth();
const fixtureContext = useContext(context);
const { selectedInfo, pageConfig, activeKey, domKey } = useSelector<SettingPanelType, STATE_PROPS | "activeKey" | "domKey">(['selectedInfo', 'pageConfig', 'activeKey', "domKey"]);
const {state: visible, toggle: setVisible } = useToggle(true);
......@@ -72,7 +74,7 @@ const EditPanel = () => {
secondaryItem: {
secondary: selectedInfo?.props?.id,
title: selectedInfo?.props?.name,
icon: [{ name:selectedInfo?.props?.name, url: selectedInfo?.props?.icon }],
icon: [{ name:selectedInfo?.props?.name, url: selectedInfo?.props?.icon }].filter((_item) => _item.url !== ''),
},
flashSale: {
blockTitle: selectedInfo?.props.title
......@@ -148,6 +150,7 @@ const EditPanel = () => {
});
const renderUploadChild = (value) => {
console.log(value);
const target = value[0];
return (
<div className={styles.image}>
......@@ -165,10 +168,11 @@ const EditPanel = () => {
const handleSubmit = (values) => {
/** 如果是tab 类型修改 */
const key = activeKey === null ? domKey : selectedInfo?.selectedKey || domKey;
const componentType: keyof typeof ComponentSchema = activeKey === null ? 'TabItem' : (selectedInfo as any)?.otherProps?.type;
const componentType: keyof typeof ComponentSchema = activeKey === null ? 'tabItem' : (selectedInfo as any)?.otherProps?.type;
console.log(values);
const formValueToProps = {
TabItem: {
tabItem: {
name: values.title,
id: values.primary
},
......@@ -211,7 +215,7 @@ const EditPanel = () => {
changeProps({
treeKey: key,
props: currentProps,
title: values?.title || values?.name || values?.productName || values.branchName,
title: values?.title || values?.name || values?.rankProduct?.name || values.productName || values?.brand?.name,
});
setVisible(false);
......@@ -220,7 +224,8 @@ const EditPanel = () => {
const fetchPrimaryOption = async () => {
const { data, code } = await PublicApi.getSearchChannelCommodityTemplateGetFirstCategoryListByMemberId({
shopId: fixtureContext!.shopId?.toString()
shopId: fixtureContext!.shopId?.toString(),
memberId: userAuth.memberId,
});
return data;
};
......@@ -233,6 +238,7 @@ const EditPanel = () => {
const { data, code } = await PublicApi.getSearchChannelCommodityTemplateGetSecondCategoryListByMemberId({
shopId: fixtureContext!.shopId?.toString(),
categoryId: activeKey!.toString(),
memberId: userAuth.memberId,
});
if (code === 1000) {
const source = data.map((_item) => ({label: _item.name, value: _item.id}));
......@@ -263,9 +269,11 @@ const EditPanel = () => {
effects={($, actions) => {
useAsyncSelect('primary', fetchPrimaryOption, ["name", "id"]);
onFieldInputChange$('*(primary, secondary)').subscribe(fieldState => {
const { originAsyncData } = fieldState;
const target = originAsyncData.filter((_item) => _item.id === fieldState.value)[0];
actions.setFieldValue('title', target?.name);
console.log(originAsyncData)
const target = originAsyncData.filter((_item) => (_item.id === fieldState.value) || _item.value === fieldState.value)[0];
actions.setFieldValue('title', target?.name || target?.label);
});
}}
......
......@@ -71,7 +71,7 @@ const BranchList = (props) => {
console.log(values);
fetchData({
shopId: fixtureContext?.shopId.toString(),
categoryId: categoryId.toString,
customerCategoryId: categoryId.toString(),
current: current.toString(),
pageSize: pageSize.toString(),
});
......@@ -84,7 +84,8 @@ const BranchList = (props) => {
};
const fetchData = async (params: any) => {
const { data, code } = await PublicApi.getSearchCommodityTemplateGetBrandList(params);
console.log(params);
const { data, code } = await PublicApi.getSearchChannelCommodityTemplateGetBrandList(params);
if (code === 1000) {
setDataSource(data.data);
setTotal(data.totalCount);
......@@ -95,9 +96,10 @@ const BranchList = (props) => {
if (!visible) {
return;
}
console.log(categoryId);
fetchData({
shopId: fixtureContext?.shopId.toString(),
categoryId: categoryId.toString,
customerCategoryId: categoryId.toString(),
current: current.toString(),
pageSize: pageSize.toString(),
});
......
......@@ -4,6 +4,7 @@ import { useSelector } from '@lingxi-disign/react';
import { context } from '../../common/context/context';
import { Product } from '@/pages/transaction/marketingAbility/marketingActivitiesManagement/activePage/fixtures/components/ProductPanel';
import CommodityDrawer from '../CommodityDrawer';
import { getAuth } from '@/utils/auth';
interface Iprops {
......@@ -32,6 +33,7 @@ interface Iprops {
/** 普通商品 */
const FormilyCommodity: React.FC<Iprops> & { isFieldComponent: boolean } = (props: Iprops) => {
const { value, mutators } = props;
const userAuth = getAuth();
/** 1 级分类 id */
const { activeKey } = useSelector<any, "activeKey" >(['activeKey']);
const fixtureContext = useContext(context);
......@@ -67,6 +69,8 @@ const FormilyCommodity: React.FC<Iprops> & { isFieldComponent: boolean } = (prop
return {
shopId: fixtureContext?.shopId.toString(),
categoryId: activeKey,
memberId: userAuth.memberId,
memberRoleId: userAuth.memberRoleId,
};
}, [fixtureContext?.shopId.toString(), activeKey]);
......
......@@ -8,7 +8,7 @@ const ProductContainer = (props) => {
marginRight: '-8px',
flexWrap: 'wrap',
alignItems: 'stretch',
minHeight: '20px'
};
const itemStyle = {
paddingRight: '8px',
......@@ -20,7 +20,7 @@ const ProductContainer = (props) => {
};
return (
<Container card={false} listStyle={listStyle as any} itemStyle={itemStyle as any} {...divProps}>
<Container card={false} listStyle={listStyle as any} itemStyle={itemStyle as any} {...divProps} tooltipTitle="精选商品">
{children}
</Container>
);
......
import React, { CSSProperties } from 'react';
import cs from 'classnames';
import { Card } from 'antd';
import { Card, Tooltip } from 'antd';
import styles from './index.less';
import CustomizeCard from '../Card';
......@@ -12,11 +12,12 @@ interface Iprops {
card?: boolean,
cardProps?: CardProps,
listStyle?: CSSProperties,
itemStyle?: CSSProperties
itemStyle?: CSSProperties,
tooltipTitle?: string,
}
const Container: React.FC<Iprops> = (props: Iprops) => {
const { children, card = true, cardProps = {}, listStyle = {}, itemStyle = {} } = props;
const { children, card = true, cardProps = {}, listStyle = {}, itemStyle = {}, tooltipTitle } = props;
const { onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver, getOperateState, className, ...rest} = props as any;
const divProps = {
onClick, onDrag, onDragEnd, onDragEnter, onDragStart, onMouseOver
......@@ -45,21 +46,24 @@ const Container: React.FC<Iprops> = (props: Iprops) => {
</div>
</CustomizeCard>
) || (
<div className={styles.list} style={listStyle}>
{
React.Children.map(children, (_child, _index) => {
if(_child === null) {
return null;
}
const node = React.cloneElement(_child);
return (
<div key={_index} className={styles.item} style={itemStyle}>
{node}
</div>
);
})
}
</div>
<Tooltip title={tooltipTitle}>
<div className={styles.list} style={listStyle}>
{
React.Children.map(children, (_child, _index) => {
if(_child === null) {
return null;
}
const node = React.cloneElement(_child);
return (
<div key={_index} className={styles.item} style={itemStyle}>
{node}
</div>
);
})
}
</div>
</Tooltip>
)
}
</div>
......
......@@ -17,9 +17,21 @@
margin-bottom: 12px;
.content {
width: 40px;
height: 40px;
display: flex;
flex-direction: column;
// background-color: red;
.image {
width: 40px;
height: 40px;
margin-bottom: 4px;
}
.name {
text-align: center;
color: '#601314'
}
}
.empty {
......@@ -28,6 +40,8 @@
flex-direction: row;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
}
}
......
......@@ -64,8 +64,11 @@ const Item = (props) => {
return (
<div className={styles.item} >
<div {...divProps} className={wrapClass}>
<img src={icon} style={{width: '100%', height: '100%'}} />
<div className={wrapClass}>
<div {...divProps} style={{width: '40px'}}>
<img src={icon} className={styles.image} />
<div className={styles.name}>{name}</div>
</div>
</div>
</div>
);
......
......@@ -7,6 +7,7 @@ import { history } from 'umi';
import styles from './index.less';
import { context } from '../../../common/context/context';
import { PublicApi } from '@/services/api';
import { getAuth } from '@/utils/auth';
const { TabPane } = Tabs;
......@@ -73,6 +74,7 @@ const getData = async (data: any) => {
const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Iprops) => {
const { children } = props;
const auth = getAuth();
const { pageConfig, shopId } = useSelector(['pageConfig', 'shopId']);
const [activeKey, setActiveKey] = useState<string>("2");
const [hasRequestTabKey, setHasRequestTabKey] = useState<string[]>([]);
......@@ -100,6 +102,8 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
shopId: shopId,
current: 1,
pageSize: ids?.length,
memberId: auth.memberId,
memberRoleId: auth.memberRoleId,
} as any);
};
......@@ -112,8 +116,9 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
shopId: shopId,
current: 1,
pageSize: ids.length,
memberId: auth.memberId,
};
return PublicApi.getSearchCommodityTemplateGetBrandList(postData as any);
return PublicApi.getSearchChannelCommodityTemplateGetBrandList(postData as any);
};
/** 并行请求 */
......@@ -197,7 +202,9 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
const { postData, dataSourceMap, domKeyMap2Type } = createPostData(matches![2]);
const resultData: any = await getAnyData(postData);
setHasRequestTabKey((prev) => prev.concat(activeKey));
// setHasRequestTabKey((prev) => prev.concat(activeKey));
const concatActiveKey = hasRequestTabKey.concat(activeKey);
setHasRequestTabKey(concatActiveKey);
const finalData = {};
const keyToValue = {
suggestProduct: 'label',
......@@ -215,7 +222,6 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
secondary: secondaryData,
...resultData
};
console.log(resultDataWithSecondary);
const cloneDeepPageConfig = cloneDeep(pageConfig);
Object.keys(resultDataWithSecondary).forEach((_item) => {
const parentKey = domKeyMap2Type.get(_item);
......@@ -255,7 +261,7 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
...cloneDeepPageConfig,
...finalData,
};
createActions({ type: 'onChangeTabKey', payload: { activeKey: matches?.[1] === 'undefined' ? null : matches?.[1] , domKey: matches?.[2], pageConfig: newConfigData } });
createActions({ type: 'onChangeTabKey', payload: { activeKey: matches?.[1] === 'undefined' ? null : matches?.[1] , domKey: matches?.[2], pageConfig: newConfigData, hasRequestTabKey: concatActiveKey } });
setActiveKey(activeKey);
};
......
......@@ -8,17 +8,18 @@ type SettingPanelType = {
}
interface Iprops {
onSubmit?: null | ((pageConfig:PageConfigType ) => void),
onSubmit?: null | ((pageConfig:PageConfigType, others: any ) => void),
children: React.ReactNode,
loading: boolean
loading: boolean,
dataConfig?: string[],
}
const ToolbarSubmit: React.FC<Iprops> = (props: Iprops) => {
const { pageConfig } = useSelector<SettingPanelType, STATE_PROPS>(['pageConfig']);
const { onSubmit = null, children, loading } = props;
const { onSubmit = null, children, loading, dataConfig = ["pageConfig"] } = props;
const { pageConfig, ...rest } = useSelector<SettingPanelType, STATE_PROPS>(dataConfig as any);
const handleCilck = () => {
onSubmit?.(pageConfig);
onSubmit?.(pageConfig, rest);
};
return (
......
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { Spin, message } from 'antd';
import { BrickProvider, createActions, ModuleTree } from '@lingxi-disign/react';
import { history } from 'umi';
......@@ -54,9 +54,19 @@ const keyFunc = {
}
};
const TITLE_MAP = {
secondary: "二级品类",
flashSale: '限时抢购',
saleRanking: '销量排行',
brand: '品牌精选',
suggestProduct: '精选商品'
};
const CategoryNavigation = () => {
const { info } = useGetLayout();
const { info, dataSourceFromRequest } = useGetLayout();
const { shopId, id } = usePageStatus();
const [loading, setLoading] = useState<boolean>(false);
useEffect(() => {
if (!info) {
return;
......@@ -64,14 +74,20 @@ const CategoryNavigation = () => {
createActions({ type: 'onChangeShopId', payload: { shopId: shopId } });
}, [info]);
const onSave = async (pageConfig) => {
const onSave = async (pageConfig, rest) => {
const hasRequestTabKey = rest.hasRequestTabKey.map((_item: string) => _item.match(/id_(.*)\/\.\$(\d+)/)?.[1]);
/** domKey 从7开始都是tab 的值 */
const tabChildren = pageConfig[4].childNodes.slice(1);
setLoading(true);
const result = tabChildren.map((_nodeKey) => {
if (!pageConfig[_nodeKey]) {
return ;
}
const { id, name, visible = true } = pageConfig[_nodeKey].props;
if (!hasRequestTabKey.includes(id.toString())) {
return dataSourceFromRequest[id];
}
const tabProps = {
id,
name,
......@@ -85,7 +101,7 @@ const CategoryNavigation = () => {
const rest = type === 'suggestProduct' ? { type: props.type, num: props.num } : {};
tabItemData[type] = {
title: props?.title || '标题',
title: props?.title || TITLE_MAP[type],
...rest,
children: childNodes.map((_son) => {
const sonData = pageConfig[_son];
......@@ -98,12 +114,12 @@ const CategoryNavigation = () => {
tabProps['children'] = tabItemData;
return tabProps;
});
console.log(result);
const postData = { style: 0, category: result };
const { data, code } = await PublicApi.postTemplateAdornAppChannelSave({
templateId: Number(id),
categoryAdornContent: postData as any,
});
setLoading(false);
if (code === 1000) {
history.goBack();
}
......@@ -120,7 +136,7 @@ const CategoryNavigation = () => {
customReducer={customReducer}
>
<div className={styles['wrapper']}>
<Toolbar title="正在编辑:品类导航页" extra={<ToolbarSubmit loading={false} onSubmit={onSave}>保存</ToolbarSubmit>} />
<Toolbar title="正在编辑:品类导航页" extra={<ToolbarSubmit loading={loading} dataConfig={['pageConfig', 'hasRequestTabKey']} onSubmit={onSave}>保存</ToolbarSubmit>} />
<div className={styles['content']}>
<div className={styles.tree}>
<ModuleTree />
......
......@@ -7,13 +7,15 @@ const columns_1 = ({
setDataSource,
handleDelete,
form,
current
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
......@@ -73,88 +75,97 @@ const columns_1 = ({
</Tooltip>,
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!value) {
return Promise.reject(new Error('请输入活动价格'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${_index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!value) {
return Promise.reject(new Error('请输入活动价格'));
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', index)} onBlur={(e) => handleInputChange(e, 'activityPrice', index)} />
</Form.Item>
)
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', _index)} onBlur={(e) => handleInputChange(e, 'activityPrice', _index)} />
</Form.Item>
)
}
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
......@@ -7,6 +7,7 @@ const columns_2 = ({
setDataSource,
handleDelete,
form,
current
}) => {
const sumTotal = (price, num) => {
return (Number(price) - Number(num))
......@@ -16,7 +17,8 @@ const columns_2 = ({
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
if (name === 'plummetPrice') {
return {
..._item,
......@@ -84,27 +86,30 @@ const columns_2 = ({
</Tooltip>,
key: 'plummetPrice',
dataIndex: 'plummetPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`plummetPrice_${index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!value) {
return Promise.reject(new Error('请输入活动价格'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`plummetPrice_${_index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!value) {
return Promise.reject(new Error('请输入活动价格'));
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'plummetPrice', index)} onBlur={(e) => handleInputChange(e, 'plummetPrice', index)} />
</Form.Item>
)
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'plummetPrice', _index)} onBlur={(e) => handleInputChange(e, 'plummetPrice', _index)} />
</Form.Item>
)
}
},
{
title: '活动价格',
......@@ -116,62 +121,68 @@ const columns_2 = ({
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
......@@ -7,13 +7,15 @@ const columns_3 = ({
setDataSource,
handleDelete,
form,
current
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
if (name === 'discount') {
return {
..._item,
......@@ -81,29 +83,32 @@ const columns_3 = ({
</Tooltip>,
key: 'discount',
dataIndex: 'discount',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`discount_${index}`}
rules={[{
required: true,
message: '请输入折扣'
},
() => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
if (!pattern.test(value)) {
return Promise.reject(new Error('折扣必须大于0'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`discount_${_index}`}
rules={[{
required: true,
message: '请输入折扣'
},
})
]}
>
<Input style={{ width: '112px' }} addonAfter="折" onPressEnter={(e) => handleInputChange(e, 'discount', index)} onBlur={(e) => handleInputChange(e, 'discount', index)} />
</Form.Item>
)
() => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
if (!pattern.test(value)) {
return Promise.reject(new Error('折扣必须大于0'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} addonAfter="折" onPressEnter={(e) => handleInputChange(e, 'discount', _index)} onBlur={(e) => handleInputChange(e, 'discount', _index)} />
</Form.Item>
)
}
},
{
title: '活动价格',
......@@ -115,62 +120,68 @@ const columns_3 = ({
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
......@@ -8,13 +8,15 @@ const columns_4 = ({
form,
handlCollocation,
value,
current
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
......@@ -71,62 +73,68 @@ const columns_4 = ({
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
import React from 'react';
import { Image, Form, Input, Popconfirm, Typography } from 'antd';
const columns_5 = ({
const columns_5 = ({
dataSource,
setDataSource,
handleDelete,
form,
current
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
......@@ -69,88 +71,97 @@ const columns_5 = ({
title: '团购价格',
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
if (!value) {
return Promise.reject(new Error('请输入团购价格'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${_index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
if (!value) {
return Promise.reject(new Error('请输入团购价格'));
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
if (!pattern.test(value) || (Number(value) >= Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', index)} onBlur={(e) => handleInputChange(e, 'activityPrice', index)} />
</Form.Item>
)
}]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', _index)} onBlur={(e) => handleInputChange(e, 'activityPrice', _index)} />
</Form.Item>
)
}
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
......@@ -7,13 +7,15 @@ const columns_7 = ({
setDataSource,
handleDelete,
form,
current
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
const _idx = Number(((current - 1) * 10) + _i);
if (_idx === index) {
return {
..._item,
[name]: Number(value)
......@@ -73,93 +75,102 @@ const columns_7 = ({
</Tooltip>,
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${index}`}
rules={[{
required: true,
message: '请输入秒杀价格'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!pattern.test(value)) {
return Promise.reject(new Error('最多保留4位小数'));
}
if ((Number(value) > Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于等于商品价格'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
name={`activityPrice_${_index}`}
rules={[{
required: true,
message: '请输入秒杀价格'
},
})
]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', index)} onBlur={(e) => handleInputChange(e, 'activityPrice', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
if (!pattern.test(value)) {
return Promise.reject(new Error('最多保留4位小数'));
}
if ((Number(value) > Number(_record.price))) {
return Promise.reject(new Error('必须大于0且小于等于商品价格'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={(e) => handleInputChange(e, 'activityPrice', _index)} onBlur={(e) => handleInputChange(e, 'activityPrice', _index)} />
</Form.Item>
)
}
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${index}`}
dependencies={[`restrictTotalNum_${index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictNum_${_index}`}
dependencies={[`restrictTotalNum_${_index}`]}
rules={[{
required: true,
message: '请输入个人限购数量'
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', index)} onBlur={(e) => handleInputChange(e, 'restrictNum', index)} />
</Form.Item>
)
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictTotalNum = getFieldValue(`restrictTotalNum_${_index}`);
if (!pattern.test(value) || !(Number(value) < Number(restrictTotalNum))) {
return Promise.reject(new Error('必须大于0且小于活动限购总数量'));
}
return Promise.resolve();
},
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictNum', _index)} />
</Form.Item>
)
}
},
{
title: '活动限购总数量',
key: 'restrictTotalNum',
dataIndex: 'restrictTotalNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
render: (_text, _record, index) => {
const _index = Number(((current - 1) * 10) + index);
return (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
validateFirst
name={`restrictTotalNum_${_index}`}
rules={[{
required: true,
message: '请输入活动限购总数量'
},
({ getFieldValue }) => ({
validator: (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,3})?$/;
const restrictNum = getFieldValue(`restrictNum_${_index}`);
if (!pattern.test(value) || !(Number(value) > Number(restrictNum))) {
return Promise.reject(new Error('必须大于0且大于个人限购数量'));
}
return Promise.resolve();
}
return Promise.resolve();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', _index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', _index)} />
</Form.Item>
)
}
},
{
title: '操作',
......
......@@ -8,6 +8,7 @@ import ListModalLayout from '@/pages/transaction/marketingAbility/components/lis
import CollocationLayout from '@/pages/transaction/marketingAbility/components/collocationLayout';
import { remindLayout, RemindLayoutProps } from '@/pages/transaction/marketingAbility/paltformSign/readySubmitExamine/components/productListLayout/remind';
import CouponsListLayout from '@/pages/transaction/marketingAbility/components/couponsListLayout';
import { number } from 'yargs';
type optionProps = {
/** key */
......@@ -42,15 +43,18 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
const [skuId, setSkuId] = useState<number>(0); // 当前设置商品的id
const [remind, setRemind] = useState<RemindLayoutProps>({});
const [collocation, setCollocation] = useState<any[]>([]);
const [current, setCurrent] = useState<number>(1);
const handlesStFieldsValue = () => {
const params = [...dataSource];
const _pagination = (current - 1) * 10;
params.forEach((_item, _i) => {
const index = Number(_pagination + _i)
form.setFieldsValue({
[`plummetPrice_${_i}`]: _item.plummetPrice,
[`activityPrice_${_i}`]: _item.activityPrice,
[`restrictNum_${_i}`]: _item.restrictNum,
[`restrictTotalNum_${_i}`]: _item.restrictTotalNum,
[`plummetPrice_${index}`]: _item.plummetPrice,
[`activityPrice_${index}`]: _item.activityPrice,
[`restrictNum_${index}`]: _item.restrictNum,
[`restrictTotalNum_${index}`]: _item.restrictTotalNum,
})
})
}
......@@ -87,8 +91,8 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
}
const columns = useMemo(() => {
return Columns[value]?.({ dataSource, setDataSource, handleDelete, form, setIdNotInList, handlCollocation, value })
}, [value, dataSource])
return Columns[value]?.({ dataSource, setDataSource, handleDelete, form, setIdNotInList, handlCollocation, value, current })
}, [value, dataSource, current])
const toggle = (flag: boolean) => {
const activityDefined = form.getFieldValue('activityDefined') || getActivityDefinedBO;
......@@ -179,6 +183,10 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
setDataSource(fields)
}
const handleOnShowSizeChange = (current, _size) => {
setCurrent(current)
}
return (
<CardLayout
id="productListLayout"
......@@ -195,6 +203,7 @@ const ProductListLayout: React.FC<ProductListProps> = (props: any) => {
dataSource={dataSource}
pagination={{
size: 'small',
onChange: handleOnShowSizeChange
}}
/>
{/* 选择活动商品 */}
......
......@@ -78,6 +78,7 @@ const AddedMarketing = () => {
roleType: item.roleId,
roleTypeName: item.roleName,
level: item.level,
levelTyp: item.levelType,
levelTypeName: item.levelTypeName,
levelTag: item.levelTag,
}
......
......@@ -123,6 +123,7 @@ const BasicInfoLayout: React.FC<BasicInfoProps> = (props: any) => {
]}>
<DatePicker
showTime
showNow={false}
allowClear
disabledDate={(current) => startTimeDisabled(current, 'endTime')}
/>
......@@ -133,6 +134,7 @@ const BasicInfoLayout: React.FC<BasicInfoProps> = (props: any) => {
rules={[{ required: true, message: '请选择活动结束时间' }]}>
<DatePicker
showTime
showNow={false}
allowClear
disabledDate={(current) => endTimeDisabled(current, 'startTime')}
/>
......
......@@ -131,7 +131,6 @@ const PartakeUserLayout: React.FC<PartakeUserLayoutProps> = (props: any) => {
</Checkbox.Group>
</Form.Item>
)}
</CardLayout>
)
}
......
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