|
@@ -5,6 +5,8 @@ import { getProduct } from '../api'
|
|
|
export default function useSelectItem() {
|
|
|
const profile = <any>inject('profile')
|
|
|
|
|
|
+ const visible = ref(false)
|
|
|
+
|
|
|
const productSelect = ref('')
|
|
|
emitter.on('ExchangeProduct-productSelect', (value: any) => {
|
|
|
productSelect.value = value
|
|
@@ -26,13 +28,16 @@ export default function useSelectItem() {
|
|
|
const selectedSkuIndex = ref(-1)
|
|
|
const selectedSku = ref('')
|
|
|
|
|
|
- function selectPaAsin(index) {
|
|
|
+ function handlePaAsinSelection(index) {
|
|
|
selectedIndex.value = index
|
|
|
const selectedItem = allData.value[index]
|
|
|
selectedParentAsin.value = selectedItem.parentAsin
|
|
|
+ }
|
|
|
+
|
|
|
+ // 点击父AsinItem
|
|
|
+ function selectPaAsin(index) {
|
|
|
+ handlePaAsinSelection(index)
|
|
|
fetchAsin()
|
|
|
- selectedAsinIndex.value = -1
|
|
|
- skuData.value = []
|
|
|
}
|
|
|
|
|
|
async function fetchAsin() {
|
|
@@ -49,10 +54,21 @@ export default function useSelectItem() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function selectAsin(index) {
|
|
|
+ // 点击父AsinItem 按钮
|
|
|
+ function clickParentAsinBtn(index) {
|
|
|
+ handlePaAsinSelection(index)
|
|
|
+ emitter.emit('useSelectItem-clickParentAsinBtn', { selectedParentAsin: selectedParentAsin.value })
|
|
|
+ resetPopover()
|
|
|
+ }
|
|
|
+
|
|
|
+ function handleAsinSelection(index) {
|
|
|
selectedAsinIndex.value = index
|
|
|
const selectedItem = asinData.value[index]
|
|
|
selectedAsin.value = selectedItem.Asin
|
|
|
+ }
|
|
|
+
|
|
|
+ function selectAsin(index) {
|
|
|
+ handleAsinSelection(index)
|
|
|
fetchSku()
|
|
|
}
|
|
|
|
|
@@ -71,24 +87,32 @@ export default function useSelectItem() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function clickAsinBtn(index) {
|
|
|
+ handleAsinSelection(index)
|
|
|
+ emitter.emit('useSelectItem-clickAsinBtn', { selectedParentAsin: selectedParentAsin.value, selectedAsin: selectedAsin.value })
|
|
|
+ resetPopover()
|
|
|
+ }
|
|
|
+
|
|
|
function selectSku(index) {
|
|
|
- emitter.emit('useSelectItem-clickSkuItem')
|
|
|
selectedSkuIndex.value = index
|
|
|
const selectedItem = skuData.value[index]
|
|
|
selectedSku.value = selectedItem.sku
|
|
|
+ emitter.emit('useSelectItem-clickSkuItem', { selectedParentAsin: selectedParentAsin.value, selectedAsin: selectedAsin.value, selectedSku: selectedSku.value })
|
|
|
+ resetPopover()
|
|
|
}
|
|
|
|
|
|
- function clickParentAsinBtn() {
|
|
|
- emitter.emit('useSelectItem-clickParentAsinBtn')
|
|
|
- }
|
|
|
-
|
|
|
- function clickAsinBtn() {
|
|
|
- emitter.emit('useSelectItem-clickAsinBtn')
|
|
|
+ function resetPopover() {
|
|
|
+ selectedIndex.value = -1
|
|
|
+ asinData.value = []
|
|
|
+ selectedAsinIndex.value = -1
|
|
|
+ selectedSkuIndex.value = -1
|
|
|
+ skuData.value = []
|
|
|
+ visible.value = false
|
|
|
}
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
emitter.all.clear()
|
|
|
})
|
|
|
|
|
|
- return { asinData, skuData, selectedIndex, selectedAsinIndex, selectedSkuIndex, selectPaAsin, selectAsin, selectSku, clickParentAsinBtn, clickAsinBtn }
|
|
|
+ return { visible, asinData, skuData, selectedIndex, selectedAsinIndex, selectedSkuIndex, selectPaAsin, selectAsin, selectSku, clickParentAsinBtn, clickAsinBtn }
|
|
|
}
|