1
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
:auto-upload="false"
|
||||
:file-list="fileList"
|
||||
:on-change="onExcelChange">
|
||||
<el-button size="small" type="danger">Excel导入</el-button>
|
||||
<el-button size="small" type="danger" :disabled="!skuList.length">Excel导入</el-button>
|
||||
</el-upload>
|
||||
<json-excel
|
||||
:data="skuList"
|
||||
@@ -29,19 +29,44 @@
|
||||
<el-button size="small" type="warning" :disabled="!skuList.length">Excel导出</el-button>
|
||||
</json-excel>
|
||||
</template>
|
||||
<template #right>
|
||||
</ai-search-bar>
|
||||
<ai-search-bar>
|
||||
<template #left>
|
||||
<div class="search-item" style="margin-bottom: 0;">
|
||||
<label>SKU:</label>
|
||||
<el-input
|
||||
v-model="search.productSkuId"
|
||||
style="width: 250px"
|
||||
size="small"
|
||||
clearable
|
||||
placeholder="请输入SKU"
|
||||
suffix-icon="iconfont iconSearch"
|
||||
@clear="getList">
|
||||
</el-input>
|
||||
</div>
|
||||
<div class="search-item" style="margin-bottom: 0;">
|
||||
<label>SKC:</label>
|
||||
<el-input
|
||||
v-model="search.productSkcId"
|
||||
style="width: 250px"
|
||||
size="small"
|
||||
placeholder="请输入SKC"
|
||||
clearable
|
||||
suffix-icon="iconfont iconSearch"
|
||||
@clear="getList">
|
||||
</el-input>
|
||||
</div>
|
||||
<el-button style="margin-left: 10px;" @click="getList" size="small" :loading="pageShow">查询</el-button>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table
|
||||
:tableData="skuList"
|
||||
:col-configs="colConfigs"
|
||||
:total="total"
|
||||
:current.sync="search.current"
|
||||
:size.sync="search.size"
|
||||
style="margin-top: 8px;"
|
||||
@getList="getList"
|
||||
@selection-change="handleSelectionChange"
|
||||
v-loading="pageShow">
|
||||
v-loading="pageShow"
|
||||
:isShowPagination="false">
|
||||
<el-table-column
|
||||
v-for="(item, index) in relationList"
|
||||
:key="index"
|
||||
@@ -50,19 +75,19 @@
|
||||
:label="item.name"
|
||||
align="center">
|
||||
</el-table-column>
|
||||
<!-- <el-table-column slot="options" label="操作" align="center" fixed="right" width="240px">
|
||||
<el-table-column slot="options" label="操作" align="center" fixed="right" width="120px">
|
||||
<template v-slot="{ row }">
|
||||
<div class="table-options">
|
||||
<el-button type="text" @click="toAdd(row.url)">编辑</el-button>
|
||||
<el-button type="text" @click="toDetail(row.url)">删除</el-button>
|
||||
<el-button type="text" @click="remove(row.id)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
<ai-dialog
|
||||
:visible.sync="isShow"
|
||||
title="添加SKU"
|
||||
width="1400px"
|
||||
customFooter
|
||||
@confirm="onConfirm">
|
||||
<div class="search-item__wrapper">
|
||||
<div class="left">
|
||||
@@ -155,6 +180,10 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
<template #footer>
|
||||
<el-button @click="isShow = false">取消</el-button>
|
||||
<el-button @click="onConfirm" type="primary" :loading="btnLoading">确认</el-button>
|
||||
</template>
|
||||
</ai-dialog>
|
||||
</template>
|
||||
</ai-list>
|
||||
@@ -176,7 +205,9 @@
|
||||
total: 0,
|
||||
search: {
|
||||
current: 1,
|
||||
size: 100
|
||||
size: -1,
|
||||
productSkuId: '',
|
||||
productSkcId: ''
|
||||
},
|
||||
lableSearch: {
|
||||
current: 1,
|
||||
@@ -225,7 +256,8 @@
|
||||
id: '',
|
||||
fileList: [],
|
||||
pageShow: false,
|
||||
relationList: []
|
||||
relationList: [],
|
||||
btnLoading: false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -239,7 +271,7 @@
|
||||
},
|
||||
|
||||
colConfigs () {
|
||||
const arr = this.isShow ? [] : this.relationList.map(v => {
|
||||
const fields = this.isShow ? [] : this.relationList.map(v => {
|
||||
return {
|
||||
prop: v.field,
|
||||
label: v.name,
|
||||
@@ -256,7 +288,7 @@
|
||||
{ prop: 'productSkuId', label: 'SKU', align: 'center' },
|
||||
{ prop: 'skuExtCode', label: 'SKU货号', align: 'center' },
|
||||
{ prop: 'skuSpecName', label: '次销售属性', align: 'center' },
|
||||
...arr
|
||||
...fields
|
||||
]
|
||||
},
|
||||
|
||||
@@ -287,8 +319,6 @@
|
||||
this.$http.post(`/api/templateRelation/getRelation?templateId=${this.$route.query.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.relationList = res.data
|
||||
|
||||
console.log(this.relationList)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -313,7 +343,6 @@
|
||||
onExcelChange (file) {
|
||||
this.pageShow = true
|
||||
this.readXLSX(file.raw).then(res => {
|
||||
console.log(res)
|
||||
this.$http.post(`/api/templateSku/updateBatchSku`, res.map(v => {
|
||||
const result = {
|
||||
templateId: this.id
|
||||
@@ -322,7 +351,6 @@
|
||||
result[this.jsonFields[item]] = v[item]
|
||||
})
|
||||
|
||||
console.log(result)
|
||||
return result
|
||||
})).then(res => {
|
||||
if (res.code === 0) {
|
||||
@@ -341,7 +369,6 @@
|
||||
},
|
||||
|
||||
handleSelectionChange(e) {
|
||||
console.log(e)
|
||||
this.chooseSkuList = e
|
||||
},
|
||||
|
||||
@@ -353,7 +380,7 @@
|
||||
mallId: this.lableSearch.mallId,
|
||||
anti: true,
|
||||
data: {
|
||||
page: 1,
|
||||
page: page,
|
||||
pageSize: 200,
|
||||
catIds: catIds
|
||||
}
|
||||
@@ -361,7 +388,7 @@
|
||||
if (res.errorCode == 1000000) {
|
||||
resolve({
|
||||
list: res.result.pageItems.map(v => v.productSkcId),
|
||||
isHasNext: page * 200 < res.result.total
|
||||
isHasNext: res.result.pageItems.length < 200
|
||||
})
|
||||
} else {
|
||||
resolve({ list: [], isHasNext: false })
|
||||
@@ -373,35 +400,28 @@
|
||||
},
|
||||
|
||||
async onCateChange() {
|
||||
this.$userCheck(this.lableSearch.mallId).then(async () => {
|
||||
let page = 1
|
||||
let list = []
|
||||
let isHasNext = true
|
||||
this.lableList = []
|
||||
this.isLoading = true
|
||||
while (isHasNext) {
|
||||
const result = await this.getSKCList([].concat(this.targetCatId.flat()), page)
|
||||
page = page + 1
|
||||
isHasNext = result.isHasNext ? true : false
|
||||
list.push(...result.list)
|
||||
let page = 1
|
||||
let list = []
|
||||
let isHasNext = true
|
||||
this.lableList = []
|
||||
this.isLoading = true
|
||||
while (isHasNext) {
|
||||
const result = await this.getSKCList([].concat(this.targetCatId.flat()), page)
|
||||
page = page + 1
|
||||
isHasNext = result.isHasNext ? true : false
|
||||
list.push(...result.list)
|
||||
|
||||
await this.$sleepSync(5000)
|
||||
}
|
||||
await this.$sleepSync(1000)
|
||||
}
|
||||
|
||||
const skcList = [...new Set(list)]
|
||||
const len = Math.ceil(skcList.length / 100)
|
||||
for (let i = 0; i < len; i++) {
|
||||
this.skuReqParams.page = 1
|
||||
this.skuReqParams.SKC = [...new Set(list)].slice(i * 100, i * 100 + 100).join(',')
|
||||
await this.requestSKUList(true)
|
||||
await this.$sleepSync(2000)
|
||||
}
|
||||
|
||||
console.log(111)
|
||||
this.isLoading = false
|
||||
}).catch(() => {
|
||||
this.lableSearch.mallId = ''
|
||||
})
|
||||
const skcList = [...new Set(list)]
|
||||
const len = Math.ceil(skcList.length / 100)
|
||||
for (let i = 0; i < len; i++) {
|
||||
this.skuReqParams.page = 1
|
||||
this.skuReqParams.SKC = [...new Set(list)].slice(i * 100, i * 100 + 100).join(',')
|
||||
await this.requestSKUList(true)
|
||||
await this.$sleepSync(500)
|
||||
}
|
||||
},
|
||||
|
||||
requestSKUList(flag) {
|
||||
@@ -437,7 +457,7 @@
|
||||
|
||||
if (res.result.total > this.lableList.length) {
|
||||
this.skuReqParams.page++
|
||||
await this.$sleepSync(5000)
|
||||
await this.$sleepSync(500)
|
||||
await this.requestSKUList()
|
||||
} else {
|
||||
!flag && (this.isLoading = false)
|
||||
@@ -451,22 +471,25 @@
|
||||
return this.$message.error('请选择店铺')
|
||||
}
|
||||
|
||||
this.$userCheck(this.lableSearch.mallId).then(() => {
|
||||
this.lableList = []
|
||||
this.skuReqParams.page = 1
|
||||
this.isLoading = true
|
||||
this.requestSKUList()
|
||||
}).catch(() => {
|
||||
this.lableSearch.mallId = ''
|
||||
})
|
||||
this.lableList = []
|
||||
this.skuReqParams.page = 1
|
||||
this.isLoading = true
|
||||
this.requestSKUList()
|
||||
},
|
||||
|
||||
getList () {
|
||||
this.$http.post(`/api/templateSku/getPage?size=-1&templateId=${this.id}`).then(res => {
|
||||
this.pageShow = true
|
||||
this.$http.post(`/api/templateSku/getPage`, null, {
|
||||
params: {
|
||||
...this.search,
|
||||
templateId: this.id
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.skuList = res.data.records
|
||||
// this.total = res.data.total
|
||||
}
|
||||
|
||||
this.pageShow = false
|
||||
})
|
||||
},
|
||||
|
||||
@@ -475,6 +498,7 @@
|
||||
return this.$message.error('请选择SKU')
|
||||
}
|
||||
|
||||
this.btnLoading = true
|
||||
this.$http.post(`/api/templateSku/addBatchSku`, this.chooseSkuList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
@@ -486,8 +510,24 @@
|
||||
this.isShow = false
|
||||
this.getList()
|
||||
}
|
||||
|
||||
this.btnLoading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
remove (id) {
|
||||
this.$confirm('确定删除该数据?', '温馨提示', {
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http.post(`/api/templateSku/removeById?id=${id}`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$message.success('删除成功')
|
||||
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user