Просмотр исходного кода

Merge branch 'feature/bug-81' into develop

cc12458 11 месяцев назад
Родитель
Сommit
974378f5d8

+ 6 - 0
src/components/ChineseMedicine.vue

@@ -1038,6 +1038,7 @@ export default {
           isMyMade: true,
           disable: false,
           name: "处方1",
+          id: "", // 当前选择的处方 id(推荐方剂)
           pharmacyID: "", // 药房id
           isPay: false, // 是否支付
           prescribed: 0, // 是否开方 0 否 1是
@@ -2820,6 +2821,11 @@ export default {
     }
   },
   computed: {
+    saveable() /* 父组件 获取 */ {
+      const recipes = this.recipe_tabs.filter(item => +item.paystate === 0);
+      if (recipes.length > 1) return true
+      return recipes[0] && recipes[0].totalTableD.some(item => item.name)
+    },
     ...mapGetters(["getuserinfo", "getPatiensInfo"])
   },
   watch: {

+ 30 - 6
src/components/MedicineAndChina.vue

@@ -23,6 +23,7 @@
                       @keydown.down.native="drugDown($event,scope)"
                       @keydown.up.native="drugUp($event,scope)"
                       @keydown.enter.native="drugEnter(scope)"
+                      :disabled="!editable"
                     ></el-input>
 
                     <div class="table-choose3" v-if="scope.row.key">
@@ -84,7 +85,7 @@
                       @keydown.down.native="drugDown($event,scope)"
                       @keydown.up.native="drugUp($event,scope)"
                       @keydown.enter.native="drugEnter(scope)"
-                      :disabled="recipe_tabs[recipe_tabs_c].disable"
+                      :disabled="!editable"
                     ></el-input>
                     <!-- v-model="scope.row.key" -->
                     <div class="table-choose3" v-if="scope.row.key">
@@ -233,10 +234,10 @@
             <el-table-column label="操作" fixed="right">
               <template slot-scope="scope">
                 <div class="operate" v-if="scope.row.name">
-                  <div>
+                  <div v-if="editable">
                     <img src="../assets/add.png" alt @click="addDrug3(scope)" />
                   </div>
-                  <div>
+                  <div v-if="editable">
                     <img src="../assets/delete1.png" alt @click="deleteDrug3(scope)" />
                   </div>
                   <div>
@@ -250,7 +251,7 @@
                 </div>
 
                 <div v-else class="operate">
-                  <div v-if="scope.row.id!==tableData3.length">
+                  <div v-if="editable && scope.row.id!==tableData3.length">
                     <img src="../assets/delete1.png" alt @click="deleteDrug3(scope)" />
                   </div>
                 </div>
@@ -403,7 +404,7 @@
             type="primary"
             size="mini"
             @click="submit()"
-            v-if="prescribed==0 || !prescribed"
+            v-if="editable"
           >保存处方</el-button>
         </template>
 
@@ -412,7 +413,7 @@
             type="primary"
             size="mini"
             @click="submit()"
-            v-if="paystate==0 || !paystate"
+            v-if="editable"
           >保存处方</el-button>
         </template>
       </div>
@@ -1111,6 +1112,29 @@ export default {
     }
   },
   computed: {
+    editable() {
+      switch (+this.isAutoCheck) {
+        case 0:
+          /**
+           * v-if="isAutoCheck==0"
+           * v-if="prescribed==0 || !prescribed"
+           * 保存处方
+           */
+          return +this.prescribed === 0
+        case 1:
+          /**
+           * v-if="isAutoCheck==1"
+           * v-if="paystate==0 || !paystate"
+           * 保存处方
+           */
+          return +this.paystate === 0
+        default:
+          return false
+      }
+    },
+    saveable() /* 父组件 获取 */ {
+      return this.editable && this.tableData3.some(item => item.name)
+    },
     ...mapGetters(["getuserinfo", "getPatiensInfo"])
   }
 };

+ 36 - 8
src/components/SuitScience.vue

@@ -24,7 +24,7 @@
                       remote
                       :value="scope.row.name"
                       filterable
-                      placeholder="请选择"
+                      placeholder="请选择" :disabled="!editable"
                       @change="acunameC($event,scope)"
                       :filter-method="filterMethod"
                     >
@@ -42,8 +42,8 @@
               <el-table-column label="操作" width="100">
                 <template slot-scope="scope">
                   <div class="operate">
-                    <img src="../assets/add.png" alt @click="addData(scope)" />
-                    <img src="../assets/delete1.png" alt @click="deleteData(scope)" />
+                    <img v-if="editable" src="../assets/add.png" alt @click="addData(scope)" />
+                    <img v-if="editable" src="../assets/delete1.png" alt @click="deleteData(scope)" />
                     <img src="../assets/find.png" alt @click="find(scope)" />
                   </div>
                 </template>
@@ -63,7 +63,7 @@
                       remote
                       :value="scope.row.name"
                       filterable
-                      placeholder="请选择"
+                      placeholder="请选择" :disabled="!editable"
                       @change="acunameC($event,scope)"
                       :filter-method="filterMethod"
                     >
@@ -81,8 +81,8 @@
               <el-table-column label="操作" width="100">
                 <template slot-scope="scope">
                   <div class="operate">
-                    <img src="../assets/add.png" alt @click="addData(scope)" />
-                    <img src="../assets/delete1.png" alt @click="deleteData(scope)" />
+                    <img v-if="editable" src="../assets/add.png" alt @click="addData(scope)" />
+                    <img v-if="editable" src="../assets/delete1.png" alt @click="deleteData(scope)" />
                     <img src="../assets/find.png" alt @click="find(scope)" />
                   </div>
                 </template>
@@ -171,7 +171,7 @@
             type="primary"
             size="mini"
             @click="submit()"
-            v-if="prescribed==0 || !prescribed"
+            v-if="editable"
           >保存处方</el-button>
         </template>
 
@@ -180,7 +180,7 @@
             type="primary"
             size="mini"
             @click="submit()"
-            v-if="paystate==0 || !paystate"
+            v-if="editable"
           >保存处方</el-button>
         </template>
       </div>
@@ -204,6 +204,29 @@ export default {
     }
   },
   computed: {
+    editable() {
+      switch (+this.isAutoCheck) {
+        case 0:
+          /**
+           * v-if="isAutoCheck==0"
+           * v-if="prescribed==0 || !prescribed"
+           * 保存处方
+           */
+          return +this.prescribed === 0
+        case 1:
+          /**
+           * v-if="isAutoCheck==1"
+           * v-if="paystate==0 || !paystate"
+           * 保存处方
+           */
+          return +this.paystate === 0
+        default:
+          return false
+      }
+    },
+    saveable() /* 父组件 获取 */ {
+      return this.editable && this.tableData4.some(item => item.name)
+    },
     ...mapGetters(["getuserinfo", "getPatiensInfo"])
   },
   data() {
@@ -213,6 +236,7 @@ export default {
       isAutoCheck: "0", // 是否自动审核 0 手动 1自动 (自动的时候用his 的是否支付成功字段 判断显示)
       paystate: 0, // 云his 是否支付  0 否 1是(为否可以编辑)
       name: "适宜技术处方",
+      recipeId: "", // 当前选择的处方 id(推荐方剂)
       tableData4: [
         {
           id: 1,
@@ -291,6 +315,10 @@ export default {
     },
     //清空处方
     clear() {
+      if (!this.editable) {
+        this.$message.warning("已支付处方不可以清空");
+        return;
+      }
       this.isMyMade = true;
       this.tableData4 = [
         {

+ 1 - 1
src/components/ui/suitMadePad.vue

@@ -109,7 +109,7 @@
         margin: 0 auto;
         width: 100%;
         // height: 609px;
-        height: 459px; // 1280 下
+        height: 560px; // 1280 下
         overflow: auto;
         padding: 5px;
         box-sizing: border-box;

+ 3 - 0
src/store/index.js

@@ -32,6 +32,9 @@ export default new Vuex.Store({
     getDrugInfo(state) {
       return state.drug.drugsInfo
     },
+    getRecipeId(state) {
+      return state.drug.recipeId;
+    },
     getIsSee(state) {
       return state.user.isSeeDoctor
     },

+ 5 - 1
src/store/modules/drug.js

@@ -2,7 +2,7 @@ export default {
   namespaced: true,
   state: {
     drugsInfo: sessionStorage.getItem('drugsInfo') ? JSON.parse(sessionStorage.getItem('drugsInfo')) : {}, // 病人信息
-
+    recipeId: sessionStorage.getItem('recipeId'),
   },
   mutations: {
     setDrugsInfo(state, data) {
@@ -10,6 +10,10 @@ export default {
       sessionStorage.setItem('drugsInfo', JSON.stringify(data))
       state.drugsInfo = data
     },
+    setRecipeId(state, id) {
+      sessionStorage.setItem('recipeId', id)
+      state.recipeId = id
+    }
 
   },
   getters: {

+ 1 - 1
src/utils/minix/prescribing.js

@@ -13,7 +13,7 @@ export default {
 
             saving: false,
 
-            // 中药处方 中成药处方 适宜技术处方提交前暂存
+            // 中药处方 中药制剂 适宜技术处方提交前暂存
             zhongPrescriptionVo: null,
             chengPrescriptionVo: null,
             technologyPrescriptionVo: null,

+ 1 - 1
src/views/Validation.vue

@@ -288,7 +288,7 @@
             </div>
           </div>
         </div>
-        <div class="title mr-t20">中成药处方</div>
+        <div class="title mr-t20">中药制剂</div>
         <div class="flex-vertical-center-l flex-wrap">
           <div class="flex-plane-center-l item" v-for="(item,index) in msg.solidPre" :key="index">
             <div v-for="(item1,index1) in item.solidPreList" :key="index1">

+ 1 - 1
src/views/business/MedRecordDetail copy.vue

@@ -99,7 +99,7 @@
           <div class="right">
             <div v-for="(item1,index1) in item.patientprescription" :key="index1">
               <div class="flex-plane-center-l opinion">
-                <span>{{item1.type=='0'?'中药处方':item1.type=="1"?'中成药处方':'适宜技术处方'}}</span>
+                <span>{{item1.type=='0'?'中药处方':item1.type=="1"?'中药制剂':'适宜技术处方'}}</span>
                 <div
                   class="flex-center zhuanfang"
                   @click="$router.push({path:'/index/prescribing?recipeID='+item1.pid})"

+ 1 - 1
src/views/business/MedRecordDetail.vue

@@ -130,7 +130,7 @@
           <div class="right">
             <div v-for="(item1,index1) in item.patientprescription" :key="index1">
               <div class="flex-plane-center-l opinion">
-                <span>{{item1.type=='0'?'中药处方':item1.type=="1"?'中成药处方':'适宜技术处方'}}</span>
+                <span>{{item1.type=='0'?'中药处方':item1.type=="1"?'中药制剂':'适宜技术处方'}}</span>
                 <div
                   class="flex-center zhuanfang"
                   @click="$router.push({path:'/index/prescribing?recipeID='+item1.pid})"

+ 1 - 1
src/views/business/Recipe.vue

@@ -149,7 +149,7 @@
           <el-table-column prop="type" label="处方类型" width="95">
             <template
               slot-scope="scope"
-            >{{scope.row.type=='0'?'中药处方':scope.row.type=='1'?'中成药处方':'适宜技术处方'}}</template>
+            >{{scope.row.type=='0'?'中药处方':scope.row.type=='1'?'中药制剂':'适宜技术处方'}}</template>
           </el-table-column>
 
           <!-- <el-table-column prop="detail" label="明细" width="170">

+ 1 - 1
src/views/business/RecipeAudit.vue

@@ -168,7 +168,7 @@
           <el-table-column prop="type" label="处方类型" width="100">
             <template
               slot-scope="scope"
-            >{{scope.row.type=='0'?'中药处方':scope.row.type=='1'?'中成药处方':'适宜技术处方'}}</template>
+            >{{scope.row.type=='0'?'中药处方':scope.row.type=='1'?'中药制剂':'适宜技术处方'}}</template>
           </el-table-column>
 
           <!-- <el-table-column prop="detail" label="明细" width="170">

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

@@ -1494,7 +1494,7 @@ export default {
 
       return zhongPrescriptionVo;
     },
-    // 处理中成药处方提交数据
+    // 处理中药制剂提交数据
     dealRecipe2() {
       let children = this.$children.filter(item => {
         return (
@@ -1506,7 +1506,7 @@ export default {
 
       let data1 = children[1];
       if (data1.tableData3.length == 1) {
-        // this.$message.error("请完善中成药处方药品信息");
+        // this.$message.error("请完善中药制剂药品信息");
         return {};
       }
       let hasDrugMsg = [];
@@ -1890,7 +1890,7 @@ export default {
         loading.close();
       }, 1000);
     },
-    // 获取数据 赋值给 中成药处方
+    // 获取数据 赋值给 中药制剂
     assignRecipe2(data, loading) {
       setTimeout(() => {
         let children = this.$children.filter(item => {

+ 161 - 215
src/views/diagnosis/Prescribing.vue

@@ -286,13 +286,9 @@
       <div class="flex-vertical-between center-header">
         <div class="center-tab flex-vertical-center-l">
           <template v-for="(item,index) in contentTabs">
-            <div
-              :class="container_i==index?'flex-center active':'flex-center'"
-              @click.self="changeContainer(index)"
-              v-if="!item.hide"
-              :key="item.name+index"
-            >
-              <span @click="changeContainer(index)" :style="{color:item.color}">{{item.name}}</span>
+            <div v-if="!item.hide" :key="item.id" class="flex-center" :class="{active: container_i === index}"
+                 @click="changeContainer(item, index)">
+              <span :style="{color:item.color}">{{ item.name }}</span>
             </div>
           </template>
         </div>
@@ -448,8 +444,8 @@
               v-for="(item1,index1) in rRecomendR"
               :key="'c'+index1"
             >
-              <div
-                :class="['med-name med-name-bg',tjRecipeId==item1.preid ||tjRecipeId==item1.pid || tjRecipeId==item1.acupreid ?'active':'',]"
+              <div class="med-name med-name-bg"
+                   :class="{active: tjRecipeId && (tjRecipeId==item1.preid ||tjRecipeId==item1.pid || tjRecipeId==item1.acupreid)}"
                 v-if="item1.showType==0"
                 @click.stop="getPreDetal(item1.preid || item1,1)"
               >
@@ -460,8 +456,8 @@
                 <!-- {{item1.prename?item1.prename+'('+item1.book?item1.book:'暂无'+')': item1.acupretype==1?'针灸':item1.acupretype==2?'艾灸':item1.acupretype==3?'推拿':'拔罐'}} -->
               </div>
               <!-- 经验方 -->
-              <div
-                :class="['med-name med-name-bg',tjRecipeId==item1.preid ||tjRecipeId==item1.pid  ?'active':'',]"
+              <div class="med-name med-name-bg"
+                   :class="{active: tjRecipeId && (tjRecipeId==item1.preid ||tjRecipeId==item1.pid) }"
                 v-else
                 @click="getExperinceDetail(item1.pid)"
               >
@@ -1310,19 +1306,26 @@ export default {
       rRecomendR: [],
       // 中间顶部tab
       container_i: 0,
+      /* 下列顺便不能轻易变动 */
       contentTabs: [
         {
+          id: '0',
+          businesstype: '1',
           name: "中药处方",
           check: true,
-          color: ""
+          hide: true,
+          color: '',
         },
         {
+          id: '1',
           name: "中药制剂",
           check: false,
           hide: true,
           color: ""
         },
         {
+          id: '2',
+          businesstype: '3',
           name: "适宜技术处方",
           check: false,
           hide: true,
@@ -1363,8 +1366,8 @@ export default {
   },
   created() {
     try {
-      this.contentTabs.find(item => item.name === '中药制剂' ).hide = !window.ZYZJ
-      this.contentTabs.find(item => item.name === '适宜技术处方' ).hide = !window.SYJS
+      const tabs = this.getuserinfo.ableprescription.split(',');
+      for (const id of tabs) try { this.contentTabs.find(item => item.id === id).hide = false; } catch (e) {}
     } catch (e) {
 
     }
@@ -1415,12 +1418,9 @@ export default {
       else if (query.doctorCase) await this.changeAndJoin();
       // 中医诊疗 -> 智能辩证
       else if (query.type === "tuidao") {
-        await Promise.all([
-          this.inferRecipe(4, "1"),
-          // this.inferRecipe(4, "3"),
-          this.inferRecipe(),
-        ])
-        this.isTuiDaoZy = true;
+        this.isTuiDaoSuit = false;
+        this.isTuiDaoZy = false;
+        await this.inferRecipe();
       }
       // 处方编辑 recipeType
       else if (query.from !== 'his' && this.getEditPreNo()) await this.getRecipeDataByid(this.getEditPreNo());
@@ -1435,9 +1435,11 @@ export default {
         else if (this.getEditPreNo()) await this.getRecipeDataByid(this.getEditPreNo());
       }
    },
-    // 参考医案
+
     // 中医诊断推导点击
     tcmClick(isauto = true) {
+     this.isTuiDaoZy = false;
+     this.isTuiDaoSuit = false;
       let params = this.$refs.TCM.getParams();
 
       if (!params.namemedicine || !params.syndrometypes) {
@@ -1462,10 +1464,11 @@ export default {
       if (isauto) {
         this.inferRecipe(2);
       }
-
+      let id = '';
+      try { id = this.contentTabs[this.container_i].id; } catch (e) {}
       setTimeout(() => {
-        this.inferRecipe(4, "1");
-        this.inferRecipe(4, "3");
+        this.inferRecipe(4, "1").then(() => { if (id === '0') this.isTuiDaoZy = true });
+        this.inferRecipe(4, "3").then(() => { if (id === '1') this.isTuiDaoSuit = true });
         if (this.getPatiensInfo.pid) {
           this.getPatiensBasisM();
         }
@@ -1486,6 +1489,7 @@ export default {
       let child3 = children[2];
 
       let obj = {
+        contentTabs: this.contentTabs,
         container_i: this.container_i,
         child1: {
           recipe_tabs: child1.recipe_tabs,
@@ -1495,12 +1499,7 @@ export default {
           tableData3: child2.tableData3,
           bottom_form: child2.bottom_form
         },
-        child3: {
-          tableData4: child3.tableData4,
-          listLeft: child3.listLeft,
-          listRight: child3.listRight,
-          bottom_form: child3.bottom_form
-        },
+        child3: Object.assign({...child3.$data}, {acupointList: []}),
         rationalMed: {
           // 保存右侧合理用药信息
           rationalMed: this.rationalMed,
@@ -1541,6 +1540,8 @@ export default {
       let child2 = children[1];
       let child3 = children[2];
 
+      child1.recipe_tabs = storageData.child1.recipe_tabs;
+      child1.recipe_tabs_c = storageData.child1.recipe_tabs_c;
       if (typeof child1.loaded === 'function') await child1.loaded(storageData.child1);
 
       if (storageData.child1.recipe_tabs[0].totalTableD.length > 1) {
@@ -1548,7 +1549,7 @@ export default {
       }
 
       if (storageData.child3.tableData4.length > 1) {
-        this.isTuiDaoZy = true;
+        this.isTuiDaoSuit = true;
       }
 
       if (ignoreTable) {
@@ -1560,10 +1561,8 @@ export default {
         storageData.child2.tableData3 = [];
         storageData.child3.tableData4 = [];
       }
-
+      this.contentTabs = storageData.contentTabs;
       this.container_i = storageData.container_i;
-      child1.recipe_tabs = storageData.child1.recipe_tabs;
-      child1.recipe_tabs_c = storageData.child1.recipe_tabs_c;
       // child1.getSelectType("剂型", 0);
       // child1.getSelectType("处方用法");
       // child1.getSelectType("中药服药时间");
@@ -1572,10 +1571,7 @@ export default {
       child2.tableData3 = storageData.child2.tableData3;
       child2.bottom_form = storageData.child2.bottom_form;
 
-      child3.tableData4 = storageData.child3.tableData4;
-      child3.listLeft = storageData.child3.listLeft;
-      child3.listRight = storageData.child3.listRight;
-      child3.bottom_form = storageData.child3.bottom_form;
+      for (const [key, value] of Object.entries(storageData.child3)) child3[key] = value;
 
       this.rationalMed = storageData.rationalMed.rationalMed;
       // 保存右侧合理用药信息
@@ -1660,16 +1656,7 @@ export default {
       }
     },
     // 处理中药处方提交数据
-    dealRecipe1() {
-      let children = this.$children.filter(item => {
-        return (
-          item.name == "中药处方" ||
-          item.name == "中药制剂" ||
-          item.name == "适宜技术处方"
-        );
-      });
-      let data1 = children[0];
-
+    dealRecipe1(data1) {
       let isAutoCheck = data1.isAutoCheck;
       let hasDoseNum = true; // 是否有剂数
       let hasData = true; // 是否有处方药品数据
@@ -1736,7 +1723,7 @@ export default {
       if (!hasData) {
         this.$message.error({
           message: "请完善中药处方药品信息",
-          showClose: false,
+          showClose: true,
           type: "error"
         });
         return [];
@@ -1892,20 +1879,11 @@ export default {
       console.groupEnd()
       return zhongPrescriptionVo;
     },
-    // 处理中成药处方提交数据
-    dealRecipe2() {
-      let children = this.$children.filter(item => {
-        return (
-          item.name == "中药处方" ||
-          item.name == "中药制剂" ||
-          item.name == "适宜技术处方"
-        );
-      });
-
-      let data1 = children[1];
+    // 处理中药制剂提交数据
+    dealRecipe2(data1) {
       let isAutoCheck = data1.isAutoCheck;
-      if (data1.tableData3.length == 1) {
-        // this.$message.error("请完善中成药处方药品信息");
+      if (!data1.tableData3.filter(item => item.name).length) {
+        this.$message.error({ message: '请完善中药制剂药品信息', showClose: true });
         return {};
       }
       let hasDrugMsg = [];
@@ -1995,18 +1973,10 @@ export default {
       return obj;
     },
     // 处理适宜剂数处方提交数据
-    dealRecipe3() {
-      let children = this.$children.filter(item => {
-        return (
-          item.name == "中药处方" ||
-          item.name == "中药制剂" ||
-          item.name == "适宜技术处方"
-        );
-      });
-      let data1 = children[2];
+    dealRecipe3(data1) {
       let isAutoCheck = data1.isAutoCheck;
-      if (data1.tableData4.length == 1) {
-        // this.$message.error('请完善适宜技术处方药品信息')
+      if (!data1.tableData4.filter(item => item.name).length) {
+        this.$message.error({ message: '请完善适宜技术处方穴位信息', showClose: true });
         return {};
       }
       let hasDrugMsg = [];
@@ -2018,7 +1988,7 @@ export default {
 
       if (hasDrugMsg.length > 0) {
         // this.$message.error(
-        //   "请完善适宜技术处方药品相关信息(序号:" + hasDrugMsg.join(",") + ")"
+        //   "请完善适宜技术处方穴位相关信息(序号:" + hasDrugMsg.join(",") + ")"
         // );
         return false;
       }
@@ -2321,7 +2291,7 @@ export default {
         loading.close();
       }, 1000);
     },
-    // 获取数据 赋值给 中成药处方
+    // 获取数据 赋值给 中药制剂
     assignRecipe2(data, loading) {
       setTimeout(() => {
         let children = this.$children.filter(item => {
@@ -2610,122 +2580,84 @@ export default {
     },
     // 提交中药处方
     async submitRecipe1() {
-      let zhongPrescriptionVo = this.dealRecipe1();
-      if (!zhongPrescriptionVo.length) return;
-
-      if (!await this.$refs.TCM.saveDiagnosisData()) return;
+      const cancel = (id) => {
+        this.saving = false;
+        if (id) this.container_i = this.contentTabs.findIndex(tab => tab.id === id);
+      }
 
       this.saving = true;
-      try {
-        const {options, force} = await this.getRationalSafeUse();
-        if (options.length) {
-          const child = this.$children.find(item => item.name === "中药处方");
-          const results = await Promise.all(child.recipe_tabs.map((_, index) => this.getRationalMed2(index)));
-          const tips = results.map((item, index) => {
-            const value = options.map(i => item[i] ? `<div class="title">${item[i].title}</div><div class="content">${item[i].collection.join('')}</div>` : '').join('');
-            return value ? `<div style="padding-top: ${index ? 12 : 0}px;border-bottom: 1px dashed #dcdcdc;"><h2 style="margin-bottom: 16px;">${item.title}</h2>${value}</div>` : '';
-          }).join('');
-          if (tips) {
-            if (!force) {
-              this.$message({
-                dangerouslyUseHTMLString: true,
-                customClass: 'message-rational-safe-use-wrapper',
-                message: tips,
-                duration: 1000 * 3,
-                showClose: true,
-              })
-            } else if (await this.$confirm(tips, '温馨提示:是否保存处方?', {
-              confirmButtonText: '保存',
-              cancelButtonText: '取消',
-              dangerouslyUseHTMLString: true,
-              customClass: 'message-rational-safe-use-wrapper',
-            }).then(() => /* 继续 */ false, () => /* 取消 */ true)) return;
-          }
-        }
-      } catch (e) {}
-      this.saving = false;
+      if (!await this.$refs.TCM.saveDiagnosisData()) return cancel();
 
+      let zhongPrescriptionVo = [];
       let chengPrescriptionVo = {};
-      if(window.ZYZJ) {
-        setTimeout(() => {
-          chengPrescriptionVo = this.dealRecipe2();
-        }, 100);
-      }
       let technologyPrescriptionVo = {};
-      if(window.SYJS) {
-        setTimeout(() => {
-          technologyPrescriptionVo = this.dealRecipe3();
-        }, 200);
-      }
 
-      setTimeout(() => {
-        /*if (technologyPrescriptionVo === false) {
-          technologyPrescriptionVo = {};
-          this.container_i = 2;
-          return;
-        }
+      const selected = this.contentTabs[this.container_i];
+      const tabs = this.contentTabs.filter(tab => tab.check && tab.id !== selected.id)
+      tabs.unshift(selected);
 
-        if (chengPrescriptionVo === false) {
-          chengPrescriptionVo = {};
-          this.container_i = 1;
-          return;
-        }*/
+      for (const tab of tabs) {
 
-        if (zhongPrescriptionVo === false) {
-          zhongPrescriptionVo = [];
-          this.container_i = 0;
-          return;
-        }
 
-        if (Object.keys(zhongPrescriptionVo).length === 0) return;
+        const child = this.$children.find(child => child.name === tab.name);
+        if (!(child.saveable || selected.id === tab.id)) continue;
 
-        /*if (
-          zhongPrescriptionVo.length == 0 &&
-          Object.keys(zhongPrescriptionVo).length == 0 &&
-          Object.keys(technologyPrescriptionVo).length == 0
-        )
-          return;*/
+        switch (tab.id) {
+          case /*中药处方*/
+          '0': {
+            zhongPrescriptionVo = this.dealRecipe1(child);
+            if (!zhongPrescriptionVo || !zhongPrescriptionVo.length) return cancel(tab.id);
+            try {
+              const {options, force} = await this.getRationalSafeUse();
+              if (options.length) {
+                const results = await Promise.all(child.recipe_tabs.map((_, index) => this.getRationalMed2(index)));
+                const tips = results.map((item, index) => {
+                  const value = options.map(i => item[i] ? `<div class="title">${item[i].title}</div><div class="content">${item[i].collection.join('')}</div>` : '').join('');
+                  return value ? `<div style="padding-top: ${index ? 12 : 0}px;border-bottom: 1px dashed #dcdcdc;"><h2 style="margin-bottom: 16px;">${item.title}</h2>${value}</div>` : '';
+                }).join('');
+                if (tips) {
+                  if (!force) {
+                    this.$message({
+                      dangerouslyUseHTMLString: true,
+                      customClass: 'message-rational-safe-use-wrapper',
+                      message: tips,
+                      duration: 1000 * 3,
+                      showClose: true,
+                    })
+                  } else if (await this.$confirm(tips, '温馨提示:是否保存处方?', {
+                    confirmButtonText: '保存',
+                    cancelButtonText: '取消',
+                    dangerouslyUseHTMLString: true,
+                    customClass: 'message-rational-safe-use-wrapper',
+                  }).then(() => /* 继续 */ false, () => /* 取消 */ true)) return cancel(tab.id);
+                }
+              }
+            } catch (e) {}
+            break;
+          }
+          case /*中药制剂*/
+          '1': {
+            if (+child.paystate === 1) continue;
+            chengPrescriptionVo = this.dealRecipe2(child);
+            if (!chengPrescriptionVo || !Object.keys(chengPrescriptionVo).length) return cancel(tab.id);
+            break;
+          }
+          case /*适宜技术*/
+          '2': {
+            if (+child.paystate === 1) continue;
+            technologyPrescriptionVo = this.dealRecipe3(child);
+            if (!technologyPrescriptionVo || !Object.keys(technologyPrescriptionVo).length) return cancel(tab.id);
+            break;
+          }
+        }
+      }
 
-        this._getRecipePriview(
+      await this._getRecipePriview(
           zhongPrescriptionVo,
           chengPrescriptionVo,
           technologyPrescriptionVo
-        );
-        // if (this.isShowDj || this.isShowPs) {
-        //   this.showAddress = true;
-        // } else {
-        //   this._getRecipePriview(
-        //     zhongPrescriptionVo,
-        //     chengPrescriptionVo,
-        //     technologyPrescriptionVo
-        //   );
-        // }
-
-        // if (zhongPrescriptionVo && zhongPrescriptionVo.length > 0) {
-        //   // 有中药处方 打开是否存为协定方界面
-        //   this.$confirm("是否存为协定方?", "温馨提示", {
-        //     confirmButtonText: "是",
-        //     cancelButtonText: "否",
-        //     type: "warning"
-        //   })
-        //     .then(() => {
-        //       this.zhongPrescriptionVo = zhongPrescriptionVo;
-        //       this.chengPrescriptionVo = chengPrescriptionVo;
-        //       this.technologyPrescriptionVo = technologyPrescriptionVo;
-
-        //       this.$refs.chineseM.saveToMine("reserve");
-        //     })
-        //     .catch(() => {
-        //       this._getRecipePriview(
-        //         zhongPrescriptionVo,
-        //         chengPrescriptionVo,
-        //         technologyPrescriptionVo
-        //       );
-        //     });
-        // } else {
-
-        // }
-      }, 500);
+      );
+      return cancel();
     },
 
     // 修改推荐方剂轮播图下标
@@ -2780,11 +2712,20 @@ export default {
     },
 
     // 顶部tab 改变
-    changeContainer(type) {
+    async changeContainer(item, type) {
       this.container_i = type;
-      if (type == 1) return;
+      item.check = true;
+      if (item.id === '1') return;
       // if (this.contentTabs[type].color == 'red') {
-      this.inferRecipe(3);
+      await this.inferRecipe(3, item.businesstype);
+
+      const child = this.$children.find(child => child.name === item.name);
+      if (!child) return
+      if (item.id === '0') {
+        try { this.tjRecipeId = child.recipe_tabs[child.recipe_tabs_c].id; } catch (e) { this.tjRecipeId = "" }
+      } else if (item.id === '2') {
+        try { this.tjRecipeId = child.recipeId; } catch (e) { this.tjRecipeId = "" }
+      }
       // }
 
       // if (type == 2) {
@@ -2829,6 +2770,7 @@ export default {
     // 名家验案转方
     turnRecipe(item) {
       this.setDrugsInfo(item.verpreitemlist);
+      this.setRecipeId('');
       this.changeAndJoin();
       this.addRecipeFrom("5");
     },
@@ -2860,6 +2802,7 @@ export default {
        });
        if (recipe.__RecipeFrom__ === '2') this.agreeAssignToTCM(recipe, void 0, true);
        this.setDrugsInfo(medicines);
+       this.setRecipeId('');
        this.changeAndJoin(1);
      } else if (recipe.__RecipeFrom__ === '2') {
        this.agreeInfo = recipe;
@@ -2999,24 +2942,24 @@ export default {
     suitChnageOrJoin(type = "") {
       // type = '' 专访 type == 1 和方
       if (this.container_i == 1) return;
+
+      const child = this.$children.find(child => child.name === '适宜技术处方');
+      if (!child) return;
+
       const loading = this.$loading({
         lock: true,
         text: "正在处理数据,请稍后",
         spinner: "el-icon-loading",
         background: "rgba(0, 0, 0, 0.7)"
       });
-      let children = this.$children.filter(item => {
-        return (
-          item.name == "中药处方" ||
-          item.name == "中药制剂" ||
-          item.name == "适宜技术处方"
-        );
-      });
-      let child = children[2];
 
       let drugs = this.getDrugInfo;
+      const recipeId = +type !== 1 ? this.getRecipeId : "";
+      this.setRecipeId('');
+      this.tjRecipeId = recipeId
 
       if (type == "") {
+        child.bottom_form.caozuo = '';
         // 转方
         child.tableData4 = [];
         drugs.forEach((item, index) => {
@@ -3027,8 +2970,7 @@ export default {
             acuid: item.acuid
           };
           // 锚点
-          child.bottom_form.caozuo +=
-            obj.acuname + ":" + item.acuoperation + " ";
+          if (item.acuoperation) child.bottom_form.caozuo += obj.acuname + ':' + item.acuoperation + ' ';
           child.tableData4.push(obj);
         });
         child.tableData4.push({
@@ -3043,15 +2985,18 @@ export default {
         });
       } else if (type == 1) {
         child.tableData4.pop();
-        drugs.forEach((item, index) => {
+        for (const item of drugs) {
+          if (child.tableData4.find(({acuid}) => acuid === item.acuid)) continue;
           let obj = {
-            id: index + 1,
+            id: child.tableData4.length + 1,
             name: item.acuname,
             acuname: item.acuname,
-            acuid: item.acuid
+            acuid: item.acuid,
           };
+          // 锚点
+          if (item.acuoperation) child.bottom_form.caozuo += obj.acuname + ':' + item.acuoperation + ' ';
           child.tableData4.push(obj);
-        });
+        }
         child.tableData4.push({
           id: "",
           name: "",
@@ -3063,7 +3008,7 @@ export default {
           return (item.id = index + 1);
         });
       }
-
+      child.recipeId = recipeId
       this.showDialog = false;
 
       loading.close();
@@ -3074,6 +3019,7 @@ export default {
       this.addRecipeFrom("4", 2);
       if (type == 1 && type1 == 1) {
         this.setDrugsInfo(item.items);
+        this.setRecipeId('');
         this.suitChnageOrJoin();
         return;
       }
@@ -3090,6 +3036,7 @@ export default {
       this.addRecipeFrom("4", 2);
       if (type == 1 && type1 == 1) {
         this.setDrugsInfo(item.items);
+        this.setRecipeId('');
         this.suitChnageOrJoin(1);
         return;
       }
@@ -3110,6 +3057,7 @@ export default {
       }
       this.addRecipeFrom("4");
       this.setDrugsInfo(this.preInfo.items);
+      this.setRecipeId('');
       this.changeAndJoin(2);
     },
     // 方剂换方
@@ -3307,13 +3255,7 @@ export default {
         this.contentTabs[1].check = res.Data.zhongchengyao.chengDetail !== null;
         this.contentTabs[2].check = res.Data.technology.detail !== null;
 
-        this.container_i = this.contentTabs[0].check
-          ? 0
-          : this.contentTabs[1].check
-          ? 1
-          : this.contentTabs[2].check
-          ? 2
-          : 0;
+        this.container_i = Math.max(this.contentTabs.findIndex(item => item.check), 0);
 
         this.chineseM.allMoney = res.Data.zhonyaoPrice;
         this.medicineC.allMoney = res.Data.zhonchengPrice;
@@ -3324,17 +3266,14 @@ export default {
           res.Data.zhongyao.forEach((item, index) => {
             this._recipeIsPay(item.preId, 2, index);
           });
-          this.container_i = 0;
         }
         if (this.contentTabs[1].check) {
           this.assignRecipe2(res.Data.zhongchengyao, loading);
           this._recipeIsPay(res.Data.zhongchengyao.preId, 2);
-          this.container_i = 1;
         }
         if (this.contentTabs[2].check) {
           this.assignRecipe3(res.Data.technology, loading);
           this._recipeIsPay(res.Data.technology.preId, 2);
-          this.container_i = 2;
         }
         if (this.getPatiensInfo.pid) {
           this.getPatiensBasisM();
@@ -3827,7 +3766,7 @@ export default {
         // }
       }
 
-      if (type != 4) {
+      if (type != 4 && businesstype == null) {
         businesstype =
           this.container_i == 0 ? "1" : this.container_i == 2 ? "3" : "1";
       }
@@ -3865,8 +3804,7 @@ export default {
         let arr2 = res.data.expList.concat(res.data.schemes[0].pres);
 
         if (type == 4) {
-          this.contentTabs[businesstype - 1].color =
-            arr2.length > 0 ? "red" : "";
+          try { this.contentTabs.find(tab => tab.businesstype === businesstype).color = arr2.length > 0 ? "red" : ""; } catch (e) {}
           return;
         }
         if (arr2.length > 0) {
@@ -3890,8 +3828,10 @@ export default {
         this.rRecomendR = arr2;
 
         if (this.$route.query.type != "tuidao" && type == 1) return;
-        if (type == 3 && this.container_i == 0 && this.isTuiDaoZy) return;
-        if (type == 3 && this.container_i == 2 && this.isTuiDaoSuit) return;
+        if (type === 3) {
+          try { if (this.contentTabs[this.container_i].id === '0' && this.isTuiDaoZy) return; } catch (e) {}
+          try { if (this.contentTabs[this.container_i].id === '2' && this.isTuiDaoSuit) return; } catch (e) {}
+        }
         if (this.rRecomendR.length == 0) return;
 
         let children = this.$children.filter(item => {
@@ -3943,6 +3883,7 @@ export default {
             //  && child2.tableData4.length == 1
             if (arr2.length > 0) {
               this.setDrugsInfo(arr2[0].items);
+              this.setRecipeId(arr2[0].acupreid);
             }
 
             this.addRecipeFrom("4", 2);
@@ -4024,6 +3965,9 @@ export default {
       let child = children[0];
       child.recipe_tabs[child.recipe_tabs_c].disable = false;
       let drugs = this.getDrugInfo;
+      const recipeId = +type === 1 ? this.getRecipeId : "";
+      this.setRecipeId('');
+      this.tjRecipeId = recipeId;
 
       // let type1 = 0
       let type1 = child.recipe_tabs[child.recipe_tabs_c].radio.split("@")[1];
@@ -4288,6 +4232,7 @@ export default {
           this.showPresc = false;
           this.showUnifyPresc = false;
           loading.close();
+          try { child.recipe_tabs[child.recipe_tabs_c].id = recipeId; } catch (e) {}
         }
       } else if (this.container_i == 2) {
         // 适宜技术处方
@@ -4355,8 +4300,8 @@ export default {
         // 适宜技术处方
         this.preInfo = id;
         this.setDrugsInfo(id.items);
+        this.setRecipeId(id.acupreid);
         this.showDialog = true;
-        this.tjRecipeId = id.acupreid;
         return;
       }
 
@@ -4366,11 +4311,11 @@ export default {
 
       if (res.code === 0) {
         this.preInfo = res.data;
-        if (type == 1 || type == "") {
+        /*if (type == 1 || type == "") {
           this.tjRecipeId = id;
-        }
-
+        }*/
         this.setDrugsInfo(res.data.items);
+        this.setRecipeId(id);
         if (!type || type == 2) {
           // console.log(res.data, 'RES.datas');
           if (type == "") {
@@ -4455,6 +4400,7 @@ export default {
       return this.$route.query && this.$route.query.recipeType === "edit" ? this.$route.query.recipeID : this.getPreNo;
     },
     ...mapMutations({
+      setRecipeId: "drug/setRecipeId",
       setDrugsInfo: "drug/setDrugsInfo"
     })
   },
@@ -4470,7 +4416,7 @@ export default {
         : 0
       ).toFixed(2);
     },
-    ...mapGetters(["getPatiensInfo", "getuserinfo", "getDrugInfo", "getIsSee", "getPreNo"])
+    ...mapGetters(["getPatiensInfo", "getuserinfo", "getDrugInfo", "getRecipeId", "getIsSee", "getPreNo"])
   },
   filters: {
     ftsjj(value) {

+ 1 - 1
src/views/system/UserSytem.vue

@@ -357,7 +357,7 @@
             <div class="input">
               <el-select v-model="diaform.defaultRecipe" multiple placeholder="请选择">
                 <el-option label="中药处方" value="0"></el-option>
-                <el-option label="中成药处方" value="1"></el-option>
+                <el-option label="中药制剂" value="1"></el-option>
                 <el-option label="适宜技术处方" value="2"></el-option>
               </el-select>
             </div>