fix: 物资领用

main
wx-jincw 1 month ago
parent f05abe4973
commit 13abd96af5

@ -287,7 +287,7 @@
} }
}, },
{ {
"path": "wish_menu/index", "path": "day_menu/index",
"style": { "style": {
"navigationBarTitleText": "每日菜单", "navigationBarTitleText": "每日菜单",
"navigationBarBackgroundColor": "#FFFFFF", "navigationBarBackgroundColor": "#FFFFFF",
@ -298,6 +298,18 @@
// #endif // #endif
} }
}, },
{
"path": "wish_menu/index",
"style": {
"navigationBarTitleText": "祈愿菜单",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTextStyle": "black"
// #ifdef H5
,
"navigationStyle": "custom"
// #endif
}
},
{ {
"path": "repair/index", "path": "repair/index",
"style": { "style": {

@ -95,7 +95,7 @@
</view> </view>
<view class="menu-txt">物资领用</view> <view class="menu-txt">物资领用</view>
</navigator> </navigator>
<navigator class='item' url='/pages/supply_chain/wish_menu/index' hover-class='none'> <navigator class='item' url='/pages/supply_chain/day_menu/index' hover-class='none'>
<view class='pictrue picsmall'> <view class='pictrue picsmall'>
<image class="image" src="/static/images/wg/wg_day_menu.png"></image> <image class="image" src="/static/images/wg/wg_day_menu.png"></image>
</view> </view>

@ -0,0 +1,719 @@
<template>
<view class="page">
<view class="date-card">
<view class="date-row">
<view class="date-btn" @click="changeDateBy(-1)"></view>
<view class="date-picker-container">
<view class="date-text" @click="openCalendar">
<text>{{ selectedDate }}</text>
<text class="iconfont icon-xiangxia"></text>
</view>
</view>
<view class="date-btn" @click="changeDateBy(1)"></view>
</view>
<view class="date-tip">默认当天可切换查看不同日期菜单</view>
</view>
<!-- 食堂筛选 -->
<view class="canteen-tabs" v-if="canteens && canteens.length > 1">
<view class="canteen-tabs-container">
<view
v-for="canteen in canteens"
:key="canteen.value"
class="canteen-tab"
:class="selectedCanteen === canteen.value ? 'active' : ''"
@click="switchCanteen(canteen.value)"
>
{{ canteen.label }}
</view>
</view>
</view>
<!-- 日历组件 -->
<uni-calendar
ref="calendar"
:insert="false"
:range="false"
:start-date="'2026-01-01'"
:end-date="'2099-12-31'"
@confirm="confirm"
></uni-calendar>
<!-- 排行榜日期范围选择器 -->
<uni-calendar
ref="rankingCalendar"
:insert="false"
:range="true"
:start-date="'2026-01-01'"
:end-date="'2099-12-31'"
@confirm="confirmRankingDate"
></uni-calendar>
<view class="section">
<view class="section-title">当日菜单</view>
<view class="meal-card" v-for="meal in mealSections" :key="meal.key">
<view class="meal-title">{{ meal.label }}</view>
<view v-if="meal.list.length">
<view class="dish-item" v-for="item in meal.list" :key="item.id">
<view class="dish-main">
<view class="dish-info">
<view class="dish-name">{{ item.itemName || '未命名菜品' }}</view>
<view class="dish-price" v-if="item.itemPrice !== undefined && item.itemPrice !== null">
{{ item.itemPrice }}
</view>
</view>
</view>
<view class="action-row">
<view class="action like" @click="submitLike(item, '1')">
<image :src="item.isLiked == '1' ? '/static/images/wg/like_.png' : '/static/images/wg/like.png'" class="action-icon" />
<span>{{ item.likeCount || 0 }}</span>
</view>
<view class="action dislike" @click="submitLike(item, '2')">
<image :src="item.isDisliked == '1' ? '/static/images/wg/dislike_.png' : '/static/images/wg/dislike.png'" class="action-icon" />
<span>{{ item.dislikeCount || 0 }}</span>
</view>
</view>
</view>
</view>
<view v-else class="empty">暂无{{ meal.label }}菜品</view>
</view>
</view>
<view class="section">
<view class="rank-header">
<view class="section-title">菜品排行</view>
<view class="rank-tabs">
<view
class="rank-tab"
:class="rankingType === 'like' ? 'active' : ''"
@click="switchRanking('like')"
>
点赞排行
</view>
<view
class="rank-tab"
:class="rankingType === 'dislike' ? 'active' : ''"
@click="switchRanking('dislike')"
>
点踩排行
</view>
</view>
</view>
<view class="rank-date-range">
<view class="date-range-container">
<view class="date-range-btn">
<view v-if="rankingDateRange.startDate && rankingDateRange.endDate" class="clear-btn" @click.stop="clearRankingDate">
</view>
<view class="date-text" @click="openRankingDatePicker">
{{ rankingDateRange.startDate && rankingDateRange.endDate ? `${rankingDateRange.startDate}${rankingDateRange.endDate}` : '选择日期范围' }}
</view>
<view class="icon" @click="openRankingDatePicker">
<text class="iconfont icon-xiangxia"></text>
</view>
</view>
</view>
</view>
<view v-if="rankingList.length">
<view class="rank-item" v-for="(item, index) in rankingList" :key="item.id || index">
<view class="rank-left">
<text class="rank-no" :class="index < 3 ? 'top' : ''">{{ index + 1 }}</text>
<text class="rank-name">{{ item.itemName || '未命名菜品' }}</text>
</view>
<view class="rank-right" :class="rankingType">
<image v-if="rankingType === 'like'" :src="'/static/images/wg/like.png'" class="rank-icon" />
<image v-else :src="'/static/images/wg/dislike.png'" class="rank-icon" />
<span>{{ rankingType === 'like' ? (item.likeCount || 0) : (item.dislikeCount || 0) }}</span>
</view>
</view>
</view>
<view v-else class="empty">暂无排行数据</view>
</view>
</view>
</template>
<script>
import {
listDailyMenuDetails,
likeDailyMenuItem,
cancelLikeDailyMenuItem,
getDailyMenuRanking
} from '@/api/property.js';
export default {
dicts: ['canteen_name'],
data() {
return {
selectedDate: '',
menuList: [],
rankingType: 'like',
rankingList: [],
mealSections: [
{ key: 'breakfast', label: '早餐', list: [] },
{ key: 'lunch', label: '中餐', list: [] },
{ key: 'dinner', label: '晚餐', list: [] }
],
canteens: [],
selectedCanteen: '',
rankingDateRange: {
startDate: '',
endDate: ''
},
showRankingDatePicker: false
};
},
onLoad() {
this.selectedDate = this.formatDate(new Date());
this.rankingDateRange.startDate = this.selectedDate;
this.rankingDateRange.endDate = this.selectedDate;
this.loadCanteens();
this.loadPageData();
},
mounted() {
//
this.$on('dictChange', () => {
this.loadCanteens();
});
},
beforeUnmount() {
this.$off('dictChange');
},
methods: {
async loadPageData() {
await Promise.all([this.loadMenuByDate(), this.loadRanking()]);
},
loadCanteens() {
const canteenDict = this.dict.get('canteen_name') || [];
this.canteens = canteenDict.map(item => ({
value: item.dictValue,
label: item.dictLabel
}));
if (this.canteens.length > 0 && !this.selectedCanteen) {
this.selectedCanteen = this.canteens[0].value;
}
},
async loadMenuByDate() {
try {
uni.showLoading({ title: '加载菜单中...', mask: true });
const res = await listDailyMenuDetails({
menuDate: this.selectedDate,
canteenName: this.selectedCanteen
});
const list = res?.data || [];
this.menuList = list;
this.groupMeals(list);
} catch (e) {
this.menuList = [];
this.groupMeals([]);
uni.showToast({
title: typeof e === 'string' ? e : '菜单加载失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
groupMeals(list) {
const breakfast = [];
const lunch = [];
const dinner = [];
list.forEach((item) => {
const mealType = this.normalizeMealType(item.mealType);
if (mealType === 'breakfast') {
breakfast.push(item);
} else if (mealType === 'lunch') {
lunch.push(item);
} else if (mealType === 'dinner') {
dinner.push(item);
}
});
this.mealSections = [
{ key: 'breakfast', label: '早餐', list: breakfast },
{ key: 'lunch', label: '中餐', list: lunch },
{ key: 'dinner', label: '晚餐', list: dinner }
];
},
normalizeMealType(type) {
if (!type) return '';
const v = String(type).trim();
if (v === '早餐' || v === '1' || v.toLowerCase() === 'breakfast') return 'breakfast';
if (v === '中餐' || v === '午餐' || v === '2' || v.toLowerCase() === 'lunch') return 'lunch';
if (v === '晚餐' || v === '3' || v.toLowerCase() === 'dinner') return 'dinner';
return '';
},
async submitLike(item, likeType) {
if (!item || !item.id) return;
try {
// /
const isLiked = likeType === '1' && item.isLiked === '1';
const isDisliked = likeType === '2' && item.isDisliked === '1';
if (isLiked || isDisliked) {
uni.showLoading({ title: likeType === '1' ? '取消点赞中...' : '取消点踩中...', mask: true });
await cancelLikeDailyMenuItem({
menuDtlId: item.id,
likeType
});
uni.showToast({
title: likeType === '1' ? '取消点赞成功' : '取消点踩成功',
icon: 'success'
});
//
if (likeType === '1') {
item.isLiked = '0';
item.likeCount = Math.max(0, (item.likeCount || 0) - 1);
} else {
item.isDisliked = '0';
item.dislikeCount = Math.max(0, (item.dislikeCount || 0) - 1);
}
} else {
uni.showLoading({ title: likeType === '1' ? '点赞中...' : '点踩中...', mask: true });
await likeDailyMenuItem({
menuDtlId: item.id,
likeType
});
uni.showToast({
title: likeType === '1' ? '点赞成功' : '点踩成功',
icon: 'success'
});
//
if (likeType === '1') {
item.isLiked = '1';
item.likeCount = (item.likeCount || 0) + 1;
} else {
item.isDisliked = '1';
item.dislikeCount = (item.dislikeCount || 0) + 1;
}
}
// await Promise.all([this.loadMenuByDate(), this.loadRanking()]);
} catch (e) {
uni.showToast({
title: typeof e === 'string' ? e : '操作失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
async loadRanking() {
try {
const res = await getDailyMenuRanking({
limit: 20,
rankingType: this.rankingType,
startDate: this.rankingDateRange.startDate,
endDate: this.rankingDateRange.endDate
});
this.rankingList = res?.data?.list || [];
} catch (e) {
this.rankingList = [];
}
},
async switchRanking(type) {
if (this.rankingType === type) return;
this.rankingType = type;
await this.loadRanking();
},
//
openCalendar() {
this.$refs.calendar.open();
},
//
async confirm(e) {
this.selectedDate = e.fulldate;
await this.loadMenuByDate();
},
async changeDateBy(step) {
const d = new Date(this.selectedDate.replace(/-/g, '/'));
d.setDate(d.getDate() + step);
this.selectedDate = this.formatDate(d);
await this.loadMenuByDate();
},
formatDate(date) {
const y = date.getFullYear();
const m = `${date.getMonth() + 1}`.padStart(2, '0');
const d = `${date.getDate()}`.padStart(2, '0');
return `${y}-${m}-${d}`;
},
async switchCanteen(canteenValue) {
if (this.selectedCanteen === canteenValue) return;
this.selectedCanteen = canteenValue;
await this.loadPageData();
},
openRankingDatePicker() {
this.$refs.rankingCalendar.open();
},
async confirmRankingDate(e) {
this.rankingDateRange.startDate = e.range.before;
this.rankingDateRange.endDate = e.range.after;
await this.loadRanking();
},
async clearRankingDate() {
this.rankingDateRange.startDate = '';
this.rankingDateRange.endDate = '';
await this.loadRanking();
}
}
};
</script>
<style lang="scss">
.page {
min-height: 100vh;
background: #f6f7fb;
padding: 24rpx;
}
/* 食堂筛选 */
.canteen-tabs {
margin-bottom: 20rpx;
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
.canteen-tabs-container {
display: inline-flex;
background: #fff;
border-radius: 16rpx;
padding: 8rpx;
}
.canteen-tab {
padding: 12rpx 24rpx;
margin: 0 4rpx;
border-radius: 999rpx;
font-size: 26rpx;
color: #6b7280;
transition: all 0.3s;
&.active {
background: #3b82f6;
color: #fff;
font-weight: 600;
}
}
}
/* 排行榜日期范围选择 */
.rank-date-range {
margin-bottom: 18rpx;
display: flex;
justify-content: flex-end;
}
.date-range-container {
display: flex;
align-items: center;
gap: 12rpx;
}
.date-range-btn {
display: flex;
align-items: center;
padding: 10rpx 16rpx;
background: #f3f4f6;
border-radius: 999rpx;
font-size: 24rpx;
color: #6b7280;
cursor: pointer;
gap: 12rpx;
.clear-btn {
font-size: 20rpx;
color: #9ca3af;
cursor: pointer;
padding: 0 4rpx;
&:hover {
color: #ef4444;
}
}
.date-text {
flex: 1;
font-size: 24rpx;
color: #6b7280;
font-weight: normal;
}
.icon {
.iconfont {
font-size: 18rpx;
}
}
}
.rank-tabs {
display: flex;
background: #f3f4f6;
border-radius: 999rpx;
padding: 4rpx;
}
.date-card,
.section,
.meal-card {
background: #fff;
border-radius: 16rpx;
}
.date-card {
padding: 24rpx;
margin-bottom: 20rpx;
}
.date-row {
display: flex;
align-items: center;
justify-content: space-between;
}
.date-btn {
width: 160rpx;
text-align: center;
height: 64rpx;
line-height: 64rpx;
background: #f2f4f8;
color: #333;
border-radius: 10rpx;
font-size: 26rpx;
}
.date-picker-container {
display: flex;
align-items: center;
}
.date-text {
min-width: 260rpx;
text-align: center;
font-size: 30rpx;
color: #1f2d3d;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
text {
margin-right: 10rpx;
}
.iconfont {
font-size: 20rpx;
color: #666;
}
}
.date-tip {
margin-top: 16rpx;
color: #8a94a6;
font-size: 24rpx;
}
.section {
padding: 24rpx;
margin-bottom: 20rpx;
}
.section-title {
font-size: 32rpx;
color: #222;
font-weight: 600;
margin-bottom: 18rpx;
}
.meal-card {
border: 1rpx solid #edf0f5;
padding: 20rpx;
margin-bottom: 16rpx;
}
.meal-title {
font-size: 28rpx;
color: #3b82f6;
font-weight: 600;
margin-bottom: 14rpx;
}
.dish-item {
padding: 16rpx 0;
border-bottom: 1rpx solid #f2f3f7;
display: flex;
align-items: flex-start;
gap: 16rpx;
}
.dish-item:last-child {
border-bottom: none;
}
.dish-main {
flex: 1;
min-width: 0;
}
.dish-info {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 4rpx;
}
.dish-name {
font-size: 28rpx;
color: #1f2937;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dish-desc {
color: #6b7280;
font-size: 20rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dish-price {
color: #ef4444;
font-size: 24rpx;
white-space: nowrap;
}
.action-row {
display: flex;
gap: 16rpx;
white-space: nowrap;
align-self: center;
}
.action {
height: 52rpx;
line-height: 52rpx;
padding: 0 20rpx;
border-radius: 26rpx;
font-size: 24rpx;
display: flex;
align-items: center;
gap: 8rpx;
}
.action-icon {
width: 28rpx;
height: 28rpx;
vertical-align: middle;
}
.like {
background: #ecfdf3;
color: #16a34a;
}
.dislike {
background: #fef2f2;
color: #dc2626;
}
.rank-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
}
.rank-tabs {
display: flex;
background: #f3f4f6;
border-radius: 999rpx;
padding: 4rpx;
}
.rank-tab {
padding: 10rpx 20rpx;
font-size: 24rpx;
color: #6b7280;
border-radius: 999rpx;
}
.rank-tab.active {
background: #fff;
color: #2563eb;
font-weight: 600;
}
.rank-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18rpx 0;
border-bottom: 1rpx solid #f2f3f7;
}
.rank-item:last-child {
border-bottom: none;
}
.rank-left {
display: flex;
align-items: center;
}
.rank-no {
width: 40rpx;
text-align: center;
font-size: 26rpx;
color: #6b7280;
margin-right: 14rpx;
}
.rank-no.top {
color: #f97316;
font-weight: 700;
}
.rank-name {
font-size: 27rpx;
color: #1f2937;
}
.rank-right {
font-size: 26rpx;
color: #6b7280;
display: flex;
align-items: center;
gap: 8rpx;
border-radius: 4rpx;
padding: 2rpx 4rpx;
}
.rank-right.like {
color: #16a34a;
}
.rank-right.dislike {
color: #dc2626;
}
.rank-icon {
width: 28rpx;
height: 28rpx;
vertical-align: middle;
}
.empty {
color: #9ca3af;
font-size: 24rpx;
padding: 20rpx 0;
text-align: center;
}
</style>

@ -28,8 +28,8 @@
<view class="multi-select"> <view class="multi-select">
<view class="selected-items" v-if="selectedMaterials.length > 0"> <view class="selected-items" v-if="selectedMaterials.length > 0">
<view class="selected-item" v-for="(item, index) in selectedMaterials" :key="item.cargoId"> <view class="selected-item" v-for="(item, index) in selectedMaterials" :key="item.cargoId">
<text>{{ item.cargoName }} ({{ item.cargoSpec }})</text> <text>{{ item.cargoName }} ({{ item.cargoSpec }}) x {{ item.quantity }}</text>
<text class="remove-btn" @click="removeMaterial(index)">×</text> <text class="remove-btn" @click="removeMaterial(index)">x</text>
</view> </view>
</view> </view>
<view class="select-btn" @click="showMaterialSelector"> <view class="select-btn" @click="showMaterialSelector">
@ -82,18 +82,30 @@
class="material-item" class="material-item"
v-for="material in filteredMaterials" v-for="material in filteredMaterials"
:key="material.cargoId" :key="material.cargoId"
@click="toggleMaterial(material)"
> >
<view class="material-info"> <view class="material-info">
<text class="material-name">{{ material.cargoName }}</text> <text class="material-name">{{ material.cargoName }}</text>
<text class="material-spec">{{ material.cargoSpec }}</text> <text class="material-spec">{{ material.cargoSpec }}</text>
</view> </view>
<view class="checkbox" :class="{ checked: isMaterialSelected(material.cargoId) }"> <view class="item-actions">
<view v-if="isMaterialSelected(material.cargoId)" class="quantity-input">
<text class="quantity-btn" @click="decreaseQuantity(material.cargoId)">-</text>
<input
type="number"
:value="getMaterialQuantity(material.cargoId)"
class="quantity-input-box"
min="1"
@input="updateQuantity(material.cargoId, $event)"
/>
<text class="quantity-btn" @click="increaseQuantity(material.cargoId)">+</text>
</view>
<view class="checkbox" :class="{ checked: isMaterialSelected(material.cargoId) }" @click="toggleMaterial(material)">
<text v-if="isMaterialSelected(material.cargoId)"></text> <text v-if="isMaterialSelected(material.cargoId)"></text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view>
<view class="popup-footer"> <view class="popup-footer">
<view class="footer-btn cancel" @click="closeMaterialSelector"></view> <view class="footer-btn cancel" @click="closeMaterialSelector"></view>
<view class="footer-btn confirm" @click="confirmMaterialSelection"></view> <view class="footer-btn confirm" @click="confirmMaterialSelection"></view>
@ -113,7 +125,13 @@
<text class="type">领用单</text> <text class="type">领用单</text>
<text <text
class="status" class="status"
:class="getStatusClass(item)" :class="{
'status-pending': getStatusText(item) === '待审批',
'status-approved': getStatusText(item) === '已审批',
'status-rejected': getStatusText(item) === '已拒绝',
'status-canceled': getStatusText(item) === '已取消',
'status-verified': getStatusText(item) === '已核销'
}"
> >
{{ getStatusText(item) }} {{ getStatusText(item) }}
</text> </text>
@ -145,7 +163,7 @@
<text class="label">领用物资</text> <text class="label">领用物资</text>
<text class="value"> <text class="value">
<text v-for="(cargo, index) in item.ckBillCargos" :key="cargo.id"> <text v-for="(cargo, index) in item.ckBillCargos" :key="cargo.id">
{{ cargo.cargoName }} ({{ cargo.cargoSpec }}){{ index < item.ckBillCargos.length - 1 ? '、' : '' }} {{ cargo.cargoName }}{{ cargo.cargoSpec ? ` (${cargo.cargoSpec})` : '' }}{{ cargo.cargoWt ? ` x ${parseFloat(cargo.cargoWt).toFixed(2).replace(/\.?0+$/, '')}` : '' }}{{ index < item.ckBillCargos.length - 1 ? '、' : '' }}
</text> </text>
</text> </text>
</view> </view>
@ -153,8 +171,8 @@
<view class="card-footer"> <view class="card-footer">
<view class="action-buttons"> <view class="action-buttons">
<view class="action-btn cancel-btn" v-if="item.cancelStatus === '0'" @click="cancelBill(item.id)"></view> <view class="action-btn cancel-btn" v-if="item.cancelStatus === '0' && item.billStatus === '0'" @click="cancelBill(item.id)"></view>
<view class="action-btn voucher-btn" @click="viewVoucher(item)"></view> <view class="action-btn voucher-btn" v-if="item.auditStatus === '1' && item.billStatus === '0'" @click="viewVoucher(item)"></view>
</view> </view>
</view> </view>
</view> </view>
@ -173,7 +191,7 @@
<text class="voucher-value">{{ currentVoucher ? currentVoucher.billNumber : '' }}</text> <text class="voucher-value">{{ currentVoucher ? currentVoucher.billNumber : '' }}</text>
</view> </view>
<view class="qrcode-container"> <view class="qrcode-container">
<canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" style="opacity: 0;" /> <canvas canvas-id="qrcode" :style="{width: `${qrcodeSize}px`, height: `${qrcodeSize}px`}" />
</view> </view>
</view> </view>
<view class="voucher-footer"> <view class="voucher-footer">
@ -201,6 +219,7 @@ export default {
'已审批': 'status-approved', '已审批': 'status-approved',
'已拒绝': 'status-rejected', '已拒绝': 'status-rejected',
'已取消': 'status-canceled', '已取消': 'status-canceled',
'已核销': 'status-verified',
'__default__': 'status-pending' '__default__': 'status-pending'
}, },
materials: [], materials: [],
@ -273,6 +292,33 @@ export default {
isMaterialSelected(cargoId) { isMaterialSelected(cargoId) {
return this.tempSelectedMaterials.some(item => item.cargoId === cargoId); return this.tempSelectedMaterials.some(item => item.cargoId === cargoId);
}, },
//
getMaterialQuantity(cargoId) {
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
return item ? item.quantity : 1;
},
//
increaseQuantity(cargoId) {
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
if (item) {
item.quantity += 1;
}
},
//
decreaseQuantity(cargoId) {
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
if (item && item.quantity > 1) {
item.quantity -= 1;
}
},
//
updateQuantity(cargoId, event) {
const item = this.tempSelectedMaterials.find(item => item.cargoId === cargoId);
if (item) {
const value = parseInt(event.target.value) || 1;
item.quantity = Math.max(1, value);
}
},
// //
confirmMaterialSelection() { confirmMaterialSelection() {
this.selectedMaterials = [...this.tempSelectedMaterials]; this.selectedMaterials = [...this.tempSelectedMaterials];
@ -283,7 +329,7 @@ export default {
this.selectedMaterials.splice(index, 1); this.selectedMaterials.splice(index, 1);
}, },
submitReceipt() { submitReceipt() {
if (this.selectedMaterials.length === 0 || !this.receiptForm.purpose || !this.receiptForm.applicant) { if (this.selectedMaterials.length === 0 || !this.receiptForm.purpose) {
uni.showToast({ uni.showToast({
title: '请填写完整信息', title: '请填写完整信息',
icon: 'none' icon: 'none'
@ -294,16 +340,24 @@ export default {
// //
const items = this.selectedMaterials.map(item => ({ const items = this.selectedMaterials.map(item => ({
cargoId: item.cargoId, cargoId: item.cargoId,
quantity: item.quantity quantity: item.quantity,
billNumber: item.billNumber,
stockId: item.stockId,
stockCode: item.stockCode,
ckCargoStockId: item.id,
})); }));
const submitData = { const submitData = {
purpose: this.receiptForm.purpose, purpose: this.receiptForm.purpose,
items: items items: items
}; };
uni.showLoading({
title: '提交中...'
});
// //
quickOutBill(submitData).then(res => { quickOutBill(submitData).then(res => {
uni.hideLoading();
if (res.code === 200) { if (res.code === 200) {
uni.showToast({ uni.showToast({
title: '领用申请提交成功', title: '领用申请提交成功',
@ -330,10 +384,15 @@ export default {
icon: 'none' icon: 'none'
}); });
} }
}).catch(() => {
uni.hideLoading();
}); });
}, },
// //
getStatusText(item) { getStatusText(item) {
if (item.billStatus === '1') {
return '已核销';
}
if (item.cancelStatus === '1') { if (item.cancelStatus === '1') {
return '已取消'; return '已取消';
} }
@ -395,16 +454,23 @@ export default {
}, },
// //
generateQRCode(billNumber) { generateQRCode(billNumber) {
console.log('开始生成二维码');
uQRCode.make({ uQRCode.make({
canvasId: 'qrcode', canvasId: 'qrcode',
text: billNumber, text: billNumber,
size: this.qrcodeSize, size: this.qrcodeSize,
margin: 10, margin: 10,
success: res => { success: res => {
console.log(res);
}, },
complete: () => { complete: () => {
}, },
fail: res => { fail: res => {
console.log(res);
uni.showToast({
title: '二维码生成失败',
icon: 'none'
});
} }
}); });
}, },
@ -418,6 +484,8 @@ export default {
} else { } else {
this.$refs.paging.complete([]); this.$refs.paging.complete([]);
} }
}).catch(e => {
this.$refs.paging.complete(false);
}); });
}, },
refreshList() { refreshList() {
@ -625,6 +693,11 @@ export default {
background-color: #F5F5F5; background-color: #F5F5F5;
color: #999; color: #999;
} }
.status-verified {
background-color: #E8F5E8;
color: #4CAF50;
}
} }
.header-right { .header-right {
@ -750,7 +823,6 @@ export default {
justify-content: space-between; justify-content: space-between;
padding: 24rpx 30rpx; padding: 24rpx 30rpx;
border-bottom: 1rpx solid #f0f0f0; border-bottom: 1rpx solid #f0f0f0;
cursor: pointer;
.material-info { .material-info {
flex: 1; flex: 1;
@ -768,6 +840,38 @@ export default {
} }
} }
.item-actions {
display: flex;
align-items: center;
gap: 20rpx;
.quantity-input {
display: flex;
align-items: center;
border: 1rpx solid #e5e5e5;
border-radius: 8rpx;
.quantity-btn {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
color: #666;
background-color: #f5f5f5;
}
.quantity-input-box {
width: 80rpx;
height: 40rpx;
border: none;
text-align: center;
font-size: 22rpx;
color: #333;
}
}
.checkbox { .checkbox {
width: 36rpx; width: 36rpx;
height: 36rpx; height: 36rpx;
@ -778,6 +882,7 @@ export default {
justify-content: center; justify-content: center;
font-size: 24rpx; font-size: 24rpx;
color: #fff; color: #fff;
cursor: pointer;
&.checked { &.checked {
background-color: #409EFF; background-color: #409EFF;
@ -787,6 +892,7 @@ export default {
} }
} }
} }
}
.popup-footer { .popup-footer {
display: flex; display: flex;
@ -819,7 +925,7 @@ export default {
/* 凭证弹窗样式 */ /* 凭证弹窗样式 */
.voucher-popup { .voucher-popup {
width: 80%; width: 680rpx;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden; overflow: hidden;

@ -1,719 +1,8 @@
<template> <template>
<view class="page">
<view class="date-card">
<view class="date-row">
<view class="date-btn" @click="changeDateBy(-1)"></view>
<view class="date-picker-container">
<view class="date-text" @click="openCalendar">
<text>{{ selectedDate }}</text>
<text class="iconfont icon-xiangxia"></text>
</view>
</view>
<view class="date-btn" @click="changeDateBy(1)"></view>
</view>
<view class="date-tip">默认当天可切换查看不同日期菜单</view>
</view>
<!-- 食堂筛选 -->
<view class="canteen-tabs" v-if="canteens && canteens.length > 1">
<view class="canteen-tabs-container">
<view
v-for="canteen in canteens"
:key="canteen.value"
class="canteen-tab"
:class="selectedCanteen === canteen.value ? 'active' : ''"
@click="switchCanteen(canteen.value)"
>
{{ canteen.label }}
</view>
</view>
</view>
<!-- 日历组件 -->
<uni-calendar
ref="calendar"
:insert="false"
:range="false"
:start-date="'2026-01-01'"
:end-date="'2099-12-31'"
@confirm="confirm"
></uni-calendar>
<!-- 排行榜日期范围选择器 -->
<uni-calendar
ref="rankingCalendar"
:insert="false"
:range="true"
:start-date="'2026-01-01'"
:end-date="'2099-12-31'"
@confirm="confirmRankingDate"
></uni-calendar>
<view class="section">
<view class="section-title">当日菜单</view>
<view class="meal-card" v-for="meal in mealSections" :key="meal.key">
<view class="meal-title">{{ meal.label }}</view>
<view v-if="meal.list.length">
<view class="dish-item" v-for="item in meal.list" :key="item.id">
<view class="dish-main">
<view class="dish-info">
<view class="dish-name">{{ item.itemName || '未命名菜品' }}</view>
<view class="dish-price" v-if="item.itemPrice !== undefined && item.itemPrice !== null">
{{ item.itemPrice }}
</view>
</view>
</view>
<view class="action-row">
<view class="action like" @click="submitLike(item, '1')">
<image :src="item.isLiked == '1' ? '/static/images/wg/like_.png' : '/static/images/wg/like.png'" class="action-icon" />
<span>{{ item.likeCount || 0 }}</span>
</view>
<view class="action dislike" @click="submitLike(item, '2')">
<image :src="item.isDisliked == '1' ? '/static/images/wg/dislike_.png' : '/static/images/wg/dislike.png'" class="action-icon" />
<span>{{ item.dislikeCount || 0 }}</span>
</view>
</view>
</view>
</view>
<view v-else class="empty">暂无{{ meal.label }}菜品</view>
</view>
</view>
<view class="section">
<view class="rank-header">
<view class="section-title">菜品排行</view>
<view class="rank-tabs">
<view
class="rank-tab"
:class="rankingType === 'like' ? 'active' : ''"
@click="switchRanking('like')"
>
点赞排行
</view>
<view
class="rank-tab"
:class="rankingType === 'dislike' ? 'active' : ''"
@click="switchRanking('dislike')"
>
点踩排行
</view>
</view>
</view>
<view class="rank-date-range">
<view class="date-range-container">
<view class="date-range-btn">
<view v-if="rankingDateRange.startDate && rankingDateRange.endDate" class="clear-btn" @click.stop="clearRankingDate">
</view>
<view class="date-text" @click="openRankingDatePicker">
{{ rankingDateRange.startDate && rankingDateRange.endDate ? `${rankingDateRange.startDate}${rankingDateRange.endDate}` : '选择日期范围' }}
</view>
<view class="icon" @click="openRankingDatePicker">
<text class="iconfont icon-xiangxia"></text>
</view>
</view>
</view>
</view>
<view v-if="rankingList.length">
<view class="rank-item" v-for="(item, index) in rankingList" :key="item.id || index">
<view class="rank-left">
<text class="rank-no" :class="index < 3 ? 'top' : ''">{{ index + 1 }}</text>
<text class="rank-name">{{ item.itemName || '未命名菜品' }}</text>
</view>
<view class="rank-right" :class="rankingType">
<image v-if="rankingType === 'like'" :src="'/static/images/wg/like.png'" class="rank-icon" />
<image v-else :src="'/static/images/wg/dislike.png'" class="rank-icon" />
<span>{{ rankingType === 'like' ? (item.likeCount || 0) : (item.dislikeCount || 0) }}</span>
</view>
</view>
</view>
<view v-else class="empty">暂无排行数据</view>
</view>
</view>
</template> </template>
<script> <script>
import {
listDailyMenuDetails,
likeDailyMenuItem,
cancelLikeDailyMenuItem,
getDailyMenuRanking
} from '@/api/property.js';
export default {
dicts: ['canteen_name'],
data() {
return {
selectedDate: '',
menuList: [],
rankingType: 'like',
rankingList: [],
mealSections: [
{ key: 'breakfast', label: '早餐', list: [] },
{ key: 'lunch', label: '中餐', list: [] },
{ key: 'dinner', label: '晚餐', list: [] }
],
canteens: [],
selectedCanteen: '',
rankingDateRange: {
startDate: '',
endDate: ''
},
showRankingDatePicker: false
};
},
onLoad() {
this.selectedDate = this.formatDate(new Date());
this.rankingDateRange.startDate = this.selectedDate;
this.rankingDateRange.endDate = this.selectedDate;
this.loadCanteens();
this.loadPageData();
},
mounted() {
//
this.$on('dictChange', () => {
this.loadCanteens();
});
},
beforeUnmount() {
this.$off('dictChange');
},
methods: {
async loadPageData() {
await Promise.all([this.loadMenuByDate(), this.loadRanking()]);
},
loadCanteens() {
const canteenDict = this.dict.get('canteen_name') || [];
this.canteens = canteenDict.map(item => ({
value: item.dictValue,
label: item.dictLabel
}));
if (this.canteens.length > 0 && !this.selectedCanteen) {
this.selectedCanteen = this.canteens[0].value;
}
},
async loadMenuByDate() {
try {
uni.showLoading({ title: '加载菜单中...', mask: true });
const res = await listDailyMenuDetails({
menuDate: this.selectedDate,
canteenName: this.selectedCanteen
});
const list = res?.data || [];
this.menuList = list;
this.groupMeals(list);
} catch (e) {
this.menuList = [];
this.groupMeals([]);
uni.showToast({
title: typeof e === 'string' ? e : '菜单加载失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
groupMeals(list) {
const breakfast = [];
const lunch = [];
const dinner = [];
list.forEach((item) => {
const mealType = this.normalizeMealType(item.mealType);
if (mealType === 'breakfast') {
breakfast.push(item);
} else if (mealType === 'lunch') {
lunch.push(item);
} else if (mealType === 'dinner') {
dinner.push(item);
}
});
this.mealSections = [
{ key: 'breakfast', label: '早餐', list: breakfast },
{ key: 'lunch', label: '中餐', list: lunch },
{ key: 'dinner', label: '晚餐', list: dinner }
];
},
normalizeMealType(type) {
if (!type) return '';
const v = String(type).trim();
if (v === '早餐' || v === '1' || v.toLowerCase() === 'breakfast') return 'breakfast';
if (v === '中餐' || v === '午餐' || v === '2' || v.toLowerCase() === 'lunch') return 'lunch';
if (v === '晚餐' || v === '3' || v.toLowerCase() === 'dinner') return 'dinner';
return '';
},
async submitLike(item, likeType) {
if (!item || !item.id) return;
try {
// /
const isLiked = likeType === '1' && item.isLiked === '1';
const isDisliked = likeType === '2' && item.isDisliked === '1';
if (isLiked || isDisliked) {
uni.showLoading({ title: likeType === '1' ? '取消点赞中...' : '取消点踩中...', mask: true });
await cancelLikeDailyMenuItem({
menuDtlId: item.id,
likeType
});
uni.showToast({
title: likeType === '1' ? '取消点赞成功' : '取消点踩成功',
icon: 'success'
});
//
if (likeType === '1') {
item.isLiked = '0';
item.likeCount = Math.max(0, (item.likeCount || 0) - 1);
} else {
item.isDisliked = '0';
item.dislikeCount = Math.max(0, (item.dislikeCount || 0) - 1);
}
} else {
uni.showLoading({ title: likeType === '1' ? '点赞中...' : '点踩中...', mask: true });
await likeDailyMenuItem({
menuDtlId: item.id,
likeType
});
uni.showToast({
title: likeType === '1' ? '点赞成功' : '点踩成功',
icon: 'success'
});
//
if (likeType === '1') {
item.isLiked = '1';
item.likeCount = (item.likeCount || 0) + 1;
} else {
item.isDisliked = '1';
item.dislikeCount = (item.dislikeCount || 0) + 1;
}
}
// await Promise.all([this.loadMenuByDate(), this.loadRanking()]);
} catch (e) {
uni.showToast({
title: typeof e === 'string' ? e : '操作失败',
icon: 'none'
});
} finally {
uni.hideLoading();
}
},
async loadRanking() {
try {
const res = await getDailyMenuRanking({
limit: 20,
rankingType: this.rankingType,
startDate: this.rankingDateRange.startDate,
endDate: this.rankingDateRange.endDate
});
this.rankingList = res?.data?.list || [];
} catch (e) {
this.rankingList = [];
}
},
async switchRanking(type) {
if (this.rankingType === type) return;
this.rankingType = type;
await this.loadRanking();
},
//
openCalendar() {
this.$refs.calendar.open();
},
//
async confirm(e) {
this.selectedDate = e.fulldate;
await this.loadMenuByDate();
},
async changeDateBy(step) {
const d = new Date(this.selectedDate.replace(/-/g, '/'));
d.setDate(d.getDate() + step);
this.selectedDate = this.formatDate(d);
await this.loadMenuByDate();
},
formatDate(date) {
const y = date.getFullYear();
const m = `${date.getMonth() + 1}`.padStart(2, '0');
const d = `${date.getDate()}`.padStart(2, '0');
return `${y}-${m}-${d}`;
},
async switchCanteen(canteenValue) {
if (this.selectedCanteen === canteenValue) return;
this.selectedCanteen = canteenValue;
await this.loadPageData();
},
openRankingDatePicker() {
this.$refs.rankingCalendar.open();
},
async confirmRankingDate(e) {
this.rankingDateRange.startDate = e.range.before;
this.rankingDateRange.endDate = e.range.after;
await this.loadRanking();
},
async clearRankingDate() {
this.rankingDateRange.startDate = '';
this.rankingDateRange.endDate = '';
await this.loadRanking();
}
}
};
</script> </script>
<style lang="scss"> <style>
.page {
min-height: 100vh;
background: #f6f7fb;
padding: 24rpx;
}
/* 食堂筛选 */
.canteen-tabs {
margin-bottom: 20rpx;
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
.canteen-tabs-container {
display: inline-flex;
background: #fff;
border-radius: 16rpx;
padding: 8rpx;
}
.canteen-tab {
padding: 12rpx 24rpx;
margin: 0 4rpx;
border-radius: 999rpx;
font-size: 26rpx;
color: #6b7280;
transition: all 0.3s;
&.active {
background: #3b82f6;
color: #fff;
font-weight: 600;
}
}
}
/* 排行榜日期范围选择 */
.rank-date-range {
margin-bottom: 18rpx;
display: flex;
justify-content: flex-end;
}
.date-range-container {
display: flex;
align-items: center;
gap: 12rpx;
}
.date-range-btn {
display: flex;
align-items: center;
padding: 10rpx 16rpx;
background: #f3f4f6;
border-radius: 999rpx;
font-size: 24rpx;
color: #6b7280;
cursor: pointer;
gap: 12rpx;
.clear-btn {
font-size: 20rpx;
color: #9ca3af;
cursor: pointer;
padding: 0 4rpx;
&:hover {
color: #ef4444;
}
}
.date-text {
flex: 1;
font-size: 24rpx;
color: #6b7280;
font-weight: normal;
}
.icon {
.iconfont {
font-size: 18rpx;
}
}
}
.rank-tabs {
display: flex;
background: #f3f4f6;
border-radius: 999rpx;
padding: 4rpx;
}
.date-card,
.section,
.meal-card {
background: #fff;
border-radius: 16rpx;
}
.date-card {
padding: 24rpx;
margin-bottom: 20rpx;
}
.date-row {
display: flex;
align-items: center;
justify-content: space-between;
}
.date-btn {
width: 160rpx;
text-align: center;
height: 64rpx;
line-height: 64rpx;
background: #f2f4f8;
color: #333;
border-radius: 10rpx;
font-size: 26rpx;
}
.date-picker-container {
display: flex;
align-items: center;
}
.date-text {
min-width: 260rpx;
text-align: center;
font-size: 30rpx;
color: #1f2d3d;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
text {
margin-right: 10rpx;
}
.iconfont {
font-size: 20rpx;
color: #666;
}
}
.date-tip {
margin-top: 16rpx;
color: #8a94a6;
font-size: 24rpx;
}
.section {
padding: 24rpx;
margin-bottom: 20rpx;
}
.section-title {
font-size: 32rpx;
color: #222;
font-weight: 600;
margin-bottom: 18rpx;
}
.meal-card {
border: 1rpx solid #edf0f5;
padding: 20rpx;
margin-bottom: 16rpx;
}
.meal-title {
font-size: 28rpx;
color: #3b82f6;
font-weight: 600;
margin-bottom: 14rpx;
}
.dish-item {
padding: 16rpx 0;
border-bottom: 1rpx solid #f2f3f7;
display: flex;
align-items: flex-start;
gap: 16rpx;
}
.dish-item:last-child {
border-bottom: none;
}
.dish-main {
flex: 1;
min-width: 0;
}
.dish-info {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 4rpx;
}
.dish-name {
font-size: 28rpx;
color: #1f2937;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dish-desc {
color: #6b7280;
font-size: 20rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.dish-price {
color: #ef4444;
font-size: 24rpx;
white-space: nowrap;
}
.action-row {
display: flex;
gap: 16rpx;
white-space: nowrap;
align-self: center;
}
.action {
height: 52rpx;
line-height: 52rpx;
padding: 0 20rpx;
border-radius: 26rpx;
font-size: 24rpx;
display: flex;
align-items: center;
gap: 8rpx;
}
.action-icon {
width: 28rpx;
height: 28rpx;
vertical-align: middle;
}
.like {
background: #ecfdf3;
color: #16a34a;
}
.dislike {
background: #fef2f2;
color: #dc2626;
}
.rank-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 18rpx;
}
.rank-tabs {
display: flex;
background: #f3f4f6;
border-radius: 999rpx;
padding: 4rpx;
}
.rank-tab {
padding: 10rpx 20rpx;
font-size: 24rpx;
color: #6b7280;
border-radius: 999rpx;
}
.rank-tab.active {
background: #fff;
color: #2563eb;
font-weight: 600;
}
.rank-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18rpx 0;
border-bottom: 1rpx solid #f2f3f7;
}
.rank-item:last-child {
border-bottom: none;
}
.rank-left {
display: flex;
align-items: center;
}
.rank-no {
width: 40rpx;
text-align: center;
font-size: 26rpx;
color: #6b7280;
margin-right: 14rpx;
}
.rank-no.top {
color: #f97316;
font-weight: 700;
}
.rank-name {
font-size: 27rpx;
color: #1f2937;
}
.rank-right {
font-size: 26rpx;
color: #6b7280;
display: flex;
align-items: center;
gap: 8rpx;
border-radius: 4rpx;
padding: 2rpx 4rpx;
}
.rank-right.like {
color: #16a34a;
}
.rank-right.dislike {
color: #dc2626;
}
.rank-icon {
width: 28rpx;
height: 28rpx;
vertical-align: middle;
}
.empty {
color: #9ca3af;
font-size: 24rpx;
padding: 20rpx 0;
text-align: center;
}
</style> </style>
Loading…
Cancel
Save