营养信息接口对接

This commit is contained in:
zzyuan 2025-05-27 17:53:00 +08:00
parent 4b2ea761fc
commit e098b0c988
5 changed files with 93 additions and 191 deletions

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 获取营养信息类别-树
export function nutritionTypeListApi(data) {
return request({
url: '/smart-canteen/menu_nutrition_type/nutritionTypeList',
url: '/smart-canteen/cook_nutrition_type/nutritionTypeList',
method: 'post',
data: data
})
@ -11,7 +11,7 @@ export function nutritionTypeListApi(data) {
// 新增营养类别接口-树
export function nutritionTypeAddApi(data) {
return request({
url: '/smart-canteen/menu_nutrition_type/add',
url: '/smart-canteen/cook_nutrition_type/add',
method: 'post',
data: data
})
@ -19,7 +19,7 @@ export function nutritionTypeAddApi(data) {
// 修改营养类别接口-树
export function nutritionTypeEditApi(data) {
return request({
url: '/smart-canteen/menu_nutrition_type/edit',
url: '/smart-canteen/cook_nutrition_type/edit',
method: 'post',
data: data
})
@ -27,9 +27,8 @@ export function nutritionTypeEditApi(data) {
// 删除营养类别接口-树
export function nutritionTypeDelApi(data) {
return request({
url: '/smart-canteen/menu_nutrition_type/del',
method: 'post',
data: data
url: '/smart-canteen/cook_nutrition_type/del/'+data.id,
method: 'post'
})
}
@ -37,28 +36,14 @@ export function nutritionTypeDelApi(data) {
// 查询获取所有营养信息
// 查询获取营养信息列表
export function listNutrition(query) {
return request({
url: '/smart-canteen/menu_nutrition/list',
method: 'post',
data: query,
params:{
pageNum:query.pageNum,
pageSize:query.pageSize
}
url: '/smart-canteen/cook_nutrition/list',
method: 'get',
params: query
})
}
// 查询详细
export function getNutrition(data) {
return request({
url: '/smart-canteen/menu_nutrition/getInfo',
method: 'post',
data: data
})
}
}
// 新增
export function addMenuNutrition(data) {
return request({
@ -71,7 +56,7 @@ export function addMenuNutrition(data) {
// 修改
export function updateNutrition(data) {
return request({
url: '/smart-canteen/menu_nutrition/edit',
url: '/smart-canteen/cook_nutrition/edit',
method: 'post',
data: data
})
@ -80,27 +65,43 @@ export function updateNutrition(data) {
// 删除
export function delNutrition(data) {
return request({
url: '/smart-canteen/menu_nutrition/del',
method: 'post',
data: data
url: '/smart-canteen/cook_nutrition/del/'+data.categoryId,
method: 'post'
})
}
// 查询详细数据
export function getNutritionInfo(data) {
return request({
url: '/smart-canteen/cook_nutrition/getInfo/'+data.nutritionId,
method: 'get',
})
}
// 获取所有营养信息
export function nutritionAllListApi(data) {
return request({
url: '/smart-canteen/menu_nutrition/getListByCategoryId',
url: '/smart-canteen/cook_nutrition/getListByCategoryId',
method: 'post',
data: data
})
}
// // 获取营养信息-详细数据
// export function nutritionDetailApi(nutritionId) {
// return request({
// url: '/smart-canteen/api/v1/menumaterial/nutrition/detail/'+nutritionId,
// method: 'post',
// // data: data
// })
// }
}

View File

@ -15,12 +15,6 @@
:picker-options="pickerOptions" >
</el-date-picker>
</el-form-item>
<!-- <el-form-item label="时间类型" prop="timeType">
<el-select v-model="queryParams.timeType" style="width: 240px" clearable>
<el-option label="下单时间" :value="1"></el-option>
<el-option label="支付时间" :value="2"></el-option>
</el-select>
</el-form-item> -->
<el-form-item label="关键字">
<el-input v-model="queryParams.searchValue" placeholder="请输入关键字" maxlength="20" clearable style="width: 240px"/>
</el-form-item>
@ -45,26 +39,6 @@
/>
</el-select>
</el-form-item>
<!-- <el-form-item label="交易类型" prop="flowTypeList">
<el-select v-model="queryParams.flowTypeList" multiple style="width: 240px" clearable>
<el-option label="消费" :value="110"></el-option>
<el-option label="消费补扣" :value="120"></el-option>
<el-option label="消费退款" :value="130"></el-option>
</el-select>
</el-form-item>
<el-form-item label="钱包类型" prop="accWalletIdList">
<el-select v-model="queryParams.accWalletIdList" multiple style="width: 240px" clearable>
<el-option label="个人钱包" value="1"></el-option>
<el-option label="补贴钱包" value="2"></el-option>
<el-option label="红包" value="4"></el-option>
</el-select>
</el-form-item>
<el-form-item label="是否在线" prop="ifOnlineList">
<el-select v-model="queryParams.ifOnlineList" multiple style="width: 240px" clearable>
<el-option label="是" value="1"></el-option>
<el-option label="否" value="2"></el-option>
</el-select>
</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>
@ -83,8 +57,7 @@
</el-table-column>
<el-table-column label="账户交易号" align="center" prop="tradeId" :show-overflow-tooltip="true" width="180"/>
<el-table-column label="用户编号" align="center" prop="userId" :show-overflow-tooltip="true" width="100"/>
<el-table-column label="用户姓名" align="center" prop="nickName" :show-overflow-tooltip="true" width="100"/>
<!-- <el-table-column label="用户手机号" align="center" prop="mobile" :show-overflow-tooltip="true" width="120"/> -->
<el-table-column label="用户姓名" align="center" prop="nickName" :show-overflow-tooltip="true" width="100"/>
<el-table-column label="所属组织" align="center" prop="deptFullName" :show-overflow-tooltip="true"/>
<el-table-column label="用户类别" align="center" prop="userType" :show-overflow-tooltip="true" width="120">
<template slot-scope="scope">

View File

@ -81,11 +81,8 @@
<template slot-scope="scope">
<span>{{ (scope.row.minSubBalLimit/100).toFixed(2) }}</span>
</template>
</el-table-column> -->
<!-- <el-table-column label="账户有效期" align="center" prop="endDate" :show-overflow-tooltip="true" width="150"/> -->
</el-table-column> -->
<!-- <el-table-column label="账户有效期" align="center" prop="endDate" :show-overflow-tooltip="true" width="150"/> -->
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
<template slot-scope="scope" v-if="scope.row.userId">
<el-button

View File

@ -105,12 +105,12 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="营养信息" prop="nutritionId">
<el-select v-model="form.nutritionId" placeholder="请选择营养信息" style="width: 100%" clearable @change="chosenNutrition">
<el-form-item label="营养信息" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择营养信息" style="width: 100%" clearable @change="chosenNutrition">
<el-option v-for="item in this.nutritionOptions"
:key="item.nutritionId"
:label="item.nutritionName"
:value="item.nutritionId"
:key="item.categoryId"
:label="item.categoryName"
:value="item.categoryId"
></el-option>
</el-select>
</el-form-item>
@ -235,7 +235,7 @@
<script>
import { systemAreaTreeApi } from "@/api/base/area";
import { systemMaterialTreeApi,getDrpUnitListApi } from "@/api/dish/material";
import { nutritionTypeListApi,nutritionAllListApi,getNutrition } from "@/api/dish/nutritionInfo";
import { nutritionTypeListApi,nutritionAllListApi,getNutritionInfo } from "@/api/dish/nutritionInfo";
export default {
name: "MaterialDialog",
props: {
@ -301,7 +301,7 @@ export default {
unitPrice: '',//()
barCode: '',//
nutritionType:null,//
nutritionId:null,//
categoryId:null,//
shelfLifeType:"1",//
shelfLifeDays:"",//
purPriceCeiling:'',//
@ -496,30 +496,24 @@ export default {
},
//
handleNutritionChange(value) {
console.log("选中营养信息类别",value)
let obj = this.getParentCategoryName(value)
this.bigType = obj.bigType
this.littleType = obj.label
// setTimeout(()=>{
this.nutritionAllList()
// },300)
console.log("选中营养信息类别",value)
// this.nutritionAllList()
},
//
nutritionAllList(){
let param = {
bigType:this.bigType,
littleType:this.littleType
}
nutritionAllListApi(param).then((response) => {
this.$set(this.form,"nutritionId",null)
this.$set(this.form,"categoryId",null)
this.nutritionOptions = response.data;
});
},
//
chosenNutrition(){
console.log("选中营养信息",this.form.nutritionId)
getNutrition({nutritionId: this.form.nutritionId}).then((response) => {
console.log("选中营养信息",this.form.categoryId)
getNutritionInfo({categoryId: this.form.categoryId}).then((response) => {
if(response.data){
this.form.menuMaterialNutritionDTO = response.data
this.formTable = [this.form.menuMaterialNutritionDTO]
@ -640,9 +634,9 @@ export default {
this.littleType = obj.label
this.nutritionAllList()
setTimeout(()=>{
this.$set(this.form,"nutritionId",row.nutritionId)
if(this.form.nutritionId){
getNutrition({nutritionId: this.form.nutritionId}).then((response) => {
this.$set(this.form,"categoryId",row.categoryId)
if(this.form.categoryId){
getNutritionInfo({categoryId: this.form.categoryId}).then((response) => {
if(response.data){
this.form.menuMaterialNutritionDTO = response.data
this.formTable = [this.form.menuMaterialNutritionDTO]
@ -698,7 +692,7 @@ export default {
unitPrice: '',//()
barCode: '',//
nutritionType:null,//
nutritionId:null,//
categoryId:null,//
shelfLifeType:"1",//
shelfLifeDays:"",//
purPriceCeiling:'',//

View File

@ -36,7 +36,7 @@
<el-button
type="text"
size="mini"
icon="el-icon-plus" v-if="data.level<2"
icon="el-icon-plus" v-if="data.level<1"
@click.stop="() => appendTreeNode(data)"
>
</el-button>
@ -63,29 +63,7 @@
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
<!-- <el-form-item label="营养信息类别" prop="type" >
<el-cascader
v-model="typeSelected" clearable
:options="cascaderOptions"
:props="{
emitPath: true,// falseid
checkStrictly: false,//
value:'label',label:'label'
}"
@change="handleChange"
></el-cascader>
</el-form-item> -->
<el-form-item label="食材编码" prop="nutritionCode">
<el-input
v-model="queryParams.nutritionCode"
placeholder="请输入食材编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
<el-form-item label="营养信息名称" prop="nutritionName">
<el-input
v-model="queryParams.nutritionName"
@ -122,8 +100,8 @@
</template>
</el-table-column>
<el-table-column label="食材编码" align="center" prop="nutritionCode" />
<el-table-column label="食材大类" align="center" prop="bigType" />
<el-table-column label="食材小类" align="center" prop="littleType" />
<el-table-column label="食材大类" align="center" prop="bigTypeName" />
<el-table-column label="食材小类" align="center" prop="smallTypeName" />
<el-table-column label="营养信息名称" align="center" prop="nutritionName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
@ -164,8 +142,8 @@
<el-form-item label="父节点名称" prop="parentName" v-if="typeForm.parentName">
<el-input v-model="typeForm.parentName" placeholder="请输入父节点名称" maxlength="30" disabled/>
</el-form-item>
<el-form-item label="类别名称" prop="name">
<el-input v-model="typeForm.name" placeholder="请输入类别名称" maxlength="30"/>
<el-form-item label="类别名称" prop="nutritionTypeName">
<el-input v-model="typeForm.nutritionTypeName" placeholder="请输入类别名称" maxlength="30"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -180,9 +158,9 @@
<el-form ref="form" :model="form" :rules="rules" label-width="180px">
<el-row>
<el-col :span="12">
<el-form-item label="营养信息类别" prop="categoryId">
<el-form-item label="营养信息类别" prop="nutritionTypeId">
<el-cascader
v-model="form.categoryId"
v-model="form.nutritionTypeId"
:options="cascaderOptions"
:props="{
emitPath: false,// falseid
@ -832,7 +810,7 @@
<script>
import { nutritionTypeListApi,nutritionTypeAddApi, nutritionTypeEditApi, nutritionTypeDelApi } from "@/api/dish/nutritionInfo";
import { listNutrition, getNutrition, delNutrition, addMenuNutrition, updateNutrition } from "@/api/dish/nutritionInfo";
import { listNutrition, getNutritionInfo, delNutrition, addMenuNutrition, updateNutrition } from "@/api/dish/nutritionInfo";
import { cascaderMixin } from './cascaderMixin';
export default {
@ -858,11 +836,7 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
nutritionCode: undefined,
nutritionName: undefined,
// type: undefined,
bigType: undefined,
littleType: undefined
nutritionName: undefined,
},
//
form: {
@ -950,9 +924,7 @@ export default {
getNutritionTypeList() {
nutritionTypeListApi().then(response => {
this.typeTreeData = response.data;
this.cascaderOptions = this.cascaderOptionsMethod();
console.log(this.cascaderOptions)
// this.updateCascaderOptions(); //
this.cascaderOptions = this.cascaderOptionsMethod();
}).catch(error => {
console.error("Failed to fetch food types:", error);
});
@ -964,15 +936,15 @@ export default {
}
return this.typeTreeData.map(item => ({
id: item.id,
label: item.bigType,
label: item.name,
parentId:0,
level:1,
level:0,
children: item.littleTypeList.map(subItem => ({
id: subItem.id,//value#
label: subItem.bigType,
bigType: item.bigType,
label: subItem.name,
bigType: item.name,
parentId:item.id,
level:2
level:1
}))
}));
},
@ -998,7 +970,7 @@ export default {
this.typeForm.parentName = data.label;
}else{
this.typeForm={}
this.typeForm.parentId = 0;
this.typeForm.parentId = 0;
}
this.resetForm("typeForm");
this.openType = true;
@ -1009,8 +981,9 @@ export default {
console.log(data)
this.typeForm={}
this.resetForm("typeForm");
this.$set(this.typeForm,"id",data.id)
this.$set(this.typeForm,"name",data.label)
this.$set(this.typeForm,"parentId","")
this.$set(this.typeForm,"nutritionTypeId",data.id)
this.$set(this.typeForm,"nutritionTypeName",data.label)
// this.typeForm = {
// ...data
// };
@ -1023,7 +996,7 @@ export default {
this.$modal
.confirm("是否确认删除数据项?")
.then(function () {
return nutritionTypeDelApi({ids:[data.id]});
return nutritionTypeDelApi({id:data.id});
})
.then(() => {
this.$modal.msgSuccess("删除成功");
@ -1042,7 +1015,7 @@ export default {
console.log(this.typeForm)
this.$refs.typeForm.validate(valid => {
if (valid) {
if (this.typeForm.id != undefined) {
if (this.typeForm.nutritionTypeId != undefined) {
console.log('修改')
nutritionTypeEditApi(this.typeForm).then(response => {
this.$modal.msgSuccess("修改成功");
@ -1059,27 +1032,16 @@ export default {
}
}
});
},
/**
* 处理级联选择器值变化
* @param {Array<string>} value - 选中的值数组
*/
handleChange(value) {
console.log(value)
if (value && value.length >= 2) {
this.queryParams.bigType = value[0];
this.queryParams.littleType = value[1];
} else {
this.queryParams.bigType = undefined;
this.queryParams.littleType = undefined;
}
},
/** 查询列表 */
getList() {
this.loading = true;
// console.log(this.$refs.nutritionTypeTree.getCheckedKeys())
let arr = this.$refs.nutritionTypeTree.getCheckedKeys()||[]
this.queryParams.categoryIds = arr;
if(arr.length>0){
this.queryParams.nutritionTypeIds = arr.join(",");
}else{
this.queryParams.nutritionTypeIds = null
}
console.log(this.queryParams)
listNutrition(this.queryParams).then(response => {
this.menuNutritionList = response.rows;
@ -1141,10 +1103,7 @@ export default {
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.$refs.nutritionTypeTree.setCheckedNodes([]);
// this.typeSelected = []; //
// this.queryParams.bigType = undefined;
// this.queryParams.littleType = undefined;
this.$refs.nutritionTypeTree.setCheckedNodes([]);
this.handleQuery();
},
/** 新增按钮操作 */
@ -1155,49 +1114,27 @@ export default {
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// const id = row.nutritionId;
this.reset();
var data = {
nutritionId: row.nutritionId
}
getNutrition(data).then(response => {
getNutritionInfo(data).then(response => {
this.form = response.data;
this.formTable = [this.form]
this.$set(this.form,"categoryId",Number(response.data.categoryId))
this.chosenType(this.form.categoryId)
this.$set(this.form,"nutritionTypeId",Number(response.data.smallTypeId))
this.open = true;
this.title = "修改营养信息";
});
},
//
getParentCategoryName(Id) {
const findNode = (nodes) => {
for (let node of nodes) {
if (node.id === Id) {
return node;
}
if (node.children) {
const result = findNode(node.children);
if (result) return result;
}
}
return "";
};
return findNode(this.cascaderOptions);
},
chosenType(e){
console.log(e)
let obj = this.getParentCategoryName(e)
this.form.bigType = obj.bigType
this.form.littleType = obj.label
console.log(this.form)
console.log(e)
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
const formData = { ...this.form };
if (formData.id != undefined) {
if (formData.nutritionId != undefined) {
updateNutrition(formData).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;