Commit 7c700b89 authored by GuanHua's avatar GuanHua
parents 30057b6e 887857e4
......@@ -265,17 +265,37 @@ const AddProducts: React.FC<{}> = (props) => {
_params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList
_params.isAllAttributePic = productInfoByEdit.isAllAttributePic
// 没有点击图片单单修改了商品价格 取原有的图片和新的价格合成(编辑属性组合变更,不点击图片,直接报存)
if (clickTabIndex.indexOf("4") !== -1) {
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
return {
id: item.id,
// if (clickTabIndex.indexOf("4") !== -1) {
// _params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
// return {
// id: item.id,
// goods: { id: item.goodsId },
// attributeAndValueList: item.attributeAndValueList,
// unitPrice: item.unitPrice,
// priceRate: item.priceRate,
// commodityPic: productInfoByEdit.unitPriceAndPicList[index].commodityPic
// }
// })
// }
try {
if (clickTabIndex.indexOf("4") !== -1) {
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
const pic = productInfoByEdit.unitPriceAndPicList[index]?.commodityPic
if (!pic) {
throw new Error('请重新上传商品图片!')
}
return {
id: item.id,
goods: { id: item.goodsId },
attributeAndValueList: item.attributeAndValueList,
unitPrice: item.unitPrice,
priceRate: item.priceRate,
commodityPic: productInfoByEdit.unitPriceAndPicList[index].commodityPic
}
})
commodityPic: pic
}
})
}
} catch (e) {
return e
}
}
}
......
......@@ -29,6 +29,8 @@ const ProductImageForm: React.FC<{}> = (props) => {
// 选中的图片
const uploadFileSelectRef = useRef<any>({})
const editRowIndexRef = useRef<number>(0)
// 点击编辑的DOM ID
const editImageIdRef = useRef<any>()
const { ProductStore } = store
const {
......@@ -170,13 +172,11 @@ const ProductImageForm: React.FC<{}> = (props) => {
}
/** 编辑的时候 监听mousemove判断是否有选文件上传 */
const addMonitor = () => {
}
const monitor = (ele) => {
const monitor = () => {
document.removeEventListener('mousemove', monitor);
if (ele.files && ele.files.length > 0) {
console.log('您选择中文件:', ele.files)
console.log(editImageIdRef.current?.files)
if (editImageIdRef.current?.files && editImageIdRef.current.files.length > 0) {
console.log('您选择中文件:', editImageIdRef.current.files)
} else {
uploadFileSelectRef.current = {}
console.log('您没有选择文件')
......@@ -244,7 +244,8 @@ const ProductImageForm: React.FC<{}> = (props) => {
editRowIndexRef.current = index
// 触发图片上传
uploadEle.click()
document.addEventListener('mousemove', () => monitor(uploadEle), false);
editImageIdRef.current = uploadEle
document.addEventListener('mousemove', monitor, false);
}
return (<div>
......
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