营养信息接口对接

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) { export function nutritionTypeListApi(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition_type/nutritionTypeList', url: '/smart-canteen/cook_nutrition_type/nutritionTypeList',
method: 'post', method: 'post',
data: data data: data
}) })
@ -11,7 +11,7 @@ export function nutritionTypeListApi(data) {
// 新增营养类别接口-树 // 新增营养类别接口-树
export function nutritionTypeAddApi(data) { export function nutritionTypeAddApi(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition_type/add', url: '/smart-canteen/cook_nutrition_type/add',
method: 'post', method: 'post',
data: data data: data
}) })
@ -19,7 +19,7 @@ export function nutritionTypeAddApi(data) {
// 修改营养类别接口-树 // 修改营养类别接口-树
export function nutritionTypeEditApi(data) { export function nutritionTypeEditApi(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition_type/edit', url: '/smart-canteen/cook_nutrition_type/edit',
method: 'post', method: 'post',
data: data data: data
}) })
@ -27,9 +27,8 @@ export function nutritionTypeEditApi(data) {
// 删除营养类别接口-树 // 删除营养类别接口-树
export function nutritionTypeDelApi(data) { export function nutritionTypeDelApi(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition_type/del', url: '/smart-canteen/cook_nutrition_type/del/'+data.id,
method: 'post', method: 'post'
data: data
}) })
} }
@ -37,28 +36,14 @@ export function nutritionTypeDelApi(data) {
// 查询获取所有营养信息 // 查询获取营养信息列表
export function listNutrition(query) { export function listNutrition(query) {
return request({ return request({
url: '/smart-canteen/menu_nutrition/list', url: '/smart-canteen/cook_nutrition/list',
method: 'post', method: 'get',
data: query, params: query
params:{
pageNum:query.pageNum,
pageSize:query.pageSize
}
}) })
} }
// 查询详细
export function getNutrition(data) {
return request({
url: '/smart-canteen/menu_nutrition/getInfo',
method: 'post',
data: data
})
}
// 新增 // 新增
export function addMenuNutrition(data) { export function addMenuNutrition(data) {
return request({ return request({
@ -71,7 +56,7 @@ export function addMenuNutrition(data) {
// 修改 // 修改
export function updateNutrition(data) { export function updateNutrition(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition/edit', url: '/smart-canteen/cook_nutrition/edit',
method: 'post', method: 'post',
data: data data: data
}) })
@ -80,27 +65,43 @@ export function updateNutrition(data) {
// 删除 // 删除
export function delNutrition(data) { export function delNutrition(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition/del', url: '/smart-canteen/cook_nutrition/del/'+data.categoryId,
method: 'post', method: 'post'
data: data
}) })
} }
// 查询详细数据
export function getNutritionInfo(data) {
return request({
url: '/smart-canteen/cook_nutrition/getInfo/'+data.nutritionId,
method: 'get',
})
}
// 获取所有营养信息 // 获取所有营养信息
export function nutritionAllListApi(data) { export function nutritionAllListApi(data) {
return request({ return request({
url: '/smart-canteen/menu_nutrition/getListByCategoryId', url: '/smart-canteen/cook_nutrition/getListByCategoryId',
method: 'post', method: 'post',
data: data 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" > :picker-options="pickerOptions" >
</el-date-picker> </el-date-picker>
</el-form-item> </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-form-item label="关键字">
<el-input v-model="queryParams.searchValue" placeholder="请输入关键字" maxlength="20" clearable style="width: 240px"/> <el-input v-model="queryParams.searchValue" placeholder="请输入关键字" maxlength="20" clearable style="width: 240px"/>
</el-form-item> </el-form-item>
@ -45,26 +39,6 @@
/> />
</el-select> </el-select>
</el-form-item> </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-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@ -83,8 +57,7 @@
</el-table-column> </el-table-column>
<el-table-column label="账户交易号" align="center" prop="tradeId" :show-overflow-tooltip="true" width="180"/> <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="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="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="deptFullName" :show-overflow-tooltip="true"/> <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"> <el-table-column label="用户类别" align="center" prop="userType" :show-overflow-tooltip="true" width="120">
<template slot-scope="scope"> <template slot-scope="scope">

View File

@ -81,11 +81,8 @@
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ (scope.row.minSubBalLimit/100).toFixed(2) }}</span> <span>{{ (scope.row.minSubBalLimit/100).toFixed(2) }}</span>
</template> </template>
</el-table-column> --> </el-table-column> -->
<!-- <el-table-column label="账户有效期" align="center" prop="endDate" :show-overflow-tooltip="true" width="150"/> -->
<!-- <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"> <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"> <template slot-scope="scope" v-if="scope.row.userId">
<el-button <el-button

View File

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

View File

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