Explorar el Código

患者信息选择理疗信息新增理疗分类

wjj hace 3 semanas
padre
commit
2b001dded1

+ 2 - 2
src/api/project/project.js

@@ -1,9 +1,9 @@
 import request from '@/utils/request'
 
 // 查询患者基本信息详细
-export function options() {
+export function options(cateId) {
   return request({
-    url: '/company/project/options',
+    url: '/company/project/options?cateId=' + cateId,
     method: 'get'
   })
 }

+ 9 - 0
src/api/projectCate/projectCate.js

@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+// 查询患者基本信息详细
+export function options() {
+  return request({
+    url: '/company/projectCate/options',
+    method: 'get'
+  })
+}

+ 55 - 5
src/views/qw/patient/index.vue

@@ -114,6 +114,12 @@
     <!-- 添加或修改患者基本信息对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="理疗分类" prop="projectCateId">
+          <el-select @change="handleCategoryChange" v-model="form.projectCateId" placeholder="请选择理疗分类">
+            <el-option v-for="dict in projectCateList" :key="dict.id" :label="dict.cateName"
+              :value="parseInt(dict.id)"></el-option>
+          </el-select>
+        </el-form-item>
         <el-form-item label="理疗方案" prop="projectId">
           <el-select v-model="form.projectId" placeholder="请选择理疗方案">
             <el-option v-for="dict in projectOptions" :key="dict.id" :label="dict.projectName"
@@ -175,6 +181,7 @@
 <script>
 import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, getWxaCodePatientUnLimit, reject } from "@/api/patient/info";
 import { options as projectOptions } from "@/api/project/project";
+import { options as projectCateOptions } from "@/api/projectCate/projectCate";
 import { options } from "@/api/course/coursePlaySourceConfig";
 
 export default {
@@ -218,6 +225,8 @@ export default {
       ],
       //理疗选项
       projectOptions: [],
+      //理疗分类
+      projectCateList: [],
       sourceList: [],
       // 查询参数
       queryParams: {
@@ -273,12 +282,23 @@ export default {
     options().then(res => {
       this.sourceList = res.data;
     });
-    projectOptions().then(res => {
-      this.projectOptions = res.data;
+    // projectOptions().then(res => {
+    //   this.projectOptions = res.data;
+    // });
+    projectCateOptions().then(res => {
+      this.projectCateList = res.data;
     });
     this.getList();
   },
   methods: {
+    handleCategoryChange(cateId){
+      this.form.projectId = null; // 重置方案选择
+      this.projectOptions = [];
+      if(!cateId) return;
+      projectOptions(cateId).then(res => {
+        this.projectOptions = res.data;
+      });
+    },
     shareSubmit(){
       let loadingRock = this.$loading({
         lock: true,
@@ -359,6 +379,7 @@ export default {
         status: 0,
         doctorStatus: 0
       };
+      this.projectOptions = [];
       this.resetForm("form");
     },
     /** 搜索按钮操作 */
@@ -388,9 +409,38 @@ export default {
       this.reset();
       const id = row.id || this.ids
       getInfo(id).then(response => {
-        this.form = response.data;
-        this.open = true;
-        this.title = "修改患者基本信息";
+        const data = response.data;
+        // 如果存在理疗分类ID,需要先加载对应的方案列表
+        if (data.projectCateId) {
+          // 1. 先设置分类ID,触发视图更新(可选,主要是为了逻辑清晰)
+          this.form.projectCateId = data.projectCateId;
+          // 2. 根据分类ID获取方案列表
+          projectOptions(data.projectCateId).then(res => {
+            this.projectOptions = res.data;
+            
+            // 确保 projectId 存在且在 options 中
+            const projectId = data.projectId;
+            if (projectId && this.projectOptions.some(opt => opt.id === projectId)) {
+              this.form.projectId = projectId;
+            } else {
+              this.form.projectId = null; // 防止无效值
+          }
+
+            // 最后赋值其他字段
+            Object.assign(this.form, data);
+            this.open = true;
+            this.title = "修改患者基本信息";
+          }).catch(err => {
+            console.error("获取方案列表失败:", err);
+            this.form = data;
+            this.open = true;
+            this.title = "修改患者基本信息";
+          });
+        } else {
+          this.form = response.data;
+          this.open = true;
+          this.title = "修改患者基本信息";
+        }
       });
     },
     /** 提交按钮 */