|
@@ -1,3 +1,96 @@
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import { Search } from '@element-plus/icons-vue'
|
|
|
|
+import { inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
|
+import { getProductLineSelect, getProduct } from '../../api'
|
|
|
|
+import emitter from '/@/utils/emitter'
|
|
|
|
+import useSelectItem from '../../hooks/useSelectItem'
|
|
|
|
+import useInfiniteScroll from '../../hooks/useInfiniteScroll'
|
|
|
|
+
|
|
|
|
+const profile = <any>inject('profile')
|
|
|
|
+const { allData, parentloading, currentPage, load, fetchProduct } = useInfiniteScroll()
|
|
|
|
+const {
|
|
|
|
+ visible,
|
|
|
|
+ skuData,
|
|
|
|
+ asinData,
|
|
|
|
+ selectedIndex,
|
|
|
|
+ selectedAsinIndex,
|
|
|
|
+ selectedSkuIndex,
|
|
|
|
+ selectPaAsin,
|
|
|
|
+ selectAsin,
|
|
|
|
+ selectSku,
|
|
|
|
+ clickParentAsinBtn,
|
|
|
|
+ clickAsinBtn,
|
|
|
|
+} = useSelectItem()
|
|
|
|
+
|
|
|
|
+const searchInp = ref('')
|
|
|
|
+const filterSelect = ref('vague')
|
|
|
|
+
|
|
|
|
+const productSelect = ref('ALL')
|
|
|
|
+const options = ref([])
|
|
|
|
+
|
|
|
|
+async function fetchProductLine() {
|
|
|
|
+ try {
|
|
|
|
+ const resp = await getProductLineSelect({ profileId: profile.value.profile_id })
|
|
|
|
+ options.value = resp.data
|
|
|
|
+ productSelect.value = options.value[0].productlineId
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log('error:', error)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function handleChange() {
|
|
|
|
+ parentloading.value = true
|
|
|
|
+ const query = {
|
|
|
|
+ profileId: profile.value.profile_id,
|
|
|
|
+ productlineId: productSelect.value,
|
|
|
|
+ searchItem: searchInp.value,
|
|
|
|
+ }
|
|
|
|
+ if (searchInp.value) {
|
|
|
|
+ const res = await getProduct(query)
|
|
|
|
+ allData.value = res.data
|
|
|
|
+ emitter.emit('ExchangeProduct-allData', allData) // 让useSelectItem()中的allData得到正确更新, 否则无法正确选择parentAsin
|
|
|
|
+ }
|
|
|
|
+ parentloading.value = false
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function searchClick() {
|
|
|
|
+ console.log(123)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function resetProductList() {
|
|
|
|
+ currentPage.value = 1
|
|
|
|
+ fetchProduct()
|
|
|
|
+ asinData.value = []
|
|
|
|
+ skuData.value = []
|
|
|
|
+ selectedIndex.value = -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+watch(searchInp, () => {
|
|
|
|
+ emitter.emit('ExchangeProduct-searchInp', searchInp)
|
|
|
|
+ if (searchInp.value === '') {
|
|
|
|
+ resetProductList()
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+// 若产品选择改变则 重置分页并清空其他的数据
|
|
|
|
+watch(
|
|
|
|
+ productSelect,
|
|
|
|
+ (value) => {
|
|
|
|
+ emitter.emit('ExchangeProduct-productSelect', value)
|
|
|
|
+ resetProductList()
|
|
|
|
+ },
|
|
|
|
+ { immediate: true }
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ fetchProductLine()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
|
+ emitter.all.clear()
|
|
|
|
+})
|
|
|
|
+</script>
|
|
|
|
+
|
|
<template>
|
|
<template>
|
|
<el-popover placement="bottom-start" :width="1000" :visible="visible">
|
|
<el-popover placement="bottom-start" :width="1000" :visible="visible">
|
|
<template #reference>
|
|
<template #reference>
|
|
@@ -11,9 +104,9 @@
|
|
<el-icon @click="visible = false" style="cursor: pointer"><CloseBold /></el-icon>
|
|
<el-icon @click="visible = false" style="cursor: pointer"><CloseBold /></el-icon>
|
|
</div>
|
|
</div>
|
|
<div class="filter-bar">
|
|
<div class="filter-bar">
|
|
- <el-input v-model="searchInp" style="max-width: 600px" @change="handleChange" placeholder="请输入标题/父ASIN/ASIN/SKU查询商品">
|
|
|
|
|
|
+ <el-input v-model="searchInp" style="max-width: 600px" @change="handleChange" placeholder="请输入标题/父ASIN/ASIN/SKU查询商品">
|
|
<template #prepend>
|
|
<template #prepend>
|
|
- <el-select v-model="filterSelect" style="width: 80px">
|
|
|
|
|
|
+ <el-select v-model="filterSelect" class="filter-bar-select">
|
|
<el-option label="模糊" value="vague" />
|
|
<el-option label="模糊" value="vague" />
|
|
<el-option label="精确" value="accurate" />
|
|
<el-option label="精确" value="accurate" />
|
|
</el-select>
|
|
</el-select>
|
|
@@ -30,7 +123,12 @@
|
|
<div class="asin-selector__part" v-loading="parentloading">
|
|
<div class="asin-selector__part" v-loading="parentloading">
|
|
<div class="part-title">父ASIN</div>
|
|
<div class="part-title">父ASIN</div>
|
|
<ul v-infinite-scroll="load" class="infinite-list" style="overflow: auto">
|
|
<ul v-infinite-scroll="load" class="infinite-list" style="overflow: auto">
|
|
- <li v-for="(item, index) in allData" :key="index" class="infinite-list-item" @click="selectPaAsin(index)" :class="{ selectedItem: index === selectedIndex }">
|
|
|
|
|
|
+ <li
|
|
|
|
+ v-for="(item, index) in allData"
|
|
|
|
+ :key="index"
|
|
|
|
+ class="infinite-list-item"
|
|
|
|
+ @click="selectPaAsin(index)"
|
|
|
|
+ :class="{ selectedItem: index === selectedIndex }">
|
|
<el-button color="#3c58af" size="small" class="view-btn" @click.stop="clickParentAsinBtn(index)">查看</el-button>
|
|
<el-button color="#3c58af" size="small" class="view-btn" @click.stop="clickParentAsinBtn(index)">查看</el-button>
|
|
<div class="list-content">
|
|
<div class="list-content">
|
|
<img :src="item.Image" class="list-item-image" />
|
|
<img :src="item.Image" class="list-item-image" />
|
|
@@ -64,7 +162,12 @@
|
|
<div class="asin-selector__part">
|
|
<div class="asin-selector__part">
|
|
<div class="part-title">ASIN</div>
|
|
<div class="part-title">ASIN</div>
|
|
<el-scrollbar height="450px">
|
|
<el-scrollbar height="450px">
|
|
- <li v-for="(item, index) in asinData" :key="index" class="infinite-list-item" @click="selectAsin(index)" :class="{ selectedItem: index === selectedAsinIndex }">
|
|
|
|
|
|
+ <li
|
|
|
|
+ v-for="(item, index) in asinData"
|
|
|
|
+ :key="index"
|
|
|
|
+ class="infinite-list-item"
|
|
|
|
+ @click="selectAsin(index)"
|
|
|
|
+ :class="{ selectedItem: index === selectedAsinIndex }">
|
|
<div class="list-content">
|
|
<div class="list-content">
|
|
<img :src="item.Image" class="asin-list-item-image" />
|
|
<img :src="item.Image" class="asin-list-item-image" />
|
|
<div>
|
|
<div>
|
|
@@ -97,7 +200,12 @@
|
|
<div class="asin-selector__part sku">
|
|
<div class="asin-selector__part sku">
|
|
<div class="part-title">SKU</div>
|
|
<div class="part-title">SKU</div>
|
|
<el-scrollbar height="450px">
|
|
<el-scrollbar height="450px">
|
|
- <li v-for="(item, index) in skuData" :key="index" class="sku-list-item" @click="selectSku(index)" :class="{ selectedItem: index === selectedSkuIndex }">
|
|
|
|
|
|
+ <li
|
|
|
|
+ v-for="(item, index) in skuData"
|
|
|
|
+ :key="index"
|
|
|
|
+ class="sku-list-item"
|
|
|
|
+ @click="selectSku(index)"
|
|
|
|
+ :class="{ selectedItem: index === selectedSkuIndex }">
|
|
<div>{{ item.sku ? item.sku : '--' }}</div>
|
|
<div>{{ item.sku ? item.sku : '--' }}</div>
|
|
</li>
|
|
</li>
|
|
</el-scrollbar>
|
|
</el-scrollbar>
|
|
@@ -106,89 +214,6 @@
|
|
</el-popover>
|
|
</el-popover>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts">
|
|
|
|
-import { Search } from '@element-plus/icons-vue'
|
|
|
|
-import { inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
|
|
-import { getProductLineSelect, getProduct } from '../../api'
|
|
|
|
-import emitter from '/@/utils/emitter'
|
|
|
|
-import useSelectItem from '../../hooks/useSelectItem'
|
|
|
|
-import useInfiniteScroll from '../../hooks/useInfiniteScroll'
|
|
|
|
-
|
|
|
|
-const profile = <any>inject('profile')
|
|
|
|
-const { allData, parentloading, currentPage, load, fetchProduct } = useInfiniteScroll()
|
|
|
|
-const { visible, skuData, asinData, selectedIndex, selectedAsinIndex, selectedSkuIndex, selectPaAsin, selectAsin, selectSku, clickParentAsinBtn, clickAsinBtn } = useSelectItem()
|
|
|
|
-
|
|
|
|
-// const visible = ref(false)
|
|
|
|
-
|
|
|
|
-const searchInp = ref('')
|
|
|
|
-const filterSelect = ref('vague')
|
|
|
|
-
|
|
|
|
-const productSelect = ref('ALL')
|
|
|
|
-const options = ref([])
|
|
|
|
-
|
|
|
|
-async function fetchProductLine() {
|
|
|
|
- try {
|
|
|
|
- const resp = await getProductLineSelect({ profileId: profile.value.profile_id })
|
|
|
|
- options.value = resp.data
|
|
|
|
- productSelect.value = options.value[0].productlineId
|
|
|
|
- } catch (error) {
|
|
|
|
- console.log('error:', error)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-async function handleChange() {
|
|
|
|
- parentloading.value = true
|
|
|
|
- const query = {
|
|
|
|
- profileId: profile.value.profile_id,
|
|
|
|
- productlineId: productSelect.value,
|
|
|
|
- searchItem: searchInp.value
|
|
|
|
- }
|
|
|
|
- if (searchInp.value) {
|
|
|
|
- const res = await getProduct(query)
|
|
|
|
- allData.value = res.data
|
|
|
|
- emitter.emit('ExchangeProduct-allData', allData) // 让useSelectItem()中的allData得到正确更新, 否则无法正确选择parentAsin
|
|
|
|
- }
|
|
|
|
- parentloading.value = false
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function searchClick() {
|
|
|
|
- console.log(123)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-function resetProductList() {
|
|
|
|
- currentPage.value = 1
|
|
|
|
- fetchProduct()
|
|
|
|
- asinData.value = []
|
|
|
|
- skuData.value = []
|
|
|
|
- selectedIndex.value = -1
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-watch (searchInp, () => {
|
|
|
|
- emitter.emit('ExchangeProduct-searchInp', searchInp)
|
|
|
|
- if (searchInp.value === '') {
|
|
|
|
- resetProductList()
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-// 若产品选择改变则 重置分页并清空其他的数据
|
|
|
|
-watch(
|
|
|
|
- productSelect,
|
|
|
|
- (value) => {
|
|
|
|
- emitter.emit('ExchangeProduct-productSelect', value)
|
|
|
|
- resetProductList()
|
|
|
|
- },
|
|
|
|
- { immediate: true }
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-onMounted(() => {
|
|
|
|
- fetchProductLine()
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-onBeforeUnmount(() => {
|
|
|
|
- emitter.all.clear()
|
|
|
|
-})
|
|
|
|
-</script>
|
|
|
|
-
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
.custom-top {
|
|
.custom-top {
|
|
display: flex;
|
|
display: flex;
|
|
@@ -210,6 +235,9 @@ onBeforeUnmount(() => {
|
|
display: flex;
|
|
display: flex;
|
|
gap: 8px;
|
|
gap: 8px;
|
|
}
|
|
}
|
|
|
|
+.filter-bar-select {
|
|
|
|
+ width: 80px;
|
|
|
|
+}
|
|
.asin-selector {
|
|
.asin-selector {
|
|
display: flex;
|
|
display: flex;
|
|
align-items: stretch;
|
|
align-items: stretch;
|