Commit 9ec53c3a authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:品类属性新建、商品单独修改价格异常

parent 81dcc4b2
...@@ -28,15 +28,9 @@ export interface ShopInfo { ...@@ -28,15 +28,9 @@ export interface ShopInfo {
url: string; url: string;
} }
export interface OrderMode {
value: number;
label: string;
platformType: number;
}
export interface Web { export interface Web {
shopInfo: ShopInfo[]; shopInfo: ShopInfo[];
orderMode: OrderMode[]; orderMode: any[];
} }
export interface CountryList { export interface CountryList {
......
...@@ -91,24 +91,20 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -91,24 +91,20 @@ const AddAtttribute: React.FC<{}> = () => {
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
align: 'center',
key: 'id', key: 'id',
}, },
{ {
title: '属性名称', title: '属性名称',
dataIndex: 'name', dataIndex: 'name',
align: 'center',
key: 'name', key: 'name',
}, },
{ {
title: '属性组名', title: '属性组名',
dataIndex: 'groupName', dataIndex: 'groupName',
align: 'center',
key: 'groupName', key: 'groupName',
}, },
{ {
title: '展示方式', title: '展示方式',
align: 'center',
dataIndex: 'type', dataIndex: 'type',
key: 'type', key: 'type',
render: (text:number) => { render: (text:number) => {
...@@ -118,7 +114,6 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -118,7 +114,6 @@ const AddAtttribute: React.FC<{}> = () => {
}, },
{ {
title: '是否必填', title: '是否必填',
align: 'center',
dataIndex: 'isEmpty', dataIndex: 'isEmpty',
key: 'isEmpty', key: 'isEmpty',
render: (text: boolean) => text?'是':'否' render: (text: boolean) => text?'是':'否'
...@@ -343,6 +338,7 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -343,6 +338,7 @@ const AddAtttribute: React.FC<{}> = () => {
onCancel={()=>setRoleVisible(false)} onCancel={()=>setRoleVisible(false)}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
width={704}
> >
<StandardTable <StandardTable
columns={columns} columns={columns}
......
...@@ -57,13 +57,13 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -57,13 +57,13 @@ const CategoryAttributes: React.FC<{}> = () => {
// 获取选中项的关联属性列表 // 获取选中项的关联属性列表
useEffect(() => { useEffect(() => {
if (selectKey) if (selectKey)
ref.current.reload({ current: 1, pageSize: 10, name: '', categoryId: selectKey }) ref.current.reload({ current: 1, pageSize: 10, name: '', categoryId: selectKey, isByCategory: true })
}, [selectKey]) }, [selectKey])
const fetchLinkAttributeData = (params: any) => { const fetchLinkAttributeData = (params: any) => {
console.log(params, 'params') console.log(params, 'params')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerCategoryAttributeList({...params, categoryId: selectKey, name: params.name || ''}).then(res=>{ PublicApi.getProductCustomerGetCustomerCategoryAttributeList({...params, categoryId: selectKey, name: params.name || '', isByCategory: true}).then(res=>{
resolve(res.data) resolve(res.data)
setLinkTableRowData(res.data.data) setLinkTableRowData(res.data.data)
}) })
...@@ -74,7 +74,10 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -74,7 +74,10 @@ const CategoryAttributes: React.FC<{}> = () => {
const fetchAttributeData = (params: any) => { const fetchAttributeData = (params: any) => {
console.log(params, 'params') console.log(params, 'params')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
PublicApi.getProductCustomerGetCustomerAttributeList({ ...params, name: params.name || '' }).then(res=>{ // PublicApi.getProductCustomerGetCustomerAttributeList({ ...params, name: params.name || '' }).then(res=>{
// resolve(res.data)
// })
PublicApi.getProductCustomerGetCustomerCategoryAttributeList({...params, categoryId: selectKey, name: params.name || '', isByCategory: false}).then(res=>{
resolve(res.data) resolve(res.data)
}) })
}) })
...@@ -86,12 +89,10 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -86,12 +89,10 @@ const CategoryAttributes: React.FC<{}> = () => {
const handleSelectOk = () => { const handleSelectOk = () => {
setRoleVisible(false) setRoleVisible(false)
// if (goodsRowCtl.selectRow.length) { PublicApi.postProductCustomerSaveCustomerCategoryAttribute({ customerCategoryId: selectKey, customerAttributeIds: goodsRowCtl.selectedRowKeys }).then(res=>{
PublicApi.postProductCustomerSaveCustomerCategoryAttribute({ customerCategoryId: selectKey, customerAttributeIds: goodsRowCtl.selectedRowKeys }).then(res=>{ if(res.code === 1000)
if(res.code === 1000) setTimeout(() => ref.current.reload(), 500)
setTimeout(() => ref.current.reload(), 500) })
})
// }
} }
const handleSelectCancel = () => { const handleSelectCancel = () => {
setRoleVisible(false) setRoleVisible(false)
...@@ -102,26 +103,22 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -102,26 +103,22 @@ const CategoryAttributes: React.FC<{}> = () => {
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
align: 'center',
key: 'id', key: 'id',
}, },
{ {
title: '属性名称', title: '属性名称',
dataIndex: 'name', dataIndex: 'name',
align: 'center',
key: 'name', key: 'name',
render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span> render: (text: any, record: any) => <span className="commonPickColor" onClick={() => handleSee(record)}>{text}&nbsp;<EyeOutlined /></span>
}, },
{ {
title: '属性组名称', title: '属性组名称',
dataIndex: 'groupName', dataIndex: 'groupName',
align: 'center',
key: 'groupName', key: 'groupName',
}, },
{ {
title: '展示方式', title: '展示方式',
dataIndex: 'type', dataIndex: 'type',
align: 'center',
key: 'type', key: 'type',
render: (text: any, record: any) => { render: (text: any, record: any) => {
let _txt: string = '' let _txt: string = ''
...@@ -138,13 +135,11 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -138,13 +135,11 @@ const CategoryAttributes: React.FC<{}> = () => {
{ {
title: '是否必填', title: '是否必填',
dataIndex: 'isEmpty', dataIndex: 'isEmpty',
align: 'center',
key: 'isEmpty', key: 'isEmpty',
render: (text: any, record: any) => (<>{text ? '是' : '否'}</>) render: (text: any, record: any) => (<>{text ? '是' : '否'}</>)
}, },
{ {
title: '状态', title: '状态',
align: 'center',
dataIndex: 'isEnable', dataIndex: 'isEnable',
key: 'isEnable', key: 'isEnable',
render: (text: any, record: any) => text ? '有效' : '无效' render: (text: any, record: any) => text ? '有效' : '无效'
...@@ -152,7 +147,6 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -152,7 +147,6 @@ const CategoryAttributes: React.FC<{}> = () => {
{ {
title: '操作', title: '操作',
dataIndex: 'option', dataIndex: 'option',
align: 'center',
render: (text: any, record: any) => { render: (text: any, record: any) => {
return ( return (
<> <>
...@@ -167,25 +161,21 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -167,25 +161,21 @@ const CategoryAttributes: React.FC<{}> = () => {
{ {
title: 'ID', title: 'ID',
dataIndex: 'id', dataIndex: 'id',
align: 'center',
key: 'id', key: 'id',
}, },
{ {
title: '属性名称', title: '属性名称',
dataIndex: 'name', dataIndex: 'name',
align: 'center',
key: 'name', key: 'name',
}, },
{ {
title: '属性组名称', title: '属性组名称',
dataIndex: 'groupName', dataIndex: 'groupName',
align: 'center',
key: 'groupName', key: 'groupName',
}, },
{ {
title: '展示方式', title: '展示方式',
dataIndex: 'type', dataIndex: 'type',
align: 'center',
key: 'type', key: 'type',
render: (text: any, record: any) => { render: (text: any, record: any) => {
let _txt: string = '' let _txt: string = ''
...@@ -202,7 +192,6 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -202,7 +192,6 @@ const CategoryAttributes: React.FC<{}> = () => {
{ {
title: '是否必填', title: '是否必填',
dataIndex: 'isEmpty', dataIndex: 'isEmpty',
align: 'center',
key: 'isEmpty', key: 'isEmpty',
render: (text: any, record: any) => (<>{text ? '是' : '否'}</>) render: (text: any, record: any) => (<>{text ? '是' : '否'}</>)
} }
...@@ -325,6 +314,7 @@ const CategoryAttributes: React.FC<{}> = () => { ...@@ -325,6 +314,7 @@ const CategoryAttributes: React.FC<{}> = () => {
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
destroyOnClose={true} destroyOnClose={true}
width={704}
> >
<StandardTable <StandardTable
columns={columnsLink} columns={columnsLink}
......
...@@ -27,6 +27,7 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -27,6 +27,7 @@ const AddProducts: React.FC<{}> = (props) => {
const [responseId, setReponseId] = useState<number>(null) const [responseId, setReponseId] = useState<number>(null)
const [attributeList, setAttributeList] = useState<any[]>([]) const [attributeList, setAttributeList] = useState<any[]>([])
const [clickTabIndex, setClickTabIndex] = useState<string[]>(['1']) const [clickTabIndex, setClickTabIndex] = useState<string[]>(['1'])
const [isDisableSaveBtn, setIsDisableSaveBtn] = useState<boolean>(false)
let [formRefs, setFormRefs] = useState([]) //子form的ref数组 let [formRefs, setFormRefs] = useState([]) //子form的ref数组
const { ProductStore } = store const { ProductStore } = store
const { const {
...@@ -64,6 +65,7 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -64,6 +65,7 @@ const AddProducts: React.FC<{}> = (props) => {
}, []) }, [])
const onSave = () => { const onSave = () => {
setIsDisableSaveBtn(true)
const { id } = history.location.query const { id } = history.location.query
if(formRefs.length > 0){ if(formRefs.length > 0){
try{ try{
...@@ -128,29 +130,36 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -128,29 +130,36 @@ const AddProducts: React.FC<{}> = (props) => {
/** 没有点击tab项做修改处理时 */ /** 没有点击tab项做修改处理时 */
// 如果没有点击商品图片第"5"项 不做校验 // 如果没有点击商品图片第"5"项 不做校验
if(clickTabIndex.indexOf("5") !== -1){ if(clickTabIndex.indexOf("5") !== -1){
let _productAttributeAndImageParams = [...productAttributeAndImageParams]
try{ try{
if(productAttributeAndImageParams.length>0){ if(_productAttributeAndImageParams.length>0){
productAttributeAndImageParams.map(_item => { _productAttributeAndImageParams.map(_item => {
console.log(_item, '_item') console.log(_item, '_item')
_item.goods = { id: _item.goodsId } // id为0表示无货品 _item.goods = { id: _item.goodsId } // id为0表示无货品
delete _item.goodsId delete _item.goodsId
if(_item.attributeAndValueList.length>0){ // if(_item.attributeAndValueList.length>0){
_item.attributeAndValueList.map(__item => { // _item.attributeAndValueList.map(__item => {
delete __item.customerAttributeName // delete __item.customerAttributeName
// **** 新字段结构变更 // // **** 新字段结构变更
__item.customerAttribute = { id: __item.customerAttributeId } // __item.customerAttribute = { id: __item.customerAttributeId }
__item.customerAttributeValue = { id: __item.id, value: __item.value } // __item.customerAttributeValue = { id: __item.id, value: __item.value }
delete __item.id // delete __item.id
delete __item.value // delete __item.value
delete __item.customerAttributeId // delete __item.customerAttributeId
}) // })
} // }
if(_item.commodityPic.length>0){ if(_item.commodityPic.length>0){
// 编辑情况下兼顾手动添加图片列表属性 // 编辑情况下兼顾手动添加图片列表属性
console.log('不一定')
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url) _item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url)
// 多种属性组合 所有属性共用的情况下 每一行都是用第一项
if(isAllAttributePic)
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}else{ }else{
if(isAllAttributePic && productAttributeAndImageParams[0].commodityPic.length>0) //处理所有属性共用 if(isAllAttributePic && _productAttributeAndImageParams[0].commodityPic.length>0){ //处理所有属性共用
_item.commodityPic = productAttributeAndImageParams[0].commodityPic console.log('所有属性共用')
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}
else else
throw new Error('每项请至少上传一张商品图片!') throw new Error('每项请至少上传一张商品图片!')
} }
...@@ -161,9 +170,26 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -161,9 +170,26 @@ const AddProducts: React.FC<{}> = (props) => {
}catch(e){ }catch(e){
return e return e
} }
_params.unitPriceAndPicList = productAttributeAndImageParams _params.unitPriceAndPicList = _productAttributeAndImageParams
}else{ // 编辑 没有点击商品图片 }else{ // 编辑 没有点击商品图片
_params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList _params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList
if(clickTabIndex.indexOf("4") !== -1){ // 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成
console.log('仅修改商品价格')
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
return {
goods: { id: item.goodsId },
attributeAndValueList: item.attributeAndValueList,
// .map(_item => {
// return {
// customerAttribute: { id: _item.customerAttributeId },
// customerAttributeValue: { id: _item.id, value: _item.value }
// }
// }),
unitPrice: item.unitPrice,
commodityPic: productInfoByEdit.unitPriceAndPicList[index].commodityPic
}
})
}
} }
if(clickTabIndex.indexOf("3")===-1) // 商品属性 if(clickTabIndex.indexOf("3")===-1) // 商品属性
_params.commodityAttributeList = productInfoByEdit.commodityAttributeList _params.commodityAttributeList = productInfoByEdit.commodityAttributeList
...@@ -194,10 +220,16 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -194,10 +220,16 @@ const AddProducts: React.FC<{}> = (props) => {
}catch(e){ }catch(e){
return e return e
} }
// 移除混入的id数字类的键值项
let numberKeys = Object.keys(_params).map(_ => Number(_)).filter(Boolean)
if(numberKeys.length>0)
numberKeys.map(item => delete _params[item])
console.log(_params, 'params') console.log(_params, 'params')
PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => { PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => {
if(res.code === 1000){ if(res.code === 1000){
setIsEnableCheck(false) setIsEnableCheck(false)
setIsDisableSaveBtn(false)
setReponseId(res.data) setReponseId(res.data)
history.goBack() history.goBack()
} }
...@@ -234,7 +266,7 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -234,7 +266,7 @@ const AddProducts: React.FC<{}> = (props) => {
title={history.location.query.id?'编辑商品':'新建商品'} title={history.location.query.id?'编辑商品':'新建商品'}
extra={[ extra={[
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>直接提交审核</Button>, <Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>直接提交审核</Button>,
<Button key="1" type="primary" icon={<SaveOutlined />} onClick={onSave}> <Button key="1" type="primary" icon={<SaveOutlined />} onClick={onSave} disabled={isDisableSaveBtn}>
保存 保存
</Button>, </Button>,
]} ]}
......
...@@ -199,11 +199,11 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -199,11 +199,11 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}else if(history.location.query?.id){ // 此时没有货品并且处于编辑状态 取接口返回的数据 }else if(history.location.query?.id){ // 此时没有货品并且处于编辑状态 取接口返回的数据
let _goods: any[] = Object.values(productInfoByEdit.unitPriceAndPicList.map(_ => _.goods)) let _goods: any[] = Object.values(productInfoByEdit.unitPriceAndPicList.map(_ => _.goods))
if(_goods.indexOf(null)===-1){ if(_goods.indexOf(null)===-1){
let goodsInApi : any = Object.values(_goods).reduce((item, next)=>{ let goodsInApi : any = Object.values(_goods.reduce((item, next)=>{
item[next.id] = next item[next.id] = next
return item return item
},{}) },{}))
_col.push({ _col.push({
title: '对应货品', title: '对应货品',
dataIndex: '对应货品', dataIndex: '对应货品',
...@@ -312,17 +312,34 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -312,17 +312,34 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let _tempArr: any = [] let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index) => { Array.isArray(item) ? item.map((_item, _index) => {
let _tempObject: any = {}; let _tempObject: any = {};
_tempObject.customerAttributeId = attributeObjArr[_index].customerAttributeId // _tempObject.customerAttributeId = attributeObjArr[_index].customerAttributeId
_tempObject.customerAttributeName = attributeObjArr[_index].attributeName // _tempObject.customerAttributeName = attributeObjArr[_index].attributeName
// _tempObject.id = attributeValObjArr[_index].find(__item=>__item.value===item[_index]).id /** 解决原有 若属性或者属性值顺序错乱无法找到正确值的问题 */ // _tempObject.id = attributeValObjArr.map(item =>item.find(_ => _.value===_item)).filter(__ => __)[0].id
_tempObject.id = attributeValObjArr.map(item =>item.find(_ => _.value===_item)).filter(__ => __)[0].id // _tempObject.value = item[_index]
_tempObject.value = item[_index] /* 新格式 */
_tempObject.customerAttribute = {
id: attributeObjArr[_index].customerAttributeId,
name: attributeObjArr[_index].attributeName
}
_tempObject.customerAttributeValue = {
id: attributeValObjArr.map(item =>item.find(_ => _.value===_item)).filter(__ => __)[0].id,
value: item[_index]
}
_tempArr.push(_tempObject) _tempArr.push(_tempObject)
}) : _tempArr.push({ }) : _tempArr.push({
customerAttributeId: attributeObjArr[0].customerAttributeId, // customerAttributeId: attributeObjArr[0].customerAttributeId,
customerAttributeName: attributeObjArr[0].attributeName, // customerAttributeName: attributeObjArr[0].attributeName,
id: attributeValObjArr[0][0].id, // id: attributeValObjArr[0][0].id,
value: item.toString() // value: item.toString()
/* 新格式 */
customerAttribute: {
id: attributeObjArr[0].customerAttributeId,
name: attributeObjArr[0].attributeName
},
customerAttributeValue: {
id: attributeValObjArr[0][0].id,
value: item.toString()
}
}) })
_paramsArray.push({goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0, attributeAndValueList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/ _paramsArray.push({goodsId: _tableDataSource[index] ? _tableDataSource[index]['对应货品'] : 0, attributeAndValueList: _tempArr, unitPrice: _tableDataSource[index]&&_tableDataSource[index]['单价']}) /*带上货品id 带上单价*/
}) : _paramsArray.push({goodsId: _tableDataSource[0] ? _tableDataSource[0]['对应货品'] : 0, attributeAndValueList: [], unitPrice: _tableDataSource[0]&&_tableDataSource[0]['单价']}) /*带上货品id 带上单价*/ }) : _paramsArray.push({goodsId: _tableDataSource[0] ? _tableDataSource[0]['对应货品'] : 0, attributeAndValueList: [], unitPrice: _tableDataSource[0]&&_tableDataSource[0]['单价']}) /*带上货品id 带上单价*/
......
...@@ -26,20 +26,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -26,20 +26,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const [defaultChecked, setDefaultChecked] = useState(-1) const [defaultChecked, setDefaultChecked] = useState(-1)
const [priceAttributeParamsByRender, setPriceAttributeParamsByRender] = useState<any[]>([]) const [priceAttributeParamsByRender, setPriceAttributeParamsByRender] = useState<any[]>([])
const [commonImageList, setCommonImageList] = useState<any>([ const [commonImageList, setCommonImageList] = useState<any>([])
// {
// uid: '-1',
// name: 'image.png',
// status: 'done',
// url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
// },
// {
// uid: '-2',
// name: 'image.png',
// status: 'done',
// url: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
// },
])
const [previewVisible, setPreviewVisible] = useState(false) const [previewVisible, setPreviewVisible] = useState(false)
const [previewImage, setPreviewImage] = useState('') const [previewImage, setPreviewImage] = useState('')
const [previewTitle, setPreviewTitle] = useState('') const [previewTitle, setPreviewTitle] = useState('')
...@@ -48,8 +35,19 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -48,8 +35,19 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const { ProductStore } = store const { ProductStore } = store
const { priceAttributeParams, productInfoByEdit, setProductAttributeAndImageParams, setIsAllAttributePic } = ProductStore const { priceAttributeParams, productInfoByEdit, setProductAttributeAndImageParams, setIsAllAttributePic } = ProductStore
/* 给数据添加图片字段 */
useEffect(()=>{ useEffect(()=>{
if(priceAttributeParams.length > 0){
console.log(priceAttributeParams, '对比')
constructImageListByRender(priceAttributeParams)
}else if(history.location.query?.id){
console.log(productInfoByEdit.unitPriceAndPicList, '对比')
constructImageListByRender(productInfoByEdit.unitPriceAndPicList)
}
},[priceAttributeParams])
/* 给数据添加图片字段 */
/* 直接进入商品图片编辑的时候 参数为空数组 但是没有价格属性的时候 也可能为空数组 区别在于是否有url id */
const constructImageListByRender = (priceAttributeParams?: any) => {
let _priceAttributeParams: any = [] let _priceAttributeParams: any = []
if(productInfoByEdit?.id){ // id判断是否新增还是编辑 if(productInfoByEdit?.id){ // id判断是否新增还是编辑
setSetImageType(productInfoByEdit.isAllAttributePic) setSetImageType(productInfoByEdit.isAllAttributePic)
...@@ -75,14 +73,8 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -75,14 +73,8 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
return _obj return _obj
}) })
} }
// console.log('???', _priceAttributeParams) setDefaultChecked(0)
// if(_priceAttributeParams?.length>0 && _priceAttributeParams[0]?.goodsCustomerAttributeList?.length!=0){ clickItemTab(0)
setDefaultChecked(0)
clickItemTab(0)
// }else{
// setDefaultChecked(-1)
// clickItemTab(-1)
// }
setPriceAttributeParamsByRender(_priceAttributeParams) setPriceAttributeParamsByRender(_priceAttributeParams)
setProductAttributeAndImageParams(_priceAttributeParams) setProductAttributeAndImageParams(_priceAttributeParams)
console.log(_priceAttributeParams, priceAttributeParams, '_p') // 这里可能为空数组 ** 如果不到此页面 前一个是旧数据 后面的为新数据 console.log(_priceAttributeParams, priceAttributeParams, '_p') // 这里可能为空数组 ** 如果不到此页面 前一个是旧数据 后面的为新数据
...@@ -90,13 +82,11 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -90,13 +82,11 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
if(setImageType && _priceAttributeParams.length>0){ if(setImageType && _priceAttributeParams.length>0){
setCommonImageList(_priceAttributeParams[0].commodityPic) setCommonImageList(_priceAttributeParams[0].commodityPic)
} }
}
},[priceAttributeParams])
const clickItemTab = (_index: number) => { const clickItemTab = (_index: number) => {
console.log(_index, '点击项') console.log(_index, '点击项')
setDefaultChecked(_index) setDefaultChecked(_index)
// console.log(priceAttributeParams, 'params')
} }
const uploadButton = ( const uploadButton = (
...@@ -161,23 +151,12 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -161,23 +151,12 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const handleChange = ({ file, fileList }, index) => { const handleChange = ({ file, fileList }, index) => {
let _priceAttributeParams = [...priceAttributeParamsByRender] let _priceAttributeParams = [...priceAttributeParamsByRender]
console.log(_priceAttributeParams, index, '图片更改初始数据') console.log(_priceAttributeParams, index, '图片更改初始数据')
// if(index===-1){ // -1表示所有属性共用 也表示表格只有默认的一行 // 无需判断 不管是共用还是不共用都需要逐条写入fileList setCommonImageList(fileList)
setCommonImageList(fileList) _priceAttributeParams[index].commodityPic = fileList
// _priceAttributeParams[0].commodityPic = fileList
// }else{
_priceAttributeParams[index].commodityPic = fileList
// }
if(!file?.status && file?.status !== 'done'){ if(!file?.status && file?.status !== 'done'){
// 不符合要求的 移除没有'done'状态的图片 let ttt = _priceAttributeParams[index].commodityPic.filter(_ => _.status === 'done')
// if(index === -1){ _priceAttributeParams[index].commodityPic = ttt
// let ttt = _priceAttributeParams[0].commodityPic.filter(_ => _.status === 'done') setCommonImageList(ttt)
// setCommonImageList(ttt)
// _priceAttributeParams[0].commodityPic = ttt
// }else{
let ttt = _priceAttributeParams[index].commodityPic.filter(_ => _.status === 'done')
_priceAttributeParams[index].commodityPic = ttt
setCommonImageList(ttt)
// }
} }
console.log(_priceAttributeParams, '图片更改之后数据') console.log(_priceAttributeParams, '图片更改之后数据')
setPriceAttributeParamsByRender(_priceAttributeParams) setPriceAttributeParamsByRender(_priceAttributeParams)
...@@ -187,10 +166,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -187,10 +166,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const onChangeSetImageType = (e) => { const onChangeSetImageType = (e) => {
setSetImageType(e.target.value) setSetImageType(e.target.value)
setIsAllAttributePic(e.target.value) setIsAllAttributePic(e.target.value)
// if(e.target.value) clickItemTab(0)
// clickItemTab(-1)
// else
clickItemTab(0)
// 切换 清空图片数组 // 切换 清空图片数组
let _priceAttributeParams = [...priceAttributeParamsByRender] let _priceAttributeParams = [...priceAttributeParamsByRender]
_priceAttributeParams.map(item => { _priceAttributeParams.map(item => {
...@@ -225,7 +201,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => { ...@@ -225,7 +201,7 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
<li key={index} className={defaultChecked == index ? styles.activedLi : ""} onClick={()=>clickItemTab(index)}> <li key={index} className={defaultChecked == index ? styles.activedLi : ""} onClick={()=>clickItemTab(index)}>
<span> <span>
{ {
item.attributeAndValueList.map((_item, _index)=>_item.value).join('/') item.attributeAndValueList.map((_item, _index)=>_item.customerAttributeValue.value).join('/')
} }
</span> </span>
</li> </li>
......
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