Commit c59c2895 authored by beisir's avatar beisir

fix: 生成商品信息

parent 63a12f9b
......@@ -44,18 +44,6 @@ const FormInformationBasic = forwardRef((props, ref) => {
useEffect(() => {
if (customer.isEdit) {
if (!editData) return;
// const initValues = {
// brandId: editData.brandId,
// supplierId: editData.supplierId,
// character: editData.character,
// name: editData.name,
// categoryId: [editData.firstCategoryId, editData.secondCategoryId, editData.thirdCategoryId],
// description: null,
// };
// if (customer.isCard) {
// const { serviceItem } = editData.skuList[0];
// initValues.description = (serviceItem || {}).description || null;
// }
form.setFieldsValue(editData);
}
}, [customer.isEdit, editData]);
......@@ -79,7 +67,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
}}
scrollToFirstError
>
<Form.Item
{/* <Form.Item
label="供应商名称"
name="supplierId"
rules={[{ required: true, message: '请选择供应商名称' }]}
......@@ -87,7 +75,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
<Select showSearch placeholder="请选择供应商名称" filterOption={fileterBrandOptions}>
{CreateSelectOption(shopList)}
</Select>
</Form.Item>
</Form.Item> */}
<Form.Item
name="categoryId"
label="商品类目"
......
......@@ -230,7 +230,15 @@ const FormPriceOrStock = forwardRef((props, ref) => {
try {
const values = await form.validateFields();
const { tableList: items } = await editRef.current.onCheck();
return items ? { ...values, items, temp: 'infoSpecData' } : null;
console.log('================>items', items);
if (items) {
return { ...values, items, temp: 'infoSpecData' };
}
notification.open({
message: '提示',
description: '请生成商品信息!',
});
return null;
} catch (errorInfo) {
return null;
}
......
......@@ -16,35 +16,18 @@ const WeekCheckBox = () =>
));
const rangeConfig = {
rules: [{ type: 'array', required: true, message: 'Please select time!' }],
rules: [{ type: 'array', required: true, message: '请选择时间!' }],
};
const FormRuleSetting = forwardRef((props, ref) => {
const { editData } = props;
const { editData, supplierIdList } = props;
const [form] = Form.useForm();
const customer = useContext(ServiceContext);
useEffect(() => {
if (customer.isEdit) {
if (!editData) return;
form.setFieldsValue(editData);
// setImageList(editData.commonImageList);
// setCommonImageList(editData.commonImageList);
// setDetailImageList(editData.detailImageList);
// const { serviceItem } = editData.skuList[0];
// form.setFieldsValue({
// 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, // 温馨提示
// });
}
}, [customer.isEdit, editData]);
......@@ -69,17 +52,12 @@ const FormRuleSetting = forwardRef((props, ref) => {
onCheck,
reset: form.resetFields,
}));
const onFinish = values => {
console.log('Received values of form: ', values);
};
return (
<>
<Form
{...formItemLayout}
form={form}
name="register"
onFinish={onFinish}
initialValues={{
useTime: [], // 使用开始时间
// useEndTime: '', // 使用结束时间
......@@ -107,9 +85,11 @@ const FormRuleSetting = forwardRef((props, ref) => {
rules={[{ required: true, message: '请选择适用门店!', type: 'array' }]}
>
<Select mode="multiple" placeholder="请选择适用门店">
<Option value={1}>Male</Option>
<Option value={2}>Female</Option>
<Option value={3}>Other</Option>
{(supplierIdList || []).map(item => (
<Option value={item.id} key={item.id}>
{item.name}
</Option>
))}
</Select>
</Form.Item>
......@@ -134,14 +114,14 @@ const FormRuleSetting = forwardRef((props, ref) => {
<Form.Item
name="useMethod"
label="使用方法"
rules={[{ required: false, message: '请输使用方法,200字以内!' }]}
rules={[{ required: true, message: '请输使用方法,200字以内!' }]}
>
<Input.TextArea showCount maxLength={200} placeholder="请输使用方法,200字以内!" />
</Form.Item>
<Form.Item
name="ruleDescription"
label="规则说明"
rules={[{ required: false, message: '请输规则说明,200字以内!' }]}
rules={[{ required: true, message: '请输规则说明,200字以内!' }]}
>
<Input.TextArea showCount maxLength={200} placeholder="请输规则说明,200字以内!" />
</Form.Item>
......
......@@ -89,7 +89,7 @@ const FormRuleVPictures = forwardRef((props, ref) => {
});
};
const { imgConfig } = TaskList[customer.productType - 1];
const [{ imgConfig }] = TaskList.filter(item => item.type === customer.productType);
return (
<>
......
......@@ -40,19 +40,6 @@ const FormSettlementOthers = forwardRef((props, ref) => {
if (!editData) return;
form.setFieldsValue(editData);
setInitValue({ ...editData });
// const { serviceItem } = editData.skuList[0];
// const data = {
// 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, // 接待数量
// };
// form.setFieldsValue(data);
// setInitValue({ ...data });
}
}, [customer.isEdit, editData]);
......@@ -64,10 +51,6 @@ const FormSettlementOthers = forwardRef((props, ref) => {
},
}));
const onFinish = values => {
console.log('Received values of form: ', values);
};
const radioChangeEvent = key => {
const value = form.getFieldValue(key);
setInitValue({
......@@ -135,11 +118,14 @@ const FormSettlementOthers = forwardRef((props, ref) => {
{...formItemLayout}
form={form}
name="register"
onFinish={onFinish}
initialValues={initValue}
scrollToFirstError
>
<Form.Item name="appointment" label="预约">
<Form.Item
name="appointment"
label="预约"
rules={[{ required: true, message: '请选择是否预约!' }]}
>
<Radio.Group>
<Radio value={1}></Radio>
<Radio value={0}></Radio>
......
......@@ -55,6 +55,26 @@ export const TaskList = [
name: '电子卡卷',
type: 3,
desc: '无需物流',
hide: true,
imgConfig: {
imageList: {
rule: true,
limit: 1,
},
commonImageList: {
rule: true,
limit: 11,
},
detailImageList: {
rule: true,
limit: 30,
},
},
},
{
name: '服务类商品',
type: 4,
desc: '无需物流',
imgConfig: {
imageList: {
rule: true,
......@@ -112,7 +132,7 @@ export const StaticColumns = customer => [
title: '供货价',
dataIndex: 'supplyPrice',
editable: true,
batchRole: [1, 2, 3],
batchRole: [1, 2, 3, 4],
roleProps: {
precision: 2,
min: 0,
......@@ -124,14 +144,14 @@ export const StaticColumns = customer => [
title: '佣金费率',
dataIndex: 'commissionRate',
editable: true,
role: [3],
role: [4],
roleRules: { required: true },
},
{
title: '市场价',
dataIndex: 'marketPrice',
editable: true,
batchRole: [1, 2, 3],
batchRole: [1, 2, 3, 4],
roleProps: {
precision: 2,
min: 0,
......@@ -139,6 +159,14 @@ export const StaticColumns = customer => [
roleRules: { required: true },
disabled: customer.isService,
},
{
title: '销售价',
dataIndex: 'salePrice',
editable: true,
batchRole: [4],
role: [4],
roleRules: { required: true },
},
{
title: '重量(kg)',
dataIndex: 'weight',
......@@ -148,30 +176,16 @@ export const StaticColumns = customer => [
precision: 3,
max: 999999.999,
},
role: [1, 2],
roleRules: { required: true },
disabled: customer.isService,
},
{
title: '销售价',
dataIndex: 'salePrice',
editable: true,
role: [],
roleRules: { required: true },
},
{
title: '库存',
dataIndex: 'productStock',
editable: true,
role: [3],
roleRules: { required: true },
// disabled: customer.isService,
},
{
title: '库存',
dataIndex: 'productStock',
editable: true,
role: [1, 2],
batchRole: [1, 2],
role: [4],
batchRole: [1, 2, 4],
batchProps: {
precision: 0,
step: 1,
......@@ -183,14 +197,32 @@ export const StaticColumns = customer => [
min: 0,
},
roleRules: { required: true },
disabled: customer.isService,
},
// {
// title: '库存',
// dataIndex: 'productStock',
// editable: true,
// role: [1, 2],
// batchRole: [1, 2],
// batchProps: {
// precision: 0,
// step: 1,
// // eslint-disable-next-line radix
// formatter: val => parseInt(val, '10') || '',
// },
// roleProps: {
// precision: 2,
// min: 0,
// },
// roleRules: { required: true },
// disabled: customer.isService,
// },
{
title: '库存预警阈值',
dataIndex: 'productStockWarning',
editable: true,
batchRole: [1],
role: [1],
role: [1, 4],
roleRules: { required: true },
disabled: customer.isService,
},
......
import React, { useState, useRef, useEffect, useCallback } from 'react';
import { Spin, Button, Modal, notification } from 'antd';
import { Spin, Button, Modal, message, notification } from 'antd';
import { ConsoleSqlOutlined } from '@ant-design/icons';
import { Title, WrapperContainer } from './components/CommonTemplate';
import { TaskTypeSelect } from './components/TaskTypeSelect';
......@@ -18,6 +18,7 @@ import {
merchantProductAdd,
// getSupplierList,
supplierListQuery,
shopGetBySupplierId,
} from './service';
import { isUrl, filterSendData } from './utils';
import { ServiceContext } from './context';
......@@ -38,12 +39,13 @@ const ServiceGoods = options => {
const [pageId, setPageId] = useState(null);
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [productType, setProductType] = useState(3); // 商品状态
const [productType, setProductType] = useState(4); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
// const [categoryList, setCategoryList] = useState([]); // 获取三级类目
const [afterAddressList, setAfterAddressList] = useState([]);
const [supplierIdList, setSupplierIdList] = useState([]);
const [shopList, setShopList] = useState([]);
// const [shopList, setShopList] = useState([]);
const [brandList, setBrandList] = useState([]); // 获取商品牌
const [specList, setSpecList] = useState([]); // 规格列表
const [editData, setEditData] = useState({}); // 编辑保存数据
......@@ -54,7 +56,7 @@ const ServiceGoods = options => {
const changeCheckList = proType => {
const newBaseCheckList =
proType === 3 ? [...baseCheckList, settingRef, settleOtrRef] : baseCheckList;
proType === 4 ? [...baseCheckList, settingRef, settleOtrRef] : baseCheckList;
setCheckFormList(newBaseCheckList);
};
......@@ -75,6 +77,16 @@ const ServiceGoods = options => {
}, 1000);
};
const handleCancel = () => {
setPageId(null);
setIsEdit(false);
setProductType(4); // 默认写死服务类商品
setEditData({});
setSpecKeyList([]);
resetForm();
options.onChange(false);
};
// 编辑回显详情数据
const getProductDetailResponse = async id => {
try {
......@@ -89,10 +101,10 @@ const ServiceGoods = options => {
};
// 获取三级类目分类数据
const getMerchantCategory = async () => {
const result = await merchantCategoryGetAll();
// setCategoryList(result.data || []);
};
// const getMerchantCategory = async () => {
// const result = await merchantCategoryGetAll();
// // setCategoryList(result.data || []);
// };
// 获取商品牌数据
const getMerchantBrandList = async () => {
if (!brandList.length) {
......@@ -115,17 +127,29 @@ const ServiceGoods = options => {
}
};
const getSupplierListResponse = async () => {
if (!shopList.length) {
const result = await supplierListQuery();
console.log('=================>result', result);
setShopList(result.data);
}
};
// const getSupplierListResponse = async () => {
// if (!shopList.length) {
// const result = await supplierListQuery();
// console.log('=================>result', result);
// setShopList(result.data);
// }
// };
const sendMerchantProductAdd = async sendData => {
setPageLoading(true);
const addResponse = await merchantProductAdd(sendData);
console.log(addResponse);
if (addResponse.data) {
message.success('添加成功!');
handleCancel();
}
setPageLoading(false);
};
const shopGetBySupplierIdResponse = async () => {
if (!supplierIdList.length) {
const result = await shopGetBySupplierId();
setSupplierIdList(result.data);
}
};
const submitEvent = async () => {
......@@ -139,12 +163,7 @@ const ServiceGoods = options => {
}, {});
const sendData = filterSendData(productType, params);
console.log('==============>生成发送数据,===>', sendData);
sendMerchantProductAdd(sendData);
// sendAsyncPost({ ...sendData, type: productType });
console.log();
}
};
......@@ -172,7 +191,8 @@ const ServiceGoods = options => {
return;
}
setPageLoading(true);
await getSupplierListResponse();
await shopGetBySupplierIdResponse();
// await getSupplierListResponse();
await getMerchantBrandList();
await getAfterSalesAddrsPage();
await getMerchantSpecList();
......@@ -185,32 +205,9 @@ const ServiceGoods = options => {
setIsEdit(true);
}
setPageLoading(false);
// setPageLoading(true);
// await getMerchantCategory();
// await getMerchantBrandList();
// await getMerchantSpecList();
// if (options.id) {
// setIsEdit(true);
// await getProductDetailResponse(options.id);
// changeCheckList(productType);
// }
// setPageLoading(false);
})();
}, [SourceData]);
const handleOk = () => {};
const handleCancel = () => {
setPageId(null);
setIsEdit(false);
setProductType(3);
setEditData({});
setSpecKeyList([]);
resetForm();
options.onChange(false);
};
const onSpecCommonImgEvent = useCallback(
keys => {
setSpecKeyList(keys);
......@@ -244,14 +241,25 @@ const ServiceGoods = options => {
pageId,
isEdit,
productType,
isCard: productType === 3,
isCard: productType === 4,
isService: SourceData.state && SourceData.state !== 4,
isJDGoods: isEdit && SourceData.pageProductType && +SourceData.pageProductType !== 1,
onEventBus,
};
return (
<Modal visible={options.visible} onOk={handleOk} onCancel={handleCancel} width={1366}>
<Modal
visible={options.visible}
width={1366}
footer={[
<Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}>
提交
</Button>,
<Button key="back" onClick={handleCancel}>
返回
</Button>,
]}
>
<Spin tip="正在加载..." spinning={pageLoading} delay={100}>
<WrapperContainer>
<ServiceContext.Provider value={providerValue}>
......@@ -262,7 +270,6 @@ const ServiceGoods = options => {
<FormInformationBasic
ref={basicRef}
editData={editData.infoMation}
shopList={shopList}
categoryList={categoryList}
brandList={brandList}
afterAddressList={afterAddressList}
......@@ -279,8 +286,12 @@ const ServiceGoods = options => {
/>
<Title title="规则设置" />
{productType === 3 && (
<FormRuleSetting ref={settingRef} editData={editData.serviceItem} />
{productType === 4 && (
<FormRuleSetting
ref={settingRef}
editData={editData.serviceItem}
supplierIdList={supplierIdList}
/>
)}
<FormRuleVPictures
......@@ -288,12 +299,9 @@ const ServiceGoods = options => {
specKeyItem={specKeyList}
editData={editData.infoImageData}
/>
{productType === 3 && (
{productType === 4 && (
<FormSettlementOthers ref={settleOtrRef} editData={editData.settlementItem} />
)}
<Button type="primary" onClick={submitEvent}>
Register
</Button>
</ServiceContext.Provider>
</WrapperContainer>
</Spin>
......
......@@ -78,3 +78,11 @@ export const supplierListQuery = () =>
prefix: config.kdspApi,
headers,
});
// supplierId: 供应商id(优先使用token中的supplierId,这里可以传任意值,建议传0)
// state: 状态:-1-全部,1-启用,0-禁用
export const shopGetBySupplierId = (state = 1, supplierId = 0) =>
request.get(`/shop/getBySupplierId/${supplierId}/${state}`, {
prefix: goodsApi,
headers,
});
......@@ -141,7 +141,7 @@ const filterItems = (type, props) => {
item.imageList = imgList.length ? imgList : commonImageList;
item.firstSpecId = infoSpecData.firstSpecId;
item.secondSpecId = infoSpecData.secondSpecId || null;
if (type === 3) {
if (type === 4) {
item.serviceItem = {
...serviceItem,
...settlementItem,
......
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