Commit 438c5643 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:新建商品无属性无货品下异常

parent 43a1de49
......@@ -31,6 +31,7 @@ const AddProducts: React.FC<{}> = (props) => {
const { ProductStore } = store
const {
productSelectAttribute,
priceAttributeParams,
productAttributeAndImageParams,
areaOption,
productDescription,
......@@ -131,9 +132,9 @@ const AddProducts: React.FC<{}> = (props) => {
if(productAttributeAndImageParams.length>0){
productAttributeAndImageParams.map(_item => {
console.log(_item, '_item')
_item.goods = { id: _item.goodsId } // id为0表示无货品
delete _item.goodsId
if(_item.attributeAndValueList.length>0){
_item.goods = { id: _item.goodsId }
delete _item.goodsId
_item.attributeAndValueList.map(__item => {
delete __item.customerAttributeName
// **** 新字段结构变更
......@@ -154,8 +155,7 @@ const AddProducts: React.FC<{}> = (props) => {
throw new Error('每项请至少上传一张商品图片!')
}
})
}
else{
}else{
throw new Error('每项请至少上传一张商品图片!')
}
}catch(e){
......
......@@ -197,26 +197,29 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
</>
})
}else if(history.location.query?.id){ // 此时没有货品并且处于编辑状态 取接口返回的数据
let goodsInApi: any = Object.values(productInfoByEdit.unitPriceAndPicList.map(_ => _.goods).reduce((item, next)=>{
item[next.id] = next
return item
},{}))
_col.push({
title: '对应货品',
dataIndex: '对应货品',
key: '对应货品',
width: 360,
render: (text: any, record: any) => <>
<Select style={{width:'100%'}} defaultValue={text} onChange={(v)=> {tableSelelctChange(v, record) }}>
{
goodsInApi.length>0 && goodsInApi.map(_item => (
<Option key={_item.id} value={_item.id}>{_item.code}/{_item.name}/{_item.type}/¥{_item.costPrice}</Option>
))
}
</Select>
</>
})
let _goods: any[] = Object.values(productInfoByEdit.unitPriceAndPicList.map(_ => _.goods))
if(_goods.indexOf(null)===-1){
let goodsInApi : any = _goods.reduce((item, next)=>{
item[next.id] = next
return item
},{})
_col.push({
title: '对应货品',
dataIndex: '对应货品',
key: '对应货品',
width: 360,
render: (text: any, record: any) => <>
<Select style={{width:'100%'}} defaultValue={text} onChange={(v)=> {tableSelelctChange(v, record) }}>
{
goodsInApi.length>0 && goodsInApi.map(_item => (
<Option key={_item.id} value={_item.id}>{_item.code}/{_item.name}/{_item.type}/¥{_item.costPrice}</Option>
))
}
</Select>
</>
})
}
}
if(_attributeNameArr.length>0){
......
......@@ -41,6 +41,7 @@ const SelectGoodsForm: React.FC<Iprops> = (props) => {
item[next.id] = next;
return item
},{}))
console.log(goodsArr, 'goods')
if(goodsArr.length>0){
setIsChecked(true)
setIsSelectGoods(true)
......
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