Commit b852abb4 authored by 陈万宝's avatar 陈万宝

feat: 禁用编辑时候可以存草稿问题

parent d53eaa83
...@@ -17,7 +17,6 @@ import { ...@@ -17,7 +17,6 @@ import {
Checkbox, Checkbox,
Radio, Radio,
Space, Space,
Modal,
Switch, Switch,
Row, Row,
Col, Col,
...@@ -35,7 +34,6 @@ import { ServiceContext } from '../context'; ...@@ -35,7 +34,6 @@ import { ServiceContext } from '../context';
import { debounce } from '@/utils/utils'; import { debounce } from '@/utils/utils';
import { isCheckPriceTwoDecimal, isIntegerNotZero } from '@/utils/validator'; import { isCheckPriceTwoDecimal, isIntegerNotZero } from '@/utils/validator';
import UploadCropImage from './UploadCropImage'; import UploadCropImage from './UploadCropImage';
// import AddSellTimeModal from './AddSellTimeModal';
import styles from '../common.less'; import styles from '../common.less';
import AddRepertoryModal from './AddRepertoryModal'; import AddRepertoryModal from './AddRepertoryModal';
import { apiTagList, apiUnits } from '../service'; import { apiTagList, apiUnits } from '../service';
...@@ -89,7 +87,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -89,7 +87,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
const showModal = () => { const showModal = () => {
addSellTimeRef.current.setOpen(true); addSellTimeRef.current.setOpen(true);
}; };
const onCheck = async () => { const onCheck = async () => {
try { try {
const values = await form.validateFields(); const values = await form.validateFields();
...@@ -102,9 +99,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -102,9 +99,11 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
return null; return null;
} }
}; };
// 过滤单位
const takeawayCalc = takeawayData => { const filterUnit = unit =>
(Array.isArray(unit) && unit?.length && unit?.slice(1).toString()) || unit;
// 商品基本信息编辑商品名称 // 商品基本信息编辑商品名称
const takeawayCalc = takeawayData => {
const { infoMation: name, infoMation, takeawayItem } = takeawayData; const { infoMation: name, infoMation, takeawayItem } = takeawayData;
// weight 份量 specs规格 生成sku规则 weight * specs // weight 份量 specs规格 生成sku规则 weight * specs
const { const {
...@@ -129,8 +128,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -129,8 +128,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
categoryId, categoryId,
} = takeawayItem; } = takeawayItem;
let { unit } = takeawayItem; let { unit } = takeawayItem;
unit = (unit && filterUnit(unit)) || unit;
unit = (unit && (Array.isArray(unit) && unit?.length && unit?.slice(1).toString())) || unit;
const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格 const singularSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 单规格
const multiSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 多规格 const multiSpecList = [{ specGroupName: '份量', generateSku: 1, specs: [] }]; // 多规格
...@@ -329,12 +327,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -329,12 +327,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
singleDelivery, singleDelivery,
specList: +repertoryType === 1 ? singularSpecList : multiSpecList, // 单库存和多库存specList specList: +repertoryType === 1 ? singularSpecList : multiSpecList, // 单库存和多库存specList
items: +repertoryType === 1 ? singularSpuData : JSON.parse(JSON.stringify(multiSpu)), items: +repertoryType === 1 ? singularSpuData : JSON.parse(JSON.stringify(multiSpu)),
// categoryId:
// (
// infoMation?.categoryId &&
// infoMation?.categoryId?.slice(infoMation?.categoryId?.length - 1)
// )?.toString() ||
// (Array.isArray(categoryId) && categoryId?.slice(categoryId?.length - 1)?.toString()),
}; };
setIntactData(intactDataTemp); setIntactData(intactDataTemp);
...@@ -481,9 +473,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -481,9 +473,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
AddRepertoryRef.current.setOpenRepertory(true); AddRepertoryRef.current.setOpenRepertory(true);
setRepertoryModel({ type, idx, item }); setRepertoryModel({ type, idx, item });
}; };
// 过滤单位
const filterUnit = unit =>
(Array.isArray(unit) && unit?.length && unit?.slice(1).toString()) || unit;
// 拼接sku 名称 // 拼接sku 名称
const calcLabelName = item => { const calcLabelName = item => {
let firstName = ''; let firstName = '';
...@@ -563,7 +553,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -563,7 +553,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
? saleTimes.map(item => [moment(item?.startTime, format), moment(item?.endTime, format)]) ? saleTimes.map(item => [moment(item?.startTime, format), moment(item?.endTime, format)])
: []; : [];
if (editData?.skuList?.length) { if (editData?.skuList?.length) {
// editData.minPurchaseNum = editData?.skuList[0]?.serviceItem.minPurchaseNum;
// 单规格 // 单规格
if (editData?.skuList?.length === 1) { if (editData?.skuList?.length === 1) {
const { const {
...@@ -582,7 +571,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -582,7 +571,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
editData.autoStock = +autoStock === 1; editData.autoStock = +autoStock === 1;
editData.productRefShopId = editData.shopId; editData.productRefShopId = editData.shopId;
editData.skuId = id; editData.skuId = id;
// setSingularSpu(JSON.parse(JSON.stringify(tempMultiSpu)) || []);
form.setFieldsValue(editData); form.setFieldsValue(editData);
} else { } else {
// 多规格 // 多规格
...@@ -608,7 +596,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -608,7 +596,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
editData.productRefShopId = editData.shopId; editData.productRefShopId = editData.shopId;
// setTempWeight(weight) // setTempWeight(weight)
// setTempSpecs(specs) // setTempSpecs(specs)
form.setFieldsValue({ weight: weight[0].specs }); form.setFieldsValue({ weight: weight[0].specs });
form.setFieldsValue(editData); form.setFieldsValue(editData);
form.setFieldsValue({ specs }); form.setFieldsValue({ specs });
...@@ -657,7 +644,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -657,7 +644,7 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
} }
setTimeType(tempEdit?.saleTimeType); setTimeType(tempEdit?.saleTimeType);
form.setFieldsValue(tempEdit); form.setFieldsValue(tempEdit);
getFormValues(); // getFormValues();
} }
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
...@@ -851,13 +838,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -851,13 +838,9 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<> <>
<Form.Item label="份量" className={styles.required}> <Form.Item label="份量" className={styles.required}>
{form.getFieldValue(['unit']) && {form.getFieldValue(['unit']) &&
Array.isArray(form.getFieldValue(['unit'])) && weightUnits.includes(filterUnit(form.getFieldValue(['unit']))) && (
weightUnits.includes( <span className="ant-form-text"> 约</span>
form )}
.getFieldValue(['unit'])
.slice(1)
.toString(),
) && <span className="ant-form-text"> 约</span>}
<Form.Item <Form.Item
// noStyle // noStyle
shouldUpdate={(prevValues, curValues) => false} shouldUpdate={(prevValues, curValues) => false}
...@@ -1164,7 +1147,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -1164,7 +1147,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
)} )}
</Form.List> </Form.List>
</Form.Item> </Form.Item>
{/* takeawayData?.takeawayItem?.weight?.length > 0 && */}
{ {
<> <>
<Form.Item> <Form.Item>
...@@ -1176,7 +1158,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -1176,7 +1158,6 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
<Form.Item key={specsField.key} className={styles.conBg}> <Form.Item key={specsField.key} className={styles.conBg}>
<Form.Item <Form.Item
{...specsField} {...specsField}
// validateTrigger={['onChange', 'onBlur']}
name={[specsField.name, 'specGroupName']} name={[specsField.name, 'specGroupName']}
rules={[ rules={[
{ {
...@@ -1189,12 +1170,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => { ...@@ -1189,12 +1170,10 @@ const TakeawayGoodsInfo = forwardRef((props, ref) => {
> >
<Input placeholder="规格名称" className={styles.nameWidth} /> <Input placeholder="规格名称" className={styles.nameWidth} />
</Form.Item> </Form.Item>
{/* {specsFields.length > 1 ? ( */}
<MinusCircleOutlined <MinusCircleOutlined
className="dynamic-delete-button" className="dynamic-delete-button"
onClick={() => remove(specsField.name)} onClick={() => remove(specsField.name)}
/> />
{/* ) : null} */}
<Form.List <Form.List
{...specsField} {...specsField}
name={[specsField.name, 'specs']} name={[specsField.name, 'specs']}
......
...@@ -94,7 +94,6 @@ const ServiceGoods = options => { ...@@ -94,7 +94,6 @@ const ServiceGoods = options => {
const typeObj = { const typeObj = {
type: productType, type: productType,
}; };
console.log('visibleCacheEdit', visibleCacheEdit, e);
if (visibleCacheEdit) { if (visibleCacheEdit) {
setVisibleCacheEdit(false); setVisibleCacheEdit(false);
localStorage.remove(localAutoSaveKey); localStorage.remove(localAutoSaveKey);
...@@ -104,8 +103,11 @@ const ServiceGoods = options => { ...@@ -104,8 +103,11 @@ const ServiceGoods = options => {
} }
if (productType === 5) { if (productType === 5) {
setTakeawayInfoMation(e); setTakeawayInfoMation(e);
if (visibleCacheEdit) {
setVisibleCacheEdit(false);
localStorage.remove(localAutoSaveKey);
}
// onAutoSaveValue(Object.assign({ type: 5 }, e)); // onAutoSaveValue(Object.assign({ type: 5 }, e));
// console.log('takeawayInfoMation', takeawayInfoMation);
} }
}; };
...@@ -468,7 +470,7 @@ const ServiceGoods = options => { ...@@ -468,7 +470,7 @@ const ServiceGoods = options => {
productName: info.infoMation.name, productName: info.infoMation.name,
productType: info.type, productType: info.type,
firstCategoryId: info.infoMation.categoryId[0], firstCategoryId: info.infoMation.categoryId[0],
firstCategoryName: first.name, firstCategoryName: first?.name,
secondCategoryId: info.infoMation.categoryId[1], secondCategoryId: info.infoMation.categoryId[1],
secondCategoryName: second?.name || '', secondCategoryName: second?.name || '',
thirdCategoryId: info.infoMation.categoryId[2], thirdCategoryId: info.infoMation.categoryId[2],
...@@ -518,9 +520,11 @@ const ServiceGoods = options => { ...@@ -518,9 +520,11 @@ const ServiceGoods = options => {
maskClosable={false} maskClosable={false}
keyboard={false} keyboard={false}
footer={[ footer={[
!isEdit && (
<Button key="draft" type="primary" ghost loading={pageLoading} onClick={onSaveDraft}> <Button key="draft" type="primary" ghost loading={pageLoading} onClick={onSaveDraft}>
保存草稿 保存草稿
</Button>, </Button>
),
<Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}> <Button key="submit" type="primary" loading={pageLoading} onClick={submitEvent}>
提交 提交
</Button>, </Button>,
......
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