|
|
@@ -25,6 +25,7 @@
|
|
|
<!-- 一级分类Tabs -->
|
|
|
<u-tabs :list="statusTabs"
|
|
|
:current="currentStatusTab"
|
|
|
+ font-size="30"
|
|
|
inactive-color="#666666"
|
|
|
:bar-style="{
|
|
|
bottom: '20rpx',
|
|
|
@@ -67,11 +68,11 @@
|
|
|
<u-image width="120rpx" height="120rpx" border-radius="12rpx" :src="goods.image" mode="aspectFill"></u-image>
|
|
|
<view class="goods-info">
|
|
|
<view class="goods-name">{{ goods.name }}</view>
|
|
|
- <view class="goods-desc">{{ goods.description }}</view>
|
|
|
+ <view class="goods-desc">{{ goods.dishName || goods.description }}</view>
|
|
|
<view class="goods-sales">销量:{{ goods.sales }}</view>
|
|
|
<view class="goods-price-line">
|
|
|
<text class="price"><text class="unit">¥</text>{{ goods.price }}</text>
|
|
|
- <text class="original-price">¥{{ goods.originalPrice }}</text>
|
|
|
+ <text class="original-price">¥{{ goods.sellingPrice }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 根据模式和状态显示不同操作 -->
|
|
|
@@ -81,7 +82,7 @@
|
|
|
type="primary" plain
|
|
|
@click="editGoods(goods)"
|
|
|
>编辑</u-button>
|
|
|
- <u-checkbox v-if="isManaging" :name="goods.id" shape="circle" v-model="goods.checked"></u-checkbox>
|
|
|
+ <u-checkbox v-if="isManaging" :name="goods.id" shape="circle" v-model="goods.checked" @change="onSelect"></u-checkbox>
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-checkbox-group>
|
|
|
@@ -89,10 +90,18 @@
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- <ListScrollView ref="listScroll0"
|
|
|
+ :api="api"
|
|
|
+ :init="{
|
|
|
+ ...initParams,
|
|
|
+ }">
|
|
|
+ <template v-slot:list="{ data }"></template>
|
|
|
+ </ListScrollView> -->
|
|
|
+
|
|
|
<!-- 批量管理底部操作栏 -->
|
|
|
<view class="footer-bar" v-if="isManaging">
|
|
|
<u-checkbox-group v-model="isAllSelected" placement="row">
|
|
|
- <u-checkbox name="all" shape="circle" v-model="isAllSelected" @change="selectAll">全选</u-checkbox>
|
|
|
+ <u-checkbox name="all" shape="circle" v-model="isAllSelected" @change="onSelectAll">全选</u-checkbox>
|
|
|
</u-checkbox-group>
|
|
|
|
|
|
<view class="action-buttons">
|
|
|
@@ -110,7 +119,6 @@
|
|
|
<Modal ref="myModal"
|
|
|
:title="modalText.title"
|
|
|
:content="modalText.content"
|
|
|
- :showCancelButton="false"
|
|
|
/>
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -118,29 +126,30 @@
|
|
|
<script>
|
|
|
import Modal from '@/components/modal/index.vue';
|
|
|
import Tabbar from '@/pages/groupMeal/tabbar/index.vue';
|
|
|
+import configService from '@/common/service/config.service';
|
|
|
+import ListScrollView from '@/components/list-scroll-view/index.vue';
|
|
|
export default {
|
|
|
components: {
|
|
|
Modal,
|
|
|
- Tabbar
|
|
|
+ Tabbar,
|
|
|
+ ListScrollView
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- isManaging: false, // 是否处于批量管理模式
|
|
|
+ api: {
|
|
|
+ url: '/groupmeal/gmMerchantPackage/pageList',
|
|
|
+ method: 'POST',
|
|
|
+ },
|
|
|
+ // 是否处于批量管理模式
|
|
|
+ isManaging: false,
|
|
|
// 一级分类
|
|
|
statusTabs: [{ name: '售卖中' }, { name: '审核中' }, { name: '未上架' }],
|
|
|
currentStatusTab: 0,
|
|
|
// 二级分类
|
|
|
categoryTabs: [{ name: '早餐' }, { name: '午餐' }, { name: '晚餐' }],
|
|
|
currentCategoryTab: 0,
|
|
|
- // 所有商品数据 (模拟)
|
|
|
- allGoods: [
|
|
|
- { id: 1, categoryId: 0, status: 0, name: '套餐名称套餐名称套餐名称套餐名称', sales: 1255, price: 10.8, originalPrice: 12, description: '米饭, 鱼香肉丝, 宫保鸡丁', image: '/static/demo/goods1.png' },
|
|
|
- { id: 2, categoryId: 0, status: 0, name: '套餐名称套餐名称', sales: 1255, price: 14.8, originalPrice: 16, description: '米饭, 红烧排骨', image: '/static/demo/goods2.png' },
|
|
|
- { id: 3, categoryId: 1, status: 0, name: '套餐名称套餐名称', sales: 1255, price: 13.1, originalPrice: 15.0, description: '米饭, 糖醋里脊', image: '/static/demo/goods3.png' },
|
|
|
- { id: 4, categoryId: 0, status: 1, name: '审核中套餐', sales: 0, price: 20, originalPrice: 25, description: '审核中商品描述', image: '/static/demo/goods1.png' },
|
|
|
- { id: 5, categoryId: 0, status: 2, name: '未上架早餐', sales: 0, price: 15, originalPrice: 18, description: '未上架商品描述', image: '/static/demo/goods2.png' },
|
|
|
- { id: 6, categoryId: 1, status: 2, name: '未上架午餐', sales: 0, price: 25, originalPrice: 30, description: '未上架商品描述', image: '/static/demo/goods3.png' },
|
|
|
- ],
|
|
|
+ // 所有商品数据
|
|
|
+ allGoods: [],
|
|
|
selectedGoods: [], // 已选中的商品ID
|
|
|
isAllSelected: false, // 用于全选checkbox的状态绑定
|
|
|
// 联动功能相关数据
|
|
|
@@ -151,20 +160,18 @@ export default {
|
|
|
modalText: {
|
|
|
title: '提示',
|
|
|
btntext: '确定',
|
|
|
- // 是否将所选商品上架?
|
|
|
// 所选商品有未通过审核商品无法批量操作上架
|
|
|
- // 是否将所选商品删除?删除后需重新添加品牌标配
|
|
|
- content: '报名成功,请等待平台审核'
|
|
|
+ content: '是否将所选商品上架?'
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
// 根据一、二级分类筛选商品
|
|
|
filteredGoods() {
|
|
|
- const filteredByCategory = this.allGoods.filter(goods => goods.status === this.currentStatusTab);
|
|
|
+ const filteredByCategory = this.allGoods;
|
|
|
const grouped = [];
|
|
|
this.categoryTabs.forEach((category, index) => {
|
|
|
- const items = filteredByCategory.filter(goods => goods.categoryId === index);
|
|
|
+ const items = filteredByCategory.filter(goods => goods.category == (index + 1));
|
|
|
if (items.length > 0) {
|
|
|
grouped.push({
|
|
|
id: index,
|
|
|
@@ -180,6 +187,35 @@ export default {
|
|
|
this.calculateCategoryOffsets();
|
|
|
});
|
|
|
return grouped;
|
|
|
+ },
|
|
|
+ // 数据参数
|
|
|
+ initParams() {
|
|
|
+ let params = {
|
|
|
+ // 商品状态: 0 未上架, 1 已上架
|
|
|
+ status: 0,
|
|
|
+ // 审核状态: 0 审核中, 1 已审核
|
|
|
+ // reviewStatus: 0,
|
|
|
+ }
|
|
|
+ // 售卖中
|
|
|
+ if (this.currentStatusTab == 0) {
|
|
|
+ params = {
|
|
|
+ status: 1,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 审核中
|
|
|
+ else if (this.currentStatusTab == 1) {
|
|
|
+ params = {
|
|
|
+ status: 0,
|
|
|
+ reviewStatus: 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 未上架
|
|
|
+ else if (this.currentStatusTab == 2) {
|
|
|
+ params = {
|
|
|
+ status: 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return params;
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
@@ -187,19 +223,24 @@ export default {
|
|
|
this.getData();
|
|
|
// 获取餐品分类
|
|
|
this.getClassData();
|
|
|
- // this.$refs.myModal.onOpen();
|
|
|
},
|
|
|
methods: {
|
|
|
// 商品数据
|
|
|
getData() {
|
|
|
let params = {
|
|
|
- status: 0,
|
|
|
- reviewStatus: 1,
|
|
|
pageNo: 1,
|
|
|
- pageSize: 10
|
|
|
+ pageSize: 10,
|
|
|
+ ...this.initParams
|
|
|
};
|
|
|
this.$http.post('/groupmeal/gmMerchantPackage/pageList', params).then(res => {
|
|
|
- if (res.data.code === 200) {}
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ this.allGoods = res.data.result.records.map(item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ image: configService.apiUrl + '/' + item.productImage.split(',')[0]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
// 餐品分类
|
|
|
@@ -213,12 +254,19 @@ export default {
|
|
|
this.isManaging = !this.isManaging;
|
|
|
this.selectedGoods = []; // 切换模式时清空选择
|
|
|
this.isAllSelected = false;
|
|
|
+ if (!this.isManaging) {
|
|
|
+ this.filteredGoods.flatMap(category => category.items.forEach(item => {
|
|
|
+ item.checked = false;
|
|
|
+ }));
|
|
|
+ }
|
|
|
},
|
|
|
// 主分类事件
|
|
|
onTabChange(e) {
|
|
|
this.currentStatusTab = e;
|
|
|
this.selectedGoods = []; // 切换Tab时清空选择
|
|
|
this.isAllSelected = false;
|
|
|
+ // 列表数据
|
|
|
+ this.getData();
|
|
|
// 切换 Tab 后,重置左侧分类高亮到第一个
|
|
|
// this.currentCategoryTab = 0;
|
|
|
// this.$nextTick(() => {
|
|
|
@@ -234,13 +282,22 @@ export default {
|
|
|
},
|
|
|
// 编辑商品
|
|
|
editGoods(goods) {
|
|
|
- console.log('编辑商品:', goods);
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/groupMeal/goods/form-step1?id=' + goods.id
|
|
|
});
|
|
|
},
|
|
|
+ // 单选
|
|
|
+ onSelect(e) {
|
|
|
+ if (e.value) {
|
|
|
+ this.selectedGoods.push(e.name);
|
|
|
+ } else {
|
|
|
+ let i = this.selectedGoods.indexOf(e.name);
|
|
|
+ this.selectedGoods.splice(i, 1);
|
|
|
+ }
|
|
|
+ this.isAllSelected = this.selectedGoods.length === this.allGoods.length;
|
|
|
+ },
|
|
|
// 全选事件
|
|
|
- selectAll(e) {
|
|
|
+ onSelectAll(e) {
|
|
|
if (e.value) {
|
|
|
// 全选
|
|
|
this.selectedGoods = this.filteredGoods.flatMap(category => category.items.map(item => item.id));
|
|
|
@@ -258,18 +315,42 @@ export default {
|
|
|
uni.showToast({ title: '请先选择商品', icon: 'none' });
|
|
|
return;
|
|
|
}
|
|
|
+ let content = '';
|
|
|
if (action === 'delete') {
|
|
|
-
|
|
|
+ content = '是否将所选商品删除?';
|
|
|
+ } else {
|
|
|
+ content = `是否将所选商品${action === 'publish' ? '上架' : '下架'}?`;
|
|
|
+ }
|
|
|
+ this.modalText.content = content;
|
|
|
+ this.$refs.myModal.onOpen(false, () => {
|
|
|
+ this.onConfirm(action);
|
|
|
+ });
|
|
|
+ console.log(`执行批量操作: ${action}`, this.selectedGoods);
|
|
|
+ },
|
|
|
+ // 弹窗确认事件
|
|
|
+ onConfirm(action) {
|
|
|
+ if (action === 'delete') {
|
|
|
+ // 单删接口
|
|
|
+ // this.$http.get('/groupmeal/gmMerchantPackage/delete');
|
|
|
+ // 多删接口
|
|
|
+ this.$http.delete('/groupmeal/gmMerchantPackage/deleteBatch', {}, {
|
|
|
+ params: { ids: this.selectedGoods.join() }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.data.code === 200) {}
|
|
|
+ this.$tip.toast(res.data.message);
|
|
|
+ });
|
|
|
} else {
|
|
|
- this.$http.post('/groupmeal/gmMerchantPackage/launch', {
|
|
|
- id: '',
|
|
|
- status: action === 'publish' ? 1 : 0
|
|
|
+ // 单个接口
|
|
|
+ // this.$http.post('/groupmeal/gmMerchantPackage/launch');
|
|
|
+ // 多选接口
|
|
|
+ this.$http.post('/groupmeal/gmMerchantPackage/batchLaunch', {
|
|
|
+ ids: this.selectedGoods,
|
|
|
+ status: this.currentStatusTab == 2 ? 1 : 0
|
|
|
}).then(res => {
|
|
|
if (res.data.code === 200) {}
|
|
|
+ this.$tip.toast(res.data.message);
|
|
|
});
|
|
|
}
|
|
|
- console.log(`执行批量操作: ${action}`, this.selectedGoods);
|
|
|
- uni.showToast({ title: '操作成功', icon: 'success' });
|
|
|
},
|
|
|
// 核心功能 1: 点击左侧二级分类,右侧商品列表滚动到对应位置
|
|
|
onCategoryTabChange(index) {
|
|
|
@@ -406,11 +487,12 @@ export default {
|
|
|
flex: 1;
|
|
|
height: 100%;
|
|
|
background-color: #fff;
|
|
|
- padding: 20rpx 24rpx;
|
|
|
+ padding: 0 24rpx 20rpx;
|
|
|
.category-title {
|
|
|
font-weight: 500;
|
|
|
font-size: 26rpx;
|
|
|
color: #000000;
|
|
|
+ padding-top: 20rpx;
|
|
|
}
|
|
|
.u-checkbox-group {
|
|
|
width: 100%;
|