chenying2100 hace 1 mes
padre
commit
78e1e227c1

+ 4 - 0
info.txt

@@ -123,6 +123,10 @@ CREATE TABLE sys_food_ingredient (
 
 
 
+          
+
+
+
 
 
 

+ 1 - 0
package.json

@@ -42,6 +42,7 @@
     "screenfull": "6.0.2",
     "vue": "3.5.13",
     "vue-cropper": "1.1.1",
+    "vue-echarts": "^7.0.3",
     "vue-i18n": "11.1.3",
     "vue-json-pretty": "2.4.0",
     "vue-router": "4.5.0",

+ 2 - 0
src/api/system/diseaseLabel/types.ts

@@ -24,6 +24,8 @@ export interface DiseaseLabelVO {
    */
   status: string;
 
+  categoryName: string;
+
 }
 
 export interface DiseaseLabelForm extends BaseEntity {

+ 8 - 0
src/api/system/foodIngredient/types.ts

@@ -24,6 +24,8 @@ export interface FoodIngredientVO {
    */
   unit: string;
 
+  unitName: string;
+
   /**
    * 入货价格(元)
    */
@@ -59,6 +61,8 @@ export interface FoodIngredientVO {
    */
   calories: number;
 
+  caloriesForInput: number;
+
   /**
    * 蛋白质(g)
    */
@@ -149,6 +153,10 @@ export interface FoodIngredientVO {
    */
   status: string;
 
+  remark: string;
+
+  quantity: number;
+
 }
 
 export interface FoodIngredientForm extends BaseEntity {

+ 22 - 0
src/api/system/recipe/index.ts

@@ -16,6 +16,28 @@ export const listRecipe = (query?: RecipeQuery): AxiosPromise<RecipeVO[]> => {
   });
 };
 
+
+export const nutrientAnalysis = (query?: RecipeQuery): AxiosPromise<JSON> => {
+  return request({
+    url: '/system/recipe/nutrientAnalysis',
+    method: 'get',
+    params: query
+  });
+};
+
+
+export const changeRecipeStatus = (recipeIds: string | number, status: string) => {
+  const data = {
+    recipeIds,
+    status
+  };
+  return request({
+    url: '/system/recipe/changeStatus',
+    method: 'put',
+    data: data
+  });
+};
+
 /**
  * 查询食谱管理详细
  * @param recipeId

+ 7 - 2
src/api/system/recipe/types.ts

@@ -14,11 +14,13 @@ export interface RecipeVO {
    */
   categoryId: string | number;
 
+  categoryName: string  ;
+
   /**
    * 基本膳食
    */
   baseDiet: string;
-
+  baseDietName: string;
   /**
    * 餐次
    */
@@ -97,7 +99,7 @@ export interface RecipeForm extends BaseEntity {
   /**
    * 适用疾病(可用逗号分隔多个)
    */
-  suitableDisease?: string;
+  suitableDisease?: string; 
 
   /**
    * 忌食病症(可用逗号分隔多个)
@@ -109,6 +111,8 @@ export interface RecipeForm extends BaseEntity {
    */
   suitableDept?: string;
 
+  suitableDeptList?:Array<string>;
+
   /**
    * 智能推荐(0否 1是)
    */
@@ -124,6 +128,7 @@ export interface RecipeForm extends BaseEntity {
    */
   status?: string;
 
+  foodList?: Array<JSON>
 }
 
 export interface RecipeQuery extends PageQuery {

+ 3 - 1
src/main.ts

@@ -8,6 +8,8 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
 import App from './App.vue';
 import store from './store';
 import router from './router';
+import ECharts from 'vue-echarts';
+import 'echarts';
 
 // 自定义指令
 import directive from './directive';
@@ -43,7 +45,7 @@ import { ElDialog } from 'element-plus';
 ElDialog.props.closeOnClickModal.default = false;
 
 const app = createApp(App);
-
+app.component('v-chart', ECharts);
 app.use(HighLight);
 app.use(ElementIcons);
 app.use(router);

+ 1 - 2
src/views/system/foodIngredient/add.vue

@@ -571,8 +571,7 @@ const getList = async () => {
     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) 
+    form.value.foodCategoryIds=res.data.foodCategoryId.toString().split(',') ;
     loading.value = false;
   }  
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 879 - 178
src/views/system/recipe/add.vue


+ 93 - 74
src/views/system/recipe/index.vue

@@ -38,15 +38,15 @@
             <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="handleNew()" v-hasPermi="['system:recipe:remove']">食谱分类</el-button>
+            <el-button  @click="handleNew()"  >食谱分类</el-button>
           </el-col>
 
           <el-col :span="1.5">
-            <el-button type="primary"  :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:recipe:remove']">批量智能推荐</el-button>
+            <el-button type="primary"  :disabled="recommend" @click="handleRecommend()">批量智能推荐</el-button>
           </el-col>
           
           <el-col :span="1.5">
-            <el-button type="primary"  :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:recipe:remove']">批量取消智能推荐</el-button>
+            <el-button type="primary"  :disabled="cancleRecommend" @click="handleCancleRecommend()">批量取消智能推荐</el-button>
           </el-col>
 
           <el-col :span="1.5">
@@ -62,31 +62,28 @@
         </el-row>
       </template>
 
-      <el-table v-loading="loading" border :data="recipeList" @selection-change="handleSelectionChange">
+      <el-table v-loading="loading" border :data="recipeList" @selection-change="handleSelectionChange" ref="tableRef">
         <el-table-column type="selection" width="55" align="center" />
-        <el-table-column label="食谱编码" align="center" prop="recipeId"/>
-        <el-table-column label="膳食类型" align="center" prop="recipeId"/>
-        <el-table-column label="食谱分类" align="center" prop="categoryId" />
-        <el-table-column label="食谱名称" align="center" prop="name" />
-        <el-table-column label="食谱价格" align="center" prop="price" />
-        <el-table-column label="智能推荐" align="center" prop="smartRecommend" />
-        <!-- <el-table-column label="基本膳食" align="center" prop="baseDiet" />
-        <el-table-column label="餐次" align="center" prop="mealTime" />        
-        <el-table-column label="适用疾病" align="center" prop="suitableDisease" />
-        <el-table-column label="忌食病症" align="center" prop="avoidDisease" />
-        <el-table-column label="适用科室" align="center" prop="suitableDept" />        
-        <el-table-column label="制作方式" align="center" prop="cookingMethod" />
-        <el-table-column label="状态" align="center" prop="status" /> -->
-        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <el-table-column label="食谱编码" align="center" prop="recipeId" width="200px"/>
+        <el-table-column label="膳食类型" align="left" prop="baseDietName"  width="150px"/>
+        <el-table-column label="食谱分类" align="left" prop="categoryName" width="150px"/>
+        <el-table-column label="食谱名称" align="left" prop="name" />
+        <el-table-column label="食谱价格" align="left" prop="price" width="150px"/>
+        <el-table-column label="智能推荐" align="left" prop="smartRecommend" width="150px">
+        <template #default="scope">
+            <el-switch v-model="scope.row.smartRecommend" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="230px">
           <template #default="scope">
             <el-tooltip content="详情" placement="top">
-              <el-button link type="primary" icon="View" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:recipe:edit']">详情</el-button>
+              <el-button link type="primary" icon="View" @click="handleUpdate(true,scope.row)" v-hasPermi="['system:recipe:edit']">详情</el-button>
             </el-tooltip>
             <el-tooltip content="编辑" placement="top">
               <el-button link type="primary" icon="Edit" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:recipe:edit']">编辑</el-button>
             </el-tooltip>
             <el-tooltip content="删除" placement="top">
-              <el-button link type="primary" icon="Delete" @click="handleDelete(true,scope.row)" v-hasPermi="['system:recipe:remove']">删除</el-button>
+              <el-button link type="danger" icon="Delete" @click="handleDelete( scope.row)" v-hasPermi="['system:recipe:remove']">删除</el-button>
             </el-tooltip>
           </template>
         </el-table-column>
@@ -121,33 +118,40 @@
         </el-table-column>
       </el-table>
     </el-dialog>
-  </div>
+  </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 { listRecipe, getRecipe, delRecipe, addRecipe, updateRecipe,changeRecipeStatus } from '@/api/system/recipe';
 import { RecipeVO, RecipeQuery, RecipeForm } from '@/api/system/recipe/types';
+import { title } from 'process';
 
 
 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, dietary_types } = toRefs<any>(proxy?.useDict('intelligent_recommendation', 'dietary_types'));
+ 
+const cancleRecommend = ref(true);
+const recommend = ref(true);
 const router = useRouter();
 const recipeList = ref<RecipeVO[]>([]);
 const buttonLoading = ref(false);
 const loading = ref(true);
 const showSearch = ref(true);
 const ids = ref<Array<string | number>>([]);
+const idRows = ref<Array<RecipeVO>>([]);
+const idForNames = ref<string>([]);
 const single = ref(true);
 const multiple = ref(true);
 const total = ref(0);
 const recipeCategoryList = ref<RecipeCategoryVO[]>([]);
-
 const queryFormRef = ref<ElFormInstance>();
-const recipeFormRef = ref<ElFormInstance>();
+const tableRef = ref<ElTableInstance>();
+
+ 
 
 const dialog = reactive<DialogOption>({
   visible: false,
@@ -218,18 +222,7 @@ const getList = async () => {
   total.value = res.total;
   loading.value = false;
 }
-
-/** 取消按钮 */
-const cancel = () => {
-  reset();
-  dialog.visible = false;
-}
-
-/** 表单重置 */
-const reset = () => {
-  form.value = {...initFormData};
-  recipeFormRef.value?.resetFields();
-}
+ 
 
 /** 搜索按钮操作 */
 const handleQuery = () => {
@@ -246,24 +239,31 @@ const resetQuery = () => {
 /** 多选框选中数据 */
 const handleSelectionChange = (selection: RecipeVO[]) => {
   ids.value = selection.map(item => item.recipeId);
-  single.value = selection.length != 1;
+  idRows.value=selection;
+  idForNames.value= selection.map(item => item.name).join(',');
+  // single.value = selection.length != 1;
   multiple.value = !selection.length;
+  if(selection&&selection.length==0){
+    recommend.value=true;
+    cancleRecommend.value=true;
+  }else{
+    recommend.value=selection.filter((value: RecipeVO, index: number, array: RecipeVO[])=>{     
+    return value.smartRecommend=='1';
+  }).length!=selection.length;
+
+  cancleRecommend.value=selection.filter((value: RecipeVO, index: number, array: RecipeVO[])=>{     
+    return value.smartRecommend=='0';
+  }).length!=selection.length;
+  }  
 }
 
 /** 新增按钮操作 */
 const handleAdd = () => {
-  // reset();
-  // dialog.visible = true;
-  // dialog.title = "添加食谱管理";
-
   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();
@@ -271,11 +271,6 @@ const handleNew = async ( ) => {
 
 /** 修改按钮操作 */
 const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
-  // reset();  
-  // const res = await getRecipe(_recipeId);
-  // Object.assign(form.value, res.data);
-  // dialog.visible = true;
-  // dialog.title = "修改食谱管理";
   const _recipeId = row?.recipeId || ids.value[0]
   if(disabled){
     router.push('/food/recipe-view/'+_recipeId);
@@ -284,22 +279,7 @@ const handleUpdate = async (disabled:boolean,row?: RecipeVO) => {
   } 
 }
 
-/** 提交按钮 */
-const submitForm = () => {
-  recipeFormRef.value?.validate(async (valid: boolean) => {
-    if (valid) {
-      buttonLoading.value = true;
-      if (form.value.recipeId) {
-        await updateRecipe(form.value).finally(() =>  buttonLoading.value = false);
-      } else {
-        await addRecipe(form.value).finally(() =>  buttonLoading.value = false);
-      }
-      proxy?.$modal.msgSuccess("操作成功");
-      dialog.visible = false;
-      await getList();
-    }
-  });
-}
+ 
 
 /** 查询食谱管理列表 */
 const getRecipeCategoryList = async () => {
@@ -349,18 +329,57 @@ const handleRecipeCategoryDelete = async (row?: RecipeCategoryVO) => {
 /** 删除按钮操作 */
 const handleDelete = async (row?: RecipeVO) => {
   const _recipeIds = row?.recipeId || ids.value;
-  await proxy?.$modal.confirm('是否确认删除食谱管理编号为"' + _recipeIds + '"的数据项?').finally(() => loading.value = false);
+  const _recipeNames = row?.name || idForNames.value;
+  await proxy?.$modal.confirm('是否确认删除食谱名称为"' + _recipeNames + '"的数据项?').finally(() => loading.value = false);
   await delRecipe(_recipeIds);
   proxy?.$modal.msgSuccess("删除成功");
   await getList();
 }
 
-/** 导出按钮操作 */
-const handleExport = () => {
-  proxy?.download('system/recipe/export', {
-    ...queryParams.value
-  }, `recipe_${new Date().getTime()}.xlsx`)
-}
+
+const handleStatusChange = async (row: RecipeVO) => {
+  const text = row.smartRecommend === '0' ? '启用' : '停用';
+  try {
+    await proxy?.$modal.confirm('确认要"' + text + '""' + row.name + '"食谱吗?');
+    await changeRecipeStatus(row.recipeId, row.smartRecommend);
+    proxy?.$modal.msgSuccess(text + '成功');  
+  } catch {
+    row.smartRecommend = row.smartRecommend === '0' ? '1' : '0';
+  }
+};
+
+const handleRecommend = async ( ) => {
+    const _recipeIds =  ids.value.join(",");
+    const _recipeNames =  idForNames.value;
+    const text =  '启用'  ;
+  try {
+    await proxy?.$modal.confirm('确认要"' + text + '""' + _recipeNames + '"食谱吗?');
+    await changeRecipeStatus(_recipeIds, '0');
+    idRows.value.forEach(item=>{
+      item.smartRecommend='0';
+      tableRef.value?.clearSelection(); 
+    })
+    proxy?.$modal.msgSuccess(text + '成功');  
+  } catch {     
+  }
+};
+
+
+const handleCancleRecommend = async ( ) => {
+    const _recipeIds =  ids.value.join(",");
+    const _recipeNames =  idForNames.value;
+    const text =  '停用'  ;
+  try {
+    await proxy?.$modal.confirm('确认要"' + text + '""' + _recipeNames + '"食谱吗?');
+    await changeRecipeStatus(_recipeIds, '1');
+    idRows.value.forEach(item=>{
+      item.smartRecommend='1';
+      tableRef.value?.clearSelection(); 
+    })
+    proxy?.$modal.msgSuccess(text + '成功');  
+  } catch {     
+  }
+};
 
 onMounted(() => {
   getList();

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio