소스 검색

商品批量下架不生效bug修复

baijunde 3 주 전
부모
커밋
2c4e748d9a
1개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 12 3
      pages/merchantDish/dish/list.vue

+ 12 - 3
pages/merchantDish/dish/list.vue

@@ -144,7 +144,7 @@
 			<view class="batch-btns">
 				<template v-if="filterStatus === '' || filterStatus === 'reviewing'">
 					<view class="b-btn disabled">批量删除</view>
-					<view class="b-btn disabled">批量下架</view>
+					<view :class="['b-btn', selectedOffIds.length ? 'danger' : 'disabled']" @click="batchOff">批量下架</view>
 					<view class="b-btn disabled">批量上架</view>
 				</template>
 				<template v-else-if="filterStatus === 'selling' || filterStatus === 'soldout'">
@@ -260,6 +260,11 @@ export default {
 			const ids = list.map((i) => i.id);
 			return ids.length > 0 && ids.every((id) => this.selectedIds.includes(id));
 		},
+		selectedOffIds() {
+			return this.currentList
+				.filter((item) => this.selectedIds.includes(item.id) && (item.status === 'selling' || item.status === 'soldout'))
+				.map((item) => item.id);
+		},
 		bannerVisible() {
 			return this.applyStatus !== 1;
 		},
@@ -472,9 +477,13 @@ export default {
 			return true;
 		},
 		async batchOff() {
-			if (!this.ensureSelected()) return;
+			const ids = this.filterStatus === '' ? this.selectedOffIds : this.selectedIds;
+			if (!ids.length) {
+				uni.showToast({ title: '请先选择在售菜品', icon: 'none' });
+				return;
+			}
 			if (!(await this.confirmModal('确定批量下架选中商品?'))) return;
-			merchantDishApi.packageBatchLaunch(this.selectedIds, 0).then((res) => {
+			merchantDishApi.packageBatchLaunch(ids, 0).then((res) => {
 				this.$tip.toast(res.data.message || (res.data.code === 200 ? '批量下架成功' : '操作失败'));
 				if (res.data.code === 200) {
 					this.exitBatch();