ソースを参照

4019670 疾病选择优化

1. 使用 $name 匹配数据
2. 搜索聚焦判断无选项重新加载
3. 中医诊断页疾病输入优化
cc12458 5 ヶ月 前
コミット
86efc6ea02
3 ファイル変更74 行追加104 行削除
  1. 28 25
      src/components/TCMDiagnosis.vue
  2. 1 1
      src/request/api.illness.js
  3. 45 78
      src/views/diagnosis/Diagnosis.vue

+ 28 - 25
src/components/TCMDiagnosis.vue

@@ -16,6 +16,7 @@
             v-model="key1"
             ref="zybm"
             @input="getDiseaseList(key1)"
+            @focus="handleFocus('bm')"
             @keydown.enter.native="handleEnter('bm')"
           >
             <div slot="suffix" class="suffix">
@@ -28,7 +29,7 @@
               v-for="item in diseaseList"
               :key="item.$uid"
               :class="{
-                active: diseaseCode === item.$code
+                active: name === item.$name
               }"
               @click="handleBm(item)"
             >{{ item.$name }}</li>
@@ -51,6 +52,7 @@
             v-model="key2"
             ref="zhengxing"
             @input="getSymptomList(key2)"
+            @focus="handleFocus('zx')"
             @keydown.enter.native="handleEnter('zx')"
           >
             <div slot="suffix" class="suffix">
@@ -63,7 +65,7 @@
               v-for="item in symptomList"
               :key="item.$uid"
               :class="{
-                active: zhengxingid === item.$code,
+                active: syndrome === item.$name,
                 matched: item.isMatched
               }"
               @click="handleZx(item)"
@@ -82,11 +84,12 @@
         <el-popover placement="bottom" width="180" trigger="focus" :close-delay="100" v-model="popoverZF">
           <el-input
               :size="size" :class="{invalid: therapy && invalid_therapy}"
-              slot="reference" :readonly="therapySearchDisabled"
+              slot="reference"
               :placeholder="key3?key3:'中医治法'"
               v-model="key3"
               ref="zhifa"
               @input="getTherapyList(key3)"
+              @focus="handleFocus('zf')"
               @keydown.enter.native="handleEnter('zf')"
           >
             <div slot="suffix" class="suffix">
@@ -99,7 +102,8 @@
               v-for="item in therapyList"
               :key="item.$uid"
               :class="{
-                active: therapy === item.$name
+                active: therapy === item.$name,
+                matched: item.isMatched
               }"
               @click="handleZf(item)"
             >{{ item.$name }}</li>
@@ -139,7 +143,6 @@ export default {
   },
   data() {
     return {
-      therapySearchDisabled: false,
       invalid_disease: false,
       invalid_symptom: false,
       invalid_therapy: false,
@@ -196,7 +199,7 @@ export default {
           this.invalid_symptom = false;
           this.syndrome = "";
           this.zhengxingid = "";
-        } else if (this.therapySearchDisabled) this.getTherapiesBySymptom();
+        }
         if (!value && oldVal) {
           this.getSymptomList();
           this.getTherapyList();
@@ -204,12 +207,15 @@ export default {
       }
     },
     key3: {
-      handler: function() {
+      handler: function(value, oldVal) {
         if (this.key3 == "") {
           this.invalid_therapy = false;
           this.therapy = "";
           this.therapyCode = "";
         }
+        if (!value && oldVal) {
+          this.getTherapyList();
+        }
       }
     },
     patiensMsg: {
@@ -243,6 +249,16 @@ export default {
     ...mapGetters(["getPatiensInfo", "getOutpatientDiagnosis"])
   },
   methods: {
+    /**
+     * focus 事件
+     * @param {'bm'|'zx'|'zf'} type
+     */
+    handleFocus(type) {
+      console.log(type);
+      if (type === 'bm' && this.diseaseList.length === 0) this.getDiseaseList(this.key1);
+      else if (type === 'zx' && this.symptomList.length === 0) this.getSymptomList(this.key2);
+      else if (type === 'zf' && this.therapyList.length === 0) this.getTherapyList(this.key3);
+    },
     /**
      * enter事件
      * @param {'bm'|'zx'|'zf'} type
@@ -296,9 +312,10 @@ export default {
     setParams(data) {
       this.name = data.namemedicine || "";
       this.zy_dise_id = data.disid || "";
+      this.diseaseCode = data.disCode || "";
       this.zhengxingid = data.symptomid || "";
-      this.therapyCode = data.therapyCode || '';
       this.syndrome = data.syndrometypes || "";
+      this.therapyCode = data.therapyCode || '';
       this.therapy = data.treatment || "";
       this.key1 = this.name || "";
       this.key2 = this.syndrome || "";
@@ -342,7 +359,6 @@ export default {
 
       this.clearZf();
       this.$refs.zhifa.focus();
-      await this.getTherapiesBySymptom();
       await this.getTherapyList();
     },
     handleZf(item) {
@@ -381,7 +397,6 @@ export default {
         disCode: this.diseaseCode,
       })
       this.symptomList = list;
-      await this.getTherapiesBySymptom();
     },
     /**
      * 获取治法
@@ -389,26 +404,14 @@ export default {
      * @return {Promise<void>}
      */
     async getTherapyList(keyword) {
-      if (this.therapySearchDisabled) {
-        await this.getTherapiesBySymptom();
-        return;
-      }
       const {total, list} = await getTherapyListMethod(1, 9999, {
         keyword,
+        disCode: this.diseaseCode,
+        symptomCode: this.zhengxingid,
         symid: this.zhengxingid,
-      }).catch(error => {
-        if (error.isAxiosError && error.message === `Request failed with status code 404`) {
-          this.therapySearchDisabled = true;
-          this.getTherapiesBySymptom();
-        }
-        throw error;
-      });
+      })
       this.therapyList = list;
     },
-    async getTherapiesBySymptom() {
-      const option = findArray(this.symptomList, ['$code', this.zhengxingid]);
-      this.therapyList = option ? option.therapies : [];
-    },
     // 新增处方来源统计
     async addRecipeFrom() {
       let res = await addRecipeFrom({

+ 1 - 1
src/request/api.illness.js

@@ -52,7 +52,7 @@ export function getTherapyListMethod(page = 1, size = 10, query = {}) {
     pagesize: size,
     ...query, name: keyword,
   }, {meta: {share: true, ignoreError: true}}).then(res => {
-    const list = getArray(res.data['diseases'], item => Object.assign(item, {
+    const list = getArray(res.data, item => Object.assign(item, {
       $uid: randomUUID(),
       $code: item.therapyCode,
       $name: item.therapy,

+ 45 - 78
src/views/diagnosis/Diagnosis.vue

@@ -264,6 +264,7 @@ export default {
   data() {
     return {
       type: "zyzd",
+      dise_id: '',
       dise_name: "",
       zy_dise_id: "",
       zhengxing: "",
@@ -699,95 +700,61 @@ export default {
     dealBackShow(res) {
       this.isEdit = res.Data.mainDiagnosis.pid;
 
-      this.type = res.Data.mainDiagnosis.diagnosis ? "xyzd" : "zyzd";
-      let dise_id = res.Data.mainDiagnosis.disid
-        ? res.Data.mainDiagnosis.disid
-        : res.Data.mainDiagnosis.westcode;
-      let dise_name = res.Data.mainDiagnosis.namemedicine
-        ? res.Data.mainDiagnosis.namemedicine
-        : res.Data.mainDiagnosis.westcode;
-
-      this.zhengxing = res.Data.mainDiagnosis.syndrometypes;
-      this.zhengxingid = res.Data.mainDiagnosis.symptomid;
-      this.zhifa = res.Data.mainDiagnosis.treatment;
-      this.dise_name = dise_name;
-      this.zy_dise_id = dise_id;
-
-      let TCM = this.$refs.TCM;
-      TCM.setParams({
-        namemedicine: this.dise_name,
-        disid: this.zy_dise_id,
-        symptomid: this.zhengxingid,
-        syndrometypes: this.zhengxing,
-        treatment: this.zhifa
-      });
+      const diagnosis = res.Data.mainDiagnosis;
 
-      // 如果主诊断 为中医诊断
-      if (res.Data.mainDiagnosis.disid) {
-        this.getCCardType(res.Data.mainDiagnosis.disid);
+      this.type = diagnosis.maindiagnosis === '0' ? 'zyzd' : 'xyzd';
 
-        setTimeout(() => {
-          let list = this.cCardTypeL.filter(item => {
-            return item.symid == this.zhengxingid;
-          });
-          this.therapy = list.length > 0 ? list[0].therapys : [];
-        }, 1000);
-      }
+      if (this.type === 'zyzd') {
+        this.$nextTick(() => {
+          this.$refs.TCM.setParams({
+            namemedicine: diagnosis.namemedicine,
+            disid: diagnosis.disid,
+            symptomid: diagnosis.symptomid,
+            syndrometypes: diagnosis.syndrometypes,
+            treatment: diagnosis.treatment,
 
-      //更新次诊断信息
+            disCode: diagnosis.disCode,
 
-      let data = [];
-      if (this.$route.query.type == "trun") {
-        //  转病例进来
-        data = res.Data.secondarydiagnosis ? res.Data.secondarydiagnosis : [];
+            diseaseCode: diagnosis.disCode,
+            symptomCode: diagnosis.symptomid,
+            therapyCode: diagnosis.therapyCode,
+          });
+        })
       } else {
-        data = res.Data.secondaryDiagnosises
-          ? res.Data.secondaryDiagnosises
-          : [];
+        this.dise_id = diagnosis.westcode;
+        this.dise_name = diagnosis.diagnosis;
       }
-      let arr = [];
 
-      data.forEach((item, index) => {
-        let obj = {
-          id: 1,
-          type: item.diagnosis ? "xyzd" : "zyzd",
-          cid: item.disid, // 中医病名id
-          xid: item.westcode, // 西医病名id
-          cname: item.namemedicine, // 中医病名
-          xname: item.diagnosis, // 西医病名
-          zhengxingid: item.symptomid, // 证型id
-          zhengxing: item.syndrometypes, // 证型
-          zhifa: item.treatment, // 治法
-          therapy: [],
-          cCardTypeL: [],
-          pid: item.pid
-        };
+      //更新次诊断信息
+      const secondaryDiagnosis = this.$route.query.type === 'trun' ? res.Data.secondarydiagnosis : res.Data.secondaryDiagnosises;
 
-        arr.push(obj);
-      });
-      if (data.length > 0) {
-        this.tableData = arr;
-
-        this.tableData.forEach((item, index) => {
-          item.id = index + 1;
-          let TCMITEM = this.$refs["TCM" + item.id];
-          TCMITEM.setParams({
-            namemedicine: item.cname,
-            disid: item.cid,
-            symptomid: item.zhengxingid,
-            syndrometypes: item.zhengxing,
-            treatment: item.zhifa
-          });
+      if (Array.isArray(secondaryDiagnosis)) {
+        this.tableData = secondaryDiagnosis.map((item, index) => {
+          const type = item.secondarydiagnosis === '0' ? 'zyzd' : 'xyzd';
+          return { type, id: index, pid: item.pid, xid: item.westcode, xname: item.diagnosis, _rawData: item };
         });
-
-        this.tableData.filter((item, index) => {
-          return (item.id = index + 1);
+        this.$nextTick(() => {
+          for (const item of this.tableData) {
+            if (item.type === "zyzd") {
+              const diagnosis = item._rawData;
+              this.$refs[`TCM${item.id}`].setParams({
+                namemedicine: diagnosis.namemedicine,
+                disid: diagnosis.disid,
+                symptomid: diagnosis.symptomid,
+                syndrometypes: diagnosis.syndrometypes,
+                treatment: diagnosis.treatment,
+
+                disCode: diagnosis.disCode,
+
+                diseaseCode: diagnosis.disCode,
+                symptomCode: diagnosis.symptomid,
+                therapyCode: diagnosis.therapyCode,
+              });
+            }
+          }
         });
       }
-
-      setTimeout(() => {
-        this.hasEdit = false;
-      }, 100);
+      this.hasEdit = false;
     },
     // 新增处方来源统计
     async addRecipeFrom() {