Commit f72e657f authored by 武广's avatar 武广

fix: 修改属性组件升级

parent 8634de87
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { Select, Space, Divider, Input, Button } from 'antd'; import { Select, Space, Divider, Input, Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import styles from './index.less';
const CustomSelect = props => { const CustomSelect = props => {
const [name, setName] = useState(''); const [name, setName] = useState('');
...@@ -45,15 +46,17 @@ const CustomSelect = props => { ...@@ -45,15 +46,17 @@ const CustomSelect = props => {
{menu} {menu}
{props.isCustom && ( {props.isCustom && (
<> <>
<Divider style={{ margin: '8px 0' }} /> <Divider className={styles.SelectDivider} />
<Space style={{ padding: '0 8px 4px' }}> <Space className={styles.SelectSpace}>
<Input <Input
className={styles.SelectInput}
placeholder="请输入自定义属性" placeholder="请输入自定义属性"
ref={inputRef} ref={inputRef}
value={name} value={name}
maxLength={30}
onChange={onNameChange} onChange={onNameChange}
/> />
<Button type="text" icon={<PlusOutlined />} onClick={addItem} /> <Button type="primary" icon={<PlusOutlined />} onClick={addItem} />
</Space> </Space>
</> </>
)} )}
......
.SelectDivider {
margin: 8px 0;
}
.SelectSpace {
width: 100%;
padding: 0 8px 4px;
:global {
.ant-space-item:first-child {
width: 100%;
}
}
}
.SelectInput {
width: 100%;
}
...@@ -98,6 +98,7 @@ const Complex = props => { ...@@ -98,6 +98,7 @@ const Complex = props => {
setLoading(true); setLoading(true);
const res = await apiGetBussinessMsgList(data, params); const res = await apiGetBussinessMsgList(data, params);
setLoading(false); setLoading(false);
if (!res) return;
if (res.code !== '0000') { if (res.code !== '0000') {
notification.error(res.msg); notification.error(res.msg);
return; return;
......
...@@ -149,6 +149,7 @@ const Simple = props => { ...@@ -149,6 +149,7 @@ const Simple = props => {
setLoading(true); setLoading(true);
const res = await apiGetBussinessMsgList(data, params); const res = await apiGetBussinessMsgList(data, params);
setLoading(false); setLoading(false);
if (!res) return;
if (res.code !== '0000') { if (res.code !== '0000') {
notification.error(res.msg); notification.error(res.msg);
return; return;
......
...@@ -56,7 +56,7 @@ class goodsManage extends Component { ...@@ -56,7 +56,7 @@ class goodsManage extends Component {
stockSkuIds: [], stockSkuIds: [],
isType: '', isType: '',
serviceVisble: true, serviceVisble: false,
serviceData: {}, serviceData: {},
visibleAuditModal: false, visibleAuditModal: false,
auditRow: {}, // 查看审核信息使用 auditRow: {}, // 查看审核信息使用
...@@ -529,7 +529,7 @@ class goodsManage extends Component { ...@@ -529,7 +529,7 @@ class goodsManage extends Component {
isType={this.state.isType} isType={this.state.isType}
templateList={this.state.templateList} templateList={this.state.templateList}
/> />
{/* '894048258062' */} {this.state.serviceVisble && (
<ServiceGoods <ServiceGoods
visible={this.state.serviceVisble} visible={this.state.serviceVisble}
onChange={this.serviceVisbleClose} onChange={this.serviceVisbleClose}
...@@ -540,6 +540,7 @@ class goodsManage extends Component { ...@@ -540,6 +540,7 @@ class goodsManage extends Component {
specListData={this.state.specListData} specListData={this.state.specListData}
permissions={permissions} permissions={permissions}
/> />
)}
</Spin> </Spin>
<InfoAudit <InfoAudit
visible={this.state.visibleAuditModal} visible={this.state.visibleAuditModal}
......
...@@ -77,19 +77,16 @@ const FormAttr = forwardRef((props, ref) => { ...@@ -77,19 +77,16 @@ const FormAttr = forwardRef((props, ref) => {
return attrs; return attrs;
}; };
const getMode = optionType => { // 获取下拉框类型
if (+optionType.code === 2) { const getMode = optionType => (+optionType.code === 2 ? 'multiple' : 'default');
return 'multiple';
}
return 'default';
};
// 获取下拉框校验
const getAttrRules = k => { const getAttrRules = k => {
if (+k.required.code === 1) { if (+k.required.code === 1) {
return [ return [
{ {
required: true, required: true,
type: +k.supportCustomValue.code === 1 || +k.optionType.code === 2 ? 'array' : 'string', type: +k.optionType.code === 2 ? 'array' : 'string',
message: '请选择', message: '请选择',
}, },
]; ];
...@@ -97,13 +94,15 @@ const FormAttr = forwardRef((props, ref) => { ...@@ -97,13 +94,15 @@ const FormAttr = forwardRef((props, ref) => {
return []; return [];
}; };
// 处理下拉框返回值
const deal = attr => { const deal = attr => {
try { try {
const json = JSON.parse(attr); const json = JSON.parse(attr);
if (typeof json === 'object' && checkInAttrList(json.attributeValueId)) { if (typeof json === 'object') {
json.attributeValueName = json.name;
return json; return json;
} }
return { attributeValueName: json }; return { attributeValueName: json.name };
} catch { } catch {
return { attributeValueName: attr }; return { attributeValueName: attr };
} }
...@@ -164,7 +163,7 @@ const FormAttr = forwardRef((props, ref) => { ...@@ -164,7 +163,7 @@ const FormAttr = forwardRef((props, ref) => {
return ( return (
<> <>
<div className={styles.attrbox + (isMore ? styles.attrboxMore : '')} more={isMore}> <div className={styles.attrbox + (isMore ? styles.attrboxMore : '')}>
<Form form={form} initialValues={getInitAttrValue()}> <Form form={form} initialValues={getInitAttrValue()}>
<Row> <Row>
{categoryAttrs.length > 0 && {categoryAttrs.length > 0 &&
......
...@@ -227,18 +227,23 @@ const FormPriceOrStock = forwardRef((props, ref) => { ...@@ -227,18 +227,23 @@ const FormPriceOrStock = forwardRef((props, ref) => {
const onCheck = async () => { const onCheck = async () => {
try { try {
const setMealContent = await packageRef.current.onCheck(); let setMealContent = '';
if (customer.isCard) {
setMealContent = await packageRef.current.onCheck();
}
const values = await form.validateFields(); const values = await form.validateFields();
const items = await editRef.current.onCheck(); const items = await editRef.current.onCheck();
if (!setMealContent) { if (customer.isCard && !setMealContent) {
notification.open({ notification.open({
message: '提示', message: '提示',
description: '请添加正确的套餐信息!', description: '请添加正确的套餐信息!',
}); });
return null; return null;
} }
if (items && setMealContent) { if (items) {
return { ...values, items, setMealContent, temp: 'infoSpecData' }; const obj = { ...values, items, temp: 'infoSpecData' };
customer.isCard && setMealContent && (obj.setMealContent = setMealContent);
return obj;
} }
notification.open({ notification.open({
message: '提示', message: '提示',
......
...@@ -44,7 +44,7 @@ const ServiceGoods = options => { ...@@ -44,7 +44,7 @@ const ServiceGoods = options => {
const [pageId, setPageId] = useState(null); const [pageId, setPageId] = useState(null);
const [categoryIds, setCategoryIds] = useState([]); // 商品品类ID const [categoryIds, setCategoryIds] = useState([]); // 商品品类ID
const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态 const [isEdit, setIsEdit] = useState(false); // 是否是编辑状态
const [productType, setProductType] = useState(1); // 商品状态 canAddNormal ? 1 : 4 const [productType, setProductType] = useState(canAddNormal ? 1 : 4); // 商品状态
const [pageLoading, setPageLoading] = useState(false); // 页面加载状态 const [pageLoading, setPageLoading] = useState(false); // 页面加载状态
const [afterAddressList, setAfterAddressList] = useState([]); // 售后地址 const [afterAddressList, setAfterAddressList] = useState([]); // 售后地址
const [supplierIdList, setSupplierIdList] = useState([]); // 适用们店列表 const [supplierIdList, setSupplierIdList] = useState([]); // 适用们店列表
...@@ -162,6 +162,7 @@ const ServiceGoods = options => { ...@@ -162,6 +162,7 @@ const ServiceGoods = options => {
if (isEdit) { if (isEdit) {
sendData.id = pageId; sendData.id = pageId;
} }
// console.log('sendData :>> ', sendData);
sendMerchantProductHttpRequest(sendData); sendMerchantProductHttpRequest(sendData);
} }
}; };
...@@ -215,6 +216,11 @@ const ServiceGoods = options => { ...@@ -215,6 +216,11 @@ const ServiceGoods = options => {
} }
}, [productType, options.visible]); }, [productType, options.visible]);
useEffect(() => {
console.log('1---canAddNormal :>> ', canAddNormal);
setProductType(canAddNormal ? 1 : 4);
}, [canAddNormal]);
const onSpecCommonImgEvent = useCallback( const onSpecCommonImgEvent = useCallback(
keys => { keys => {
setSpecKeyList(keys); setSpecKeyList(keys);
...@@ -295,8 +301,8 @@ const ServiceGoods = options => { ...@@ -295,8 +301,8 @@ const ServiceGoods = options => {
/> />
{[1, 2].includes(productType) && [ {[1, 2].includes(productType) && [
<Title title="商品属性" />, <Title title="商品属性" key="attrtitle" />,
<FormAttr ref={attrRef} categoryIds={categoryIds} initData={editData} />, <FormAttr key="attr" ref={attrRef} categoryIds={categoryIds} initData={editData} />,
]} ]}
<Title title="价格与库存" /> <Title title="价格与库存" />
......
...@@ -107,10 +107,10 @@ const filterItems = (type, props) => { ...@@ -107,10 +107,10 @@ const filterItems = (type, props) => {
export const filterSendData = (type, params) => { export const filterSendData = (type, params) => {
console.log('===============>生成数据', params); console.log('===============>生成数据', params);
const { infoMation, infoImageData } = params; const { infoMation, infoImageData, attributeApplyList } = params;
const items = filterItems(type, params); const items = filterItems(type, params);
const commonImageList = type === 4 ? [] : infoImageData.commonImageList; const commonImageList = type === 4 ? [] : infoImageData.commonImageList;
return { const obj = {
type, type,
items, items,
name: infoMation.name, name: infoMation.name,
...@@ -123,6 +123,10 @@ export const filterSendData = (type, params) => { ...@@ -123,6 +123,10 @@ export const filterSendData = (type, params) => {
detailImageList: infoImageData.detailImageList, detailImageList: infoImageData.detailImageList,
commonImageList, commonImageList,
}; };
if (attributeApplyList && attributeApplyList.attributeApplyList) {
obj.attributeApplyList = attributeApplyList.attributeApplyList;
}
return obj;
}; };
export const fliterSkuListSortData = list => { export const fliterSkuListSortData = list => {
......
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