浏览代码

营养设定

HuRongxin 1 月之前
父节点
当前提交
7a8a01ee86

+ 1 - 1
src/api/patients/nutritionSetting/index.ts

@@ -68,7 +68,7 @@ export const delSetting = (id: string | number | Array<string | number>) => {
  */
 export const recalculateValue = (data: NutritionSettingForm) => {
   return request({
-    url: '/patients/recalculate',
+    url: '/patients/nutritionSetting/recalculate',
     method: 'post',
     data: data
   });

+ 5 - 1
src/api/patients/nutritionSetting/types.ts

@@ -521,7 +521,11 @@ export interface NutritionSettingForm extends BaseEntity {
     /*烧伤面积*/
     burnArea?: number;
 
-    BMI?: number;
+    bmi?: number;
+
+    gender?: string;
+
+    age?: number;
 
 }
 

+ 1 - 0
src/views/patients/checkLabel/index.vue

@@ -46,6 +46,7 @@
     const showSearch = ref(true);
     const tableData = ref([]); // 空数据
     const page = ref(1);
+    const emit = defineEmits(['change'])
 </script>
 
 <style scoped>

+ 66 - 247
src/views/patients/medicalRecord/index.vue

@@ -119,7 +119,7 @@
   </div>
 </template>
 
-<script setup lang="ts">
+<script setup name="MedicalRecord" lang="ts">
 import {ref, onMounted, getCurrentInstance, toRefs, defineAsyncComponent} from 'vue';
 import {useRoute, useRouter} from 'vue-router';
 import {ArrowLeft} from '@element-plus/icons-vue';
@@ -135,30 +135,26 @@ const NutriDiagnosis = defineAsyncComponent(() => import('@/views/patients/nutri
 const CheckLabel = defineAsyncComponent(() => import('@/views/patients/checkLabel/index.vue'));
 const NutritionScreeningAdd = defineAsyncComponent(() => import('@/views/patients/screening/add.vue'));
 const NutritionEvaluationAdd = defineAsyncComponent(() => import('@/views/patients/evaluation/add.vue'));
-
 const NutritionEducation = defineAsyncComponent(() => import('@/views/patients/nutritionEducation/index.vue'));
 const NutritionSetting = defineAsyncComponent(() => import('@/views/patients/nutritionSetting/index.vue'));
 const DietTherapy = defineAsyncComponent(() => import('@/views/patients/dietTherapy/index.vue'));
 
 const componentMap = {
-  medicalRecord: MedicalRecord, // “营养病例”对应MedicalRecord.vue
-  checkLabel: CheckLabel, // “检查标签”对应CheckLabel.vue
+  medicalRecord: MedicalRecord,
+  checkLabel: CheckLabel,
   nutritionDiagnosis: NutriDiagnosis,
-
   nutritionScreening: NutritionScreening,
   nutritionScreeningAdd: NutritionScreeningAdd,
   nutritionEvaluation: NutritionEvaluation,
   nutritionEvaluationAdd: NutritionEvaluationAdd,
-
   nutritionEducation: NutritionEducation,
   nutritionSetting: NutritionSetting,
   dietTherapy: DietTherapy
-  // ... 其它映射
 };
-const currentComponent = ref(componentMap['medicalRecord']); // 默认显示
+const currentComponent = ref(componentMap['medicalRecord']);
 const route = useRoute();
 const router = useRouter();
-const {proxy} = getCurrentInstance() as ComponentInternalInstance;
+const {proxy} = getCurrentInstance() as any;
 
 const activeMenu = ref('medicalRecord');
 
@@ -170,7 +166,13 @@ const patientInfo = ref({
   type: '',
   deptId: '',
   deptName: '',
-  outpatientNo: ''
+  outpatientNo: '',
+  height: '',
+  weight: '',
+  bmi: '',
+  activity: '',
+
+ 
 });
 
 // 弹窗控制
@@ -241,6 +243,7 @@ const handleNext = () => {
     currentPatientIndex.value++;
   }
 };
+
 const handleTabChange = (tab: string) => {
   if (tab == 'wait') {
     getList();
@@ -248,15 +251,14 @@ const handleTabChange = (tab: string) => {
     patientList.value = [];
   }
 };
+
 // 编辑按钮处理
 const handleEdit = async () => {
   if (!patientInfo.value.id) {
     proxy?.$modal.msgError('请先选择患者');
     return;
   }
-
   try {
-    // 获取患者详细信息
     const res = await getTreatmentUser(patientInfo.value.id);
     editData.value = res.data;
     showEditDialog.value = true;
@@ -272,9 +274,7 @@ const handleDetail = async () => {
     proxy?.$modal.msgError('请先选择患者');
     return;
   }
-
   try {
-    // 获取患者详细信息
     const res = await getTreatmentUser(patientInfo.value.id);
     detailData.value = res.data;
     showDetailDialog.value = true;
@@ -296,7 +296,6 @@ const handleEditClose = () => {
 };
 
 const handleEditSave = (data) => {
-  // 可在此处调用保存API,保存后刷新列表
   showEditDialog.value = false;
   proxy?.$modal.msgSuccess('保存成功');
   getList();
@@ -313,247 +312,67 @@ const getList = async () => {
       pageNum: 1,
       pageSize: 10
     };
-    const currentComponent = ref(componentMap['medicalRecord']); // 默认显示
-    const route = useRoute();
-    const router = useRouter();
-    const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-
-    const activeMenu = ref('medicalRecord');
-
-    const patientInfo = ref({
-        id: '',
-        name: '',
-        age: '',
-        gender: '',
-        type: '',
-        deptId: '',
-        deptName: '',
-        outpatientNo: '',
-        BMI: '',
-        height: '',
-        weight: '',
-        activity: '',
-
-    });
-
-    // 弹窗控制
-    const showDetailDialog = ref(false);
-    const detailData = ref({});
-    const physicalActivityDict = ref([]);
-
-    const showEditDialog = ref(false);
-    const editData = ref({} as any);
-
-    const handleSelect = (key: string, other ? : string[]) => {
-        if (key == 'nutritionScreeningAdd' || key == 'nutritionEvaluationAdd') {
-            activeMenu.value = key.replace('Add', '');
-        } else {
-            activeMenu.value = key;
-        }
-        currentComponent.value = componentMap[key] || null;
-        patientInfo.value['other'] = other;
-        patientInfo.value.type = route.query.type;
-        patientInfo.value.outpatientNo = route.query.outpatientNo;
-    };
-
-    const goBack = () => {
-        router.back();
-    };
-
-    const searchValue = ref('');
-    const patientTab = ref('wait');
-    const patientList = ref([]);
-    const loading = ref(false);
-
-    const currentPatientIndex = ref(0);
-
-    const tableRowClassName = ({ row, rowIndex }) => {
-        return rowIndex === currentPatientIndex.value ? 'current-row' : '';
-    };
-
-    const handleRowClick = (row, column, event) => {
-        activeMenu.value = 'medicalRecord';
-        currentComponent.value = componentMap['medicalRecord'];
-        const idx = patientList.value.findIndex(item => item === row);
-        patientInfo.value = row;
-        patientInfo.value.type = route.query.type;
-        patientInfo.value.outpatientNo = route.query.outpatientNo;
-        if (idx !== -1) {
-            currentPatientIndex.value = idx;
-        }
-    };
-
-    const handlePrev = () => {
-        activeMenu.value = 'medicalRecord';
-        currentComponent.value = componentMap['medicalRecord']
-        if (currentPatientIndex.value > 0) {
-            patientInfo.value = patientList.value[currentPatientIndex.value - 1];
-            patientInfo.value.type = route.query.type;
-            patientInfo.value.outpatientNo = route.query.outpatientNo;
-            currentPatientIndex.value--;
-        }
-    };
-
-    const handleNext = () => {
-        activeMenu.value = 'medicalRecord';
-        currentComponent.value = componentMap['medicalRecord']
-        patientInfo.value = patientList.value[currentPatientIndex.value + 1];
-        patientInfo.value.type = route.query.type;
-        patientInfo.value.outpatientNo = route.query.outpatientNo;
-        if (currentPatientIndex.value < patientList.value.length - 1) {
-            currentPatientIndex.value++;
-        }
-    };
-    const handleTabChange = (tab: string) => {
-        if (tab == 'wait') {
-            getList();
-        } else {
-            patientList.value = [];
-        }
-
+    if (searchValue.value) {
+      params.searchFlag = searchValue.value;
     }
-    // 编辑按钮处理
-    const handleEdit = async () => {
-        if (!patientInfo.value.id) {
-            proxy  ?.$modal.msgError('请先选择患者');
-            return;
+    const res = await listTreatmentUser(params);
+    patientList.value = (res.rows || []).map(item => ({
+      id: item.id,
+      name: item.treatName,
+      type: item.type,
+      deptId: item.doorId,
+      deptName: item.deptName,
+      outpatientNo: item.outpatientNo,
+      gender: item.sex === '0' ? '男' : item.sex === '1' ? '女' : '',
+      age: item.age,
+      BMI: item.bmi,
+      height: item.height,
+      weight: item.weight,
+      activity: item.activity,
+    }));
+    waitingCount.value = patientList.value.length;
+    // 如果有患者数据,根据路由参数或默认选中第一个
+    if (patientList.value.length > 0) {
+      const { id } = route.query;
+      if (typeof id === 'string') {
+        const targetIndex = patientList.value.findIndex(patient => patient.id === id);
+        if (targetIndex !== -1) {
+          patientInfo.value = patientList.value[targetIndex];
+          patientInfo.value.type = typeof route.query.type === 'string' ? route.query.type : '';
+          patientInfo.value.outpatientNo = typeof route.query.outpatientNo === 'string' ? route.query.outpatientNo : '';
+          currentPatientIndex.value = targetIndex;
+        } else {
+          patientInfo.value = patientList.value[0];
+          patientInfo.value.type = typeof route.query.type === 'string' ? route.query.type : '';
+          patientInfo.value.outpatientNo = typeof route.query.outpatientNo === 'string' ? route.query.outpatientNo : '';
+          currentPatientIndex.value = 0;
         }
       } else {
-        // 没有路由参数,默认选中第一个
         patientInfo.value = patientList.value[0];
-        patientInfo.value.type = route.query.type;
-        patientInfo.value.outpatientNo = route.query.outpatientNo;
+        patientInfo.value.type = typeof route.query.type === 'string' ? route.query.type : '';
+        patientInfo.value.outpatientNo = typeof route.query.outpatientNo === 'string' ? route.query.outpatientNo : '';
         currentPatientIndex.value = 0;
       }
     }
+    loading.value = false;
+  } catch (error) {
+    console.error('获取列表失败:', error);
+    loading.value = false;
+  }
+};
 
-        try {
-            // 获取患者详细信息
-            const res = await getTreatmentUser(patientInfo.value.id);
-            editData.value = res.data;
-            showEditDialog.value = true;
-        } catch (error) {
-            console.error('获取患者详情失败:', error);
-            proxy  ?.$modal.msgError('获取患者详情失败');
-        }
-    };
-
-    // 详情按钮处理
-    const handleDetail = async () => {
-        if (!patientInfo.value.id) {
-            proxy  ?.$modal.msgError('请先选择患者');
-            return;
-        }
-
-        try {
-            // 获取患者详细信息
-            const res = await getTreatmentUser(patientInfo.value.id);
-            detailData.value = res.data;
-            showDetailDialog.value = true;
-        } catch (error) {
-            console.error('获取患者详情失败:', error);
-            proxy  ?.$modal.msgError('获取患者详情失败');
-        }
-    };
-
-    // 详情弹窗关闭处理
-    const handleDetailClose = () => {
-        showDetailDialog.value = false;
-        detailData.value = {};
-    };
-
-    const handleEditClose = () => {
-        showEditDialog.value = false;
-        editData.value = {};
-    };
-
-    const handleEditSave = (data) => {
-        // 可在此处调用保存API,保存后刷新列表
-        showEditDialog.value = false;
-        proxy  ?.$modal.msgSuccess('保存成功');
-        getList();
-    };
-
-    const waitingCount = ref(0);
-    const treatingCount = ref(0);
-    const treatedCount = ref(0);
-
-
-
-    const getList = async () => {
-        loading.value = true;
-        try {
-            const params: any = {
-                pageNum: 1,
-                pageSize: 10
-            };
-            if (searchValue.value) {
-                params.searchFlag = searchValue.value;
-            }
-            const res = await listTreatmentUser(params);
-
-            patientList.value = (res.rows || []).map(item => ({
-                id: item.id,
-                name: item.treatName,
-                type: item.type, // 0: 门诊,1: 住院
-                deptId: item.doorId,
-                deptName: item.deptName,
-                outpatientNo: item.outpatientNo,
-                gender: item.sex === '0' ? '男' : item.sex === '1' ? '女' : '',
-                age: item.age,
-                BMI: item.bmi,
-                height: item.height,
-                weight: item.weight,
-                activity: item.activity,
-            }));
-            waitingCount.value = patientList.value.length;
-
-            // 如果有患者数据,根据路由参数或默认选中第一个
-            if (patientList.value.length > 0) {
-                const { id } = route.query;
-                if (id) {
-                    // 查找从工作台点击进入的患者
-                    const targetIndex = patientList.value.findIndex(patient => patient.id === id);
-                    if (targetIndex !== -1) {
-                        patientInfo.value = patientList.value[targetIndex];
-                        patientInfo.value.type = route.query.type;
-                        patientInfo.value.outpatientNo = route.query.outpatientNo;
-                        currentPatientIndex.value = targetIndex;
-                    } else {
-                        // 如果没找到,默认选中第一个
-                        patientInfo.value = patientList.value[0];
-                        currentPatientIndex.value = 0;
-                    }
-                } else {
-                    // 没有路由参数,默认选中第一个
-                    patientInfo.value = patientList.value[0];
-                    patientInfo.value.type = route.query.type;
-                    patientInfo.value.outpatientNo = route.query.outpatientNo;
-                    currentPatientIndex.value = 0;
-                }
-            }
-
-            loading.value = false;
-        } catch (error) {
-            console.error('获取列表失败:', error);
-            loading.value = false;
-        }
-    };
-
-    const handleSearch = () => {
-        getList();
-    };
-
-
+const handleSearch = () => {
+  getList();
+};
 
-    onMounted(() => {
-        // 获取体力活动字典
-        const { physical_activity } = toRefs(proxy  ?.useDict('physical_activity'));
-        physicalActivityDict.value = physical_activity  ?.value || [];
-        patientInfo.value.type = route.query.type;
-        patientInfo.value.outpatientNo = route.query.outpatientNo;
-        getList();
-    });
+onMounted(() => {
+  // 获取体力活动字典
+  const { physical_activity } = toRefs(proxy?.useDict('physical_activity'));
+  physicalActivityDict.value = physical_activity?.value || [];
+  patientInfo.value.type = typeof route.query.type === 'string' ? route.query.type : '';
+  patientInfo.value.outpatientNo = typeof route.query.outpatientNo === 'string' ? route.query.outpatientNo : '';
+  getList();
+});
 </script>
 
 <style lang="scss" scoped>

+ 20 - 16
src/views/patients/nutriDiagnosis/index.vue

@@ -51,7 +51,7 @@
                         </template>
                     </el-table-column>
                     <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
-                    <el-table-column label="营养诊断" align="center" prop="diagnosisLabelStr" width="350"/>
+                    <el-table-column label="营养诊断" align="center" prop="diagnosisLabelStr" width="350" />
                     <el-table-column label="诊断医生" align="center" prop="createByUser" />
                     <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                         <template #default="scope">
@@ -117,6 +117,7 @@
     import { log } from 'console';
     import DetailDialog from './detailDialog.vue';
     import { watch } from 'vue';
+    const emit = defineEmits(['change'])
     const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
     const ConsultantTemplateDialog = defineAsyncComponent(() => import('./consultantTemplateDialog.vue'));
@@ -198,21 +199,24 @@
 
     // 监听患者ID变化,自动同步到表单和查询参数
     watch(
-      () => props.patientInfo.id,
-      (newId) => {
-        form.value.treatmentUserId = newId;
-        queryParams.value.treatmentUserId = newId;
-      },
-      { immediate: true }
+        () => props.patientInfo.id,
+        (newId) => {
+            form.value.treatmentUserId = newId;
+            queryParams.value.treatmentUserId = newId;
+        }, { immediate: true }
     );
 
     /** 查询营养诊断列表 */
     const getList = async () => {
         loading.value = true;
-        const res = await listDiagnosis(queryParams.value);
-        diagnosisList.value = res.rows;
-
-        total.value = res.total;
+        try {
+            const res = await listDiagnosis(queryParams.value);
+            diagnosisList.value = res.rows || [];
+            total.value = res.total || 0;
+        } catch (error) {
+            proxy ?.$modal.msgError('获取列表失败');
+            diagnosisList.value = [];
+        }
         loading.value = false;
     }
 
@@ -236,7 +240,7 @@
         try {
             // 获取患者详细信息
             const res = await fetchTreatmentUser(props.patientInfo ?.id);
-            const patientDetail = res.data || {};
+            const patientDetail = res.data as any || {};
             form.value.consultantTemplateId = data.id;
             // 替换模板中的占位符
             let processedContent = templateContent;
@@ -284,10 +288,10 @@
 
     /** 表单重置 */
     const reset = () => {
-        form.value = { 
+        form.value = {
             ...initFormData,
             treatmentUserId: props.patientInfo ?.id // 用最新id
-         };
+        };
         diagnosisFormRef.value ?.resetFields();
     }
 
@@ -384,8 +388,8 @@
     }
 
     const handleDetail = (row: any) => {
-        currentDetail.value = row;
-        currentDetail.value.consultantResult= stripHtml(currentDetail.value.consultantResult);
+        currentDetail.value = row as any;
+        currentDetail.value.consultantResult = stripHtml((currentDetail.value as any).consultantResult);
         showDetailDialog.value = true;
     };
 

+ 106 - 109
src/views/patients/nutritionEducation/index.vue

@@ -1,118 +1,114 @@
-<template></template>
-    <div class="p-2">
-        <div v-show="type === 'list'">
-            <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
-                <div v-show="showSearch" class="mb-[10px]">
-                    <el-card shadow="hover">
-                        <el-form ref="queryFormRef" :model="queryParams" :inline="true">
-                            <el-form-item>
-                                <el-date-picker v-model="queryParams.dateRange" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
-                            </el-form-item>
-                            <el-form-item label="看诊类型">
-                                <el-select v-model="queryParams.type" class="spec-unit-select">
-                                    <el-option v-for="dict in treatment_user_type" :key="dict.value" :label="dict.label" :value="dict.value" />
-                                </el-select>
-                            </el-form-item>
-                            <el-form-item>
-                                <el-input v-model="queryParams.searchValue" placeholder="姓名/门诊/住院号" style="width: 240px; " clearable />
-                            </el-form-item>
-                            <el-form-item>
-                                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
-                                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
-                            </el-form-item>
-                        </el-form>
-                    </el-card>
-                </div>
-            </transition>
-
-            <el-card shadow="never">
-                <template #header>
-                    <el-row :gutter="10" class="mb8">
-                        <el-col :span="1.5">
-                            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['patients:nutritionEducation:add']">新增营养宣教</el-button>
-                        </el-col>
-                        <el-col :span="1.5">
-                            <el-button disabled>打印已选病历</el-button>
-                        </el-col>
-                        <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
-                    </el-row>
-                </template>
-
-                <el-table v-loading="loading" border :data="educationList" @selection-change="handleSelectionChange">
-                    <el-table-column type="selection" width="55" align="center" />
-                    <el-table-column label="时间" align="center" prop="createTime" />
-                    <el-table-column label="看诊类型" align="center" prop="createTime">
-                        <template #default="scope">
-                            <span>{{ scope.row.patientType == 1 ? '门诊' : '住院' }}</span>
-                        </template>
-                    </el-table-column>
-                    <el-table-column label="科室" align="center" prop="deptName" />
-                    <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
-                    <el-table-column label="营养宣教标题" align="center" prop="educationTitle" />
-                    <el-table-column label="内容描述" align="center" prop="description">
-                        <template #default="scope">
-                            <div class="description-cell" @mouseenter="showTooltip($event, scope.row.description)" @mouseleave="hideTooltip">
-                                {{ scope.row.description }}
-                            </div>
-                        </template>
-                    </el-table-column>
-                    <el-table-column label="正文" align="center" prop="content">
-                        <template #default="scope">
-                            <div class="description-cell" @mouseenter="showTooltip($event, scope.row.content)" @mouseleave="hideTooltip">
-                                {{ stripHtml(scope.row.content) }}
-                            </div>
-                        </template>
-                    </el-table-column>
-                    <el-table-column label="宣教医生/护士" align="center" prop="createByUser" />
-                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
-                        <template #default="scope">
-                            <el-tooltip content="详情" placement="top">
-                                <el-button link type="primary" icon="Edit" @click="handleDetail(scope.row)">详情</el-button>
-                            </el-tooltip>
-                            <el-tooltip content="删除" placement="top">
-                                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
-                            </el-tooltip>
-                        </template>
-                    </el-table-column>
-                </el-table>
-
-                <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
-            </el-card>
-        </div>
-        <div v-show="type === 'addForm'">
-            <!-- 添加或修改营养宣教对话框 -->
-            <el-button type="primary" @click="handleBack">返回</el-button> <span style="margin-left: 20px;">新增营养宣教</span>
-            <el-form ref="educationFormRef" :model="form" :rules="rules" label-width="120px" style="margin-top: 20px;">
-                <el-form-item label="科室:" prop="deptName">
-                    <el-input v-model="form.deptName" placeholder="请输入科室" :disabled="true" style="width: 30%;" />
-                </el-form-item>
-                <el-form-item label="营养宣教标题:" prop="educationTitle">
-                    <el-input v-model="form.educationTitle" placeholder="请输入营养宣教标题" style="width: 30%;" />
-                    <el-button style="margin-left: 10px;" type="primary" @click="showTemplateDialog = true">导入模板</el-button>
-                </el-form-item>
-                <el-form-item label="描述:" prop="description">
-                    <el-input v-model="form.description" type="textarea" :rows="5" placeholder="请输入内容" style="width: 30%;" />
-                </el-form-item>
-                <el-form-item label="正文:">
-                    <editor v-model="form.content" :min-height="192" style="width: 75%;" />
-                </el-form-item>
+<template>
+  <div class="p-2">
+    <div v-show="type === 'list'">
+      <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
+        <div v-show="showSearch" class="mb-[10px]">
+          <el-card shadow="hover">
+            <el-form ref="queryFormRef" :model="queryParams" :inline="true">
+              <el-form-item>
+                <el-date-picker v-model="queryParams.dateRange" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
+              </el-form-item>
+              <el-form-item label="看诊类型">
+                <el-select v-model="queryParams.type" class="spec-unit-select">
+                  <el-option v-for="dict in treatment_user_type" :key="dict.value" :label="dict.label" :value="dict.value" />
+                </el-select>
+              </el-form-item>
+              <el-form-item>
+                <el-input v-model="queryParams.searchValue" placeholder="姓名/门诊/住院号" style="width: 240px; " clearable />
+              </el-form-item>
+              <el-form-item>
+                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
+                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+              </el-form-item>
             </el-form>
-            <EducationTemplateDialog v-model:visible="showTemplateDialog" @select="onTemplateSelect" />
-            <div class="dialog-footer" style="text-align: center; margin-top: 100px">
-                <el-button @click="handleCancel">取 消</el-button>
-                <el-button :loading="buttonLoading" type="primary" @click="submitForm">提 交</el-button>
-            </div>
+          </el-card>
         </div>
+      </transition>
+      <el-card shadow="never">
+        <template #header>
+          <el-row :gutter="10" class="mb8">
+            <el-col :span="1.5">
+              <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['patients:nutritionEducation:add']">新增营养宣教</el-button>
+            </el-col>
+            <el-col :span="1.5">
+              <el-button disabled>打印已选病历</el-button>
+            </el-col>
+            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+          </el-row>
+        </template>
+        <el-table v-loading="loading" border :data="educationList" @selection-change="handleSelectionChange">
+          <el-table-column type="selection" width="55" align="center" />
+          <el-table-column label="时间" align="center" prop="createTime" />
+          <el-table-column label="看诊类型" align="center" prop="createTime">
+            <template #default="scope">
+              <span>{{ scope.row.patientType == 1 ? '门诊' : '住院' }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="科室" align="center" prop="deptName" />
+          <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
+          <el-table-column label="营养宣教标题" align="center" prop="educationTitle" />
+          <el-table-column label="内容描述" align="center" prop="description">
+            <template #default="scope">
+              <div class="description-cell" @mouseenter="showTooltip($event, scope.row.description)" @mouseleave="hideTooltip">
+                {{ scope.row.description }}
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column label="正文" align="center" prop="content">
+            <template #default="scope">
+              <div class="description-cell" @mouseenter="showTooltip($event, scope.row.content)" @mouseleave="hideTooltip">
+                {{ stripHtml(scope.row.content) }}
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column label="宣教医生/护士" align="center" prop="createByUser" />
+          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+            <template #default="scope">
+              <el-tooltip content="详情" placement="top">
+                <el-button link type="primary" icon="Edit" @click="handleDetail(scope.row)">详情</el-button>
+              </el-tooltip>
+              <el-tooltip content="删除" placement="top">
+                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
+              </el-tooltip>
+            </template>
+          </el-table-column>
+        </el-table>
+        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+      </el-card>
+    </div>
+    <div v-show="type === 'addForm'">
+      <!-- 添加或修改营养宣教对话框 -->
+      <el-button type="primary" @click="handleBack">返回</el-button> <span style="margin-left: 20px;">新增营养宣教</span> 
+      <el-form ref="educationFormRef" :model="form" :rules="rules" label-width="120px" style="margin-top: 20px;">
+        <el-form-item label="科室:" prop="deptName">
+          <el-input v-model="form.deptName" placeholder="请输入科室" :disabled="true" style="width: 30%;" />
+        </el-form-item>
+        <el-form-item label="营养宣教标题:" prop="educationTitle">
+          <el-input v-model="form.educationTitle" placeholder="请输入营养宣教标题" style="width: 30%;" />
+          <el-button style="margin-left: 10px;" type="primary" @click="showTemplateDialog = true">导入模板</el-button>
+        </el-form-item>
+        <el-form-item label="描述:" prop="description">
+          <el-input v-model="form.description" type="textarea" :rows="5" placeholder="请输入内容" style="width: 30%;" />
+        </el-form-item>
+        <el-form-item label="正文:">
+          <editor v-model="form.content" :min-height="192" style="width: 75%;" />
+        </el-form-item>
+      </el-form>
+      <EducationTemplateDialog v-model:visible="showTemplateDialog" @select="onTemplateSelect" />
+      <div class="dialog-footer" style="text-align: center; margin-top: 100px">
+        <el-button @click="handleCancel">取 消</el-button>
+        <el-button :loading="buttonLoading" type="primary" @click="submitForm">提 交</el-button>
+      </div>
     </div>
     <Teleport to="body">
-        <Transition name="fade">
-            <div v-if="tooltipVisible" class="custom-tooltip" :style="tooltipStyle">
-                {{ tooltipContent }}
-            </div>
-        </Transition>
+      <Transition name="fade">
+        <div v-if="tooltipVisible" class="custom-tooltip" :style="tooltipStyle">
+          {{ tooltipContent }}
+        </div>
+      </Transition>
     </Teleport>
-    <!-- 详情弹窗始终挂载在最外层div内 -->
     <detail-dialog v-model="showDetailDialog" :detail="currentDetail" />
+  </div>
 </template>
 
 <script setup name="Education" lang="ts">
@@ -135,6 +131,7 @@
     const showTemplateDialog = ref(false);
     const showDetailDialog = ref(false);
     const currentDetail = ref({});
+     const emit = defineEmits(['change'])
     const queryFormRef = ref < ElFormInstance > ();
     const educationFormRef = ref < ElFormInstance > ();
 

+ 54 - 24
src/views/patients/nutritionSetting/addForm.vue

@@ -9,8 +9,8 @@
                 <span class="bee-title">{{ title }}</span>
             </div>
             <el-row :gutter="20" align="middle" class="info-row">
-                <el-col :span="2"><span>性别:</span></el-col>
-                <el-col :span="2"><span>年龄:</span>44岁3月</el-col>
+                <el-col :span="2"><span>性别:</span>{{form.gender}}</el-col>
+                <el-col :span="2"><span>年龄:</span>{{form.age}}</el-col>
                 <el-col :span="2"><span class="required">*</span><span>BMI:{{ form.bmi }}</span></el-col>
                 <el-col :span="4"><span class="required">*</span><span>身高:</span>
                     <el-input v-model="form.height" style="width: 120px;" /> <span>cm</span></el-col>
@@ -39,7 +39,7 @@
                     <el-input v-model="form.calfCircumference" style="width: 120px;" /> <span>cm</span>
                 </el-col>
                 <el-col :span="20" style="text-align:right;">
-                    <el-button type="primary" class="recalc-btn" @click="()=>recalculate(form.gender, form.age, form.height, form.weight, form.activity, form.stress)">重新计算</el-button>
+                    <el-button type="primary" class="recalc-btn" @click="()=>recalculate(form.gender, form.age, form.height, form.weight, form.activity, form.stressType)">重新计算</el-button>
                 </el-col>
             </el-row>
         </div>
@@ -48,11 +48,9 @@
             注:常量元素、微量元素、维生素、氨基酸、脂肪酸、膳食纤维默认为DRIS数据,如有必要请自行修改。
         </div>
         <div v-show="showFlag=='true'">
-            <el-form label-position="right" label-width="170px">
-
+            <el-form ref="NutritionSettingFormRef" :model="form" :rules="rules" label-position="right" label-width="170px">
                 <!-- 能量及三大营养素 -->
                 <div class="group-card">
-
                     <div class="group-title">能量及三大营养素</div>
                     <el-row :gutter="20">
                         <el-col :span="8">
@@ -64,7 +62,7 @@
                         <el-col :span="8">
                             <el-form-item label="所需热量:" class="right-label">
                                 <span>{{ form.caloriesKcalPerKgDay }}</span>
-                                <span class="unit">kcal/kg·d</span>
+                                <span class="unit">kcal/kg*d</span>
                             </el-form-item>
                         </el-col>
                         <el-col :span="8">
@@ -84,7 +82,7 @@
                         <el-col :span="8">
                             <el-form-item label="所需蛋白质:" class="right-label">
                                 <span>{{ form.proteinGPerKgDay }}</span>
-                                <span class="unit">g/kg·d</span>
+                                <span class="unit">g/kg*d</span>
                             </el-form-item>
                         </el-col>
                         <el-col :span="8">
@@ -104,7 +102,7 @@
                         <el-col :span="8">
                             <el-form-item label="所需脂肪:" class="right-label">
                                 <span>{{ form.fatGPerKgDay }}</span>
-                                <span class="unit">g/kg·d</span>
+                                <span class="unit">g/kg*d</span>
                             </el-form-item>
                         </el-col>
                         <el-col :span="8">
@@ -123,13 +121,12 @@
                         </el-col>
                         <el-col :span="8">
                             <el-form-item label="所需碳水化合物:" class="right-label">
-                                <el-input v-model="form.carbohydrateGPerKgDay" style="width: 200px;" />
-                                <span class="unit">g/kg·d</span>
+                                <span>{{ form.carbohydrateGPerKgDay }}</span> <span class="unit">g/kg·d</span>
                             </el-form-item>
                         </el-col>
                         <el-col :span="8">
                             <el-form-item label="所需碳水化合物:" class="right-label">
-                                <el-input v-model="form.carbohydrateGPerDay" style="width: 200px;" />
+                                <span>{{ form.carbohydrateGPerDay }}</span>
                                 <span class="unit">g/d</span>
                             </el-form-item>
                         </el-col>
@@ -370,45 +367,78 @@
                     </el-row>
                 </div>
             </el-form>
+            <div class="flex justify-center gap-2 mt-4">
+                <el-button :loading="buttonLoading" type="primary" @click="submitForm">保 存</el-button>
+            </div>
         </div>
 
     </div>
 </template>
 
 <script setup lang="ts">
-    import { ref } from 'vue';
+    import { ref, toRefs, getCurrentInstance } from 'vue';
     import { addSetting, updateSetting, recalculateValue } from '@/api/patients/nutritionSetting';
     import type { FormInstance } from 'element-plus';
-    const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+    const { proxy } = getCurrentInstance() as any;
     const { physical_activity, stress_level } = toRefs(proxy ?.useDict('physical_activity', 'stress_level'));
-
-
+    const emit = defineEmits(['change'])
     const props = defineProps({
         form: { type: Object, required: true },
         rules: { type: Object, required: true },
         buttonLoading: { type: Boolean, required: true },
-        submitForm: { type: Function, required: true },
         cancel: { type: Function, required: true },
-        handleCancel: { type: Function, required: true },
+        handleCancelOne: { type: Function, required: true },
         title: { type: String }
     });
-    const { handleCancel, form } = props;
+    const { handleCancelOne, form, rules } = props;
     const { title } = toRefs(props);
     const showFlag = ref('false');
+    const buttonLoading = ref(false);
     const NutritionSettingFormRef = ref < FormInstance > ();
-    const handleAdd = async () => { await addSetting({ ...form }); };
-    const handleUpdate = async () => { await updateSetting({ ...form }); };
+
+
     const recalculate = async (gender, age, height, weight, activity, stressType) => {
-      //  const res = await recalculateValue({ gender, age, height, weight, activity, stressType });
+        const res = await recalculateValue({ gender, age, height, weight, activity, stressType });
+        if (res) {
+            const keepSettingType = form.settingType;
+            Object.assign(form, res);
+            form.settingType = keepSettingType; // 恢复settingType的值
 
-        // 重新计算逻辑预留
+        }
         showFlag.value = 'true';
     };
 
+    /** 提交按钮 */
+    const submitForm = async () => {
+        if (!NutritionSettingFormRef.value) return;
+        await NutritionSettingFormRef.value.validate(async (valid: boolean) => {
+            if (valid) {
+                buttonLoading.value = true;
+                try {
+                    if (form.id) {
+                        await updateSetting(form);
+                    } else {
+                        console.log(form.settingType);
+                        await addSetting(form);
+                    }
+                    proxy ?.$modal.msgSuccess('操作成功');
+                    onBack();
+                } catch (error) {
+                    console.error('提交失败', error);
+                } finally {
+                    buttonLoading.value = false;
+                }
+            }
+        });
+    };
+    const close = async () => {
+
+    };
 
     const onBack = () => {
         showFlag.value = 'false';
-        handleCancel();
+        emit('change', 'nutritionSetting');
+        handleCancelOne();
     };
 </script>
 

+ 169 - 228
src/views/patients/nutritionSetting/index.vue

@@ -30,57 +30,42 @@
                 </div>
             </transition>
 
-      <el-card shadow="never">
-        <template #header>
-          <el-row :gutter="10" class="mb8">
-            <el-col :span="1.5">
-              <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['patients:nutritionSetting:add']">新增营养设定</el-button>
-            </el-col>
-            <!-- <el-col :span="1.5">
-                            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['patients:nutritionSetting:edit']">修改</el-button>
-                        </el-col>
+            <el-card shadow="never">
+                <template #header>
+                    <el-row :gutter="10" class="mb8">
                         <el-col :span="1.5">
-                            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['patients:nutritionSetting:remove']">删除</el-button>
+                            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['patients:nutritionSetting:add']">新增营养设定</el-button>
                         </el-col>
-                        <el-col :span="1.5">
-                            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['patients:nutritionSetting:export']">导出</el-button>
-                        </el-col> -->
-            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
-          </el-row>
-        </template>
-
-        <el-table v-loading="loading" border :data="settingList" @selection-change="handleSelectionChange">
-          <el-table-column type="selection" width="55" align="center" />
-          <el-table-column label="时间" align="center" prop="createTime" />
-          <el-table-column label="看诊类型" align="center" prop="type" />
-          <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
-          <el-table-column label="营养设定方式" align="center" prop="settingType" />
-          <el-table-column label="所需热量(kcal/d)" align="center" prop="type" />
-          <el-table-column label="评估医生" align="center" prop="createByUser" />
-          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
-            <template #default="scope">
-              <el-tooltip content="修改" placement="top">
-                <el-button
-                  link
-                  type="primary"
-                  icon="Edit"
-                  @click="handleUpdate(scope.row)"
-                  v-hasPermi="['patients:nutritionSetting:edit']"
-                ></el-button>
-              </el-tooltip>
-              <el-tooltip content="删除" placement="top">
-                <el-button
-                  link
-                  type="primary"
-                  icon="Delete"
-                  @click="handleDelete(scope.row)"
-                  v-hasPermi="['patients:nutritionSetting:remove']"
-                ></el-button>
-              </el-tooltip>
-            </template>
-          </el-table-column>
-        </el-table>
-
+                        <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+                    </el-row>
+                </template>
+                <el-table v-loading="loading" border :data="settingList" @selection-change="handleSelectionChange">
+                    <el-table-column type="selection" width="55" align="center" />
+                    <el-table-column label="时间" align="center" prop="createTime" />
+                    <el-table-column label="看诊类型" align="center" prop="type">
+                        <template #default="scope">
+                            <span>{{getDictLabel(treatment_user_type ,scope.row.type )|| '--' }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
+                    <el-table-column label="营养设定方式" align="center" prop="settingType">
+                        <template #default="scope">
+                            <span>{{getDictLabel(nutrition_setting_type ,scope.row.settingType )|| '--' }}</span>
+                        </template>
+                    </el-table-column>
+                    <el-table-column label="所需热量(kcal/d)" align="center" prop="caloriesKcalPerDay" />
+                    <el-table-column label="评估医生" align="center" prop="createByUser" />
+                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+                        <template #default="scope">
+                            <!-- <el-tooltip content="修改" placement="top">
+                                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['patients:nutritionSetting:edit']"></el-button>
+                            </el-tooltip> -->
+                            <el-tooltip content="删除" placement="top">
+                                <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['patients:nutritionSetting:remove']">删除</el-button>
+                            </el-tooltip>
+                        </template>
+                    </el-table-column>
+                </el-table>
                 <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
             </el-card>
         </div>
@@ -106,71 +91,23 @@
         </div>
         <div v-show="type=='addForm'">
             <!-- 添加或修改营养设定对话框 -->
-            <add-form :form="form" :rules="rules" :buttonLoading="buttonLoading" :submitForm="submitForm" :cancel="cancel" :handleCancel="handleCancel" :title="title"/>
+            <add-form :form="form" :rules="rules" :buttonLoading="buttonLoading" :cancel="cancel" :handleCancelOne="handleCancelOne" :title="title" />
         </div>
     </div>
-    <div>
-      <el-dialog
-        :title="'选择营养设定'"
-        v-model="dialog.visible"
-        width="737px"
-        append-to-body
-        :close-on-click-modal="false"
-        :show-close="true"
-        class="nutrition-setting-dialog"
-      >
-        <el-row :gutter="20" style="margin-bottom: 10px">
-          <el-col :span="12">
-            <el-button
-              :class="['setting-type-btn', form.settingType === '1' ? 'active' : '']"
-              style="width: 100%; height: 46px"
-              @click="handleSelectSettingType('1')"
-              >BEE</el-button
-            >
-          </el-col>
-          <el-col :span="12">
-            <el-button
-              :class="['setting-type-btn', form.settingType === '2' ? 'active' : '']"
-              style="width: 100%; height: 46px"
-              @click="handleSelectSettingType('2')"
-              >DRIS</el-button
-            >
-          </el-col>
-        </el-row>
-        <el-row :gutter="20">
-          <el-col :span="12">
-            <el-button
-              :class="['setting-type-btn', form.settingType === '3' ? 'active' : '']"
-              style="width: 100%; height: 46px"
-              @click="handleSelectSettingType('3')"
-              >拇指测法</el-button
-            >
-          </el-col>
-          <el-col :span="12">
-            <el-button
-              :class="['setting-type-btn', form.settingType === '4' ? 'active' : '']"
-              style="width: 100%; height: 46px"
-              @click="handleSelectSettingType('4')"
-              >烧伤公式</el-button
-            >
-          </el-col>
-        </el-row>
-      </el-dialog>
-    </div>
-    <div v-show="type == 'addForm'">
-      <!-- 添加或修改营养设定对话框 -->
-      <add-form :form="form" :rules="rules" :buttonLoading="buttonLoading" :submitForm="submitForm" :cancel="cancel" />
-    </div>
-  </div>
+
 </template>
 
 <script setup name="NutritionSetting" lang="ts">
-import {listSetting, getSetting, delSetting, addSetting, updateSetting} from '@/api/patients/nutritionSetting';
-import {NutritionSettingVO, NutritionSettingQuery, NutritionSettingForm} from '@/api/patients/nutritionSetting/types';
-import AddForm from './addForm.vue';
+    // 变量声明区
+    import { ref, reactive, toRefs, onMounted, getCurrentInstance, nextTick } from 'vue';
+    import { listSetting, getSetting, delSetting, addSetting, updateSetting } from '@/api/patients/nutritionSetting';
+    import { NutritionSettingVO, NutritionSettingQuery, NutritionSettingForm } from '@/api/patients/nutritionSetting/types';
+    import AddForm from './addForm.vue';
+    const emit = defineEmits(['change'])
+    import { log } from 'vxe-table';
 
-const {proxy} = getCurrentInstance() as ComponentInternalInstance;
-const {treatment_user_type, nutrition_setting_type} = toRefs<any>(proxy?.useDict('treatment_user_type', 'nutrition_setting_type'));
+    const { proxy } = getCurrentInstance();
+    const { treatment_user_type, nutrition_setting_type } = toRefs(proxy ?.useDict('treatment_user_type', 'nutrition_setting_type'));
 
     const settingList = ref < NutritionSettingVO[] > ([]);
     const buttonLoading = ref(false);
@@ -181,30 +118,29 @@ const {treatment_user_type, nutrition_setting_type} = toRefs<any>(proxy?.useDict
     const multiple = ref(true);
     const total = ref(0);
     const type = ref('list');
-    const title= ref('');
+    const title = ref('');
 
-const queryFormRef = ref<ElFormInstance>();
-const NutritionSettingFormRef = ref<ElFormInstance>();
+    const queryFormRef = ref();
+    const NutritionSettingFormRef = ref();
 
-const dialog = reactive<DialogOption>({
-  visible: false,
-  title: ''
-});
+    const dialog = reactive({
+        visible: false,
+        title: ''
+    });
 
-// 声明接收的 props
-const props = defineProps({
-  patientInfo: {
-    type: Object,
-    required: true,
-    default: () => ({
-      id: '',
-      name: '',
-      age: '',
-      deptId: '',
-      gender: ''
-    })
-  }
-});
+    const props = defineProps({
+        patientInfo: {
+            type: Object,
+            required: true,
+            default: () => ({
+                id: '',
+                name: '',
+                age: '',
+                deptId: '',
+                gender: ''
+            })
+        }
+    });
 
     const initFormData: NutritionSettingForm = {
         id: undefined,
@@ -255,152 +191,157 @@ const props = defineProps({
         deptId: props.patientInfo ?.deptId,
         deptName: undefined,
         outpatientNo: props.patientInfo ?.outpatientNo,
-        BMI: props.patientInfo ?.bmi,
+        bmi: props.patientInfo ?.bmi,
         height: props.patientInfo ?.height,
         weight: props.patientInfo ?.weight,
         activity: props.patientInfo ?.activity,
         stressType: undefined,
         highHip: undefined,
         lowHip: undefined,
-        burnArea: undefined, // 燃烧面积
-    }
-  });
-};
+        burnArea: undefined,
+        gender: props.patientInfo ?.gender,
+        age: props.patientInfo ?.age,
+
+    };
+
+    const form = ref({ ...initFormData });
+    const queryParams = ref({
+        patientId: props.patientInfo ?.id,
+        dateRange: [],
+        type: '',
+        settingType: '',
+        searchValue: '',
+        pageNum: 1,
+        pageSize: 10
+    });
+
+    const rules = ref({
+        height: [
+            { required: true, message: '身高不能为空', trigger: 'blur' }
+        ],
+        activity: [
+            { required: true, message: '体力活动不能为空', trigger: 'change' }
+        ],
+        // 只有在 BEE 公式下才校验应激状态
+        stressType: [{
+            required: true,
+            message: '应激状态不能为空',
+            trigger: 'change',
+            validator: (rule, value, callback) => {
+                if (title.value === 'BEE' && (value === undefined || value === null || value === '')) {
+                    callback(new Error('应激状态不能为空'));
+                } else {
+                    callback();
+                }
+            }
+        }]
+    });
 
-/** 删除按钮操作 */
-const handleDelete = async (row?: NutritionSettingVO) => {
-  const _ids = row?.id || ids.value;
-  await proxy?.$modal.confirm('是否确认删除营养设定编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
-  await delSetting(_ids);
-  proxy?.$modal.msgSuccess('删除成功');
-  await getList();
-};
+    // 事件函数区
+    const handleDelete = async (row ? : NutritionSettingVO) => {
+        const _ids = row ?.id || ids.value;
+        await proxy ?.$modal.confirm('是否确认删除营养设定编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
+        await delSetting(_ids);
+        proxy ?.$modal.msgSuccess('删除成功');
+        await getList();
+    };
 
-/** 导出按钮操作 */
-const handleExport = () => {
-  proxy?.download(
-    '/patients/nutritionSetting/export',
-    {
-      ...queryParams.value
-    },
-    `setting_${new Date().getTime()}.xlsx`
-  );
-};
+    const handleExport = () => {
+        proxy ?.download('/patients/nutritionSetting/export', {
+            ...queryParams.value
+        }, `setting_${new Date().getTime()}.xlsx`)
+    };
 
-    const handleSelectSettingType = (settingType,typeName) => {
+    const handleSelectSettingType = (settingType, typeName) => {
         form.value.settingType = settingType;
         title.value = typeName;
         dialog.visible = false;
-        // 切换到表单填写界面
         nextTick(() => {
             type.value = 'addForm';
         });
     };
 
-    /** 取消按钮 */
+    // 字典label工具
+    function getDictLabel(dictList: any[], value: string) {
+        if (!dictList || !Array.isArray(dictList)) return value || '--';
+        const found = dictList.find(item => item.value === value);
+        return found ? found.label : value || '--';
+    }
+
     const cancel = () => {
         reset();
         dialog.visible = false;
-    }
-       const handleCancel = () => {
+    };
+    const handleCancel = () => {
+        type.value = 'list';
+    };
+    const handleCancelOne = () => {
+        getList();
         type.value = 'list';
     };
-
-    /** 表单重置 */
     const reset = () => {
         form.value = { ...initFormData };
         NutritionSettingFormRef.value ?.resetFields();
-    }
-
-    /** 搜索按钮操作 */
+    };
     const handleQuery = () => {
         queryParams.value.pageNum = 1;
         getList();
-    }
-
-    /** 重置按钮操作 */
+    };
     const resetQuery = () => {
         queryFormRef.value ?.resetFields();
+        queryParams.value.dateRange = undefined;
+        queryParams.value.type = undefined;
+        queryParams.value.settingType = undefined;
+        queryParams.value.searchValue = undefined;
         handleQuery();
-    }
-
-    /** 多选框选中数据 */
+    };
     const handleSelectionChange = (selection: NutritionSettingVO[]) => {
         ids.value = selection.map(item => item.id);
         single.value = selection.length != 1;
         multiple.value = !selection.length;
-    }
-
-    /** 新增按钮操作 */
+    };
     const handleAdd = () => {
-        reset();
         dialog.visible = true;
-        dialog.title = "添加营养设定";
-    }
-
-    /** 修改按钮操作 */
+        dialog.title = '选择营养设定方式';
+    };
     const handleUpdate = async (row ? : NutritionSettingVO) => {
         reset();
-        const _id = row ?.id || ids.value[0]
+        const _id = row ?.id || ids.value[0];
         const res = await getSetting(_id);
         Object.assign(form.value, res.data);
         dialog.visible = true;
-        dialog.title = "修改营养设定";
-    }
-
-    /** 提交按钮 */
-    const submitForm = () => {
-        NutritionSettingFormRef.value ?.validate(async (valid: boolean) => {
-            if (valid) {
-                buttonLoading.value = true;
-                if (form.value.id) {
-                    await updateSetting(form.value).finally(() => buttonLoading.value = false);
-                } else {
-                    await addSetting(form.value).finally(() => buttonLoading.value = false);
-                }
-                proxy ?.$modal.msgSuccess("操作成功");
-                dialog.visible = false;
-                await getList();
-            }
-        });
-    }
-
-    /** 删除按钮操作 */
-    const handleDelete = async (row ? : NutritionSettingVO) => {
-        const _ids = row ?.id || ids.value;
-        await proxy ?.$modal.confirm('是否确认删除营养设定编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
-        await delSetting(_ids);
-        proxy ?.$modal.msgSuccess("删除成功");
-        await getList();
-    }
+        dialog.title = '修改营养设定';
+    };
 
-    /** 导出按钮操作 */
-    const handleExport = () => {
-        proxy ?.download('/patients/nutritionSetting/export', {
-            ...queryParams.value
-        }, `setting_${new Date().getTime()}.xlsx`)
-    }
+    const getList = async () => {
+        loading.value = true;
+        //  这里补充你的获取数据逻辑
+        const res = await listSetting(queryParams.value);
+        settingList.value = res.rows || [];
+        total.value = res.total;
+        loading.value = false;
+    };
 
     onMounted(() => {
         getList();
     });
 </script>
 <style scoped>
-.nutrition-setting-dialog .setting-type-btn {
-  font-size: 18px;
-  border: 1.5px solid #409eff;
-  color: #409eff;
-  background: #fff;
-  transition:
-    background 0.2s,
-    color 0.2s;
-}
+    .nutrition-setting-dialog .setting-type-btn {
+        font-size: 18px;
+        border: 1.5px solid #409eff;
+        color: #409eff;
+        background: #fff;
+        transition:
+            background 0.2s,
+            color 0.2s;
+    }
 
-.nutrition-setting-dialog .setting-type-btn.active,
-.nutrition-setting-dialog .setting-type-btn:active,
-.nutrition-setting-dialog .setting-type-btn:focus {
-  background: #e6f0ff;
-  color: #409eff;
-  border-color: #409eff;
-}
-</style>
+    .nutrition-setting-dialog .setting-type-btn.active,
+    .nutrition-setting-dialog .setting-type-btn:active,
+    .nutrition-setting-dialog .setting-type-btn:focus {
+        background: #e6f0ff;
+        color: #409eff;
+        border-color: #409eff;
+    }
+</style>