@@ -155,6 +187,10 @@
+
+ 取消
+ 确认
+
@@ -176,7 +212,10 @@
total: 0,
search: {
current: 1,
- size: 100
+ size: -1,
+ productSkuId: '',
+ productSkcId: '',
+ isShowWhite: ''
},
lableSearch: {
current: 1,
@@ -225,11 +264,25 @@
id: '',
fileList: [],
pageShow: false,
- relationList: []
+ relationList: [],
+ btnLoading: false
}
},
computed: {
+ list () {
+ if (!this.skuList.length) {
+ return []
+ }
+
+ if (this.search.isShowWhite !== '1') {
+ return this.skuList
+ }
+
+ const keys = this.relationList.map(v => v.field)
+ return this.skuList.filter(v => keys.some(e => !v[e]))
+ },
+
currMall () {
if (!this.$store.state.mallList.length) {
return {}
@@ -239,7 +292,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 +309,7 @@
{ prop: 'productSkuId', label: 'SKU', align: 'center' },
{ prop: 'skuExtCode', label: 'SKU货号', align: 'center' },
{ prop: 'skuSpecName', label: '次销售属性', align: 'center' },
- ...arr
+ ...fields
]
},
@@ -287,16 +340,13 @@
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)
}
})
},
readXLSX(file) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
const reader = new FileReader()
-
reader.readAsBinaryString(file)
reader.onload = evt => {
const data = evt.target.result
@@ -313,7 +363,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 +371,6 @@
result[this.jsonFields[item]] = v[item]
})
- console.log(result)
return result
})).then(res => {
if (res.code === 0) {
@@ -341,7 +389,6 @@
},
handleSelectionChange(e) {
- console.log(e)
this.chooseSkuList = e
},
@@ -353,7 +400,7 @@
mallId: this.lableSearch.mallId,
anti: true,
data: {
- page: 1,
+ page,
pageSize: 200,
catIds: catIds
}
@@ -361,7 +408,7 @@
if (res.errorCode == 1000000) {
resolve({
list: res.result.pageItems.map(v => v.productSkcId),
- isHasNext: page * 200 < res.result.total
+ isHasNext: res.result.total && res.result.pageItems.length && (res.result.pageItems.length < 200 && res.result.total > 200)
})
} else {
resolve({ list: [], isHasNext: false })
@@ -373,35 +420,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 +477,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 +491,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 +518,7 @@
return this.$message.error('请选择SKU')
}
+ this.btnLoading = true
this.$http.post(`/api/templateSku/addBatchSku`, this.chooseSkuList.map(v => {
return {
...v,
@@ -486,8 +530,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()
+ }
+ })
+ })
+ },
}
}
diff --git a/src/view/lables/Template.vue b/src/view/lables/Template.vue
index feceea0..7145ca9 100644
--- a/src/view/lables/Template.vue
+++ b/src/view/lables/Template.vue
@@ -8,10 +8,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 查询
添加
-
-
+ @getList="getList"
+ :loading="isLoading">
- 添加SKU
+ 管理SKU
编辑
- 删除
+ 删除
@@ -43,14 +76,18 @@
return {
colConfigs: [
{ prop: 'name', label: '模板名称', align: 'left' },
- { prop: 'count', label: '绑定SKU数量', align: 'center' },
+ { prop: 'skuTotal', label: '绑定SKU数量', align: 'center' },
{ prop: 'createTime', label: '创建时间', align: 'center' },
],
+ isLoading: false,
tableData: [],
total: 0,
search: {
current: 1,
- size: 10
+ size: 10,
+ name: '',
+ productSkuId: '',
+ productSkcId: ''
}
}
},
@@ -69,6 +106,7 @@
},
getList () {
+ this.isLoading = true
this.$http.post('/api/template/getPage', null, {
params: {
...this.search
@@ -78,6 +116,22 @@
this.tableData = res.data.records
this.total = res.data.total
}
+
+ this.isLoading = false
+ })
+ },
+
+ remove (id) {
+ this.$confirm('确定删除该模板?', '温馨提示', {
+ type: 'warning'
+ }).then(() => {
+ this.$http.post(`/api/template/removeById?id=${id}`).then(res => {
+ if (res.code == 0) {
+ this.$message.success('删除成功')
+
+ this.getList()
+ }
+ })
})
},
@@ -89,4 +143,9 @@