Commit def7f675 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents b86060d8 3d23566e
......@@ -54,6 +54,14 @@ interface IProps {
* 是否可编辑的
*/
editable?: boolean,
/**
* 是否显示下拉框
*/
echo?: boolean,
/**
* 只显示文字
*/
extra?: React.ReactNode,
}
export type SubmitValuesType = {
......@@ -111,6 +119,8 @@ const AddressSelect: React.FC<IProps> = (props) => {
isDefaultAddress = false,
disabled = false,
editable = true,
echo = false,
extra,
} = props;
const [list, setList] = useState<AddressValueType[]>([]);
const [internalValue, setInternalValue] = useState<AddressValueType>();
......@@ -412,31 +422,31 @@ const AddressSelect: React.FC<IProps> = (props) => {
value: v.code,
})));
});
const res = addressType === 2 ? await PublicApi.getLogisticsShipperAddressGet({ id: `${id}`}) : await PublicApi.getLogisticsReceiverAddressGet({ id: `${id}`});
if (res.code === 1000) {
formActions.setFieldValue('name', addressType === 2 ? (res.data as GetLogisticsShipperAddressGetResponse).shipperName : (res.data as GetLogisticsReceiverAddressGetResponse).receiverName);
formActions.setFieldValue('provinceCode', res.data.provinceCode);
formActions.setFieldValue('cityCode', res.data.cityCode);
formActions.setFieldValue('districtCode', res.data.districtCode);
formActions.setFieldValue('detailed', res.data.address);
formActions.setFieldValue('postalCode', res.data.postalCode);
formActions.setFieldValue('areaCode', res.data.areaCode);
formActions.setFieldValue('phone', res.data.phone);
formActions.setFieldValue('tel', res.data.tel);
formActions.setFieldValue('isDefault', res.data.isDefault);
formActions.setFieldState('ADDRESS_NEW', state => {
state.visible = true;
});
formActions.setFieldState('ADD_ACTION', state => {
state.props['x-component-props'] = {
flag: false,
};
});
const res = addressType === 2 ? await PublicApi.getLogisticsShipperAddressGet({ id: `${id}` }) : await PublicApi.getLogisticsReceiverAddressGet({ id: `${id}` });
if (res.code === 1000) {
formActions.setFieldValue('name', addressType === 2 ? (res.data as GetLogisticsShipperAddressGetResponse).shipperName : (res.data as GetLogisticsReceiverAddressGetResponse).receiverName);
formActions.setFieldValue('provinceCode', res.data.provinceCode);
formActions.setFieldValue('cityCode', res.data.cityCode);
formActions.setFieldValue('districtCode', res.data.districtCode);
formActions.setFieldValue('detailed', res.data.address);
formActions.setFieldValue('postalCode', res.data.postalCode);
formActions.setFieldValue('areaCode', res.data.areaCode);
formActions.setFieldValue('phone', res.data.phone);
formActions.setFieldValue('tel', res.data.tel);
formActions.setFieldValue('isDefault', res.data.isDefault);
formActions.setFieldState('ADDRESS_NEW', state => {
state.visible = true;
});
formActions.setFieldState('ADD_ACTION', state => {
state.props['x-component-props'] = {
flag: false,
};
});
editAddressId.current = id;
} else {
message.warn('获取地址信息失败');
}
editAddressId.current = id;
} else {
message.warn('获取地址信息失败');
}
} catch (error) {
console.warn(error);
}
......@@ -471,17 +481,24 @@ const AddressSelect: React.FC<IProps> = (props) => {
}}
>
<div className={styles['address-select']}>
<div className={styles['address-select-input']}>
<Select
options={options}
value={value?.id}
onChange={handleSelectChange}
disabled={disabled}
style={{
width: '100%',
}}
/>
</div>
{!echo && (
<div className={styles['address-select-input']}>
<Select
options={options}
value={value?.id}
onChange={handleSelectChange}
disabled={disabled}
style={{
width: '100%',
}}
/>
</div>
)}
{echo && (
<div className={styles['address-select-input']}>
{extra}
</div>
)}
<Button
onClick={() => handleVisibleDrawer(true)}
className={styles['address-select-action']}
......
This diff is collapsed.
......@@ -13,6 +13,8 @@ const count = 0;
const BasicLayout: React.FC<BasicInfoProps> = (props: any) => {
const { effect } = props;
console.log(effect)
return (
<Card
id='basicLayout'
......
......@@ -10,7 +10,6 @@ import { SaveOutlined } from "@ant-design/icons";
import AttachLayout from "./components/attach";
import { getCookie } from '@/utils/cookie'
import { PublicApi } from "@/services/api";
import { isEmpty } from "lodash";
const layout: any = {
colon: false,
......@@ -69,7 +68,9 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
phoneCode: res.phoneCode,
shopId: res.shopId,
}
id && (params.id = id);
if (id && !two) {
params.id = id
}
fetchRequest({ ...params }).then(res => {
if (res.code !== 1000) {
setLoading(false)
......@@ -167,6 +168,10 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
memberId: data.memberId,
memberRoleId: data.memberRoleId,
taxRate: data.taxRate,
upperMemberId: data.upperMemberId,
upperMemberName: data.upperMemberName,
upperMemberRoleId: data.upperMemberRoleId,
upperMemberRoleName: data.upperMemberRoleName,
})
setMenberInfo({
memberId: data.memberId,
......@@ -189,7 +194,10 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
const { data } = res;
const inquiryListProductRequests: any[] = [];
setEnclosureUrls(data.enclosureUrls)
setFullAddress()
setFullAddress({
fullAddress: data.fullAddress,
fullAddressId: data.fullAddressId,
})
if (two) {
PublicApi.getTransactionInquiryGetUpperMemberCommodity({ inquiryId: id }).then(res => {
if (res.code !== 1000) {
......@@ -208,23 +216,29 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
logistics: '',
memberId: item.memberId,
memberRoleId: item.memberRoleId,
taxRate: item.taxRate
taxRate: item.taxRate,
upperMemberId: item.upperMemberId,
upperMemberName: item.upperMemberName,
upperMemberRoleId: item.upperMemberRoleId,
upperMemberRoleName: item.upperMemberRoleName,
})
})
setMenberInfo({
memberId: res.data.memberId,
roleId: res.data.memberRoleId,
roleName: res.data.memberName,
roleName: res.data.memberRoleName,
})
setInquiryProduct(inquiryListProductRequests)
})
form.setFieldsValue({
...data,
deliveryTime: moment(data.deliveryTime),
quotationAsTime: moment(data.quotationAsTime),
"inquiryListProductRequests": inquiryListProductRequests,
"enclosureUrls": data.enclosureUrls,
form.setFieldsValue({
...data,
deliveryTime: moment(data.deliveryTime),
quotationAsTime: moment(data.quotationAsTime),
"inquiryListProductRequests": inquiryListProductRequests,
"enclosureUrls": data.enclosureUrls,
memberName: res.data.memberName,
})
})
} else {
setMenberInfo({
......@@ -291,7 +305,7 @@ const AddedFormLayout: React.FC<AddedFormLayoutProps> = (props: any) => {
>
<BasicInfoLatyout getMemberInfo={getMemberInfo} memb={memberInfo} isEdit={spam || two} />
<InquiryProductLayout getInquiryProduct={getInquiryProduct} member={memberInfo} setInquiryProduct={inquiryProduct} />
<TradeTermsLayout getFullAddress={getFullAddress} getContacts={getContacts} fullAddress={fullAddress} />
<TradeTermsLayout isEdit={two} getFullAddress={getFullAddress} getContacts={getContacts} fullAddress={fullAddress} />
<AttachLayout enclosureUrls={enclosureUrls} getEnclosureUrls={getEnclosureUrls} removeEnclosureUrls={removeEnclosureUrls} />
</Form>
}
......
......@@ -145,6 +145,8 @@ const InquiryProductLayout: React.FC<InquiryProductLayoutProps> = (props: any) =
taxRate: v.taxRate,
upperCommoditySkuId: v.commodityUnitPriceAndPicId,
upperMemberId: v.upperMemberId,
upperMemberName: v.upperMemberName,
upperMemberRoleName: v.upperMemberRoleName,
upperMemberRoleId: v.upperMemberRoleId,
})
})
......
......@@ -22,10 +22,12 @@ interface TradeTermsLayoutProps {
getContacts?: (e) => void,
/** 回显数据 */
fullAddress?: any,
/** 二次询价 */
isEdit?: boolean,
}
const TradeTermsLayout: React.FC<TradeTermsLayoutProps> = (props: any) => {
const { getFullAddress, getContacts, fullAddress } = props;
const { getFullAddress, getContacts, fullAddress, isEdit } = props;
const [visible, setVisible] = useState<boolean>(false)
const [address, setaddress] = useState<any>({});
const [telCode, setTelCode] = useState<any>([]);
......@@ -111,7 +113,15 @@ const TradeTermsLayout: React.FC<TradeTermsLayoutProps> = (props: any) => {
/>
</Form.Item>
<Form.Item label='交付地址'>
<AddressSelect value={address} isDefaultAddress addressType={1} disabled={false} onChange={getFullAddress} />
<AddressSelect
echo={isEdit}
extra={fullAddress.fullAddress}
value={address}
isDefaultAddress
addressType={1}
disabled={false}
onChange={getFullAddress}
/>
</Form.Item>
<Form.Item label='报价截止时间' name='quotationAsTime' rules={[{ required: true, message: '请选择报价截止时间' }]}>
<DatePicker
......
import React, { useCallback, useEffect, useState } from 'react';
import React from 'react';
import AddForm from './addForm';
import { history } from 'umi';
import { PublicApi } from '@/services/api';
import { isEmpty } from 'lodash';
const RfqEnquiryOrder = (props: any) => {
const { id } = history.location.query;
const [spam, setSpam] = useState<any>({});
const handleGetSpam = useCallback(async () => {
await PublicApi.getTransactionInquiryGetUpperMemberCommodity({ inquiryId: id }).then(res => {
if (res.code !== 1000) {
return
}
setSpam(res.data)
})
}, [])
useEffect(() => {
handleGetSpam()
}, [])
return (
<AddForm
......
......@@ -286,18 +286,18 @@ export const GeneralEffect = (int, data) => {
return [
{
col: [
{ label: '每日秒杀时间段', extra: '' },
{ label: '每日秒杀时间段', extra: `${format(data.startTime, 'HH:mm:ss')}~${format(data.endTime, 'HH:mm:ss')}` },
{ label: '活动描述', extra: data.describe }
]
},
{
col: [
{ label: '叠加优惠券', extra: '' },
{ label: '叠加优惠券', extra: data.allowCoupon ? '允许叠加' : '不允许叠加' },
]
},
{
col: [
{ label: '超限规则', extra: '' },
{ label: '超限规则', extra: data.exceedRule === 1 ? '原价购买' : '不可购买' },
]
}
]
......
......@@ -111,99 +111,99 @@ const CollocationLayout: React.FC<CollocationLayoutProps> = (props: any) => {
return (
<TableModal
modalType="Drawer"
visible={visible}
title="选择活动商品"
fetchData={handleFetchData}
columns={columns}
mode="checkbox"
tableProps={{
rowKey: 'id',
}}
customKey="id"
onClose={() => toggle(false)}
onOk={handleOk}
effects={($, actions) => {
actions.reset()
useStateFilterSearchLinkageEffect($, actions, "commodityName", FORM_FILTER_PATH)
}}
schema={{
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
properties: {
commodityName: {
type: "string",
"x-component": "Search",
"x-mega-props": {},
"x-component-props": {
placeholder: "商品名称",
align: "flex-left",
}
modalType="Drawer"
visible={visible}
title="选择活动商品"
fetchData={handleFetchData}
columns={columns}
mode="checkbox"
tableProps={{
rowKey: 'id',
}}
customKey="id"
onClose={() => toggle(false)}
onOk={handleOk}
effects={($, actions) => {
actions.reset()
useStateFilterSearchLinkageEffect($, actions, "commodityName", FORM_FILTER_PATH)
}}
schema={{
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
properties: {
commodityName: {
type: "string",
"x-component": "Search",
"x-mega-props": {},
"x-component-props": {
placeholder: "商品名称",
align: "flex-left",
}
}
}
},
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
justifyContent: "flex-start",
flexWrap: "nowrap"
},
colStyle: {//改变间隔
marginRight: 20
}
},
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
justifyContent: "flex-start",
flexWrap: "nowrap"
properties: {
PRO_LAYOUT: {
type: "object",
"x-component": "mega-layout",
"x-mega-props": {
span: 5
},
colStyle: {//改变间隔
marginRight: 20
}
},
properties: {
PRO_LAYOUT: {
type: "object",
"x-component": "mega-layout",
"x-mega-props": {
span: 5
},
"x-component-props": {
inline: true
},
properties: {
customerCategoryId: {
type: "string",
"x-component-props": {
placeholder: "商品品类",
style: {
width: 160
}
},
enum: []
"x-component-props": {
inline: true
},
properties: {
customerCategoryId: {
type: "string",
"x-component-props": {
placeholder: "商品品类",
style: {
width: 160
}
},
brandId: {
type: "string",
"x-component-props": {
placeholder: "商品品牌",
style: {
width: 160
}
},
enum: []
enum: []
},
brandId: {
type: "string",
"x-component-props": {
placeholder: "商品品牌",
style: {
width: 160
}
},
}
},
sumbit: {
"x-component": "Submit",
"x-mega-props": {
span: 1
enum: []
},
"x-component-props": {
children: "查询"
}
}
},
sumbit: {
"x-component": "Submit",
"x-mega-props": {
span: 1
},
"x-component-props": {
children: "查询"
}
}
}
}
}}
/>
}
}}
/>
)
}
export default CollocationLayout
......@@ -459,7 +459,9 @@ export const Columns = (int) => {
秒杀价格 <QuestionCircleOutlined />
</Tooltip>,
key: 'activityPrice',
dataIndex: 'activityPrice'
dataIndex: 'activityPrice',
editable: true,
},
{
title: '个人限购数量',
......@@ -475,8 +477,9 @@ export const Columns = (int) => {
},
{
title: '操作',
key: '',
dataIndex: ''
key: 'operation',
dataIndex: 'operation',
operation: true,
},
]
case 14:
......
......@@ -3,7 +3,21 @@ import { CaretRightOutlined, DeleteOutlined } from '@ant-design/icons';
import cx from 'classnames';
import style from '../../index.less';
type RemindLayoutProps = {
/** 弹窗标题 */
modalTitle?: string,
/** 选择商品按钮名称 */
buttonTitle?: string,
/** 列表标题 */
listTitle?: string
/** 列表label */
label?: {[key: number]: string},
/** 提醒 */
message?: {[key: number]: string},
}
interface CollapseLayoutProps {
/** message */
remind?: RemindLayoutProps,
/** 组编号优惠阶梯换购阶梯 */
index: number,
/** 删除一个 */
......@@ -11,7 +25,7 @@ interface CollapseLayoutProps {
}
const CollapseLayout: React.FC<CollapseLayoutProps> = (props: any) => {
const { children, index, deletion } = props;
const { remind, children, index, deletion } = props;
const [isActive, setIsActive] = useState<boolean>(false);
useEffect(() => {
......@@ -26,7 +40,7 @@ const CollapseLayout: React.FC<CollapseLayoutProps> = (props: any) => {
{/* 头部 */}
<div className={style.collapse_header} onClick={() => setIsActive(!isActive)}>
<CaretRightOutlined rotate={isActive ? 90 : 0} />
<span className={style.collapse_arrow}>搭配商品</span>
<span className={style.collapse_arrow}>{remind.listTitle}</span>
<DeleteOutlined onClick={() => deletion(index)} />
</div>
{/* 内容 */}
......
import React, { Fragment, useEffect, useState } from 'react';
import { Form, Input, Row, Col, Image } from 'antd';
import { Form, Input, Row, Col, Image, Space } from 'antd';
import { DeleteOutlined } from '@ant-design/icons';
import style from '../../index.less';
......@@ -26,7 +26,22 @@ type ListProps = {
productImgUrl?: string
}
type RemindLayoutProps = {
/** 弹窗标题 */
modalTitle?: string,
/** 选择商品按钮名称 */
buttonTitle?: string,
/** 列表标题 */
listTitle?: string
/** 列表label */
label?: { [key: number]: string },
/** 提醒 */
message?: { [key: number]: string },
}
export interface ProductLayoutProps {
/** message */
remind?: RemindLayoutProps,
/** 最外层标号 */
index: number,
/** list 数据 */
......@@ -38,7 +53,7 @@ export interface ProductLayoutProps {
}
const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
const { index, list, onDeletion, onEntry } = props;
const { remind, index, list, onDeletion, onEntry } = props;
const handleChange = (e, name, _index?) => {
onEntry(name, Number(e.target.value), _index)
......@@ -48,22 +63,24 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<Fragment>
{/* 套餐价格 */}
<Form.Item
name={`groupPrice_${index}`}
label='套餐价格'
rules={[{ required: true, message: '请输入套餐价格' }]}
name={`${remind.type}_${index}`}
label={remind.label[1]}
rules={[{ required: true, message: remind.message[4] }]}
>
<Input addonAfter='元' onBlur={(e) => handleChange(e, 'groupPrice' )} />
<Input addonBefore={remind.type === 'limitValue' && '买'} addonAfter={remind.label[2]} onBlur={(e) => handleChange(e, `${remind.type}`)} />
</Form.Item>
{/* 搭配商品 */}
{list.map((_item: ListProps, _index: number) => (
<div key={`list_${_index + 1}`}>
<div className={style.productLayout_title}>
<span className={style.productLayout_arrow}>搭配商品{_index + 1}</span>
<span className={style.productLayout_arrow}>
{remind.label[3]}{_index + 1}
</span>
<DeleteOutlined onClick={() => onDeletion(_index)} />
</div>
<div className={style.productLayout_contenxt}>
<Form.Item
label='搭配商品'
label={remind.label[3]}
className={style.productLayout_formItem}
>
<div className={style.productLayout_item}>
......@@ -87,11 +104,11 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
</div>
</Form.Item>
<Form.Item
label='搭配数量'
label={remind.label[4]}
name={`num_${index}_${_index}`}
rules={[{ required: true, message: '请输入搭配数量' }]}
rules={[{ required: true, message: remind.message[5] }]}
>
<Input addonAfter={_item.unit} onBlur={(e) => handleChange(e, 'num', _index )} />
<Input addonAfter={_item.unit} onBlur={(e) => handleChange(e, 'num', _index)} />
</Form.Item>
</div>
</div>
......
......@@ -9,11 +9,25 @@ import CollocationLayout from '../collocationLayout';
const layout: any = {
labelCol: { style: { width: "100px" } },
labelAlign: "left",
validateFirst: true
};
type RemindLayoutProps = {
/** 弹窗标题 */
modalTitle?: string,
/** 选择商品按钮名称 */
buttonTitle?: string,
/** 列表标题 */
listTitle?: string
/** 列表label */
label?: {[key: number]: string},
/** 提醒 */
message?: {[key: number]: string},
}
interface ListModalLayoutProps {
idNotInList?: number[],
/** messges */
remind?: RemindLayoutProps,
/** 数据回显 */
value?: any[],
/** 设置标题 */
......@@ -63,7 +77,7 @@ interface GoodsSubsidiaryListProps {
}
const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const { idNotInList, value, shopIdList, title, visible, onClose, onConfirm } = props;
const { idNotInList, remind, value, shopIdList, title, visible, onClose, onConfirm } = props;
const [form] = Form.useForm();
const [dataSource, setDataSource] = useState<GoodsSubsidiaryListProps[]>([]);
const [tableModalVisible, setTableModalVisible] = useState<boolean>(false);
......@@ -94,7 +108,6 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
})]
}
form.setFieldsValue({
'dataSource': fields,
[`dataSource_${idx}`]: fields[idx].list,
})
setDataSource(fields);
......@@ -102,7 +115,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const handleSubmit = (selectRowRecord: any) => {
if (isEmpty(selectRowRecord)) {
message.warning('请选择搭配商品!')
message.warning(remind.message[1])
return
}
handleComposed(selectRowRecord)
......@@ -111,6 +124,10 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const handleClick = () => {
form.validateFields().then(_res => {
if (isEmpty(_res)) {
message.warning(remind.message[2])
return
}
onConfirm(dataSource)
})
}
......@@ -142,10 +159,11 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const handleDeletion = (index: number) => {
const fields = [...dataSource];
fields.splice(index, 1);
form.resetFields()
fields.forEach((item, _index) => {
item.list.forEach((_item, __index) => {
form.setFieldsValue({
'dataSource': fields,
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
})
......@@ -164,10 +182,12 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const handleDeletionColloCation = (index: number, _index: number) => {
const fields: GoodsSubsidiaryListProps[] = [...dataSource];
fields[index].list.splice(_index, 1);
form.resetFields()
fields.forEach((item, _index) => {
item.list.forEach((_item, __index) => {
form.setFieldsValue({
'dataSource': fields,
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
})
})
......@@ -178,8 +198,10 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
/** 输入一个价格或者数量 */
const handleEntryNumber = (index: number, name: string, num: number, _index?: number) => {
const fields: GoodsSubsidiaryListProps[] = [...dataSource];
console.log(name)
if (name === 'groupPrice' || name === 'limitValue') {
fields[index][name] = Number(num);
console.log(fields[index][name])
} else {
fields[index].list[_index][name] = Number(num);
}
......@@ -187,12 +209,13 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
}
useEffect(() => {
console.log(value, 10086)
const fields = [...value];
fields.forEach((item, _index) => {
item.list.forEach((_item, __index) => {
form.setFieldsValue({
'dataSource': fields,
[`dataSource_${_index}`]: fields[_index].list,
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
})
......@@ -206,38 +229,40 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
width={600}
title={title}
visible={visible}
destroyOnClose
onClose={onClose}
footer={renderFooter()}
>
{/* 分组列表 */}
<Form {...layout} form={form}>
<Form.Item style={{ marginBottom: '0px' }} name='dataSource' rules={[{ required: true, message: '请设置搭配商品' }]}>
{dataSource.map((item: GoodsSubsidiaryListProps, index: number) => (
<Form.Item
style={{ marginBottom: '0px' }}
name={`dataSource_${index}`}
rules={[{ required: true, message: '请选择搭配商品' }]}
key={`CollapseLayout_${index}`}
{dataSource.map((item: GoodsSubsidiaryListProps, index: number) => (
<Form.Item
style={{ marginBottom: '0px' }}
name={`dataSource_${index}`}
rules={[{ required: true, message: remind.message[3] }]}
key={`CollapseLayout_${index}`}
>
<CollapseLayout
index={index}
remind={remind}
deletion={handleDeletion}
>
<CollapseLayout
index={index}
deletion={handleDeletion}
>
{!isEmpty(item.list) && (
<ProductLayout
index={index}
list={item.list}
onDeletion={(_index: number) => handleDeletionColloCation(index, _index)}
onEntry={(name: string, num: number, _index?: number) => handleEntryNumber(index, name, num, _index)}
/>
)}
{/* 选择搭配商品 */}
<Button type="dashed" block icon={<PlusOutlined />} onClick={() => handleCollocation(index)}>
选择搭配商品
</Button>
</CollapseLayout>
</Form.Item>
))}
</Form.Item>
{!isEmpty(item.list) && (
<ProductLayout
index={index}
remind={remind}
list={item.list}
onDeletion={(_index: number) => handleDeletionColloCation(index, _index)}
onEntry={(name: string, num: number, _index?: number) => handleEntryNumber(index, name, num, _index)}
/>
)}
{/* 选择搭配商品 */}
<Button type="dashed" block icon={<PlusOutlined />} onClick={() => handleCollocation(index)}>
{remind.buttonTitle}
</Button>
</CollapseLayout>
</Form.Item>
))}
</Form>
{/* 添加分组 */}
<Button type="dashed" block icon={<PlusOutlined />} onClick={handleAppend}>添加</Button>
......
......@@ -36,13 +36,29 @@ const EditableCell = ({
break;
case 3:
values = await form.getFieldValue('discount');
record.activityPrice = Number(record.price) * (Number(values)) / 100
record.activityPrice = Number(record.price) * (Number(values)) / 100;
break;
}
console.log(values)
handleSave({ ...record, ...values });
} catch (errInfo) { }
}
const handleValidator = async (_rule, value, dataIndex) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
const plummetPrice = await form.getFieldValue('plummetPrice');
if (!value) {
return Promise.reject(new Error('必填项'));
}
if ((Number(activities) === 11 && dataIndex === 'activityPrice') && (!pattern.test(value) || (Number(value) >= Number(plummetPrice)))) {
return Promise.reject(new Error('必须大于0且小于起始价格'));
}
if (!pattern.test(value) || (Number(value) >= Number(record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
}
/** 编辑按钮 */
if (editable) {
switch (dataIndex) {
......@@ -58,22 +74,8 @@ const EditableCell = ({
rules={[
{
required: true,
validator: async (_rule, value) => {
const pattern = /^(\-)?\d+(\.\d{1,4})?$/;
const plummetPrice = await form.getFieldValue('plummetPrice');
if (!value) {
return Promise.reject(new Error('必填项'));
}
if ((Number(activities) === 11 && dataIndex === 'activityPrice') && (!pattern.test(value) || (Number(value) >= Number(plummetPrice)))) {
console.log((Number(activities) === 11 && dataIndex === 'activityPrice'), !pattern.test(value) || (Number(value) >= Number(plummetPrice)), 10086)
return Promise.reject(new Error('必须大于0且小于起始价格'));
}
if (!pattern.test(value) || (Number(value) >= Number(record.price))) {
return Promise.reject(new Error('必须大于0且小于商品价格'));
}
return Promise.resolve();
},
},
validator: (_rule, value) => handleValidator(_rule, value, dataIndex),
}
]}
>
<Input style={{ width: '112px' }} addonBefore="¥" onPressEnter={rate} onBlur={rate} />
......@@ -169,27 +171,43 @@ const EditableCell = ({
}
/** 操作按钮 */
if (operation) {
if (Number(activities) === 15) {
childNode = (
<>
<Button type='link' onClick={() => handleSetting(record)}>设置搭配</Button>
switch (Number(activities)) {
case 6:
childNode = (
<>
<Button type='link' onClick={() => handleSetting(record)}>设置赠品</Button>
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(record.id)}
>
<Button type='link'>删除</Button>
</Popconfirm>
</>
)
break;
case 15:
childNode = (
<>
<Button type='link' onClick={() => handleSetting(record)}>设置搭配</Button>
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(record.id)}
>
<Button type='link'>删除</Button>
</Popconfirm>
</>
)
break;
default:
childNode = (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(record.id)}
>
<Button type='link'>删除</Button>
<a>删除</a>
</Popconfirm>
</>
)
} else {
childNode = (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(record.id)}
>
<a>删除</a>
</Popconfirm>
)
)
break;
}
}
......
......@@ -9,6 +9,7 @@ import { PlusOutlined } from '@ant-design/icons';
import { EditableContext } from '@/pages/transaction/components/detailLayout/components/context';
import ListModalLayout from '../listModalLayout';
import CollocationLayout from '../collocationLayout';
import { remindLayout, RemindLayoutProps } from './remind';
/** 表格头 */
const EditableRow = ({ index, ...props }) => {
......@@ -40,6 +41,7 @@ const ProductListLayout: React.FC<ProductListLayoutProps> = (props: any) => {
const [skuId, setSkuId] = useState<number>(0);
const [collocation, setCollocation] = useState<any[]>([]);
const [idNotInList, setIdNotInList] = useState<number[]>([]); // 排除的id集合 ,Long
const [remind, setRemind] = useState<RemindLayoutProps>({});
const components = {
......@@ -129,6 +131,17 @@ const ProductListLayout: React.FC<ProductListLayoutProps> = (props: any) => {
}
}, [signUpId])
useEffect(() => {
if (!isEmpty(data)) {
const { activityDefinedBO: { activityType, giveType, giftType } } = data;
if (giveType && giftType) {
setRemind(remindLayout(activityType, giveType, giftType))
return
}
setRemind(remindLayout(activityType))
}
}, [data])
return (
<Card
id="productListLayout"
......@@ -172,15 +185,18 @@ const ProductListLayout: React.FC<ProductListLayoutProps> = (props: any) => {
onConfirm={handleOk}
/>
{/* 设置搭配商品 */}
<ListModalLayout
title="设置搭配商品"
idNotInList={[skuId]}
shopIdList={shopIdList}
visible={listModalVisible}
onClose={() => setListModalVisible(false)}
onConfirm={handleConfirm}
value={collocation}
/>
{!isEmpty(remind) && (
<ListModalLayout
title={remind.modalTitle}
remind={remind}
idNotInList={[skuId]}
shopIdList={shopIdList}
visible={listModalVisible}
onClose={() => setListModalVisible(false)}
onConfirm={handleConfirm}
value={collocation}
/>
)}
</Card>
)
}
......
export type RemindLayoutProps = {
/** 弹窗标题 */
modalTitle?: string,
/** 选择商品按钮名称 */
buttonTitle?: string,
/** 列表标题 */
listTitle?: string
/** 列表label */
label?: {[key: number]: string},
/** 提醒 */
message?: {[key: number]: string},
}
export const remindLayout = (int, giveType?, giftType?) => {
const give = (giveType === 1 ? '满额': '买商品');
const gift = (giftType === 1 ? '赠商品' : '赠优惠券');
switch(int) {
case 6:
return {
type: 'limitValue',
modalTitle: `设置赠品-${give}${gift}`,
buttonTitle: '添加赠送商品',
listTitle: `${give}${gift}`,
label: {
1: '优惠门槛',
2: giveType === 1 ? '元' : '个',
3: '赠送商品',
4: '赠送数量',
5: '买',
6: '',
},
message: {
1: '请选择赠送商品!',
2: '请设置赠送商品!',
3: '请选择赠送商品!',
4: '请输入优惠门槛!',
5: '请输入赠送数量!',
}
}
case 13: {
return {
type: 'limitValue',
modalTitle: `设置换购商品-${give}换购商品`,
buttonTitle: '添加换购商品',
listTitle: `${give}换购商品`,
label: {
1: '换购门槛',
2: giveType === 1 ? '元' : '个',
3: '换购商品',
4: '换购数量',
5: '满',
6: '换购单价',
},
message: {
1: '请选择换购商品!',
2: '请设置换购商品!',
3: '请选择换购商品!',
4: '请输入换购门槛!',
5: '请输入允许换购数量!',
}
}
}
case 15:
return {
type: 'groupPrice',
modalTitle: '设置搭配商品',
buttonTitle: '选择搭配商品',
listTitle: '套餐搭配商品',
label: {
1: '套餐价格',
2: '元',
3: '搭配商品',
4: '搭配数量',
5: '',
6: '',
},
message: {
1: '请选择搭配商品!',
2: '请设置搭配商品!',
3: '请选择搭配商品!',
4: '请输入套餐价格!',
5: '请输入搭配数量!',
}
}
}
}
......@@ -286,18 +286,18 @@ export const GeneralEffect = (int, data) => {
return [
{
col: [
{ label: '每日秒杀时间段', extra: '' },
{ label: '每日秒杀时间段', extra: <>{format(data.startTime, 'HH:mm:ss')}~{format(data.endTime, 'HH:mm:ss')}</> },
{ label: '活动描述', extra: data.describe }
]
},
{
col: [
{ label: '叠加优惠券', extra: '' },
{ label: '叠加优惠券', extra: data.allowCoupon ? '允许叠加' : '不允许叠加' },
]
},
{
col: [
{ label: '超限规则', extra: '' },
{ label: '超限规则', extra: data.exceedRule === 1 ? '原价购买' : '不可购买' },
]
}
]
......
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