|
|
@@ -299,57 +299,53 @@ export default {
|
|
|
url: '/pages/product/creatProduct?productId=' + item.productId + '&tabIndex=' + this.tabIndex
|
|
|
})
|
|
|
},
|
|
|
+ getSelectedProducts() {
|
|
|
+ return this.productList.filter(item => item.select)
|
|
|
+ },
|
|
|
+ showSelectRequiredToast() {
|
|
|
+ uni.showToast({
|
|
|
+ title: '至少选择一个商品',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ },
|
|
|
select(item) {
|
|
|
item.select = !item.select
|
|
|
- this.productHandleList.push(item.productId)
|
|
|
+ this.isAll = this.productList.length > 0 && this.productList.every(i => i.select)
|
|
|
},
|
|
|
//批量上下架status:0下架。1上架
|
|
|
deletes(status) {
|
|
|
- let that = this
|
|
|
- // this.productStatus == 0 ?this.isSell = true:this.isDelist = true
|
|
|
+ const selectedList = this.getSelectedProducts().map(item => ({
|
|
|
+ productId: item.productId,
|
|
|
+ productStatus: status,
|
|
|
+ productType: this.tabIndex
|
|
|
+ }))
|
|
|
+ if (!selectedList.length) {
|
|
|
+ this.showSelectRequiredToast()
|
|
|
+ return
|
|
|
+ }
|
|
|
if (this.productStatus == 0) {
|
|
|
+ this.sellProducts = selectedList
|
|
|
this.isSell = true
|
|
|
- this.productList.forEach(item => {
|
|
|
- if (item.select) {
|
|
|
- this.sellProducts.push({
|
|
|
- productId: item.productId,
|
|
|
- productStatus: status,
|
|
|
- productType:this.tabIndex
|
|
|
- // productType = 自有或者标品(1: 标品, 0: 自有
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
} else {
|
|
|
+ this.delistList = selectedList
|
|
|
this.isDelist = true
|
|
|
- this.productList.forEach(item => {
|
|
|
- if (item.select) {
|
|
|
- this.delistList.push({
|
|
|
- productId: item.productId,
|
|
|
- productStatus: status,
|
|
|
- productType:this.tabIndex
|
|
|
- // productType = 自有或者标品(1: 标品, 0: 自有
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
//批量删除
|
|
|
remove() {
|
|
|
- this.productList.forEach((item => {
|
|
|
- if (item.select) {
|
|
|
- this.productHandleList.push(item.productId)
|
|
|
- }
|
|
|
-
|
|
|
- }))
|
|
|
+ this.productHandleList = this.getSelectedProducts().map(item => item.productId)
|
|
|
+ if (!this.productHandleList.length) {
|
|
|
+ this.showSelectRequiredToast()
|
|
|
+ return
|
|
|
+ }
|
|
|
this.isDelete = true
|
|
|
- // this.getProductList()
|
|
|
},
|
|
|
removeProduct() {
|
|
|
- let ids = []
|
|
|
- ids = this.productHandleList.join(',')
|
|
|
- console.log(ids)
|
|
|
+ if (!this.productHandleList.length) {
|
|
|
+ this.showSelectRequiredToast()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const ids = this.productHandleList.join(',')
|
|
|
this.$http.get("/app/product/deleteBatch?ids=" + ids,)
|
|
|
.then(res => {
|
|
|
if (res.data.code == 200) {
|
|
|
@@ -426,6 +422,10 @@ export default {
|
|
|
},
|
|
|
//下架商品
|
|
|
delistProduct() {
|
|
|
+ if (!this.delistList.length) {
|
|
|
+ this.showSelectRequiredToast()
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$http.post("/app/product/shelves", this.delistList)
|
|
|
.then(res => {
|
|
|
if (res.data.code == 200) {
|
|
|
@@ -470,7 +470,10 @@ export default {
|
|
|
// }
|
|
|
},
|
|
|
sellProduct() {
|
|
|
-
|
|
|
+ if (!this.sellProducts.length) {
|
|
|
+ this.showSelectRequiredToast()
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$http.post("/app/product/shelves", this.sellProducts)
|
|
|
.then(res => {
|
|
|
if (res.data.code == 200) {
|