bugfix: 多页编辑
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
<TopImageSection :images="previewImageMap" @crop="handleClickCrop" />
|
||||
<ProductImageList
|
||||
:image-list="prodImgList"
|
||||
:first-selected-index="firstSelectedIndex"
|
||||
:first-selected-index="currentListing.firstSelectedIndex"
|
||||
@select="handleSelectProdImg"
|
||||
/>
|
||||
<ApparelSketchList
|
||||
@@ -130,6 +130,7 @@
|
||||
desc: "",
|
||||
gender: "FEMALE",
|
||||
category: null,
|
||||
firstSelectedIndex: null,
|
||||
prodImageList: [],
|
||||
sketchList: []
|
||||
})
|
||||
@@ -162,8 +163,6 @@
|
||||
cover: currentListing.value.cover
|
||||
}))
|
||||
|
||||
const firstSelectedIndex = ref<number | null>(null) //显示main标签的图片索引
|
||||
|
||||
const getSortedDetailImages = (images: ListingDetailImage[] = []) => {
|
||||
return [...images].sort((prev, next) => (prev.sortOrder ?? 0) - (next.sortOrder ?? 0))
|
||||
}
|
||||
@@ -234,6 +233,9 @@
|
||||
listing.prodImageList.find((item) => item.selected)?.url || ""
|
||||
}
|
||||
|
||||
const selectedIndex = listing.prodImageList.findIndex((item) => item.selected)
|
||||
listing.firstSelectedIndex = selectedIndex === -1 ? null : selectedIndex
|
||||
|
||||
listing.productImage = listing.prodImageList.map((item) => item.url)
|
||||
listing.apparelSketch = listing.sketchList
|
||||
.map((item) => item.url)
|
||||
@@ -243,20 +245,21 @@
|
||||
}
|
||||
|
||||
const handleSelectProdImg = (index: number) => {
|
||||
const listing = currentListing.value
|
||||
const target = prodImgList.value[index]
|
||||
const willSelect = !target.selected
|
||||
|
||||
target.selected = willSelect
|
||||
|
||||
if (willSelect && firstSelectedIndex.value === null) {
|
||||
currentListing.value.mainProductImage = target.url
|
||||
firstSelectedIndex.value = index
|
||||
if (willSelect && listing.firstSelectedIndex === null) {
|
||||
listing.mainProductImage = target.url
|
||||
listing.firstSelectedIndex = index
|
||||
return
|
||||
}
|
||||
|
||||
if (!willSelect && currentListing.value.mainProductImage === target.url) {
|
||||
firstSelectedIndex.value = null
|
||||
currentListing.value.mainProductImage = ""
|
||||
if (!willSelect && listing.mainProductImage === target.url) {
|
||||
listing.firstSelectedIndex = null
|
||||
listing.mainProductImage = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +363,7 @@
|
||||
price: item.price,
|
||||
status: type === "draft" ? 0 : 1,
|
||||
images: [],
|
||||
designFor: item.gender.toLowerCase,
|
||||
designFor: (item.gender || "FEMALE").toLowerCase(),
|
||||
productCategory: item.category
|
||||
}
|
||||
|
||||
@@ -394,8 +397,6 @@
|
||||
})
|
||||
paramsList.push(params)
|
||||
})
|
||||
console.log(paramsList)
|
||||
debugger
|
||||
await fetchUpdateListing(paramsList)
|
||||
}
|
||||
const handleClickMenu = async (status: StatusType) => {
|
||||
@@ -433,11 +434,9 @@
|
||||
const handleGetDetailById = () => {
|
||||
fetchListingDetailById(itemId.value).then((res: ListingDetailResponse) => {
|
||||
const listing = createListingItemFromDetail(res)
|
||||
const selectedIndex = listing.prodImageList.findIndex((item) => item.selected)
|
||||
|
||||
currentPage.value = 1
|
||||
selectList.value = [listing]
|
||||
firstSelectedIndex.value = selectedIndex === -1 ? null : selectedIndex
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user