Эх сурвалжийг харах

智能开方处方保存调整

cc12458 11 сар өмнө
parent
commit
8e2a82ff5c

+ 93 - 160
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>
@@ -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) {
 
     }
@@ -1653,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; // 是否有处方药品数据
@@ -1729,7 +1723,7 @@ export default {
       if (!hasData) {
         this.$message.error({
           message: "请完善中药处方药品信息",
-          showClose: false,
+          showClose: true,
           type: "error"
         });
         return [];
@@ -1886,19 +1880,10 @@ export default {
       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 = [];
@@ -1988,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 = [];
@@ -2011,7 +1988,7 @@ export default {
 
       if (hasDrugMsg.length > 0) {
         // this.$message.error(
-        //   "请完善适宜技术处方药品相关信息(序号:" + hasDrugMsg.join(",") + ")"
+        //   "请完善适宜技术处方穴位相关信息(序号:" + hasDrugMsg.join(",") + ")"
         // );
         return false;
       }
@@ -2603,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();
     },
 
     // 修改推荐方剂轮播图下标
@@ -2773,11 +2712,14 @@ export default {
     },
 
     // 顶部tab 改变
-    changeContainer(type) {
+    changeContainer(item, type) {
       this.container_i = type;
+      item.check = true;
       if (type == 1) return;
+      if (this.isTuiDaoZy && item.id === '0') return;
+      if (this.isTuiDaoSuit && item.id === '2') return;
       // if (this.contentTabs[type].color == 'red') {
-      this.inferRecipe(3);
+      this.inferRecipe(3, item.businesstype);
       // }
 
       // if (type == 2) {
@@ -3300,13 +3242,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;
@@ -3317,17 +3253,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();
@@ -3820,7 +3753,7 @@ export default {
         // }
       }
 
-      if (type != 4) {
+      if (type != 4 && businesstype == null) {
         businesstype =
           this.container_i == 0 ? "1" : this.container_i == 2 ? "3" : "1";
       }