Merge branch 'bonus-jyy-smart-canteen' of http://192.168.0.75:3000/bonus/bonus-ui into bonus-jyy-smart-canteen

This commit is contained in:
zzyuan 2025-06-05 11:14:02 +08:00
commit 38a835fd34
2 changed files with 112 additions and 113 deletions

View File

@ -74,7 +74,7 @@ export function getPageRecipeListApi(data) {
params: data
})
}
//菜谱-新增
export function addMenuRecipeApi(data) {
return request({
@ -145,14 +145,14 @@ export function getMenuRecipeTemplateDetailApi(data) {
data: data
})
}
export function menuUpLoadApi(param){
const formData = new FormData()
formData.append('file', param.file)
formData.append('recipeId', param.recipeId)
return request({
url: '/smart-canteen/menu_recipe/recipe/import/dishes',
url: '/smart-canteen/cook_recipe/recipe/import/dishes',
method: 'post',
data: formData,
header:'multipart/form-data'

View File

@ -2,8 +2,8 @@
<div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane label="当前菜谱" name="currentRecipe"></el-tab-pane>
<el-tab-pane label="菜谱列表" name="pageRecipe"></el-tab-pane>
</el-tabs>
<el-tab-pane label="菜谱列表" name="pageRecipe"></el-tab-pane>
</el-tabs>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-row class="mb8" v-if="activeName=='currentRecipe'">
<el-button plain v-for="item in menuTypeList" :key="item.id" :class="queryParams.key==item.id?'primary':''" @click="choseMenuType(item)">{{ item.name }}</el-button>
@ -11,14 +11,14 @@
<el-row class="mb8" v-if="activeName=='currentRecipe'">
<span style="margin: 0px 20px;">日期</span>
<el-radio-group v-model="queryParams.applyDate" @change="handleQuery">
<el-radio v-for="item in daysList" :key="item.data" :label="item.data">{{item.data}} {{ item.weekValue }}</el-radio>
<el-radio v-for="item in daysList" :key="item.data" :label="item.data">{{item.data}} {{ item.weekValue }}</el-radio>
</el-radio-group>
</el-row>
<el-row class="mb8">
<el-form-item label="所属区域" prop="areaId">
<el-cascader v-model="queryParams.areaId"
:options="treeAreaOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
:props="{
:props="{
emitPath: false,// falseid
checkStrictly: false,//
value:'id',label:'label'
@ -32,7 +32,7 @@
:label="item.canteenName"
:value="item.canteenId"
></el-option>
</el-select>
</el-select>
</el-form-item>
<el-form-item label="所属档口" prop="stallId">
<el-select v-model="queryParams.stallId" clearable placeholder="请选择所属档口" style="width: 100%;" >
@ -41,8 +41,8 @@
:label="item.stallName"
:value="item.stallId"
></el-option>
</el-select>
</el-form-item>
</el-select>
</el-form-item>
<el-form-item label="菜谱名称" prop="recipeName">
<el-input
v-model="queryParams.recipeName"
@ -51,14 +51,14 @@
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row :gutter="10" class="mb8" v-if="activeName=='pageRecipe'">
<el-col :span="1.5">
<el-button
@ -68,10 +68,10 @@
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tableListData" height="800">
<el-table-column label="序号" align="center" width="80" type="index" fixed="left">
<template slot-scope="scope">
@ -84,7 +84,7 @@
<el-table-column label="菜谱名称" align="center" prop="recipeName" :show-overflow-tooltip="true" width="200">
<template slot-scope="scope">
<div style="display: flex;align-items: center;justify-content: center;" v-if="activeName=='currentRecipe'">
<span v-if="scope.row.recipeId">{{scope.row.recipeName}}</span>
<span v-if="scope.row.recipeId">{{scope.row.recipeName}}</span>
<img v-if="scope.row.recipeId" src="../../../assets/canteen/replace.png" style="width: 16px;height: 16px;margin-left: 10px;cursor: pointer;" alt="" @click="choseMenuRecipe(scope.row)">
<i v-if="scope.row.recipeId" class="el-icon-delete" style="color: red;font-size: 16px;margin-left: 10px;cursor: pointer;" @click="handleUnbind(scope.row)" ></i>
@ -92,13 +92,13 @@
<span style="color: #0099ff;">选择菜谱</span>
<img src="../../../assets/canteen/add.png" style="width: 16px;height: 16px;margin-left: 10px;" alt="">
</div>
</div>
<div v-if="activeName=='pageRecipe'">
<span>{{scope.row.recipeName}}</span>
<span>{{scope.row.recipeName}}</span>
</div>
</template>
</el-table-column>
</el-table-column>
<el-table-column v-for="item in mealTimeList" :key="item.mealtimeType" :label="item.mealtimeName" :show-overflow-tooltip="true" align="center" v-if="activeName=='currentRecipe'">
<template slot-scope="scope">
@ -111,11 +111,11 @@
<div>{{ lastItem.dishesName }}; </div>
</div>
</div>
</div>
</div>
</div>
<div v-else>
<span>无菜品</span>
</div>
</div>
</div>
<div v-if="scope.row.detail">
@ -124,19 +124,19 @@
<div v-for="(lastItem,index) in subItem.dishesList" :key="lastItem.dishesId">
<div v-if="index<4">{{ lastItem.dishesName }}</div>
<div v-if="index==4">...</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div v-else>
<span>无菜品</span>
</div>
</div>
</el-tooltip>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="菜谱更新时间" align="center" prop="uptime" width="150" v-if="activeName=='currentRecipe'"/>
<el-table-column label="菜谱类型" align="center" prop="recipeType" v-if="activeName=='pageRecipe'">
<el-table-column label="菜谱类型" align="center" prop="recipeType" v-if="activeName=='pageRecipe'">
<template slot-scope="scope">
<span v-if="scope.row.recipeType==1">指定日期菜谱</span>
<span v-if="scope.row.recipeType==2">每日循环菜谱</span>
@ -146,54 +146,54 @@
<el-table-column label="菜品数量" align="center" prop="dishesCount" v-if="activeName=='pageRecipe'"/>
<el-table-column label="菜谱生效日期" align="center" prop="applyDateStringList" v-if="activeName=='pageRecipe'">
<template slot-scope="scope" v-if="activeName=='pageRecipe'">
<el-popover placement="top" width="400">
<el-popover placement="top" width="400">
<div style="width: 100%;padding: 10px;border-bottom: 1px solid #ccc;margin-bottom: 10px;">
{{currentMonth}}
</div>
</div>
<div style="width: 100%;display: flex;align-items: center;margin-bottom: 10px;">
<div v-for="(item,index) in currentWeekList" :key="index" style="width: 14%;text-align: center;">{{item}}</div>
</div>
<div style="width: 100%;display: flex;align-items: center;margin-bottom: 10px;flex-wrap: wrap;">
<div v-for="(item,index) in monthDaysList" :key="index" :class="scope.row.applyDateStringList.findIndex(v=>v==item)>-1 ? 'dateTable2' : 'dateTable'" class="" >{{item}}</div>
</div>
<div style="color: #1890ff;cursor: pointer;" slot="reference">查看详情</div>
<div v-for="(item,index) in monthDaysList" :key="index" :class="scope.row.applyDateStringList.findIndex(v=>v==item)>-1 ? 'dateTable2' : 'dateTable'" class="" >{{item}}</div>
</div>
<div style="color: #1890ff;cursor: pointer;" slot="reference">查看详情</div>
</el-popover>
</template>
</el-table-column>
<!-- <el-table-column label="用户范围" align="center" prop="effName" v-if="activeName=='pageRecipe'"/> -->
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" v-if="activeName=='currentRecipe'" >
<template slot-scope="scope">
<el-button
size="mini"
type="text" v-if="queryParams.key=='2'"
@click="handleDevice(scope.row)"
>设备详情</el-button>
@click="handleDevice(scope.row)"
>设备详情</el-button>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" fixed="right" v-if="activeName=='pageRecipe'">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
@click="handleUpdate(scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
@click="handleDelete(scope.row)"
>删除</el-button>
<el-button
size="mini"
type="text" v-if="scope.row.recipeType==1"
@click="handleImport(scope.row)"
type="text" v-if="scope.row.recipeType==1"
@click="handleImport(scope.row)"
>导入</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
@ -209,7 +209,7 @@
<el-option label="指定日期" value="1"></el-option>
<el-option label="每日循环" value="2"></el-option>
<el-option label="每周循环" value="3"></el-option>
</el-select>
</el-select>
</el-form-item>
<el-form-item label="菜谱名称" prop="recipeId">
<el-select v-model="menuForm.recipeId" placeholder="请选择菜谱名称" style="width: 300px;" clearable>
@ -217,10 +217,10 @@
:key="item.recipeId"
:label="item.recipeName"
:value="item.recipeId"
></el-option>
</el-select>
</el-form-item>
</el-form>
></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmBindMenu"> </el-button>
<el-button @click="openMenu=false"> </el-button>
@ -233,10 +233,10 @@
<span>1下载模板按规范填写信息</span>
<el-button
size="mini" type="text"
@click="importTemplate"
@click="importTemplate"
style="margin-left: 40px;"
>模板下载
</el-button>
</el-button>
</div>
<div style="width: 80%;display: flex;align-items: center;justify-content: space-between;">
<span>2上传文件</span>
@ -244,29 +244,29 @@
ref="upload"
:http-request="fileUpLoad"
action="#"
accept=".xlsx, .xls"
:show-file-list="false"
accept=".xlsx, .xls"
:show-file-list="false"
>
<el-button
type="text"
size="mini"
size="mini"
>上传导入
</el-button>
</el-upload>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="openUpload=false"> </el-button>
<el-button type="primary" @click="openUpload=false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { systemAreaTreeApi,getCanteenByAreaApi,getStallByCanteenApi } from "@/api/base/stall";
import { mealTimeListApi,menuTypeListApi } from "@/api/dish/menu";
import { getCurrentRecipeListApi, getPageRecipeListApi,removeMenuRecipeApi,unbindMenuRecipeApi,menuUpLoadApi } from "@/api/dish/menu";
import { mealTimeListApi,menuTypeListApi } from "@/api/dish/menu";
import { getCurrentRecipeListApi, getPageRecipeListApi,removeMenuRecipeApi,unbindMenuRecipeApi,menuUpLoadApi } from "@/api/dish/menu";
import { getToken } from '@/utils/auth'
import { downloadFileByUrl } from '@/utils/download'
export default {
@ -287,7 +287,7 @@
//
total: 0,
//
tableListData: [],
tableListData: [],
activeName:"currentRecipe",
bindType:"",
//
@ -296,9 +296,9 @@
pageSize: 10,
key:"2",
applyDate:"",
areaId:null,
canteenId:null,
stallId:null,
areaId:null,
canteenId:null,
stallId:null,
recipeName:"",
},
mealTimeList:[],//
@ -327,26 +327,26 @@
],
recipeId: [
{ required: true, message: "菜谱名称不能为空", trigger: "change" }
]
]
},
//
upload: {
upload: {
//
isUploading: false,
isUploading: false,
//
headers: { Authorization: 'Bearer ' + getToken() },
//
url: process.env.VUE_APP_BASE_API + '/smart-canteen/menu_recipe/recipe/import/dishes',
},
url: process.env.VUE_APP_BASE_API + '/smart-canteen/cook_recipe/recipe/import/dishes',
},
uploadRow:{},
openUpload:false
};
},
created() {
created() {
this.getMealTimeList();
this.getMealTypeList();
this.daysList = this.getRecentWeekDates();
this.monthDaysList = this.getRecentMonthDates();
this.daysList = this.getRecentWeekDates();
this.monthDaysList = this.getRecentMonthDates();
// console.log(this.currentWeekList)
// console.log(this.monthDaysList)
this.queryParams.applyDate = this.daysList[0].data;
@ -354,12 +354,12 @@
this.getList()//
},
methods: {
handleTabClick(tab, event) {
handleTabClick(tab, event) {
console.log(tab.name,tab.label)
if(this.activeName=='currentRecipe'){
this.queryParams.key="2"
this.queryParams.applyDate = this.daysList[0].data;
}else if(this.activeName=='pageRecipe'){
this.queryParams.key=undefined
this.queryParams.applyDate=undefined
@ -367,7 +367,7 @@
this.handleQuery()
},
//
getMealTimeList() {
getMealTimeList() {
this.mealTimeList= [
{
mealtimeType:"1",
@ -392,10 +392,10 @@
]
// mealTimeListApi({}).then(response => {
// this.mealTimeList=response
// });
// });
},
//
getMealTypeList() {
getMealTypeList() {
// menuTypeListApi({}).then(response => {
// response.data.forEach(item=>{
// if(item.id==2||item.id==6||item.id==7||item.id==8){
@ -404,7 +404,7 @@
// })
this.menuTypeList = [{bindType: 7,id: 2,name: "智慧餐台/消费机"},{bindType: 1,id: 6,name: "移动端当餐点餐"},{bindType: 2,id: 7,name: "移动端预订餐"},{bindType: 3,id: 8,name: "移动端一周菜谱"}]
this.bindType = this.menuTypeList[0].bindType
// });
// });
},
choseMenuType(item){
this.bindType = item.bindType
@ -414,7 +414,7 @@
//
getRecentWeekDates() {
let currentDate = new Date(); //
let weekDates = [];
let weekDates = [];
for (let i = 0; i < 7; i++) {
let day = currentDate.getDate();
let month = currentDate.getMonth() + 1; // 0+1
@ -431,7 +431,7 @@
"dateValue":formattedDate,
"weekValue":days[dayOfWeek]
}
weekDates.push(obj);
weekDates.push(obj);
currentDate.setDate(currentDate.getDate() + 1); //
}
return weekDates;
@ -439,14 +439,14 @@
// 28
getRecentMonthDates() {
let currentDate = new Date(new Date().getTime()-24*60*60*1000); //
let monthDates = [];
let monthDates = [];
let month = new Date().getMonth() + 1; // 0+1
let year = new Date().getFullYear();
this.currentMonth = `${year}${month < 10 ? '0' + month : month}`;
for (let i = 0; i < 28; i++) {
let day = currentDate.getDate();
let month = currentDate.getMonth() + 1; // 0+1
let month = currentDate.getMonth() + 1; // 0+1
//
let formattedDate = `${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
//
@ -455,19 +455,19 @@
if(i<7){
this.currentWeekList.push(days[dayOfWeek])
}
monthDates.push(formattedDate);
monthDates.push(formattedDate);
currentDate.setDate(currentDate.getDate() + 1); //
}
}
return monthDates;
},
//
getAreaTreeData() {
systemAreaTreeApi({}).then((response) => {
this.treeAreaOptions = response.data;
this.treeAreaOptions = response.data;
});
},
//-
handleAreaChange(e){
handleAreaChange(e){
let param= {
areaId:this.queryParams.areaId,canteenType: 1
}
@ -479,7 +479,7 @@
});
},
//-
handleCanteenChange(e){
handleCanteenChange(e){
let param= {
canteenId:this.queryParams.canteenId
}
@ -487,8 +487,8 @@
this.stallOptions=response.rows||[]
this.queryParams.stallId=null
});
},
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
@ -501,9 +501,9 @@
pageSize: 10,
key:"2",
applyDate:this.daysList[0].data,
areaId:null,
canteenId:null,
stallId:null,
areaId:null,
canteenId:null,
stallId:null,
recipeName:"",
}
this.resetForm("queryForm");
@ -511,39 +511,39 @@
},
/** 查询当前菜谱列表 */
getList() {
this.loading = true;
this.loading = true;
this.queryParams.pageNum = this.queryParams.pageNum
this.queryParams.pageSize = this.queryParams.pageSize
if(this.activeName=='currentRecipe'){
if(this.activeName=='currentRecipe'){
getCurrentRecipeListApi(this.queryParams).then(response => {
this.tableListData = response.rows;
this.total = Number(response.total);
this.loading = false;
});
});
}else if(this.activeName=='pageRecipe'){
getPageRecipeListApi(this.queryParams).then(response => {
this.tableListData = response.rows;
this.total = Number(response.total);
this.loading = false;
});
});
}
},
},
/** 新增按钮操作 */
handleAdd() {
this.$router.push({ path: "/dish/menuDetail" });
this.$router.push({ path: "/dish/menuDetail" });
},
/** 修改按钮操作 */
handleUpdate(row) {
// let param = {
// let param = {
// recipeId:row.recipeId
// }
// getPageRecipeListApi(param).then(response => {
// let obj = response.rows[0]
this.$router.push({ path: "/dish/menuEdit",query: {pageJson:JSON.stringify(row)} });
// });
this.$router.push({ path: "/dish/menuEdit",query: {pageJson:JSON.stringify(row)} });
// });
},
/** 查看设备 */
handleDevice(row) {
@ -552,13 +552,13 @@
canteenId:row.canteenId,
stallId:row.stallId,
}
this.$router.push({ path: "/device/doubleScreen",query: obj });
this.$router.push({ path: "/device/doubleScreen",query: obj });
},
/** 删除按钮操作 */
handleDelete(row) {
console.log(row)
console.log(row)
this.$modal.confirm('是否确认删除菜谱?').then(function() {
return removeMenuRecipeApi({"recipeId":row.recipeId})
return removeMenuRecipeApi({"recipeId":row.recipeId})
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
@ -566,7 +566,7 @@
},
//-
handleUnbind(row) {
console.log(row)
console.log(row)
let param = {
bindType: this.bindType,
handleType: 2,//
@ -576,7 +576,7 @@
}
this.$modal.confirm('是否确认解绑菜谱?').then(function() {
return unbindMenuRecipeApi(param)
return unbindMenuRecipeApi(param)
}).then(() => {
this.getList();
this.$modal.msgSuccess("解绑成功");
@ -607,13 +607,13 @@
}
})
}
console.log(this.recipeOptions)
console.log(this.recipeOptions)
},
//-
confirmBindMenu(){
console.log(this.menuForm)
this.$refs["menuForm"].validate(valid => {
if (valid) {
if (valid) {
console.log(this.menuForm)
let param = {
bindType: this.bindType,
@ -627,12 +627,12 @@
this.openMenu=false
});
}
});
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (valid) {
if (this.form.cookId != undefined) {
// editMenuDishesCookApi(this.form).then(response => {
// this.$modal.msgSuccess("");
@ -651,31 +651,31 @@
},
/** 修改按钮操作 */
handleImport(row) {
handleImport(row) {
this.uploadRow = row
this.openUpload = true
this.openUpload = true
},
fileUpLoad(param){
param.recipeId = this.uploadRow.recipeId
menuUpLoadApi(param).then((res) => {
if (res.code == 200) {
this.$modal.msgSuccess("操作成功");
this.openUpload = false;
this.openUpload = false;
this.getList()
} else {
this.$modal.msgError(res.msg);
}
}).catch((error) => {
}).catch((error) => {
this.$modal.msgError(error)
})
},
},
/** 下载模板操作 */
importTemplate() {
let url = window.location.origin + '/glweb/template/导入菜谱模板.xlsx';
let url = window.location.origin + '/glweb/template/导入菜谱模板.xlsx';
downloadFileByUrl(url)
},
}
};
</script>
@ -690,7 +690,7 @@
color: #606266;
display: flex;align-items: center;justify-content: center;
border: 1px solid #e6ebf5;
}
.dateTable2{
width: 14%;
@ -700,4 +700,3 @@
border: 1px solid #FFF;
}
</style>