|
@@ -0,0 +1,426 @@
|
|
|
|
+<template>
|
|
|
|
+ <div style="overflow-y: scroll;" :style=divStyle>
|
|
|
|
+ <el-card shadow="always">
|
|
|
|
+ <el-button type="primary" plain size="large" @click="close()">返回</el-button>
|
|
|
|
+ <span style="margin-left: 20px;">{{isView?'查看食谱':form.foodIngredientId?'编辑食谱':'食谱管理'}}</span>
|
|
|
|
+ <el-divider />
|
|
|
|
+ <div style="font-size: 14px; margin-top: -10px;margin-bottom: -10px;">基本信息</div>
|
|
|
|
+ <el-divider />
|
|
|
|
+ <div width="1024px" >
|
|
|
|
+ <el-form ref="foodIngredientFormRef" :model="form" :rules="rules" append-to-body label-width="130px">
|
|
|
|
+ <el-row style="margin-top: 20px;">
|
|
|
|
+ <el-col :span="24" style="margin-left: 100px;">
|
|
|
|
+ <div><span style="color: red;"> </span></div>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="基本膳食" prop="baseDiet">
|
|
|
|
+ <el-radio-group v-model="form.baseDiet">
|
|
|
|
+ <el-radio v-for="item in dietary_types" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="餐次" prop="mealTime">
|
|
|
|
+ <el-checkbox-group v-model="form.mealTimes">
|
|
|
|
+ <el-checkbox v-for="item in meal_times" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
+ </el-checkbox-group>
|
|
|
|
+
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="食谱名称" prop="name">
|
|
|
|
+ <el-input v-model="form.name" placeholder="请输入" :disabled="isView"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="食谱分类" prop="edibleRatio">
|
|
|
|
+ <el-select v-model="form.unit" placeholder="请选择" clearable :disabled="isView">
|
|
|
|
+ <el-option v-for="dict in food_unit" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="食谱价格" prop="shelfLife">
|
|
|
|
+ <el-input v-model="form.shelfLife" placeholder="请输入" :disabled="isView"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="适用疾病" prop="stockWarning">
|
|
|
|
+ <el-input v-model="form.stockWarning" placeholder="请输入" :disabled="isView"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="忌食病症" prop="expiryWarning">
|
|
|
|
+ <el-input v-model="form.expiryWarning" placeholder="请输入" :disabled="isView"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="适用科室" prop="expiryWarning">
|
|
|
|
+ <el-input v-model="form.expiryWarning" placeholder="请输入" :disabled="isView"/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="2" style="margin-left: -100px;">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="9">
|
|
|
|
+ <el-form-item label="智能推荐" prop="smartRecommend">
|
|
|
|
+ <el-radio-group v-model="form.smartRecommend" :disabled="isView">
|
|
|
|
+ <el-radio v-for="item in intelligent_recommendation" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
|
|
|
|
+ </el-radio-group>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-form>
|
|
|
|
+
|
|
|
|
+ <el-divider />
|
|
|
|
+ <div style="font-size: 14px;margin-top: -10px;margin-bottom: -10px;">食材组成</div>
|
|
|
|
+ <el-divider />
|
|
|
|
+ <div style="margin-top: 10px; margin-bottom: 20px;"><span>食材总量:111.0000 g</span><span style="margin-left: 100px;">膳食总热量:410.70kcal</span></div>
|
|
|
|
+ <el-table border :data="foodIngredientList" @selection-change="handleSelectionChange">
|
|
|
|
+ <!-- <el-table-column type="selection" width="55" align="center" /> -->
|
|
|
|
+ <el-table-column label="食材名称" align="center" prop="bigCategory" />
|
|
|
|
+ <el-table-column label="食材分类" align="center" prop="subCategory" />
|
|
|
|
+ <el-table-column label="用量" align="center" prop="name" />
|
|
|
|
+ <el-table-column label="热量(kcal)" align="center" prop="name" />
|
|
|
|
+ <el-table-column label="备注" align="center" prop="name" />
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-tooltip content="删除" placement="top">
|
|
|
|
+ <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:foodIngredient:remove']">删除</el-button>
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8" align="center" style="margin-top: 30PX;">
|
|
|
|
+ <el-link type="primary" icon="Plus" @click="handleDelete()">添加食材</el-link>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
|
+ <el-col :span="24">
|
|
|
|
+ <el-form-item label="制作方式" prop="description">
|
|
|
|
+ <el-input v-model="form.description" type="textarea" placeholder="请输入" :disabled="isView" :rows="3" maxlength="3000" show-word-limit/>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <el-card shadow="always" class="card-footer" v-if="!isView">
|
|
|
|
+ <div>
|
|
|
|
+ <el-button type="primary" size="large" plain @click="close" v-hasPermi="['system:hospital:add']">
|
|
|
|
+ 营养数据分析
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button type="primary" size="large" @click="submitForm" v-hasPermi="['system:hospital:add']">
|
|
|
|
+ 提交
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup name="FoodIngredient" lang="ts">
|
|
|
|
+import { listTree} from '@/api/system/foodCategory';
|
|
|
|
+
|
|
|
|
+import { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe } from '@/api/system/recipe';
|
|
|
|
+import { RecipeVO, RecipeQuery, RecipeForm } from '@/api/system/recipe/types';
|
|
|
|
+
|
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
+const { intelligent_recommendation,meal_times,dietary_types } = toRefs<any>(proxy?.useDict('intelligent_recommendation','meal_times','dietary_types'));
|
|
|
|
+
|
|
|
|
+const recipeList = ref<RecipeVO[]>([]);
|
|
|
|
+const buttonLoading = ref(false);
|
|
|
|
+const loading = ref(true);
|
|
|
|
+const showSearch = ref(true);
|
|
|
|
+const ids = ref<Array<string | number>>([]);
|
|
|
|
+const single = ref(true);
|
|
|
|
+const multiple = ref(true);
|
|
|
|
+const total = ref(0);
|
|
|
|
+
|
|
|
|
+const divStyle = ref({
|
|
|
|
+ height: '755px'
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const queryFormRef = ref<ElFormInstance>();
|
|
|
|
+const isView = ref<boolean>(false)
|
|
|
|
+const route = useRoute();
|
|
|
|
+
|
|
|
|
+const dialog = reactive<DialogOption>({
|
|
|
|
+ visible: false,
|
|
|
|
+ title: ''
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const initFormData: RecipeForm = {
|
|
|
|
+ recipeId: undefined,
|
|
|
|
+ name: undefined,
|
|
|
|
+ categoryId: undefined,
|
|
|
|
+ baseDiet: '1',
|
|
|
|
+ mealTime: undefined,
|
|
|
|
+ price: undefined,
|
|
|
|
+ suitableDisease: undefined,
|
|
|
|
+ avoidDisease: undefined,
|
|
|
|
+ suitableDept: undefined,
|
|
|
|
+ smartRecommend: '1',
|
|
|
|
+ cookingMethod: undefined,
|
|
|
|
+ status: undefined,
|
|
|
|
+}
|
|
|
|
+const data = reactive<PageData<RecipeForm, RecipeQuery>>({
|
|
|
|
+ form: {...initFormData},
|
|
|
|
+ queryParams: {
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 10,
|
|
|
|
+ name: undefined,
|
|
|
|
+ categoryId: undefined,
|
|
|
|
+ baseDiet: undefined,
|
|
|
|
+ mealTime: undefined,
|
|
|
|
+ price: undefined,
|
|
|
|
+ suitableDisease: undefined,
|
|
|
|
+ avoidDisease: undefined,
|
|
|
|
+ suitableDept: undefined,
|
|
|
|
+ smartRecommend: undefined,
|
|
|
|
+ cookingMethod: undefined,
|
|
|
|
+ status: undefined,
|
|
|
|
+ params: {
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ rules: {
|
|
|
|
+ recipeId: [
|
|
|
|
+ { required: true, message: "主键ID不能为空", trigger: "blur" }
|
|
|
|
+ ],
|
|
|
|
+ name: [
|
|
|
|
+ { required: true, message: "食谱名称不能为空", trigger: "blur" }
|
|
|
|
+ ],
|
|
|
|
+ categoryId: [
|
|
|
|
+ { required: true, message: "食谱分类ID不能为空", trigger: "blur" }
|
|
|
|
+ ],
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/** 关闭按钮 */
|
|
|
|
+const close = () => {
|
|
|
|
+ const obj: RouteLocationNormalized = {
|
|
|
|
+ fullPath: '',
|
|
|
|
+ hash: '',
|
|
|
|
+ matched: [],
|
|
|
|
+ meta: undefined,
|
|
|
|
+ name: undefined,
|
|
|
|
+ params: undefined,
|
|
|
|
+ query: undefined,
|
|
|
|
+ redirectedFrom: undefined,
|
|
|
|
+ path: '/food/recipe'
|
|
|
|
+ };
|
|
|
|
+ proxy?.$tab.closeOpenPage(obj);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getListTree = async () => {
|
|
|
|
+ const res = await listTree(queryParams.value);
|
|
|
|
+ foodCategoryList.value = res.rows;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 查询食材管理列表 */
|
|
|
|
+const getList = async () => {
|
|
|
|
+ const foodIngredientId = route.params && route.params.id;
|
|
|
|
+ const vfoodIngredientId = route.params && route.params.vid;
|
|
|
|
+ let id=undefined;
|
|
|
|
+ if(vfoodIngredientId){
|
|
|
|
+ isView.value=true;
|
|
|
|
+ id=vfoodIngredientId;
|
|
|
|
+ }else{
|
|
|
|
+ isView.value=false ;
|
|
|
|
+ id=foodIngredientId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (id&&id!='0') {
|
|
|
|
+ loading.value = true;
|
|
|
|
+ const res = await getFoodIngredient(id as string);
|
|
|
|
+ Object.assign(form.value, res.data);
|
|
|
|
+ form.value.foodCategoryIds=res.data.foodCategoryId.toString().split(',') ;
|
|
|
|
+ console.log(form.value.foodCategoryIds)
|
|
|
|
+ loading.value = false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 取消按钮 */
|
|
|
|
+const cancel = () => {
|
|
|
|
+ reset();
|
|
|
|
+ dialog.visible = false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 表单重置 */
|
|
|
|
+const reset = () => {
|
|
|
|
+ form.value = {...initFormData};
|
|
|
|
+ foodIngredientFormRef.value?.resetFields();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 搜索按钮操作 */
|
|
|
|
+const handleQuery = () => {
|
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
|
+ getList();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 重置按钮操作 */
|
|
|
|
+const resetQuery = () => {
|
|
|
|
+ queryFormRef.value?.resetFields();
|
|
|
|
+ handleQuery();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 多选框选中数据 */
|
|
|
|
+const handleSelectionChange = (selection: FoodIngredientVO[]) => {
|
|
|
|
+ ids.value = selection.map(item => item.foodIngredientId);
|
|
|
|
+ single.value = selection.length != 1;
|
|
|
|
+ multiple.value = !selection.length;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 新增按钮操作 */
|
|
|
|
+const handleAdd = () => {
|
|
|
|
+ reset();
|
|
|
|
+ dialog.visible = true;
|
|
|
|
+ dialog.title = "添加食材管理";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 修改按钮操作 */
|
|
|
|
+const handleUpdate = async (row?: FoodIngredientVO) => {
|
|
|
|
+ reset();
|
|
|
|
+ const _foodIngredientId = row?.foodIngredientId || ids.value[0]
|
|
|
|
+ const res = await getFoodIngredient(_foodIngredientId);
|
|
|
|
+ Object.assign(form.value, res.data);
|
|
|
|
+ dialog.visible = true;
|
|
|
|
+ dialog.title = "修改食材管理";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 提交按钮 */
|
|
|
|
+const submitForm = () => {
|
|
|
|
+ foodIngredientFormRef.value?.validate(async (valid: boolean) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ buttonLoading.value = true;
|
|
|
|
+ let params=ref<FoodIngredientForm>({});
|
|
|
|
+ Object.assign(params.value, form.value);
|
|
|
|
+ params.value.foodCategoryId = form.value.foodCategoryIds.join(',')
|
|
|
|
+ if (form.value.foodIngredientId) {
|
|
|
|
+ await updateFoodIngredient(params.value).finally(() => buttonLoading.value = false);
|
|
|
|
+ } else {
|
|
|
|
+ await addFoodIngredient(params.value).then(res=>{
|
|
|
|
+ form.value.foodIngredientId=res.data;
|
|
|
|
+ }).finally(() => buttonLoading.value = false);
|
|
|
|
+ }
|
|
|
|
+ proxy?.$modal.msgSuccess("操作成功");
|
|
|
|
+ if(currentIndex.value=='2'){
|
|
|
|
+ close()
|
|
|
|
+ }else{
|
|
|
|
+ currentIndex.value='2';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 删除按钮操作 */
|
|
|
|
+const handleDelete = async (row?: FoodIngredientVO) => {
|
|
|
|
+ const _foodIngredientIds = row?.foodIngredientId || ids.value;
|
|
|
|
+ await proxy?.$modal.confirm('是否确认删除食材管理编号为"' + _foodIngredientIds + '"的数据项?').finally(() => loading.value = false);
|
|
|
|
+ await delFoodIngredient(_foodIngredientIds);
|
|
|
|
+ proxy?.$modal.msgSuccess("删除成功");
|
|
|
|
+ await getList();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/** 导出按钮操作 */
|
|
|
|
+const handleExport = () => {
|
|
|
|
+ proxy?.download('system/foodIngredient/export', {
|
|
|
|
+ ...queryParams.value
|
|
|
|
+ }, `foodIngredient_${new Date().getTime()}.xlsx`)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const handleSelect = (key: string, keyPath: string[]) => {
|
|
|
|
+ currentIndex.value=key.toString()
|
|
|
|
+ // console.log(key, keyPath,currentIndex)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ getListTree()
|
|
|
|
+ getList();
|
|
|
|
+ let timerId=setInterval(() => {
|
|
|
|
+ if(food_unit&&food_unit.value.length>0){
|
|
|
|
+ form.value.unit=food_unit.value[0].value;
|
|
|
|
+ clearInterval(timerId);
|
|
|
|
+ }
|
|
|
|
+ }, 300);
|
|
|
|
+
|
|
|
|
+});
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.card-footer{
|
|
|
|
+ z-index: 99;
|
|
|
|
+ bottom: 0px;
|
|
|
|
+ left: calc(var(--left-menu-max-width) + var(--app-content-padding));
|
|
|
|
+ right: 0px;
|
|
|
|
+ height: 90px;
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: center;
|
|
|
|
+ align-items: center;
|
|
|
|
+}
|
|
|
|
+</style>
|