Commit c1e77168 authored by 前端-许佳敏's avatar 前端-许佳敏
parents 851c0d86 240e4910
......@@ -280,6 +280,12 @@ const AddressSelect: React.FC<IProps> = (props) => {
formActions.setFieldState('ADDRESS_NEW', state => {
state.visible = false;
});
formActions.setFieldState('ADD_ACTION', state => {
state.props['x-component-props'] = {
flag: true,
};
});
}
setSubmitLoading(false);
} catch (error) {
......@@ -316,7 +322,16 @@ const AddressSelect: React.FC<IProps> = (props) => {
getAddressList();
editAddressId.current = null;
formActions.reset({ selector: 'ADDRESS_NEW.*' });
formActions.reset({ selector: 'ADDRESS_NEW.*', validate: false });
formActions.setFieldState('ADDRESS_NEW', state => {
state.visible = false;
});
formActions.setFieldState('ADD_ACTION', state => {
state.props['x-component-props'] = {
flag: true,
};
});
}
setSubmitLoading(false);
} catch (error) {
......@@ -465,7 +480,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
}, [list]);
if (!editable && value) {
const current = list.find((item) => item.id === value);
const current = list.find((item) => item.id === value.id);
const full = current ? `${current.name} ${current.fullAddress} ${current.phone}` : null;
const isStr = typeof value === 'string';
......
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_1 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title="活动价格表示商城直接以该商品的活动价格进行销售">
活动价格 <QuestionCircleOutlined />
</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('请输入活动价格'));
}
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>
)
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_1
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_2 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
const sumTotal = (price, num) => {
return (Number(price) - Number(num))
}
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
if (name === 'plummetPrice') {
return {
..._item,
[name]: Number(value),
'activityPrice': sumTotal(_item.price, value)
}
} else {
return {
..._item,
[name]: Number(value)
}
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title="直降价格为商品价格的直降价格,如原价每件¥20.00的商品,每件降价¥2.00,则直降价格输入框中输入 ¥2.00">
直降价格 <QuestionCircleOutlined />
</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('请输入活动价格'));
}
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>
)
},
{
title: '活动价格',
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (text) => text ? `¥${Number(text).toFixed(2)}` : `¥0`
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_2
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_3 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
if (name === 'discount') {
return {
..._item,
[name]: Number(value),
'activityPrice': Number(_item.price) * (Number(value)) / 100,
}
} else {
return {
..._item,
[name]: Number(value)
}
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title="折扣为商品价格的折扣,输入数字,如85折,输入85,9折输入90">
折扣 <QuestionCircleOutlined />
</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();
},
})
]}
>
<Input style={{ width: '112px' }} addonAfter="折" onPressEnter={(e) => handleInputChange(e, 'discount', index)} onBlur={(e) => handleInputChange(e, 'discount', index)} />
</Form.Item>
)
},
{
title: '活动价格',
key: 'activityPrice',
dataIndex: 'activityPrice',
render: (text) => text ? `¥${Number(text).toFixed(2)}` : `¥0`
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_3
import React from 'react';
import { Image, Form, Input, Popconfirm, Button } from 'antd';
const columns_4 = ({
dataSource,
setDataSource,
handleDelete,
form,
handlCollocation,
value,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<>
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
{(value === 6) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置赠品</Button>
)}
{(value === 13) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置换购商品</Button>
)}
{(value === 15) && (
<Button type='link' onClick={() => handlCollocation(_record)}>设置搭配商品</Button>
)}
</>
)
},
]
)
}
export default columns_4
import React from 'react';
import { Image, Form, Input, Popconfirm } from 'antd';
const columns_5 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
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('请输入团购价格'));
}
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>
)
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_5
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_6 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title="第一个用户帮砍价时的起始价格">
起始价格 <QuestionCircleOutlined />
</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('请输入起始价格'));
}
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, 'plummetPrice', index)} onBlur={(e) => handleInputChange(e, 'plummetPrice', index)} />
</Form.Item>
)
},
{
title: <Tooltip placement="top" title="砍价过程中最后一次砍价不能超过砍价底价">
砍价底价 <QuestionCircleOutlined />
</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})?$/;
const plummetPrice = getFieldValue(`plummetPrice_${index}`);
if (!pattern.test(value)) {
return Promise.reject(new Error('最多保留4位小数'));
}
if (!(Number(value) < Number(plummetPrice))) {
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}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_6
import React from 'react';
import { Tooltip, Image, Form, Input, Popconfirm } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
const columns_7 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: <Tooltip placement="top" title="秒杀价格表示在秒杀时间段内商城直接以该商品的秒杀价格进行销售">
秒杀价格 <QuestionCircleOutlined />
</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();
},
})
]}
>
<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}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_7
import React from 'react';
import { Image, Form, Input, Popconfirm } from 'antd';
const columns_8 = ({
dataSource,
setDataSource,
handleDelete,
form,
}) => {
/** 输入 */
const handleInputChange = (e, name, index) => {
const { value } = e.target;
const params = [...dataSource];
const newData = params.map((_item, _i) => {
if (_i === index) {
return {
..._item,
[name]: Number(value)
}
}
return _item
})
form.setFieldsValue({
'productList': newData
})
setDataSource(newData)
}
return (
[
{
title: 'skuId',
key: 'skuId',
dataIndex: 'skuId'
},
{
title: '商品图片',
key: 'productImgUrl',
dataIndex: 'productImgUrl',
render: (text) => <Image width={32} height={32} src={text} />
},
{
title: '商品名称',
key: 'productName',
dataIndex: 'productName'
},
{
title: '品类',
key: 'category',
dataIndex: 'category'
},
{
title: '品牌',
key: 'brand',
dataIndex: 'brand'
},
{
title: '单位',
key: 'unit',
dataIndex: 'unit'
},
{
title: '商品价格',
key: 'price',
dataIndex: 'price',
render: (text) => `¥${Number(text).toFixed(2)}`
},
{
title: '预售价格',
key: 'activityPrice',
dataIndex: 'activityPrice',
},
{
title: '单位定金',
key: 'activityPrice',
dataIndex: 'activityPrice',
},
{
title: '定金抵扣单价',
key: 'activityPrice',
dataIndex: 'activityPrice',
},
{
title: '个人限购数量',
key: 'restrictNum',
dataIndex: 'restrictNum',
render: (_text, _record, index) => (
<Form.Item
style={{ marginBottom: 0 }}
initialValue={_text}
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();
},
})
]}
>
<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}
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();
}
})
]}
>
<Input style={{ width: '112px' }} onPressEnter={(e) => handleInputChange(e, 'restrictTotalNum', index)} onBlur={(e) => handleInputChange(e, 'restrictTotalNum', index)} />
</Form.Item>
)
},
{
title: '操作',
key: 'operation',
dataIndex: 'operation',
render: (_text, _record) => (
<Popconfirm
title="是否删除?"
onConfirm={() => handleDelete(_record.skuId)}
>
<a>删除</a>
</Popconfirm>
)
},
]
)
}
export default columns_8
import columns_1 from './columns_1';
import columns_2 from './columns_2';
import columns_3 from './columns_3';
import columns_4 from './columns_4';
import columns_5 from './columns_4';
import columns_6 from './columns_4';
import columns_7 from './columns_4';
import columns_8 from './columns_4';
import columns_9 from './columns_5';
import columns_11 from './columns_6';
import columns_12 from './columns_7';
import columns_13 from './columns_4';
import columns_14 from './columns_8';
import columns_15 from './columns_4';
import columns_16 from './columns_4';
export const Columns = {
1: columns_1,
2: columns_2,
3: columns_3,
4: columns_4,
5: columns_5,
6: columns_6,
7: columns_7,
8: columns_8,
9: columns_9,
11: columns_11,
12: columns_12,
13: columns_13,
14: columns_14,
15: columns_15,
16: columns_16,
}
......@@ -48,6 +48,7 @@ const AuditLayout: React.FC<AutditLayoutProps> = (props: any) => {
placement="topLeft"
title={
<Space direction='vertical'>
<Typography.Text style={{ color: '#FFF' }}>接受会员报价后则下采购订单进行采购操作</Typography.Text>
<Typography.Text style={{ color: '#FFF' }}>1.报价单查询列表,直接创建采购订单</Typography.Text>
<Typography.Text style={{ color: '#FFF' }}>2.新增采购订单,选择接受的报价单</Typography.Text>
</Space>
......
......@@ -58,13 +58,13 @@ const OfferSearch = () => {
title: '外部状态',
key: 'externalState',
dataIndex: 'externalState',
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text]}>{record.externalStateName}</Tag>
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text] || 'error'}>{record.externalStateName}</Tag>
},
{
title: '内部状态',
key: 'interiorState',
dataIndex: 'interiorState',
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text]} text={record.interiorStateName} />
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text] || 'error'} text={record.interiorStateName} />
},
{
title: '操作',
......
......@@ -64,13 +64,13 @@ const WaitAuditInquiryOne = () => {
title: '外部状态',
key: 'externalState',
dataIndex: 'externalState',
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text]}>{record.externalStateName}</Tag>
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text] || 'error'}>{record.externalStateName}</Tag>
},
{
title: '内部状态',
key: 'interiorState',
dataIndex: 'interiorState',
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text]} text={record.interiorStateName} />
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text] || 'error'} text={record.interiorStateName} />
},
{
title: '操作',
......
......@@ -64,13 +64,13 @@ const WaitAuditInquiryOne = () => {
title: '外部状态',
key: 'externalState',
dataIndex: 'externalState',
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text]}>{record.externalStateName}</Tag>
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text] || 'error'}>{record.externalStateName}</Tag>
},
{
title: '内部状态',
key: 'interiorState',
dataIndex: 'interiorState',
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text]} text={record.interiorStateName} />
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text] || 'error'} text={record.interiorStateName} />
},
{
title: '操作',
......
......@@ -69,13 +69,13 @@ const WaitSubmitAuditOffer = () => {
title: '外部状态',
key: 'externalState',
dataIndex: 'externalState',
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text]}>{record.externalStateName}</Tag>
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text] || 'error'}>{record.externalStateName}</Tag>
},
{
title: '内部状态',
key: 'interiorState',
dataIndex: 'interiorState',
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text]} text={record.interiorStateName} />
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text] || 'error'} text={record.interiorStateName} />
},
{
title: '操作',
......
......@@ -68,13 +68,13 @@ const WaitSubmitOffer = () => {
title: '外部状态',
key: 'externalState',
dataIndex: 'externalState',
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text]}>{record.externalStateName}</Tag>
render: (text: any, record: any) => <Tag color={EXTERNALSTATE_COLOR[text] || 'error'}>{record.externalStateName}</Tag>
},
{
title: '内部状态',
key: 'interiorState',
dataIndex: 'interiorState',
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text]} text={record.interiorStateName} />
render: (text: any, record: any) => <Badge status={INTERNALSTATE_COLOR[text] || 'error'} text={record.interiorStateName} />
},
{
title: '操作',
......
......@@ -89,7 +89,7 @@ const ProductQuoteLayout: React.FC<ProductQuoteLayoutProps> = (props: any) => {
dataIndex: "price",
width: 150,
render: (text, record, index) => (
<Form.Item initialValue={record.price} name={`purchaseCount${index}`} rules={[{ required: true, message: '请输入采购数量' }]} style={{ marginBottom: '0px' }}>
<Form.Item initialValue={record.price} name={`purchaseCount${index}`} rules={[{ required: true, message: '请输入报价单价' }]} style={{ marginBottom: '0px' }}>
<Input
onBlur={(e) => handleChange(record.productId, e)}
addonBefore="¥"
......
......@@ -5,3 +5,10 @@
}
}
}
.address_style {
:global {
.ant-form-item-control {
width: 0;
}
}
}
......@@ -121,7 +121,7 @@ const TradeTermsLayout: React.FC<TradeTermsLayoutProps> = (props: any) => {
format="YYYY-MM-DD HH:mm:ss"
/>
</Form.Item>
<Form.Item label='交付地址'>
<Form.Item label='交付地址' className={style.address_style}>
<AddressSelect
echo={isEdit}
extra={fullAddress.fullAddress}
......
......@@ -81,7 +81,18 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<Form.Item
name={`${remind.type}_${index}`}
label={remind.label[1]}
rules={[{ required: true, message: remind.message[4] }]}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^-?[1-9]\d*(\.\d{1,2})?$/;
if (!value) {
return Promise.reject(new Error(remind.message[4]));
}
if (!pattern.test(value)) {
return Promise.reject(new Error(remind.label[1] + `必须大于0最多保留2位小数`));
}
return Promise.resolve();
}
}]}
>
<Input addonBefore={remind.type === 'limitValue' && '买'} addonAfter={remind.label[2]} onBlur={(e) => handleChange(e, `${remind.type}`)} />
</Form.Item>
......@@ -141,7 +152,19 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<Form.Item
label={remind.label[4]}
name={`num_${index}_${_index}`}
rules={[{ required: true, message: remind.message[5] }]}
initialValue={1}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^-?[1-9]\d*$/;
if (!value) {
return Promise.reject(new Error(remind.message[5]));
}
if (!pattern.test(value)) {
return Promise.reject(new Error(remind.label[4] + `必须大于0`));
}
return Promise.resolve();
}
}]}
>
<Input addonAfter={_item.unit} onBlur={(e) => handleChange(e, 'num', _index)} />
</Form.Item>
......
......@@ -63,7 +63,7 @@ const CouponsListLayout: React.FC<CouponsListLayoutProps> = (props: any) => {
const handleAppend = () => {
const CouponGroup: CouponGroupListProps = {
groupNo: 0,
limitValue: 0,
limitValue: remind.type === 'limitValue' ? 1 : 0,
list: []
}
setCouponSource([...couponSource, CouponGroup]);
......
import React, { useCallback, useState } from 'react';
import { Modal, Form, DatePicker, Input } from 'antd';
import moment from 'moment';
interface DateModalProps {
id?: number,
/** 标题 */
title?: string,
/** 显示隐藏 */
visible?: boolean,
/** 取消 */
onCancel: Function,
/** 确定 */
onSubmit: Function,
/** 接口 */
fieldApi?: () => Promise<unknown>
}
const DateModalLayout: React.FC<DateModalProps> = (props: any) => {
const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(false);
const { id, title, visible, onCancel, onSubmit, fieldApi } = props;
const handleSubmit = useCallback(() => {
form.validateFields().then(res => {
const params = {
id,
time: moment(res.time).format('x'),
reason: res.reason,
}
console.log(params, fieldApi)
setLoading(true)
fieldApi(params).then(res => {
if (res.code !== 1000) {
setLoading(false)
return
}
onSubmit();
}).catch(err => {
setLoading(false)
})
})
form.resetFields();
}, [id])
return (
<Modal
title={`${title}原因`}
visible={visible}
onCancel={onCancel}
confirmLoading={loading}
onOk={handleSubmit}
>
<Form layout='vertical' form={form}>
<Form.Item
label={`${title}时间`}
name='time'
initialValue={moment(new Date())}
>
<DatePicker style={{ width: '100%' }} disabled format='YYYY-MM-DD HH:mm:ss' />
</Form.Item>
<Form.Item
label={`${title}原因`}
name='reason'
rules={[{required: true, message: '请输入原因'}]}
>
<Input.TextArea rows={3} />
</Form.Item>
</Form>
</Modal>
)
}
export default DateModalLayout
......@@ -74,7 +74,18 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<Form.Item
name={`${remind.type}_${index}`}
label={remind.label[1]}
rules={[{ required: true, message: remind.message[4] }]}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^-?[1-9]\d*(\.\d{1,2})?$/;
if (!value) {
return Promise.reject(new Error(remind.message[4]));
}
if (!pattern.test(value)) {
return Promise.reject(new Error(remind.label[1] + `必须大于0最多保留2位小数`));
}
return Promise.resolve();
}
}]}
>
<Input addonBefore={remind.type === 'limitValue' && '买'} addonAfter={remind.label[2]} onBlur={(e) => handleChange(e, `${remind.type}`)} />
</Form.Item>
......@@ -88,6 +99,26 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<DeleteOutlined onClick={() => onDeletion(_index)} />
</div>
<div className={style.productLayout_contenxt}>
{remind.name === 'swapValue' && (
<Form.Item
label='换购单价'
name={`swapPrice_${index}_${_index}`}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^-?[1-9]\d*(\.\d{1,3})?$/;
if (!value) {
return Promise.reject(new Error('请输入换购单价'));
}
if (!pattern.test(value)) {
return Promise.reject(new Error(`换购单价必须大于0最多保留3位小数`));
}
return Promise.resolve();
}
}]}
>
<Input addonAfter='¥' onBlur={(e) => handleChange(e, 'swapPrice', _index)} />
</Form.Item>
)}
<Form.Item
label={remind.label[3]}
className={style.productLayout_formItem}
......@@ -113,7 +144,19 @@ const ProductLayout: React.FC<ProductLayoutProps> = (props: any) => {
<Form.Item
label={remind.label[4]}
name={`num_${index}_${_index}`}
rules={[{ required: true, message: remind.message[5] }]}
initialValue={1}
rules={[{
required: true, validator: (_rule, value) => {
const pattern = /^-?[1-9]\d*$/;
if (!value) {
return Promise.reject(new Error(remind.message[5]));
}
if (!pattern.test(value)) {
return Promise.reject(new Error(remind.label[4] + `必须大于0`));
}
return Promise.resolve();
}
}]}
>
<Input addonAfter={_item.unit} onBlur={(e) => handleChange(e, 'num', _index)} />
</Form.Item>
......
......@@ -105,7 +105,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
unit: item.unit,
price: item.price,
swapPrice: item.swapPrice,
num: item.num,
num: item.num || 1,
productImgUrl: item.productImgUrl,
}
})]
......@@ -116,6 +116,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
[`dataSource_${idx}`]: fields[idx].list,
[`limitValue_${_index}`]: item.limitValue,
[`num_${_index}_${__index}`]: _item.num,
[`swapPrice_${_index}_${__index}`]: _item.swapPrice,
})
})
})
......@@ -158,8 +159,8 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
const handleAppend = () => {
const GoodsSubsidiary: GoodsSubsidiaryListProps = {
groupNo: 0,
limitValue: 0,
groupPrice: 0,
limitValue: remind.type === 'limitValue' ? 1 : 0,
groupPrice: remind.type === 'groupPrice' ? 1 : 0,
list: []
}
setDataSource([...dataSource, GoodsSubsidiary]);
......@@ -174,6 +175,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
[`swapPrice_${_index}_${__index}`]: _item.swapPrice,
})
})
})
......@@ -189,6 +191,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
[`swapPrice_${_index}_${__index}`]: _item.swapPrice,
})
})
})
......@@ -206,6 +209,7 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
[`swapPrice_${_index}_${__index}`]: _item.swapPrice,
})
})
})
......@@ -215,10 +219,8 @@ 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);
}
......@@ -234,11 +236,11 @@ const ListModalLayout: React.FC<ListModalLayoutProps> = (props: any) => {
[`limitValue_${_index}`]: item.limitValue,
[`groupPrice_${_index}`]: item.groupPrice,
[`num_${_index}_${__index}`]: _item.num,
[`swapPrice_${_index}_${__index}`]: _item.swapPrice,
})
})
})
setDataSource(value);
console.log(remind.value)
}, [value])
return (
......
export const _data = {
id: 1,
activityId: 888,
activityName: '自建营销活动管理',
marketingNo: 'XJBX888888',
externalState: 5,
externalStateName: '已结束',
interiorState: 5,
interiorStateName: '已结束',
activityType: 1,
orderModal: '询价报价下单',
membersName: '温州龙昌手袋有限公司',
creationTime: 1624603001552,
activityStartTime: 1624603001552,
activityEndTime: 1624603001552,
externalLogStates: [
{
isExecute: 1,
operationalProcess: "提交营销活动",
roleName: "供应商",
state: 1,
stateName: null,
},
{
isExecute: 0,
operationalProcess: "审核营销活动",
roleName: "平台",
state: 1,
stateName: null,
},
{
isExecute: 0,
operationalProcess: "上线营销活动",
roleName: "供应商",
state: 1,
stateName: null,
},
],
externalLogs: [
{
auditOpinion: "",
createMemberId: 20,
createMemberRoleId: 11,
createTime: 1624600139800,
id: 1,
operation: "提交营销活动",
purchaseInquiryId: 956,
roleName: "供应商",
state: 2,
stateName: "待平台审核",
},
{
auditOpinion: "同意",
createMemberId: 20,
createMemberRoleId: 11,
createTime: 1624600139800,
id: 2,
operation: "审核营销活动",
purchaseInquiryId: 956,
roleName: "平台",
state: 2,
stateName: "待上线活动",
},
],
interiorLogStates: [
{
isExecute: 1,
operationalProcess: "提交营销活动",
roleName: "新增营销活动",
state: 1,
stateName: null,
},
{
isExecute: 0,
operationalProcess: "审核营销活动",
roleName: "审核营销活动(一级)",
state: 1,
stateName: null,
},
{
isExecute: 0,
operationalProcess: "审核营销活动(二级)",
roleName: "运营总监",
state: 1,
stateName: null,
},
{
isExecute: 0,
operationalProcess: "提交营销活动",
roleName: "运营人员",
state: 1,
stateName: null,
},
],
interiorLogs: [
{
auditOpinion: "",
createMemberId: 20,
createRoleId: 11,
createTime: 1624600137942,
department: "运营人员",
id: 3968,
memberId: null,
memberRoleId: null,
operation: "新增营销活动",
position: "运营部",
purchaseInquiryId: 956,
roleName: "张三",
state: 1,
stateName: "待审核(一级)",
step: 1,
},
],
}
......@@ -144,7 +144,6 @@ const DetialLayout = () => {
setLoading(false)
return
}
setLoading(false)
setUnsaved(false)
history.goBack()
}).catch(_err => {
......
import React, { useRef } from 'react';
import React, { Fragment, useRef, useState } from 'react';
import { Button } from 'antd';
import { history } from 'umi';
import TableLayout from '@/pages/transaction/components/tableLayout'
import { ColumnType } from 'antd/lib/table';
import EyePreview from '@/components/EyePreview';
......@@ -8,10 +10,40 @@ import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PublicApi } from '@/services/api';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { FormEffectHooks } from '@formily/react';
import DateModalLayout from '../../components/dateModal';
const { onFormMount$ } = FormEffectHooks;
type dateInfoProps = {
/** id */
id: number,
/** 标题 */
title: string,
/** 接口 */
fieldApi: any
}
const Search = () => {
const ref = useRef<any>({});
const [dateInfo, setDateInfo] = useState<dateInfoProps>();
const [dateVisible, setDateVisible] = useState<boolean>(false);
const Api = (operate) => {
switch (operate) {
case 'stop':
return PublicApi.postMarketingMerchantActivityStop
case 'start':
return PublicApi.postMarketingMerchantActivityRestart
}
}
const handleOperate = (record, operate) => {
setDateInfo({
id: record.id,
title: operate === 'stop' ? '终止' : '启动',
fieldApi: Api(operate)
})
setDateVisible(true)
}
const columns: ColumnType<any>[] = [
{
......@@ -63,6 +95,13 @@ const Search = () => {
title: '操作',
key: 'state',
dataIndex: 'state',
render: (_text, record) => (
<Fragment>
{record.update && <Button type='link' onClick={() => history.push(`/memberCenter/marketingAbility/selfManagement/readySubmitExamine/edit?id=${record.id}`)}>修改</Button>}
{record.stop && <Button type='link' onClick={() => handleOperate(record, 'stop')}>终止</Button>}
{record.restart && <Button type='link' onClick={() => handleOperate(record, 'start')}>重新启动</Button>}
</Fragment>
)
}
]
......@@ -93,118 +132,133 @@ const Search = () => {
})
}
const handleOnSubmit = () => {
setDateVisible(false);
ref.current.reload();
}
return (
<TableLayout
reload={ref}
columns={columns}
effects="id"
fetch={PublicApi.getMarketingMerchantActivityPage}
useStateEffects={useStateEffects}
schema={{
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
properties: {
id: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '活动ID',
align: "flex-left",
<Fragment>
<TableLayout
reload={ref}
columns={columns}
effects="id"
fetch={PublicApi.getMarketingMerchantActivityPage}
useStateEffects={useStateEffects}
schema={{
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
properties: {
id: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '活动ID',
align: "flex-left",
},
},
},
}
},
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
justifyContent: "flex-start",
flexWrap: "nowrap"
},
colStyle: {//改变间隔
marginRight: 20
}
},
properties: {
PRO_LAYOUT: {
type: "object",
"x-component": "mega-layout",
"x-mega-props": {
span: 5
},
"x-component-props": {
inline: true
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
justifyContent: "flex-start",
flexWrap: "nowrap"
},
properties: {
activityName: {
type: 'string',
'x-component-props': {
placeholder: '活动名称',
style: {
width: 160,
colStyle: {//改变间隔
marginRight: 20
}
},
properties: {
PRO_LAYOUT: {
type: "object",
"x-component": "mega-layout",
"x-mega-props": {
span: 5
},
"x-component-props": {
inline: true
},
properties: {
activityName: {
type: 'string',
'x-component-props': {
placeholder: '活动名称',
style: {
width: 160,
},
},
},
},
'[startTime,endTime]': {
type: 'string',
"x-component": "DateRangePickerUnix",
'x-component-props': {
placeholder: ['开始时间', '结束时间'],
style: {
width: 240,
'[startTime,endTime]': {
type: 'string',
"x-component": "DateRangePickerUnix",
'x-component-props': {
placeholder: ['开始时间', '结束时间'],
style: {
width: 240,
},
},
},
},
activityType: {
type: 'string',
'x-component-props': {
placeholder: '活动类型',
style: {
width: 160,
activityType: {
type: 'string',
'x-component-props': {
placeholder: '活动类型',
style: {
width: 160,
},
},
enum: [],
},
enum: [],
},
outerStatus: {
type: 'string',
'x-component-props': {
placeholder: '外部状态',
style: {
width: 160,
outerStatus: {
type: 'string',
'x-component-props': {
placeholder: '外部状态',
style: {
width: 160,
},
},
enum: [],
},
enum: [],
},
innerStatus: {
type: 'string',
'x-component-props': {
placeholder: '内部状态',
style: {
width: 160,
innerStatus: {
type: 'string',
'x-component-props': {
placeholder: '内部状态',
style: {
width: 160,
},
},
enum: [],
},
enum: [],
},
}
},
sumbit: {
"x-component": "Submit",
"x-mega-props": {
span: 1
}
},
"x-component-props": {
children: "查询"
sumbit: {
"x-component": "Submit",
"x-mega-props": {
span: 1
},
"x-component-props": {
children: "查询"
}
}
}
}
}
}
}}
/>
}}
/>
<DateModalLayout
id={dateInfo?.id}
title={dateInfo?.title}
visible={dateVisible}
fieldApi={dateInfo?.fieldApi}
onCancel={() => setDateVisible(false)}
onSubmit={handleOnSubmit}
/>
</Fragment>
)
}
export default Search;
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