chenying2100 1 månad sedan
förälder
incheckning
7463d3b436

+ 30 - 2
.specstory/history/2025-06-24_02-08-调整表单label宽度以完全显示.md → .specstory/history/2025-06-24_02-08Z-调整表单label宽度以完全显示.md

@@ -1,6 +1,6 @@
 <!-- Generated by SpecStory -->
 
-# 调整表单label宽度以完全显示 (2025-06-24 10:08:34)
+# 调整表单label宽度以完全显示 (2025-06-24 02:08Z)
 
 _**User**_
 
@@ -2646,7 +2646,35 @@ _**Assistant**_
 
 ---
 
-已为
+已为 `sys_recipe_food_ingredient` 关联表增加了一个热量字段,字段如下:
+
+```sql
+calories DECIMAL(10,2) DEFAULT 0.00 COMMENT '热量(kcal)'
+```
+
+完整表结构片段如下:
+
+```sql
+CREATE TABLE sys_recipe_food_ingredient (
+    id                  BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    recipe_id           BIGINT NOT NULL COMMENT '食谱ID',
+    food_ingredient_id  BIGINT NOT NULL COMMENT '食材ID',
+    quantity            DECIMAL(10,2) DEFAULT 0.00 COMMENT '用量(可选,单位自定义)',
+    unit                VARCHAR(20) DEFAULT NULL COMMENT '用量单位(如g、ml等,可选)',
+    calories            DECIMAL(10,2) DEFAULT 0.00 COMMENT '热量(kcal)',
+    sort                INT DEFAULT 0 COMMENT '排序(可选)',
+    create_time         DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_time         DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    remark              VARCHAR(255) DEFAULT NULL COMMENT '备注',
+    UNIQUE KEY uniq_recipe_food (recipe_id, food_ingredient_id),
+    INDEX idx_recipe_id (recipe_id),
+    INDEX idx_food_ingredient_id (food_ingredient_id),
+    FOREIGN KEY (recipe_id) REFERENCES sys_recipe(id),
+    FOREIGN KEY (food_ingredient_id) REFERENCES sys_food_ingredient(id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='食谱与食材关联表';
+```
+
+如需添加更多营养成分字段或有其他需求,请随时告知!
 
 ---
 

+ 1 - 1
src/api/system/recipe/types.ts

@@ -92,7 +92,7 @@ export interface RecipeForm extends BaseEntity {
   /**
    * 食谱价格
    */
-  price?: number;
+  price?: string |number;
 
   /**
    * 适用疾病(可用逗号分隔多个)

+ 63 - 0
src/api/system/recipeCategory/index.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { RecipeCategoryVO, RecipeCategoryForm, RecipeCategoryQuery } from '@/api/system/recipeCategory/types';
+
+/**
+ * 查询食谱分类管理列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listRecipeCategory = (query?: RecipeCategoryQuery): AxiosPromise<RecipeCategoryVO[]> => {
+  return request({
+    url: '/system/recipeCategory/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询食谱分类管理详细
+ * @param recipeCategoryId
+ */
+export const getRecipeCategory = (recipeCategoryId: string | number): AxiosPromise<RecipeCategoryVO> => {
+  return request({
+    url: '/system/recipeCategory/' + recipeCategoryId,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增食谱分类管理
+ * @param data
+ */
+export const addRecipeCategory = (data: RecipeCategoryForm) => {
+  return request({
+    url: '/system/recipeCategory',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改食谱分类管理
+ * @param data
+ */
+export const updateRecipeCategory = (data: RecipeCategoryForm) => {
+  return request({
+    url: '/system/recipeCategory',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除食谱分类管理
+ * @param recipeCategoryId
+ */
+export const delRecipeCategory = (recipeCategoryId: string | number | Array<string | number>) => {
+  return request({
+    url: '/system/recipeCategory/' + recipeCategoryId,
+    method: 'delete'
+  });
+};

+ 71 - 0
src/api/system/recipeCategory/types.ts

@@ -0,0 +1,71 @@
+export interface RecipeCategoryVO {
+  /**
+   * 主键ID
+   */
+  recipeCategoryId: string | number;
+
+  /**
+   * 食谱分类名称
+   */
+  name: string;
+
+  /**
+   * 排序
+   */
+  sort: number;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status: string;
+
+}
+
+export interface RecipeCategoryForm extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  recipeCategoryId?: string | number;
+
+  /**
+   * 食谱分类名称
+   */
+  name?: string;
+
+  /**
+   * 排序
+   */
+  sort?: number;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+}
+
+export interface RecipeCategoryQuery extends PageQuery {
+
+  /**
+   * 食谱分类名称
+   */
+  name?: string;
+
+  /**
+   * 排序
+   */
+  sort?: number;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+    /**
+     * 日期范围参数
+     */
+    params?: any;
+}
+
+
+

+ 1 - 1
src/types/global.d.ts

@@ -28,7 +28,7 @@ declare global {
      */
     visible: boolean;
 
-    disabled: boolean;
+    disabled?: boolean;
   }
 
   declare interface UploadOption {

+ 534 - 256
src/views/system/recipe/add.vue

@@ -1,209 +1,415 @@
 <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 />
+    <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" >
+      <div width="1024px">
         <el-form ref="foodIngredientFormRef" :model="form" :rules="rules" append-to-body label-width="130px">
-          <el-row style="margin-top: 20px;">                  
+          <el-row style="margin-top: 20px;">
             <el-col :span="24" style="margin-left: 100px;">
-              <div><span style="color: red;">&nbsp; </span></div>    
-            </el-col>                   
-          </el-row> 
-          <el-row>            
-            <el-col :span="2" style="margin-left: -100px;">              
+              <div><span style="color: red;">&nbsp; </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-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-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>
+            <el-col :span="2">
+            </el-col>
+            <el-col :span="9">
+            </el-col>
             <el-col :span="2">
-            </el-col>  
-            <el-col :span="9">               
-            </el-col>  
-            <el-col :span="2">               
-            </el-col>              
+            </el-col>
           </el-row>
 
-          <el-row>            
-            <el-col :span="2" style="margin-left: -100px;">              
+          <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-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-col>
+            <el-col :span="2">
+            </el-col>
           </el-row>
 
-          <el-row>            
-            <el-col :span="2" style="margin-left: -100px;">              
+          <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-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-form-item label="食谱分类" prop="categoryId">
+                <el-select v-model="form.categoryId" placeholder="请选择" clearable :disabled="isView">
+                  <el-option v-for="dict in recipeCategoryList" :key="dict.recipeCategoryId" :label="dict.name"
+                    :value="dict.recipeCategoryId"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="2">
+            </el-col>
           </el-row>
 
-          <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-form-item label="食谱价格" prop="price">
+                <el-input v-model="form.price" 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-form-item label="适用疾病" prop="suitableDisease">
+                <span style="width: 100%;" @click="openAvoidDiseaseDialog">
+                  <el-input v-model="form.suitableDisease" placeholder="请选择" :disabled="isView" readonly>
+                  <template #suffix>
+                    <el-icon class="el-input__icon">
+                      <ArrowDown />
+                    </el-icon>
+                  </template>
+                </el-input>
+                </span>                
+              </el-form-item>
+            </el-col>
+            <el-col :span="2">
+            </el-col>
           </el-row>
 
-          <el-row>            
-            <el-col :span="2" style="margin-left: -100px;">              
+          <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-form-item label="忌食病症" prop="avoidDisease">
+                <span style="width: 100%;" @click="openAvoidDiseaseDialog2">
+                  <el-input v-model="form.avoidDisease" placeholder="请选择" :disabled="isView" readonly>
+                  <template #suffix>
+                    <el-icon class="el-input__icon">
+                      <ArrowDown />
+                    </el-icon>
+                  </template>
+                </el-input></span>                
+              </el-form-item>
+            </el-col>
+            <el-col :span="2">
+            </el-col>
+            <el-col :span="9">
+              <el-form-item label="适用科室" prop="suitableDept">
+                <el-tree-select :disabled="isView" v-model="form.suitableDept" show-checkbox multiple
+                  :default-expanded-keys="[2, 3]" :data="enabledDeptOptions"
+                  :props="{ value: 'id', label: 'label', children: 'children' } as any" value-key="id"
+                  placeholder="请选择" />
+
+              </el-form-item>
+            </el-col>
+            <el-col :span="2">
+            </el-col>
+
           </el-row>
 
-          <el-row>            
-            <el-col :span="2" style="margin-left: -100px;">              
+          <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-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-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="handleSelectionChange3">
+          <!-- <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-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>        
+        <el-row :gutter="10" class="mb8">
+          <el-col :span="24">
+            <el-form-item label="制作方式" prop="cookingMethod">
+              <el-input v-model="form.cookingMethod" 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">
+
+  <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']">
-          &nbsp;&nbsp;&nbsp;营养数据分析&nbsp;&nbsp;&nbsp;
-        </el-button>
-        <el-button type="primary" size="large" @click="submitForm" v-hasPermi="['system:hospital:add']">
-          &nbsp;&nbsp;&nbsp;提交&nbsp;&nbsp;&nbsp;
-        </el-button>
-      </div> 
-    </el-card> 
+      <el-button type="primary" size="large" plain @click="close" v-hasPermi="['system:hospital:add']">
+        &nbsp;&nbsp;&nbsp;营养数据分析&nbsp;&nbsp;&nbsp;
+      </el-button>
+      <el-button type="primary" size="large" @click="submitForm" v-hasPermi="['system:hospital:add']">
+        &nbsp;&nbsp;&nbsp;提交&nbsp;&nbsp;&nbsp;
+      </el-button>
+    </div>
+  </el-card>
+
+  <!-- 适用疾病对话框 -->
+  <el-dialog :title="dialog.title" v-model="dialog.visible" width="78%" append-to-body>
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="24">
+        <!-- <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==1}">常见营养诊断</span>
+        <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==2}">ICD诊断</span>
+        <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==3}">营养诊断</span> -->
+        <span class="diagnosis-tag" :class="{ 'diagnosisActive': diseaseLabelQuery.category == item.value }"
+          v-for="item in disease_label" :key="item.value" @click="changeTag(item.value)">{{ item.label }}</span>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+        <el-form-item prop="labelCode">
+          <el-input v-model="diseaseLabelQuery.labelCode" placeholder="疾病名称/疾病编码" clearable />
+        </el-form-item>
+      </el-col>
+      <el-col :span="12" align="left">
+        <el-button type="primary" @click="getDiseaseLabelList">查询</el-button>
+        <el-button type="primary" @click="addDiseaseLabelDialog">新增疾病标签</el-button>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+        <el-table border stripe :data="diseaseLabelList" @selection-change="handleSelectionChange" ref="diseaseLabelRef" >
+          <el-table-column type="selection" width="55" align="center"/>
+          <el-table-column label="疾病/部位名称" align="center" prop="labelName" />
+          <el-table-column label="疾病/部位编码" align="center" prop="labelCode" />
+          <el-table-column label="所属分类" align="center" prop="categoryName" />
+        </el-table>
+        <div style="margin-left: 10px;width: 100%;">
+          <pagination v-show="total > -1" :total="total" v-model:page="queryParams.pageNum"
+            layout="total, sizes, prev, pager, next" v-model:limit="queryParams.pageSize" @pagination="getDiseaseLabelList"
+            size="small" />
+        </div>
+      </el-col>
+      <el-col :span="12" align="right">
+        <div style="height: 100%;">
+          <el-table border :data="selecteddiseaseLabelList">
+            <el-table-column label="疾病/部位名称" align="center" prop="labelName" />
+            <el-table-column label="疾病/部位编码" align="center" prop="labelCode" />
+            <el-table-column label="所属分类" align="center" prop="categoryName" />
+            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
+              <template #default="scope">
+                <el-tooltip content="删除" placement="top">
+                  <el-button link type="danger" icon="Delete" @click="handleSelectedDelete(scope.row)">删除</el-button>
+                </el-tooltip>
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+      </el-col>
+      <el-col :span="12" align="left" style="margin-top: -40px;">
+        <span style="color: rgb(118, 180, 244);">已选:{{ selecteddiseaseLabelList.length }}项</span>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="24" align="center">        
+        <el-button type="primary" @click="handleSelectedconfirm">&nbsp;&nbsp;&nbsp;确定&nbsp;&nbsp;&nbsp;</el-button>
+        <el-button @click="dialog.visible=!dialog.visible">&nbsp;&nbsp;&nbsp;取消&nbsp;&nbsp;&nbsp;</el-button>
+      </el-col>
+    </el-row>
+  </el-dialog>
+
+  <!-- 添加或修改疾病/部位标签对话框 -->
+  <!-- <el-dialog :title="diseaseLabelDialog.title" v-model="diseaseLabelDialog.visible" width="700px" append-to-body>
+    <el-form ref="diseaseLabelFormRef" :model="form" :rules="rules" label-width="150px">
+      <el-form-item label="疾病/部位名称" prop="labelName">
+        <el-input v-model="form.labelName" placeholder="请输入" />
+      </el-form-item>
+      <el-form-item label="所属分类" prop="category">
+        <el-select v-model="form.category" placeholder="请选择" clearable>
+          <el-option v-for="dict in disease_label" :key="dict.value" :label="dict.label"
+            :value="dict.value"></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="疾病/部位编码" prop="labelCode">
+        <el-input v-model="form.labelCode" placeholder="请输入" />
+      </el-form-item>
+    </el-form>
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </template>
+  </el-dialog> -->
+
+
+  <!-- 忌食病症 -->
+  <el-dialog :title="dialog2.title" v-model="dialog2.visible" width="78%" append-to-body>
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="24">
+        <!-- <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==1}">常见营养诊断</span>
+        <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==2}">ICD诊断</span>
+        <span class="diagnosis-tag" :class="{'diagnosisActive':diseaseLabelQuery.category==3}">营养诊断</span> -->
+        <span class="diagnosis-tag" :class="{ 'diagnosisActive': diseaseLabelQuery.category == item.value }"
+          v-for="item in disease_label" :key="item.value" @click="changeTag(item.value)">{{ item.label }}</span>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+        <el-form-item prop="labelCode">
+          <el-input v-model="diseaseLabelQuery.labelCode" placeholder="疾病名称/疾病编码" clearable />
+        </el-form-item>
+      </el-col>
+      <el-col :span="12" align="left">
+        <el-button type="primary" @click="getDiseaseLabelList">查询</el-button>
+        <el-button type="primary">新增疾病标签</el-button>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+        <el-table border stripe :data="diseaseLabelList" @selection-change="handleSelection2Change" ref="diseaseLabel2Ref">
+          <el-table-column type="selection" width="55" align="center" />
+          <el-table-column label="疾病/部位名称" align="center" prop="labelName" />
+          <el-table-column label="疾病/部位编码" align="center" prop="labelCode" />
+          <el-table-column label="所属分类" align="center" prop="categoryName" />
+        </el-table>
+        <div style="margin-left: 10px;width: 100%;">
+          <pagination v-show="total > -1" :total="total" v-model:page="queryParams.pageNum"
+            layout="total, sizes, prev, pager, next" v-model:limit="queryParams.pageSize" @pagination="getDiseaseLabelList"
+            size="small" />
+        </div>
+      </el-col>
+      <el-col :span="12" align="right">
+        <div style="height: 100%;">
+          <el-table border :data="selecteddiseaseLabel2List">
+            <el-table-column label="疾病/部位名称" align="center" prop="labelName" />
+            <el-table-column label="疾病/部位编码" align="center" prop="labelCode" />
+            <el-table-column label="所属分类" align="center" prop="categoryName" />
+            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
+              <template #default="scope">
+                <el-tooltip content="删除" placement="top">
+                  <el-button link type="danger" icon="Delete" @click="handleSelected2Delete(scope.row)">删除</el-button>
+                </el-tooltip>
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="12">
+      </el-col>
+      <el-col :span="12" align="left" style="margin-top: -40px;">
+        <span style="color: rgb(118, 180, 244);">已选:{{ selecteddiseaseLabel2List.length }}项</span>
+      </el-col>
+    </el-row>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="24" align="center">
+        <el-button type="primary" @click="handleSelected2confirm">&nbsp;&nbsp;&nbsp;确定&nbsp;&nbsp;&nbsp;</el-button>
+        <el-button @click="dialog2.visible=!dialog2.visible">&nbsp;&nbsp;&nbsp;取消&nbsp;&nbsp;&nbsp;</el-button>
+      </el-col>
+    </el-row>
+  </el-dialog>    
 </template>
 
-<script setup name="FoodIngredient" lang="ts"> 
-import { listTree} from '@/api/system/foodCategory';
- 
+<script setup name="FoodIngredient" lang="ts">
+import { listTree } from '@/api/system/foodCategory';
+import { listDiseaseLabel, getDiseaseLabel, delDiseaseLabel, addDiseaseLabel, updateDiseaseLabel } from '@/api/system/diseaseLabel';
+import { DiseaseLabelVO, DiseaseLabelQuery, DiseaseLabelForm } from '@/api/system/diseaseLabel/types';
 import { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe } from '@/api/system/recipe';
 import { RecipeVO, RecipeQuery, RecipeForm } from '@/api/system/recipe/types';
+import { listRecipeCategory, getRecipeCategory, delRecipeCategory, addRecipeCategory, updateRecipeCategory } from '@/api/system/recipeCategory';
+import { RecipeCategoryVO, RecipeCategoryQuery, RecipeCategoryForm } from '@/api/system/recipeCategory/types';
+import { DeptTreeVO } from '@/api/system/dept/types';
+import api from '@/api/system/user';
+import { View } from '@element-plus/icons-vue';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-const {  intelligent_recommendation,meal_times,dietary_types } = toRefs<any>(proxy?.useDict('intelligent_recommendation','meal_times','dietary_types'));
+const { intelligent_recommendation, meal_times, dietary_types, disease_label } = toRefs<any>(
+  proxy?.useDict('intelligent_recommendation', 'meal_times', 'dietary_types', 'disease_label'));
+
 
-const recipeList = ref<RecipeVO[]>([]);
+const selecteddiseaseLabelList = ref<DiseaseLabelVO[]>([]);
+const selecteddiseaseLabel2List = ref<DiseaseLabelVO[]>([]);
+const selecteddiseaseLabelListBak = ref<DiseaseLabelVO[]>([]);
+const selecteddiseaseLabel2ListBak = ref<DiseaseLabelVO[]>([]);
+const diseaseLabelList = ref<DiseaseLabelVO[]>([]);
+const enabledDeptOptions = ref<DeptTreeVO[]>([]); 
 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 loading = ref(true); 
 const total = ref(0);
+const recipeCategoryList = ref<RecipeCategoryVO[]>([]);
+const diseaseLabelRef=ref<ElTableInstance>();
+const diseaseLabel2Ref=ref<ElTableInstance>();
 
 const divStyle = ref({
   height: '755px'
 });
-
-const queryFormRef = ref<ElFormInstance>();
-const isView  = ref<boolean>(false) 
+ 
+const isView = ref<boolean>(false)
 const route = useRoute();
 
 const dialog = reactive<DialogOption>({
@@ -211,13 +417,38 @@ const dialog = reactive<DialogOption>({
   title: ''
 });
 
+
+const diseaseLabelDialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+
+const diseaseLabelDialog2 = reactive<DialogOption>({
+  visible: false,
+  title: ''
+}); 
+
+const diseaseLabelQuery = ref<DiseaseLabelQuery>({
+  labelCode: undefined,
+  category: '1',
+  pageNum: 1,
+  pageSize: 10,
+})
+
+const dialog2 = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+
 const initFormData: RecipeForm = {
   recipeId: undefined,
   name: undefined,
   categoryId: undefined,
   baseDiet: '1',
   mealTime: undefined,
-  price: undefined,
+  price: '0.00',
   suitableDisease: undefined,
   avoidDisease: undefined,
   suitableDept: undefined,
@@ -226,7 +457,7 @@ const initFormData: RecipeForm = {
   status: undefined,
 }
 const data = reactive<PageData<RecipeForm, RecipeQuery>>({
-  form: {...initFormData},
+  form: { ...initFormData },
   queryParams: {
     pageNum: 1,
     pageSize: 10,
@@ -275,152 +506,199 @@ const close = () => {
   };
   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 handleSelectionChange = (selection: DiseaseLabelVO[]) => {
+  selecteddiseaseLabelList.value = selection;  
 }
 
-/** 重置按钮操作 */
-const resetQuery = () => {
-  queryFormRef.value?.resetFields();
-  handleQuery();
-}
+const handleSelection2Change = (selection: DiseaseLabelVO[]) => {
+  selecteddiseaseLabel2List.value = selection;
+} 
 
-/** 多选框选中数据 */
-const handleSelectionChange = (selection: FoodIngredientVO[]) => {
-  ids.value = selection.map(item => item.foodIngredientId);
-  single.value = selection.length != 1;
-  multiple.value = !selection.length;
+const handleSelectedDelete = (row?: DiseaseLabelVO[]) => {
+  if (row) {
+    const tList = ref<DiseaseLabelVO[]>([]);
+    selecteddiseaseLabelList.value.forEach(item => {
+      if (item.labelId != row.labelId) {
+        tList.value.push(item);
+      }
+    });
+    selecteddiseaseLabelList.value = tList.value;    
+  }
 }
 
-/** 新增按钮操作 */
-const handleAdd = () => {
-  reset();
-  dialog.visible = true;
-  dialog.title = "添加食材管理";
+const handleSelected2Delete = (row?: DiseaseLabelVO[]) => {
+  if (row) {
+    const tList = ref<DiseaseLabelVO[]>([]);
+      selecteddiseaseLabel2List.value.forEach(item => {
+      if (item.labelId != row.labelId) {
+        tList.value.push(item);
+      }
+    });
+    selecteddiseaseLabel2List.value = tList.value;
+    selecteddiseaseLabel2ListBak.value = tList.value;
+  }
 }
 
-/** 修改按钮操作 */
-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>({});
+      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);
+        await updateFoodIngredient(params.value).finally(() => buttonLoading.value = false);
       } else {
-        await addFoodIngredient(params.value).then(res=>{
-          form.value.foodIngredientId=res.data;
-        }).finally(() =>  buttonLoading.value = false);
+        await addFoodIngredient(params.value).then(res => {
+          form.value.foodIngredientId = res.data;
+        }).finally(() => buttonLoading.value = false);
       }
-      proxy?.$modal.msgSuccess("操作成功"); 
-      if(currentIndex.value=='2'){
+      proxy?.$modal.msgSuccess("操作成功");
+      if (currentIndex.value == '2') {
         close()
-      }else{
-        currentIndex.value='2';   
-      }           
+      } 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 getRecipeCategoryList = async () => {
+  const queryParams = ref<RecipeCategoryQuery>({
+    pageNum: 1,
+    pageSize: -1,
+  })
+  const res = await listRecipeCategory(queryParams.value);
+  recipeCategoryList.value = res.rows;
+}
+
+/** 查询科室下拉树结构 */
+const getDeptTree = async () => {
+  const res = await api.deptTreeSelect();
+  enabledDeptOptions.value = res.data;
+};
 
-/** 导出按钮操作 */
-const handleExport = () => {
-  proxy?.download('system/foodIngredient/export', {
-    ...queryParams.value
-  }, `foodIngredient_${new Date().getTime()}.xlsx`)
+/** 查询疾病/部位标签列表 */
+const getDiseaseLabelList = async () => {
+  const res = await listDiseaseLabel(diseaseLabelQuery.value);
+  diseaseLabelList.value = res.rows;
+  total.value = res.total;
+  loading.value=true;
 }
 
+const changeTag = async (tagVal: string) => {
+  diseaseLabelQuery.value.category = tagVal;
+  getDiseaseLabelList();
+}
 
-const handleSelect = (key: string, keyPath: string[]) => {
-  currentIndex.value=key.toString()   
-  // console.log(key, keyPath,currentIndex)
+const openAvoidDiseaseDialog=async ()=>{
+  dialog.visible=true;
+  dialog.title='添加疾病标签';
+  diseaseLabelQuery.value.labelCode=''
+  diseaseLabelQuery.value.category=disease_label.value[0].value;   
+  await getDiseaseLabelList();   
+  if(selecteddiseaseLabelListBak.value&&selecteddiseaseLabelListBak.value.length>0){    
+    let dataMap=ref({});
+    selecteddiseaseLabelListBak.value.forEach(item=>{
+      dataMap[item.labelId]=true;      
+    });
+
+    diseaseLabelList.value.forEach(item=>{
+      if(dataMap[item.labelId]){        
+        diseaseLabelRef.value.toggleRowSelection(item,true);      
+      }
+    });
+  }  
+}
+
+const openAvoidDiseaseDialog2=async ()=>{
+  dialog2.visible=true;
+  dialog2.title='添加疾病标签';
+  diseaseLabelQuery.value.labelCode=''
+  diseaseLabelQuery.value.category=disease_label.value[disease_label.value.length -1].value;  
+  await getDiseaseLabelList();   
+  if(selecteddiseaseLabel2ListBak.value&&selecteddiseaseLabel2ListBak.value.length>0){    
+    let dataMap=ref({});
+    selecteddiseaseLabel2ListBak.value.forEach(item=>{
+      dataMap[item.labelId]=true;      
+    });
+
+    diseaseLabelList.value.forEach(item=>{
+      if(dataMap[item.labelId]){       
+        diseaseLabel2Ref.value.toggleRowSelection(item,true);      
+      }
+    });
+  } 
+}
+
+const handleSelectedconfirm=async ()=>{
+  dialog.visible=false;
+  form.value.suitableDisease=selecteddiseaseLabelList.value.map(v=>v.labelName).join(',')
+  selecteddiseaseLabelListBak.value = selecteddiseaseLabelList.value;
+}
+
+const handleSelected2confirm=async ()=>{
+  dialog2.visible=false;
+  form.value.avoidDisease=selecteddiseaseLabel2List.value.map(v=>v.labelName).join(',')
+  selecteddiseaseLabel2ListBak.value = selecteddiseaseLabel2List.value;
 }
 
 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);
-  
+  getDiseaseLabelList()
+  getDeptTree();
+  getRecipeCategoryList();
 });
 </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;     
+.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;
+}
+
+.diagnosis-tag {
+  border-left: 1px solid #409EFF;
+  border-top: 1px solid #409EFF;
+  border-bottom: 1px solid #409EFF;
+  padding: 8px 8px;
+  color: #409EFF;
+  background: #f4f8ff;
+  display: inline-block;
+  width: 33.3%;
+  margin-bottom: 10px;
+  text-align: center;
+  vertical-align: middle;
+}
+
+.diagnosis-tag:last-child {
+  border-right: 1px solid #409EFF;
+}
+
+.diagnosisActive {
+  background: #409EFF;
+  color: #fff;
+}
+
+.el-pagination__sizes {
+  width: 100px;
 }
 </style>

+ 105 - 43
src/views/system/recipe/index.vue

@@ -5,13 +5,19 @@
         <el-card shadow="hover">
           <el-form ref="queryFormRef" :model="queryParams" :inline="true">
             <el-form-item label="膳食类型" prop="name">
-              <el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+              <el-select v-model="queryParams.baseDiet" placeholder="请选择" clearable>
+                <el-option v-for="dict in dietary_types" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+              </el-select>
             </el-form-item>
             <el-form-item label="食谱分类" prop="categoryId">
-              <el-input v-model="queryParams.categoryId" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+              <el-select v-model="queryParams.categoryId" placeholder="请选择" clearable>
+                <el-option v-for="dict in recipeCategoryList" :key="dict.recipeCategoryId" :label="dict.name" :value="dict.recipeCategoryId"></el-option>
+              </el-select>
             </el-form-item>
             <el-form-item label="智能推荐" prop="smartRecommend">
-              <el-input v-model="queryParams.smartRecommend" placeholder="请输入智能推荐" clearable @keyup.enter="handleQuery" />
+              <el-select v-model="queryParams.smartRecommend" placeholder="请选择" clearable>
+                <el-option v-for="dict in intelligent_recommendation" :key="dict.value" :label="dict.label=='启用'?dict.label:'未启用'" :value="dict.value"></el-option>
+              </el-select>
             </el-form-item>
             <el-form-item label="食谱名称" prop="name">
               <el-input v-model="queryParams.name" placeholder="请输入食谱名称" clearable @keyup.enter="handleQuery" />
@@ -32,7 +38,7 @@
             <el-button type="primary"   icon="Plus" @click="handleAdd" v-hasPermi="['system:recipe:add']">新增食谱</el-button>
           </el-col>
           <el-col :span="1.5">
-            <el-button  @click="handleDelete()" v-hasPermi="['system:recipe:remove']">食谱分类</el-button>
+            <el-button  @click="handleNew()" v-hasPermi="['system:recipe:remove']">食谱分类</el-button>
           </el-col>
 
           <el-col :span="1.5">
@@ -89,54 +95,45 @@
       <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
     </el-card>
     <!-- 添加或修改食谱管理对话框 -->
-    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
-      <el-form ref="recipeFormRef" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="食谱名称" prop="name">
-          <el-input v-model="form.name" placeholder="请输入食谱名称" />
-        </el-form-item>
-        <el-form-item label="食谱分类ID" prop="categoryId">
-          <el-input v-model="form.categoryId" placeholder="请输入食谱分类ID" />
-        </el-form-item>
-        <el-form-item label="基本膳食" prop="baseDiet">
-          <el-input v-model="form.baseDiet" placeholder="请输入基本膳食" />
-        </el-form-item>
-        <el-form-item label="餐次" prop="mealTime">
-          <el-input v-model="form.mealTime" placeholder="请输入餐次" />
-        </el-form-item>
-        <el-form-item label="食谱价格" prop="price">
-          <el-input v-model="form.price" placeholder="请输入食谱价格" />
-        </el-form-item>
-        <el-form-item label="适用疾病" prop="suitableDisease">
-          <el-input v-model="form.suitableDisease" placeholder="请输入适用疾病" />
-        </el-form-item>
-        <el-form-item label="忌食病症" prop="avoidDisease">
-          <el-input v-model="form.avoidDisease" placeholder="请输入忌食病症" />
-        </el-form-item>
-        <el-form-item label="适用科室" prop="suitableDept">
-          <el-input v-model="form.suitableDept" placeholder="请输入适用科室" />
-        </el-form-item>
-        <el-form-item label="智能推荐" prop="smartRecommend">
-          <el-input v-model="form.smartRecommend" placeholder="请输入智能推荐" />
-        </el-form-item>
-        <el-form-item label="制作方式" prop="cookingMethod">
-          <el-input v-model="form.cookingMethod" placeholder="请输入制作方式" />
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
-          <el-button @click="cancel">取 消</el-button>
-        </div>
-      </template>
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="800px" append-to-body>
+      <el-row :gutter="10" class="mb8">         
+          <el-col :span="21"> 
+            <el-form-item label="新增食谱分类" prop="name">
+              <el-input v-model="recipeCategoryFormData.name" placeholder="请输入食谱分类名称" clearable/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="3" align="right">
+            <el-button :loading="buttonLoading" type="primary" @click="submitRecipeCategoryForm">确 定</el-button>     
+          </el-col> 
+        </el-row> 
+
+      <el-table border :data="recipeCategoryList">
+        <el-table-column label="食谱分类名称" align="left" prop="name" />        
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
+          <template #default="scope"> 
+            <el-tooltip content="编辑" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleRecipeCategoryUpdate(scope.row)">编辑</el-button>
+            </el-tooltip>          
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="danger" icon="Delete" @click="handleRecipeCategoryDelete(scope.row)">删除</el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
     </el-dialog>
   </div>
 </template>
 
+
 <script setup name="Recipe" lang="ts">
+import { listRecipeCategory, getRecipeCategory, delRecipeCategory, addRecipeCategory, updateRecipeCategory } from '@/api/system/recipeCategory';
+import { RecipeCategoryVO, RecipeCategoryQuery, RecipeCategoryForm } from '@/api/system/recipeCategory/types';
 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 router = useRouter();
 const recipeList = ref<RecipeVO[]>([]);
@@ -147,6 +144,7 @@ const ids = ref<Array<string | number>>([]);
 const single = ref(true);
 const multiple = ref(true);
 const total = ref(0);
+const recipeCategoryList = ref<RecipeCategoryVO[]>([]);
 
 const queryFormRef = ref<ElFormInstance>();
 const recipeFormRef = ref<ElFormInstance>();
@@ -156,6 +154,14 @@ const dialog = reactive<DialogOption>({
   title: ''
 });
 
+
+const recipeCategoryFormData  =ref<RecipeCategoryForm> ({
+  recipeCategoryId: undefined,
+  name: undefined,
+  sort: undefined,   
+  status: undefined,
+});
+
 const initFormData: RecipeForm = {
   recipeId: undefined,
   name: undefined,
@@ -253,6 +259,16 @@ const handleAdd = () => {
   router.push('/food/recipe-page/0');
 }
 
+/** 修改按钮操作 */
+const handleNew = async ( ) => {
+  reset();  
+  // const res = await getRecipe(_recipeId);
+  // Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = "食谱分类管理";
+  await getRecipeCategoryList();
+}
+
 /** 修改按钮操作 */
 const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
   // reset();  
@@ -285,6 +301,51 @@ const submitForm = () => {
   });
 }
 
+/** 查询食谱管理列表 */
+const getRecipeCategoryList = async () => {
+  const queryParams =ref<RecipeCategoryQuery>({
+      pageNum: 1,
+      pageSize: -1,
+    }) 
+  const res = await listRecipeCategory(queryParams.value);
+  recipeCategoryList.value = res.rows;   
+}
+
+/** 提交按钮 */
+const submitRecipeCategoryForm = async () => {
+  if(!recipeCategoryFormData.value.name){
+    proxy?.$modal.msgError("请输入食谱分类名称");
+    return;
+  }
+  recipeCategoryFormData.value.name=recipeCategoryFormData.value.name.trim();
+  if(recipeCategoryFormData.value.name.length<1){
+    proxy?.$modal.msgError("请输入食谱分类名称");
+    return;
+  }
+
+  buttonLoading.value = true;
+  const res =await addRecipeCategory(recipeCategoryFormData.value).finally(() =>  buttonLoading.value = false);
+  if(res.code==200){
+      proxy?.$modal.msgSuccess("操作成功");       
+      await getRecipeCategoryList();
+    }else{
+      proxy?.$modal.msgError(res.message);
+    }  
+}
+
+const handleRecipeCategoryUpdate = async (row?: RecipeCategoryVO) => {  
+  recipeCategoryFormData.value.name=row?.name.trim();
+}
+
+const handleRecipeCategoryDelete = async (row?: RecipeCategoryVO) => {
+  await proxy?.$modal.confirm('是否确认删除食谱分类名称为"' + row?.name + '"的数据项?').finally(() => loading.value = false);
+  await delRecipeCategory(row?.recipeCategoryId) ;
+  proxy?.$modal.msgSuccess("删除成功");
+  await getRecipeCategoryList();
+}
+
+
+
 /** 删除按钮操作 */
 const handleDelete = async (row?: RecipeVO) => {
   const _recipeIds = row?.recipeId || ids.value;
@@ -303,5 +364,6 @@ const handleExport = () => {
 
 onMounted(() => {
   getList();
+  getRecipeCategoryList();
 });
 </script>

+ 1 - 1
src/views/system/ward/index.vue

@@ -71,7 +71,7 @@
                 v-model="form.deptIds"
                 show-checkbox                 
                 multiple
-                :render-after-expand="false"
+                default-expand-all
                 :data="enabledDeptOptions"
                 :props="{ value: 'id', label: 'label', children: 'children' } as any"
                 value-key="id"