Преглед на файлове

Merge branch 'feature/therapy' into develop

cc12458 преди 5 месеца
родител
ревизия
8467593d23
променени са 3 файла, в които са добавени 153 реда и са изтрити 103 реда
  1. 9 0
      src/api/knowledge.js
  2. 141 100
      src/components/TCMDiagnosis.vue
  3. 3 3
      src/views/diagnosis/Prescribing.vue

+ 9 - 0
src/api/knowledge.js

@@ -29,6 +29,15 @@ export function getCCardType(data) {
     })
 };
 
+// 获取中医治法
+export function getCTherapy(data) {
+    return request({
+        url: '/basis/knowlib/getTherapyAll',
+        method: 'post',
+        data
+    })
+};
+
 // 获取穴位信息
 export function getXueweiList(data) {
     return request({

+ 141 - 100
src/components/TCMDiagnosis.vue

@@ -15,8 +15,8 @@
             :placeholder="key1?key1:'中医病名'"
             v-model="key1"
             ref="zybm"
-            id="zybm"
-            @input="getOriginNameData(key1)"
+            @input="getNamemedData(key1)"
+            @keydown.enter.native="handleEnter('bm')"
           >
             <div slot="suffix" class="suffix">
               <i class="el-icon-arrow-down" v-if="!key1"></i>
@@ -27,7 +27,9 @@
             <li
               v-for="(item,index) in cDiseaseNameL"
               :key="index"
-              :class="[zy_dise_id==item.disid?'active':'']"
+              :class="{
+                active: zy_dise_id === item.disid
+              }"
               @click="handleBm(item)"
             >{{ item.disname }}</li>
           </ul>
@@ -48,8 +50,8 @@
             :placeholder="key2?key2:'中医证型'"
             v-model="key2"
             ref="zhengxing"
-            id="zyzx"
-            @input="getOriginZxData(key2)"
+            @input="getCardType(key2)"
+            @keydown.enter.native="handleEnter('zx')"
           >
             <div slot="suffix" class="suffix">
               <i class="el-icon-arrow-down" v-if="!key2"></i>
@@ -60,7 +62,10 @@
             <li
               v-for="(item,index) in cCardTypeL"
               :key="index"
-              :class="[zhengxingid==item.symid?'active':'',item.isMatched?'matched':'']"
+              :class="{
+                active: zhengxingid === item.symid,
+                matched: item.isMatched
+              }"
               @click="handleZx(item)"
             >{{ item.symname }}</li>
           </ul>
@@ -74,9 +79,33 @@
         <span>治法:</span>
       </div>
       <div class="value">
-        <el-select :size="size" v-model="therapy" ref="zhifa" :automatic-dropdown="true">
-          <el-option v-for="(item,index) in therapyList" :key="index" :value="item"></el-option>
-        </el-select>
+        <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"
+              :placeholder="key3?key3:'中医治法'"
+              v-model="key3"
+              ref="zhifa"
+              @input="getTherapy(key3)"
+              @keydown.enter.native="handleEnter('zf')"
+          >
+            <div slot="suffix" class="suffix">
+              <i class="el-icon-arrow-down" v-if="!key3"></i>
+              <i class="el-icon-circle-close" v-else @click="clearZf"></i>
+            </div>
+          </el-input>
+          <ul class="option-list">
+            <li
+              v-for="(item,index) in therapyList"
+              :key="index"
+              :class="{
+                active: therapy === item.therapy
+              }"
+              @click="handleZf(item)"
+            >{{ item.therapy }}
+            </li>
+          </ul>
+        </el-popover>
       </div>
     </div>
   </div>
@@ -85,11 +114,20 @@
 import {
   getCDiseaseName,
   getXDiseaseName,
-  getCCardType
+  getCCardType,
+  getCTherapy,
 } from "@/api/knowledge.js";
 import {addDiagnosisData2} from '@/api/diagnosis.js';
 import { addRecipeFrom } from "@/api/dataAnalysis.js";
 import { mapGetters } from "vuex";
+
+/**
+ * 搜索类型,1为拼音码,2为五笔码,搜索中文时可传空
+ * @param value
+ * @return {'1'|''}
+ */
+const isPY = (value) => value && /^[A-Za-z]+$/g.test(value) ? '1' : '';
+
 export default {
   props: {
     title: {
@@ -115,6 +153,9 @@ export default {
     return {
       invalid_dis: false,
       invalid_symptom: false,
+      invalid_therapy: false,
+
+      popoverZF: false,
 
       name: "", // 病名
       zy_dise_id: "", // 病名id
@@ -123,6 +164,7 @@ export default {
       zhengxingid: "", // 证型id
 
       therapy: "", // 治法
+      therapyCode: '', // 治法
 
       cDiseaseNameL: [], // 病名列表
       cCardTypeL: [], // 证型列表
@@ -131,6 +173,7 @@ export default {
       isInit: false, // 是否根据传入的数据初始化过
       key1: "", // 病名搜索条件
       key2: "", // 证型
+      key3: '', // 治法
 
       isEnter1: false, // 是否进入病名输入框
       isEnter2: false // 是否进入证型输入宽
@@ -139,18 +182,7 @@ export default {
   mounted() {
     this.getNamemedData();
     this.getCardType();
-
-    let _this = this;
-    document.getElementById("zybm").addEventListener("keydown", function(e) {
-      if (e.key === "Enter") {
-        _this.handleBmEnter();
-      }
-    });
-    document.getElementById("zyzx").addEventListener("keydown", function(e) {
-      if (e.key === "Enter") {
-        _this.handleZxEnter();
-      }
-    });
+    this.getTherapy();
   },
   watch: {
     key1: {
@@ -171,6 +203,15 @@ export default {
         }
       }
     },
+    key3: {
+      handler: function() {
+        if (this.key3 == "") {
+          this.invalid_therapy = false;
+          this.therapy = "";
+          this.therapyCode = "";
+        }
+      }
+    },
     patiensMsg: {
       immediate: true,
       deep: true,
@@ -186,10 +227,13 @@ export default {
         this.zhengxingid = this.patiensMsg.maindiagnosis.symptomid || "";
         // 治法
         this.therapy = this.patiensMsg.maindiagnosis.treatment || "";
+        this.therapyCode = this.patiensMsg.maindiagnosis.therapyCode || '';
         this.key1 = this.name || "";
         this.key2 = this.syndrome || "";
-        this.getNamemedData(this.name, "");
-        this.getCardType(this.syndrome, "");
+        this.key3 = this.therapy || '';
+        if (this.key1) this.getNamemedData(this.key1);
+        if (this.key2) this.getCardType(this.key2);
+        if (this.key3) this.getTherapy(this.key3);
         this.isInit = true;
       }
     }
@@ -198,15 +242,14 @@ export default {
     ...mapGetters(["getPatiensInfo", "getOutpatientDiagnosis"])
   },
   methods: {
-    // 病名enter事件
-    handleBmEnter() {
-      if (this.cDiseaseNameL.length == 0) return;
-      this.handleBm(this.cDiseaseNameL[0]);
-    },
-    // 症行enter事件
-    handleZxEnter() {
-      if (this.cCardTypeL.length == 0) return;
-      this.handleZx(this.cCardTypeL[0]);
+    /**
+     * enter事件
+     * @param {'bm'|'zx'|'zf'} type
+     */
+    handleEnter(type) {
+      if (type === 'bm' && this.cDiseaseNameL.length) this.handleBm(this.cDiseaseNameL[0]);
+      else if (type === 'zx' && this.cCardTypeL.length) this.handleZx(this.cCardTypeL[0]);
+      else if (type === 'zf' && this.therapyList.length) this.handleZf(this.therapyList[0]);
     },
     // 获取中医诊断信息
     getDiamsg() {
@@ -214,9 +257,15 @@ export default {
       return {
         disid: this.zy_dise_id,
         symptomid: this.zhengxingid,
+        therapyCode: this.therapyCode,
         treatment: this.therapy
       };
     },
+    optimalTherapyCode() {
+      if (this.therapy && !this.therapyCode) try {
+        this.therapyCode = this.therapyList.find(item => [item.therapy, item['therapyName']].includes(this.therapy)).therapyCode;
+      } catch (_) {}
+    },
     // 获取内容参数
     getParams() {
       return {
@@ -227,6 +276,7 @@ export default {
         symptomid: this.zhengxingid,
         syndrometypes: this.syndrome,
         //   治法
+        therapyCode: this.therapyCode,
         treatment: this.therapy
       };
     },
@@ -235,37 +285,18 @@ export default {
       this.name = data.namemedicine || "";
       this.zy_dise_id = data.disid || "";
       this.zhengxingid = data.symptomid || "";
+      this.therapyCode = data.therapyCode || '';
       this.syndrome = data.syndrometypes || "";
       this.therapy = data.treatment || "";
       this.key1 = this.name || "";
       this.key2 = this.syndrome || "";
-      this.getNamemedData(this.name, "");
-      this.getCardType(this.syndrome, "");
+      this.key3 = this.therapy || '';
+      if (this.key1) this.getNamemedData(this.key1);
+      if (this.key2) this.getCardType(this.key2);
+      if (this.key3) this.getTherapy(this.key3);
 
       this.$forceUpdate();
     },
-    // 远程搜索病名
-    getOriginNameData(e) {
-      let pinyin = /^[A-Za-z]+$/g;
-      if (pinyin.test(e)) {
-        // 拼音
-        this.getNamemedData(e, "1");
-      } else {
-        // 中文
-        this.getNamemedData(e, "");
-      }
-    },
-    // 搜索证型
-    getOriginZxData(e) {
-      let pinyin = /^[A-Za-z]+$/g;
-      if (pinyin.test(e)) {
-        // 拼音
-        this.getCardType(e, "1");
-      } else {
-        // 中文
-        this.getCardType(e, "");
-      }
-    },
     // 病名选中
     handleBm(item) {
       this.invalid_dis = false
@@ -274,10 +305,7 @@ export default {
       this.key1 = item.disname;
       this.$refs.zybm.blur();
 
-      this.key2 = '';
-      this.syndrome = "";
-      this.zhengxingid = "";
-      this.therapy = "";
+      this.clearZx();
 
       if (this.name === "") return;
       // this.getCCardType(this.zy_dise_id);
@@ -290,11 +318,8 @@ export default {
     clearBm() {
       this.name = "";
       this.zy_dise_id = "";
-      this.syndrome = "";
-      this.zhengxingid = "";
-      this.therapy = "";
       this.key1 = "";
-      this.key2 = "";
+      this.clearZx();
     },
     // 证型选中\
     handleZx(item) {
@@ -304,58 +329,70 @@ export default {
       this.zhengxingid = item.symid;
       this.$refs.zhengxing.blur();
 
-      this.therapy = "";
-      this.therapyList = item.therapys;
-
+      this.clearZf();
+      this.getTherapy();
       setTimeout(() => {
         this.$refs.zhifa.focus();
       }, 0);
     },
+    handleZf(item) {
+      this.invalid_therapy = false;
+      this.therapy = item.therapy;
+      this.therapyCode = item.therapyCode;
+      this.key3 = this.therapy;
+      this.$nextTick(() => {
+        this.$refs.zhifa.blur();
+        this.popoverZF = false;
+      });
+    },
     // 清空证型
     clearZx() {
       this.syndrome = "";
       this.zhengxingid = "";
-      this.therapy = "";
-
       this.key2 = "";
+      this.clearZf();
+    },
+    // 清空证型
+    clearZf() {
+      this.therapy = '';
+      this.therapyCode = '';
+      this.key3 = '';
     },
     //获取病名数据
-    async getNamemedData(key = "", serchtype = "") {
-      /*
-      serchtype:搜索类型,1为拼音码,2为五笔码,搜索中文时可传空
-      */
-      let params = {
+    async getNamemedData(keyword = '') {
+      const res = await getCDiseaseName({
         pageid: 1,
         pagesize: 9999,
-        keyword: key,
-        serchtype
-      };
-      let res = await getCDiseaseName(params);
-      if (res.code == 0) {
-        this.cDiseaseNameL = res.data.diseases;
-      }
+        keyword,
+        serchtype: isPY(keyword),
+      }).catch(() => ({code: -1}));
+      this.cDiseaseNameL = res.code === 0 ? res.data.diseases : [];
     },
     // 获取证型数据
-    async getCardType(key = "", serchtype = "") {
-      let params = {
+    async getCardType(keyword = '') {
+      const res = await getCCardType({
         pageid: 1,
-        pagesize: 20000,
-        keyword: key,
-        serchtype,
+        pagesize: 9999,
+        keyword,
+        serchtype: isPY(keyword),
         disid: this.zy_dise_id
-      };
-      let res = await getCCardType(params);
-      if (res.code == 0) {
-        this.cCardTypeL = res.data.sysptoms;
-        setTimeout(() => {
-          this.cCardTypeL.map(item => {
-            if (item.symid == this.zhengxingid) {
-              // console.log(item, "dayin item");
-              this.therapyList = item.therapys;
-            }
-          });
-        }, 200);
-      }
+      }).catch(() => ({code: -1}));
+      this.cCardTypeL = res.code === 0 ? res.data.sysptoms : [];
+    },
+    /**
+     * 获取治法
+     * @param keyword
+     * @return {Promise<void>}
+     */
+    async getTherapy(keyword) {
+      const res = await getCTherapy({
+        pageid: 1,
+        pagesize: 9999,
+        serchtype: isPY(keyword),
+        name: keyword,
+        symid: this.zhengxingid,
+      }).catch(() => ({code: -1}));
+      this.therapyList = res.code === 0 ? res.data : [];
     },
     // 新增处方来源统计
     async addRecipeFrom() {
@@ -365,10 +402,12 @@ export default {
     },
     // 保存中医诊断信息
     async saveDiagnosisData() {
+      this.optimalTherapyCode();
       let params = {
         mainDiagnosis: {
           disid: this.zy_dise_id,
           symptomid: this.zhengxingid,
+          therapyCode: this.therapyCode,
           treatment: this.therapy,
           maindiagnosis: "0",
           recordsid: this.getPatiensInfo.pid,
@@ -385,9 +424,11 @@ export default {
 
         this.invalid_dis = !mainDiagnosis.disid;
         this.invalid_symptom = !mainDiagnosis.symptomid;
+        this.invalid_therapy = !mainDiagnosis.therapyCode;
         const tips = [
           this.invalid_dis ? `${this.title}病名` : '',
           this.invalid_symptom ? `证型` : '',
+          this.invalid_therapy ? `治法` : '',
         ].filter(Boolean).join(',');
         if (tips) throw {message: `当前${tips}与医保不匹配,请更换${tips}等诊断信息!`};
 

+ 3 - 3
src/views/diagnosis/Prescribing.vue

@@ -1874,7 +1874,7 @@ export default {
           usestr: item.bottom_form.usege, //处方用法
           zhongdetail: [], // 中药明细 表格内部数据
           // preId: this.$route.query.recipeID ? this.$route.query.recipeID : ""
-          preId: item.preId ? item.pageId : ""
+          preId: item.preId || "",
         };
         console.log("保存值", obj.isdelivery)
         item.totalTableD.forEach(item1 => {
@@ -1978,7 +1978,7 @@ export default {
         type: 1,
         chengDetail: [],
         // preId: this.$route.query.recipeID ? this.$route.query.recipeID : ""
-        preId: data1.preId ? data1.pageId : ""
+        preId: data1.preId || "",
       };
 
       data1.tableData3.forEach(item => {
@@ -2062,7 +2062,7 @@ export default {
         type: 2,
         useexplain: data1.bottom_form.caozuo,
         // preId: this.$route.query.recipeID ? this.$route.query.recipeID : "",
-        preId: data1.preId ? data1.pageId : "",
+        preId: data1.preId || "",
         detail: []
       };