Commit d9af01f6 authored by beisir's avatar beisir

fix: 提交本地

parent 3c966ed7
...@@ -9,6 +9,7 @@ module.exports = { ...@@ -9,6 +9,7 @@ module.exports = {
'max-len': ['error', { code: 200 }], 'max-len': ['error', { code: 200 }],
'no-param-reassign': 0, 'no-param-reassign': 0,
'no-console': 0, 'no-console': 0,
'no-plusplus': ['off'],
'@typescript-eslint/camelcase': ['off'], '@typescript-eslint/camelcase': ['off'],
'@typescript-eslint/no-unused-vars': ['off'], '@typescript-eslint/no-unused-vars': ['off'],
}, },
......
import React from 'react'; import React from 'react';
import { Button, Badge } from 'antd'; import { Button, Badge } from 'antd';
import styles from './style.less'; import styles from './style.less';
import { resetTime } from '../../utils/utils';
export const productType = [ export const productType = [
{ {
...@@ -257,6 +258,36 @@ export const ProcessEditData = (data, row) => { ...@@ -257,6 +258,36 @@ export const ProcessEditData = (data, row) => {
const orginSpecItem = filterSpecData(data.skuList); const orginSpecItem = filterSpecData(data.skuList);
const imageList = filterCarouseList(data.carouseList); const imageList = filterCarouseList(data.carouseList);
const servesItemParams =
data.productType === 3
? {
serviceItem: {
useTime: [resetTime(serviceItem.useStartTime), resetTime(serviceItem.useEndTime)],
purchaseTime: [
resetTime(serviceItem.purchaseStartTime),
resetTime(serviceItem.purchaseEndTime),
], // 购买开始时间
shopIds: serviceItem.shopIds || [], // 适用门店列表
unavailableDate: serviceItem.unavailableDate, // 不可用日期
useTimeDescription: serviceItem.useTimeDescription, // 使用时间
useMethod: serviceItem.useMethod, // 使用方法
ruleDescription: serviceItem.ruleDescription, // 规则说明
applyScope: serviceItem.applyScope, // 适用范围
tips: serviceItem.tips, // 温馨提示
},
settlementItem: {
settlementMethod: 1,
limitPurchase: Boolean(serviceItem.limitPurchase), // 是否限购1:限购/0:不限购
limitPurchaseType: serviceItem.limitPurchaseType, // 限购类型,如果限购必填1:长期限购/2:周期限购
limitPurchaseCycle: serviceItem.limitPurchaseCycle, // 限购周期1:每天/7:7天/30:30天
limitPurchaseQuantity: serviceItem.limitPurchaseQuantity, // 限购数量
packageContent: serviceItem.packageContent,
appointment: serviceItem.appointment, // 预约
receptionVolume: serviceItem.receptionVolume, // 接待数量
},
}
: {};
const SourceData = { const SourceData = {
productType: data.productType, productType: data.productType,
pageProductType: row.productType, pageProductType: row.productType,
...@@ -277,14 +308,15 @@ export const ProcessEditData = (data, row) => { ...@@ -277,14 +308,15 @@ export const ProcessEditData = (data, row) => {
secondSpecId: oneItem.secondSpecId, secondSpecId: oneItem.secondSpecId,
secondSpecValue: orginSpecItem.secondSpecValue, secondSpecValue: orginSpecItem.secondSpecValue,
}, },
infoImageData: { infoImageData: {
imageList, imageList,
commonImageList: data.commonImageList, commonImageList: data.commonImageList,
detailImageList: data.detailImageList, detailImageList: data.detailImageList,
}, },
skuList: data.skuList, skuList: data.skuList,
...servesItemParams,
}; };
return SourceData; return SourceData;
// data.state = state; // data.state = state;
......
...@@ -72,3 +72,9 @@ ...@@ -72,3 +72,9 @@
} }
} }
} }
.pullImage {
position: absolute;
top: 30px;
right: -80px;
}
...@@ -9,6 +9,7 @@ import React, { ...@@ -9,6 +9,7 @@ import React, {
} from 'react'; } from 'react';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
import { CreateFormInput } from './CommonTemplate'; import { CreateFormInput } from './CommonTemplate';
import UUID from '../../../utils/uuid';
const UpdateSkuName = ({ skuVisble, value, confirmEvent, cancelEvent }) => { const UpdateSkuName = ({ skuVisble, value, confirmEvent, cancelEvent }) => {
const [skuForm] = Form.useForm(); const [skuForm] = Form.useForm();
...@@ -92,7 +93,7 @@ const EditableCell = props => { ...@@ -92,7 +93,7 @@ const EditableCell = props => {
style={{ margin: 0 }} style={{ margin: 0 }}
hidden={roleHidden} hidden={roleHidden}
name={['tableList', rowIndex, dataIndex]} name={['tableList', rowIndex, dataIndex]}
rules={[{ required: roleRules.required, message: `${title} is required.` }]} rules={[{ required: roleRules.required, message: `请输入${title}.` }]}
> >
{editable ? ( {editable ? (
<CreateFormInput <CreateFormInput
...@@ -223,7 +224,7 @@ const EditFormTable = forwardRef((props, ref) => { ...@@ -223,7 +224,7 @@ const EditFormTable = forwardRef((props, ref) => {
}} }}
bordered bordered
dataSource={dataSource} dataSource={dataSource}
rowKey={(row, rowInd) => (customer.isEdit ? row.id : rowInd)} rowKey={row => UUID.createUUID()}
columns={columns} columns={columns}
/> />
</EditableContext.Provider> </EditableContext.Provider>
......
...@@ -19,10 +19,12 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -19,10 +19,12 @@ const FormInformationBasic = forwardRef((props, ref) => {
const { editData, categoryList, brandList, afterAddressList, specListData } = props; const { editData, categoryList, brandList, afterAddressList, specListData } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [noreBrandList, setNoreBrandList] = useState([]); const [noreBrandList, setNoreBrandList] = useState([]);
const customer = useContext(ServiceContext);
const onCheck = async () => { const onCheck = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
values.temp = 'infoMation';
return values; return values;
} catch (errorInfo) { } catch (errorInfo) {
return null; return null;
...@@ -33,7 +35,6 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -33,7 +35,6 @@ const FormInformationBasic = forwardRef((props, ref) => {
onCheck, onCheck,
reset: form.resetFields, reset: form.resetFields,
})); }));
const customer = useContext(ServiceContext);
useEffect(() => { useEffect(() => {
const noreList = (brandList || []).filter(item => item.name === '虚拟商品'); const noreList = (brandList || []).filter(item => item.name === '虚拟商品');
...@@ -91,21 +92,23 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -91,21 +92,23 @@ const FormInformationBasic = forwardRef((props, ref) => {
options={categoryList} options={categoryList}
/> />
</Form.Item> </Form.Item>
<Form.Item {!customer.isCard && (
name="brandId" <Form.Item
label="商品品牌" name="brandId"
rules={[{ required: true, message: '请选择商品品牌!' }]} label="商品品牌"
extra="若需新增品牌请联系业务员" rules={[{ required: true, message: '请选择商品品牌!' }]}
> extra="若需新增品牌请联系业务员"
<Select
disabled={customer.isService}
showSearch
placeholder="请选择商品品牌"
filterOption={fileterBrandOptions}
> >
{CreateSelectOption(customer.productType === 2 ? noreBrandList : brandList)} <Select
</Select> disabled={customer.isService}
</Form.Item> showSearch
placeholder="请选择商品品牌"
filterOption={fileterBrandOptions}
>
{CreateSelectOption(customer.productType === 2 ? noreBrandList : brandList)}
</Select>
</Form.Item>
)}
<Popover content={form.getFieldValue('name')} trigger="hover"> <Popover content={form.getFieldValue('name')} trigger="hover">
<Form.Item <Form.Item
key="name" key="name"
...@@ -139,7 +142,7 @@ const FormInformationBasic = forwardRef((props, ref) => { ...@@ -139,7 +142,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
rules={[{ required: true, message: '请选择售后地址!' }]} rules={[{ required: true, message: '请选择售后地址!' }]}
> >
<Select showSearch placeholder="请选择商品品牌" filterOption={fileterBrandOptions}> <Select showSearch placeholder="请选择商品品牌" filterOption={fileterBrandOptions}>
{afterAddressList.map(item => ( {([{ id: 9527, addressName: '测试地址' }] || afterAddressList).map(item => (
<Select.Option key={item.id} value={item.id}> <Select.Option key={item.id} value={item.id}>
{item.addressName} {item.addressName}
</Select.Option> </Select.Option>
......
...@@ -229,7 +229,8 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -229,7 +229,8 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const onCheck = async () => { const onCheck = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
return values; const { tableList: items } = await editRef.current.onCheck();
return items ? { ...values, items, temp: 'infoSpecData' } : null;
} catch (errorInfo) { } catch (errorInfo) {
return null; return null;
} }
...@@ -384,7 +385,6 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -384,7 +385,6 @@ const FormPriceOrStock = forwardRef((props, ref) => {
</div> </div>
<CreateBatchFormItems <CreateBatchFormItems
batchChange={batchChange} batchChange={batchChange}
editRef={editRef}
specInitValue={specInitValue} specInitValue={specInitValue}
defaultColumns={defaultColumns} defaultColumns={defaultColumns}
/> />
......
...@@ -3,6 +3,7 @@ import React, { useState, useEffect, forwardRef, useImperativeHandle, useContext ...@@ -3,6 +3,7 @@ import React, { useState, useEffect, forwardRef, useImperativeHandle, useContext
import moment from 'moment'; import moment from 'moment';
import { WeeksList, formItemLayout } from '../config'; import { WeeksList, formItemLayout } from '../config';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
import { formatTime } from '../../../utils/utils';
const { Option } = Select; const { Option } = Select;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
...@@ -14,9 +15,6 @@ const WeekCheckBox = () => ...@@ -14,9 +15,6 @@ const WeekCheckBox = () =>
</Checkbox> </Checkbox>
)); ));
const formatTime = (time, crm = 'YYYY-MM-DD HH') => time.format(crm);
const resetTime = (time, crm = 'YYYY-MM-DD HH') => moment(time, crm);
const rangeConfig = { const rangeConfig = {
rules: [{ type: 'array', required: true, message: 'Please select time!' }], rules: [{ type: 'array', required: true, message: 'Please select time!' }],
}; };
...@@ -25,30 +23,28 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -25,30 +23,28 @@ const FormRuleSetting = forwardRef((props, ref) => {
const { editData } = props; const { editData } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
const [imageList, setImageList] = useState([]);
const [commonImageList, setCommonImageList] = useState([]);
const [detailImageList, setDetailImageList] = useState([]);
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!Object.keys(editData).length) return; if (!editData) return;
setImageList(editData.commonImageList); form.setFieldsValue(editData);
setCommonImageList(editData.commonImageList); // setImageList(editData.commonImageList);
setDetailImageList(editData.detailImageList); // setCommonImageList(editData.commonImageList);
const { serviceItem } = editData.skuList[0]; // setDetailImageList(editData.detailImageList);
form.setFieldsValue({ // const { serviceItem } = editData.skuList[0];
useTime: [resetTime(serviceItem.useStartTime), resetTime(serviceItem.useEndTime)], // form.setFieldsValue({
purchaseTime: [ // useTime: [resetTime(serviceItem.useStartTime), resetTime(serviceItem.useEndTime)],
resetTime(serviceItem.purchaseStartTime), // purchaseTime: [
resetTime(serviceItem.purchaseEndTime), // resetTime(serviceItem.purchaseStartTime),
], // 购买开始时间 // resetTime(serviceItem.purchaseEndTime),
shopIds: serviceItem.shopIds || [], // 适用门店列表 // ], // 购买开始时间
unavailableDate: serviceItem.unavailableDate, // 不可用日期 // shopIds: serviceItem.shopIds || [], // 适用门店列表
useTimeDescription: serviceItem.useTimeDescription, // 使用时间 // unavailableDate: serviceItem.unavailableDate, // 不可用日期
useMethod: serviceItem.useMethod, // 使用方法 // useTimeDescription: serviceItem.useTimeDescription, // 使用时间
ruleDescription: serviceItem.ruleDescription, // 规则说明 // useMethod: serviceItem.useMethod, // 使用方法
applyScope: serviceItem.applyScope, // 适用范围 // ruleDescription: serviceItem.ruleDescription, // 规则说明
tips: serviceItem.tips, // 温馨提示 // applyScope: serviceItem.applyScope, // 适用范围
}); // tips: serviceItem.tips, // 温馨提示
// });
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
...@@ -61,6 +57,7 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -61,6 +57,7 @@ const FormRuleSetting = forwardRef((props, ref) => {
purchaseStartTime: formatTime(purchaseTime[0]), purchaseStartTime: formatTime(purchaseTime[0]),
purchaseEndTime: formatTime(purchaseTime[1]), purchaseEndTime: formatTime(purchaseTime[1]),
temp: 'serviceItem',
...values, ...values,
}; };
} catch (errorInfo) { } catch (errorInfo) {
...@@ -95,10 +92,6 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -95,10 +92,6 @@ const FormRuleSetting = forwardRef((props, ref) => {
ruleDescription: '', // 规则说明 ruleDescription: '', // 规则说明
applyScope: '', // 适用范围 applyScope: '', // 适用范围
tips: '', // 温馨提示 tips: '', // 温馨提示
imageList,
commonImageList,
detailImageList,
}} }}
scrollToFirstError scrollToFirstError
> >
......
import React, { useState, useEffect, useContext, forwardRef, useImperativeHandle } from 'react'; import React, { useState, useEffect, useContext, forwardRef, useImperativeHandle } from 'react';
import { Form } from 'antd'; import { Form, Button } from 'antd';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
import { TaskList, formItemLayout } from '../config';
import UploadImage from './UploadImage'; import UploadImage from './UploadImage';
import { formItemLayout } from '../config'; import commonStyle from '../common.less';
const { imgConfig: defaultImgConfig } = TaskList[0];
const FormRuleVPictures = forwardRef((props, ref) => { const FormRuleVPictures = forwardRef((props, ref) => {
const { editData, specKeyItem } = props; const { editData, specKeyItem } = props;
...@@ -10,27 +13,10 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -10,27 +13,10 @@ const FormRuleVPictures = forwardRef((props, ref) => {
const [imageList, setImageList] = useState({}); const [imageList, setImageList] = useState({});
const [commonImageList, setCommonImageList] = useState([]); const [commonImageList, setCommonImageList] = useState([]);
const [detailImageList, setDetailImageList] = useState([]); const [detailImageList, setDetailImageList] = useState([]);
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
// if (!Object.keys(editData).length) return;
// setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图
// setDetailImageList(editData.detailImageList); // 编辑状态下设置详情图
// const commImg = editData.skuList.reduce((orgin, item) => {
// const keyString = `${item.firstSpecValue}`; // _${item.firstSpecId}
// if (!Object.keys(orgin).includes(keyString)) {
// orgin[keyString] = item.imageList;
// }
// return orgin;
// }, {});
// setImageList(commImg);
// form.setFieldsValue({
// imageList: commImg,
// commonImageList: editData.commonImageList,
// detailImageList: editData.detailImageList,
// });
if (editData) { if (editData) {
setImageList(editData.imageList); setImageList(editData.imageList);
setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图 setCommonImageList(editData.commonImageList); // 编辑状态下设置公共图
...@@ -45,6 +31,7 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -45,6 +31,7 @@ const FormRuleVPictures = forwardRef((props, ref) => {
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => { useEffect(() => {
if (customer.isCard) return;
if (specKeyItem.length) { if (specKeyItem.length) {
const newImageList = specKeyItem.reduce((origin, item) => { const newImageList = specKeyItem.reduce((origin, item) => {
const showItem = imageList[item] || []; const showItem = imageList[item] || [];
...@@ -58,7 +45,7 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -58,7 +45,7 @@ const FormRuleVPictures = forwardRef((props, ref) => {
const onCheck = async () => { const onCheck = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
console.log(values); values.temp = 'infoImageData';
return values; return values;
} catch (errorInfo) { } catch (errorInfo) {
return null; return null;
...@@ -81,11 +68,29 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -81,11 +68,29 @@ const FormRuleVPictures = forwardRef((props, ref) => {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
}; };
const onPictureSuccessEvent = (imgList, key) => { const onPictureSuccessEvent = (imgList, key) => {
setImageList({ const newImgList = { ...imageList, [key]: imgList };
...imageList, setImageList(newImgList);
[key]: imgList, form.setFieldsValue({
imageList: newImgList,
}); });
}; };
const onCommonSuccessEvent = imgList => {
setCommonImageList(imgList);
form.setFieldsValue({
commonImageList: imgList,
});
};
const onDetailSuccessImageList = imgList => {
setDetailImageList(imgList);
form.setFieldsValue({
detailImageList: imgList,
});
};
const { imgConfig } = TaskList[customer.productType - 1];
return ( return (
<> <>
<Form <Form
...@@ -105,53 +110,79 @@ const FormRuleVPictures = forwardRef((props, ref) => { ...@@ -105,53 +110,79 @@ const FormRuleVPictures = forwardRef((props, ref) => {
name="commonImageList" name="commonImageList"
extra={`建议尺寸: ##宽##高 (${commonImageList.length} / 1) `} extra={`建议尺寸: ##宽##高 (${commonImageList.length} / 1) `}
rules={[ rules={[
{ required: true, type: 'array', message: '请输入温馨提示', validateTrigger: 'submit' }, {
required: imgConfig.commonImageList.rule,
type: 'array',
message: '请上传图片!',
validateTrigger: 'submit',
},
{
validator(rule, value, callback) {
if (customer.productType !== 1) callback();
const checkImageList = form.getFieldValue('imageList');
const check = Object.keys(checkImageList).length;
return check > 0 ? callback() : callback('请上传封面图片');
},
validateTrigger: 'submit',
},
]} ]}
> >
<UploadImage <UploadImage
disabled={customer.isService}
name="commonImageList" name="commonImageList"
limit={1} limit={1}
pictures={commonImageList} pictures={commonImageList}
setPictureList={setCommonImageList} setPictureList={list => onCommonSuccessEvent(list)}
/> />
</Form.Item> </Form.Item>
{Object.keys(imageList).map(key => ( {!customer.isCard &&
<Form.Item Object.keys(imageList).map(key => (
key={key} <Form.Item
label={`商品图片(${key})`} key={key}
name={['imageList', key]} label={`商品图片(${key})`}
extra={`建议尺寸: ##宽##高 (${imageList[key].length} / 11) `} name={['imageList', key]}
rules={[ extra={`建议尺寸: ##宽##高 (${imageList[key].length} / 11) `}
{ rules={[
required: true, {
type: 'array', required: imgConfig.imageList.rule,
message: '请输入温馨提示', type: 'array',
validateTrigger: 'submit', message: '请上传图片!',
}, validateTrigger: 'submit',
]} },
> ]}
<UploadImage >
name={key} <UploadImage
limit={11} disabled={customer.isService}
pictures={imageList[key]} name={key}
setPictureList={list => onPictureSuccessEvent(list, key)} limit={11}
/> pictures={imageList[key]}
</Form.Item> setPictureList={list => onPictureSuccessEvent(list, key)}
))} />
<Button className={commonStyle.pullImage} type="primary">
拉取公共图
</Button>
</Form.Item>
))}
<Form.Item <Form.Item
label="商品详情图" label="商品详情图"
name="detailImageList" name="detailImageList"
extra={`最多上传30张,${detailImageList.length} / 30`} extra={`最多上传30张,${detailImageList.length} / 30`}
rules={[ rules={[
{ required: true, type: 'array', message: '请输入温馨提示', validateTrigger: 'submit' }, {
type: 'array',
required: imgConfig.detailImageList.rule,
message: '请上传商品详情图!',
validateTrigger: 'submit',
},
]} ]}
> >
<UploadImage <UploadImage
disabled={customer.isService}
name="detailImageList" name="detailImageList"
limit={4}
pictures={detailImageList} pictures={detailImageList}
setPictureList={setDetailImageList} setPictureList={list => onDetailSuccessImageList(list)}
/> />
</Form.Item> </Form.Item>
</Form> </Form>
......
...@@ -4,15 +4,30 @@ import { Title } from './CommonTemplate'; ...@@ -4,15 +4,30 @@ import { Title } from './CommonTemplate';
import { formItemLayout } from '../config'; import { formItemLayout } from '../config';
import { ServiceContext } from '../context'; import { ServiceContext } from '../context';
const createInitValues = () => ({
settlementMethod: 1,
limitPurchase: null, // 是否限购1:限购/0:不限购
limitPurchaseType: null, // 限购类型,如果限购必填1:长期限购/2:周期限购
limitPurchaseCycle: null, // 限购周期1:每天/7:7天/30:30天
limitPurchaseQuantity: null, // 限购数量
packageContent: '',
appointment: null, // 预约
receptionVolume: null,
});
const FormSettlementOthers = forwardRef((props, ref) => { const FormSettlementOthers = forwardRef((props, ref) => {
const { editData } = props; const { editData } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [initValue, setInitValue] = useState(createInitValues());
const customer = useContext(ServiceContext);
const onCheck = async () => { const onCheck = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
return { return {
...values, ...values,
temp: 'settlementItem',
limitPurchase: values.limitPurchase ? 1 : 0, limitPurchase: values.limitPurchase ? 1 : 0,
}; };
} catch (errorInfo) { } catch (errorInfo) {
...@@ -20,45 +35,34 @@ const FormSettlementOthers = forwardRef((props, ref) => { ...@@ -20,45 +35,34 @@ const FormSettlementOthers = forwardRef((props, ref) => {
} }
}; };
useImperativeHandle(ref, () => ({
onCheck,
reset: form.resetFields,
}));
const customer = useContext(ServiceContext);
const [initValue, setInitValue] = useState({
settlementMethod: 1,
limitPurchase: null, // 是否限购1:限购/0:不限购
limitPurchaseType: null, // 限购类型,如果限购必填1:长期限购/2:周期限购
limitPurchaseCycle: null, // 限购周期1:每天/7:7天/30:30天
limitPurchaseQuantity: null, // 限购数量
packageContent: '',
appointment: null, // 预约
receptionVolume: null,
});
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!Object.keys(editData).length) return; if (!editData) return;
const { serviceItem } = editData.skuList[0]; form.setFieldsValue(editData);
setInitValue({ ...editData });
const data = { // const { serviceItem } = editData.skuList[0];
settlementMethod: 1, // const data = {
limitPurchase: Boolean(serviceItem.limitPurchase), // 是否限购1:限购/0:不限购 // settlementMethod: 1,
limitPurchaseType: serviceItem.limitPurchaseType, // 限购类型,如果限购必填1:长期限购/2:周期限购 // limitPurchase: Boolean(serviceItem.limitPurchase), // 是否限购1:限购/0:不限购
limitPurchaseCycle: serviceItem.limitPurchaseCycle, // 限购周期1:每天/7:7天/30:30天 // limitPurchaseType: serviceItem.limitPurchaseType, // 限购类型,如果限购必填1:长期限购/2:周期限购
limitPurchaseQuantity: serviceItem.limitPurchaseQuantity, // 限购数量 // limitPurchaseCycle: serviceItem.limitPurchaseCycle, // 限购周期1:每天/7:7天/30:30天
packageContent: serviceItem.packageContent, // limitPurchaseQuantity: serviceItem.limitPurchaseQuantity, // 限购数量
appointment: serviceItem.appointment, // 预约 // packageContent: serviceItem.packageContent,
receptionVolume: serviceItem.receptionVolume, // 接待数量 // appointment: serviceItem.appointment, // 预约
}; // receptionVolume: serviceItem.receptionVolume, // 接待数量
// };
form.setFieldsValue(data); // form.setFieldsValue(data);
setInitValue({ ...data }); // setInitValue({ ...data });
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => {}, [form]); useImperativeHandle(ref, () => ({
onCheck,
reset: () => {
setInitValue(createInitValues());
form.resetFields();
},
}));
const onFinish = values => { const onFinish = values => {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
......
...@@ -25,7 +25,9 @@ const uploadButton = ( ...@@ -25,7 +25,9 @@ const uploadButton = (
const UploadImage = props => { const UploadImage = props => {
const { const {
name = `${Date.now()}`, name = `${Date.now()}`,
limit = 1, limit = null,
multiple = true,
disabled,
uploadParams, uploadParams,
pictures = [], pictures = [],
onChange = () => {}, onChange = () => {},
...@@ -59,7 +61,6 @@ const UploadImage = props => { ...@@ -59,7 +61,6 @@ const UploadImage = props => {
const bundleChange = imgFile => { const bundleChange = imgFile => {
const imgList = imgFile.map(item => item.url); const imgList = imgFile.map(item => item.url);
setPictureList(imgList); setPictureList(imgList);
onChange(imgList);
}; };
const handleRemove = file => { const handleRemove = file => {
...@@ -145,7 +146,7 @@ const UploadImage = props => { ...@@ -145,7 +146,7 @@ const UploadImage = props => {
(file, fileArray) => (file, fileArray) =>
// 文件显示 // 文件显示
new Promise(async () => { new Promise(async () => {
if (fileListRef.current.length + fileArray.length > limit) { if (limit && fileListRef.current.length + fileArray.length > limit) {
Modal.warning({ Modal.warning({
maskClosable: true, maskClosable: true,
title: '超出上传个数', title: '超出上传个数',
...@@ -180,8 +181,9 @@ const UploadImage = props => { ...@@ -180,8 +181,9 @@ const UploadImage = props => {
return ( return (
<Spin tip="正在上传..." spinning={uploadLoading} delay={100}> <Spin tip="正在上传..." spinning={uploadLoading} delay={100}>
<Upload <Upload
disabled={disabled}
{...uploadParams} {...uploadParams}
multiple={limit > 1} multiple={multiple}
name={name} name={name}
customRequest={() => {}} customRequest={() => {}}
listType="picture-card" listType="picture-card"
......
...@@ -12,21 +12,61 @@ export const TaskList = [ ...@@ -12,21 +12,61 @@ export const TaskList = [
name: '实体商品', name: '实体商品',
type: 1, type: 1,
desc: '物流发货', desc: '物流发货',
imgConfig: {
imageList: {
tip: '(图片最大上传2M)',
rule: false,
limit: null,
},
commonImageList: {
tip: '(图片最大上传2M)',
rule: false,
limit: null,
},
detailImageList: {
tip: '(图片最大上传2M)',
rule: true,
limit: null,
},
},
}, },
{ {
name: '虚拟商品', name: '虚拟商品',
type: 2, type: 2,
desc: '无需物流', desc: '无需物流',
imgConfig: {
imageList: {
rule: false,
limit: null,
},
commonImageList: {
rule: false,
limit: false,
},
detailImageList: {
rule: false,
limit: false,
},
},
}, },
{ {
name: '电子卡卷', name: '电子卡卷',
type: 3, type: 3,
desc: '无需物流', desc: '无需物流',
}, imgConfig: {
{ imageList: {
name: '服务类商品', rule: true,
type: 4, limit: 1,
desc: '无需物流', },
commonImageList: {
rule: true,
limit: 11,
},
detailImageList: {
rule: true,
limit: 30,
},
},
}, },
]; ];
......
...@@ -15,8 +15,9 @@ import { ...@@ -15,8 +15,9 @@ import {
merchantSpecList, merchantSpecList,
afterSalesAddrsPage, afterSalesAddrsPage,
merchantgetJdPicList, merchantgetJdPicList,
merchantProductAdd,
} from './service'; } from './service';
import { isUrl } from './utils'; import { isUrl, filterSendData } from './utils';
import { ServiceContext } from './context'; import { ServiceContext } from './context';
/** /**
...@@ -62,23 +63,13 @@ const ServiceGoods = options => { ...@@ -62,23 +63,13 @@ const ServiceGoods = options => {
}); });
}; };
// useEffect(() => {
// const timer = setTimeout(() => {
// console.log(checkFormList);
// clearTimeout(timer);
// }, 1000);
// }, [checkFormList, options.visible]);
const productChange = task => { const productChange = task => {
setProductType(task.type); setProductType(task.type);
changeCheckList(task.type); changeCheckList(task.type);
}; const timer = setTimeout(() => {
resetForm();
const submitEvent = async () => { clearTimeout(timer);
const checkPromiseList = checkFormList.map(({ current }) => current.onCheck()); }, 1000);
const resuslt = await Promise.all(checkPromiseList);
console.log(resuslt);
}; };
// 编辑回显详情数据 // 编辑回显详情数据
...@@ -121,6 +112,31 @@ const ServiceGoods = options => { ...@@ -121,6 +112,31 @@ const ServiceGoods = options => {
} }
}; };
const sendMerchantProductAdd = async sendData => {
const addResponse = await merchantProductAdd(sendData);
console.log(addResponse);
};
const submitEvent = async () => {
const checkPromiseList = checkFormList.map(({ current }) => current.onCheck());
const resuslt = await Promise.all(checkPromiseList);
if (!resuslt.includes(null)) {
const params = resuslt.reduce((origin, item) => {
const { temp, ...other } = item;
origin[temp] = other;
return origin;
}, {});
const sendData = filterSendData(productType, params);
console.log('==============>生成发送数据,===>', sendData);
sendMerchantProductAdd(sendData);
// sendAsyncPost({ ...sendData, type: productType });
console.log();
}
};
const getMerchantgetJdPicList = async params => { const getMerchantgetJdPicList = async params => {
const result = await merchantgetJdPicList(params); const result = await merchantgetJdPicList(params);
if (result) { if (result) {
...@@ -249,15 +265,19 @@ const ServiceGoods = options => { ...@@ -249,15 +265,19 @@ const ServiceGoods = options => {
skuList={editData.skuList} skuList={editData.skuList}
/> />
{/* <Title title="规则设置" /> <Title title="规则设置" />
{productType === 3 && <FormRuleSetting ref={settingRef} editData={editData} />} */} {productType === 3 && (
<FormRuleSetting ref={settingRef} editData={editData.serviceItem} />
)}
<FormRuleVPictures <FormRuleVPictures
ref={picturesRef} ref={picturesRef}
specKeyItem={specKeyList} specKeyItem={specKeyList}
editData={editData.infoImageData} editData={editData.infoImageData}
/> />
{/* {productType === 3 && <FormSettlementOthers ref={settleOtrRef} editData={editData} />} */} {productType === 3 && (
<FormSettlementOthers ref={settleOtrRef} editData={editData.settlementItem} />
)}
<Button type="primary" onClick={submitEvent}> <Button type="primary" onClick={submitEvent}>
Register Register
</Button> </Button>
......
...@@ -66,3 +66,9 @@ export const merchantgetJdPicList = async params => { ...@@ -66,3 +66,9 @@ export const merchantgetJdPicList = async params => {
}); });
return data; return data;
}; };
export const merchantProductAdd = data =>
request.post('/product/api/merchant/add', {
prefix: goodsApi,
data,
});
...@@ -54,6 +54,7 @@ const createSecondProduct = (secondSpecList, initItem, secondSpec, dataSource, c ...@@ -54,6 +54,7 @@ const createSecondProduct = (secondSpecList, initItem, secondSpec, dataSource, c
} }
specSecond.secondSpecId = secondSpec; specSecond.secondSpecId = secondSpec;
specSecond.secondSpecValue = secondItem.secondSpecValue; specSecond.secondSpecValue = secondItem.secondSpecValue;
// specSecond.uuid = UUID.createUUID();
dataSource.push(specSecond); dataSource.push(specSecond);
}); });
}; };
...@@ -67,6 +68,7 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco ...@@ -67,6 +68,7 @@ export const createProductData = ({ firstValues, secondValues, firstSpecId, seco
const specFirst = createInitProduct(fisrtItem, true); const specFirst = createInitProduct(fisrtItem, true);
specFirst.firstSpecId = firstSpecId; specFirst.firstSpecId = firstSpecId;
specFirst.firstSpecValue = fisrtItem.firstSpecValue; specFirst.firstSpecValue = fisrtItem.firstSpecValue;
// specFirst.uuid = UUID.createUUID();
if (secondSpecId && secondValues.length) { if (secondSpecId && secondValues.length) {
createSecondProduct(secondValues, specFirst, secondSpecId, dataSource, specSecond => { createSecondProduct(secondValues, specFirst, secondSpecId, dataSource, specSecond => {
if (!countRowSpan[specFirst.firstSpecValue]) { if (!countRowSpan[specFirst.firstSpecValue]) {
...@@ -126,3 +128,40 @@ export const batchTableSourceData = ({ batchItem, tableData, bacthSecon, bacthFi ...@@ -126,3 +128,40 @@ export const batchTableSourceData = ({ batchItem, tableData, bacthSecon, bacthFi
return item; return item;
}); });
}; };
const filterItems = (type, props) => {
const { infoSpecData, serviceItem, infoImageData, infoMation, settlementItem } = props;
const { imageList = {}, commonImageList } = infoImageData;
return infoSpecData.items.map(item => {
const imgList = imageList[item.firstSpecValue] || [];
item.imageList = imgList.length ? imgList : commonImageList;
item.firstSpecId = infoSpecData.firstSpecId;
item.secondSpecId = infoSpecData.secondSpecId || null;
if (type === 3) {
item.serviceItem = {
...serviceItem,
...settlementItem,
description: infoMation.description || '',
};
}
return item;
});
};
export const filterSendData = (type, params) => {
console.log('===============>生成数据', params);
const { infoMation, infoImageData } = params;
const items = filterItems(type, params);
return {
type,
items,
name: infoMation.name,
brandId: infoMation.brandId || null,
character: infoMation.character,
categoryId: infoMation.categoryId[2],
afterAddressId: infoMation.afterAddressId,
detailImageList: infoImageData.detailImageList,
commonImageList: infoImageData.commonImageList,
};
};
import { parse } from 'querystring'; import { parse } from 'querystring';
import pathRegexp from 'path-to-regexp'; import pathRegexp from 'path-to-regexp';
import moment from 'moment';
/* eslint no-useless-escape:0 import/prefer-default-export:0 */ /* eslint no-useless-escape:0 import/prefer-default-export:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
...@@ -52,3 +53,6 @@ export function toThousands(data, num) { ...@@ -52,3 +53,6 @@ export function toThousands(data, num) {
} }
return result; return result;
} }
export const formatTime = (time, crm = 'YYYY-MM-DD HH') => time.format(crm);
export const resetTime = (time, crm = 'YYYY-MM-DD HH') => moment(time, crm);
/**
* [UUID 生成UUID]
*/
class UUID {
constructor() {
this.id = this.createUUID();
}
/**
* [valueOf 重写 valueOf 方法]
* @return {String} [description]
*/
valueOf() {
return this.id;
}
/**
* [valueOf 重写 toString 方法]
* @return {String} [description]
*/
toString() {
return this.id;
}
/**
* [createUUID 创建UUID]
* @return {String} [description]
*/
createUUID() {
const dg = new Date(1582, 10, 15, 0, 0, 0, 0);
const dc = new Date();
const t = dc.getTime() - dg.getTime();
const h = '';
const tl = this.getIntegerBits(t, 0, 31);
const tm = this.getIntegerBits(t, 32, 47);
const thv = `${this.getIntegerBits(t, 48, 59)}1`; // version 1, security version is 2
const csar = this.getIntegerBits(this.rand(4095), 0, 7);
const csl = this.getIntegerBits(this.rand(4095), 0, 7);
const n =
this.getIntegerBits(this.rand(8191), 0, 7) +
this.getIntegerBits(this.rand(8191), 8, 15) +
this.getIntegerBits(this.rand(8191), 0, 7) +
this.getIntegerBits(this.rand(8191), 8, 15) +
this.getIntegerBits(this.rand(8191), 0, 15); // this last number is two octets long
return tl + h + tm + h + thv + h + csar + csl + h + n;
}
/**
* [getIntegerBits description]
* @param {[type]} val [description]
* @param {[type]} start [description]
* @param {[type]} end [description]
* @return {[type]} [description]
*/
getIntegerBits(val, start, end) {
const base16 = this.returnBase(val, 16);
const quadArray = [];
let quadString = '';
let i = 0;
for (i = 0; i < base16.length; i++) {
quadArray.push(base16.substring(i, i + 1));
}
for (i = Math.floor(start / 4); i <= Math.floor(end / 4); i++) {
if (!quadArray[i] || quadArray[i] === '') {
quadString += '0';
} else {
quadString += quadArray[i];
}
}
return quadString;
}
/**
* [returnBase description]
* @param {[type]} number [description]
* @param {[type]} base [description]
* @return {[type]} [description]
*/
returnBase(number, base) {
const convert = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
let output;
if (number < base) {
output = convert[number];
} else {
const MSD = `${Math.floor(number / base)}`;
const LSD = number - MSD * base;
if (MSD >= base) {
output = this.returnBase(MSD, base) + convert[LSD];
} else {
output = convert[MSD] + convert[LSD];
}
}
return output;
}
/**
* [rand description]
* @param {[type]} max [description]
* @return {[type]} [description]
*/
// eslint-disable-next-line class-methods-use-this
rand(max) {
return Math.floor(Math.random() * max);
}
}
export default new UUID();
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