Forráskód Böngészése

已支付状态下的转方

张田田 1 hete
szülő
commit
5563a9e1a3

+ 63 - 6
src/views/business/components/AcupointTable.vue

@@ -16,14 +16,19 @@
           </el-tooltip>
           <div
             @click.stop="removePrescription(index)"
+            v-show="!isPrescriptionPaid(index)"
           >X</div>
+          <img
+            :src="require('../../../assets/new-icon/isPay.png')"
+            v-show="isPrescriptionPaid(index)"
+          />
         </div>
       </div>
       <div class="top-btns">
         <el-button size="mini" type="warning" @click="openAddDialog()"
           >新增处方</el-button
         >
-        <el-button size="mini" type="warning" @click="clearAll();$emit('clear')">清空处方</el-button>
+        <el-button size="mini" type="warning" @click="clearAll();$emit('clear')" v-if="!isLocked">清空处方</el-button>
       </div>
     </div>
 
@@ -502,7 +507,7 @@
           协定方总金额:<span>{{ totalPrice || "0.00" }}元</span>
         </div>
       </div>
-      <div class="t-b-b-right flex-vertical-center-r">
+      <div class="t-b-b-right flex-vertical-center-r" v-if="!isLocked">
         <el-button
           type="primary"
           size="mini"
@@ -680,6 +685,8 @@ function createPrescriptionData(options = {}) {
     totalPrice: "0.00",
     currentUnitPrice: unitPrice,
     _manualSingleCount: false,
+    paystate: 0, // 每个处方独立的支付状态
+    isPay: false,
   };
 }
 
@@ -759,6 +766,8 @@ export default {
       },
       innerIsEditable: this.isEditable,
       innerDetailTypes: ["经络"],
+      paystate: 0, // 云his 是否支付  0 否 1是(为否可以编辑)
+      isPay: false,
       detailRequired: false,
       // 统计相关
       currentUnitPrice: 0,
@@ -805,6 +814,15 @@ export default {
   },
   computed: {
     isLocked() {
+      // 获取当前激活处方的支付状态
+      const currentData = this.prescriptionDataMap[this.activeIndex];
+      const paystate = currentData?.paystate ?? this.paystate;
+      const isPay = currentData?.isPay ?? this.isPay;
+
+      // 付费后不允许编辑(与旧版 SuitScience 逻辑保持一致)
+      if (isPay || paystate == 1) {
+        return true;
+      }
       return this.useIsUpdateLock && this.innerIsEditable === "0";
     },
     activeDetailTypes() {
@@ -842,7 +860,12 @@ export default {
         .filter(Boolean);
     },
     saveable() {
-      return this.prescriptions && this.prescriptions.length > 0;
+      // 过滤掉已付费的处方(与中药处方逻辑保持一致)
+      const unpaidRecipes = this.prescriptions.filter((_, index) => {
+        const data = this.prescriptionDataMap[index];
+        return !data || (!data.isPay && data.paystate != 1);
+      });
+      return unpaidRecipes && unpaidRecipes.length > 0;
     },
     // 当前激活项目
     activeProject() {
@@ -898,21 +921,29 @@ export default {
         totalPrice: this.totalPrice,
         currentUnitPrice: this.currentUnitPrice,
         _manualSingleCount: this._manualSingleCount,
+        paystate: this.paystate, // 保存处方的支付状态
+        isPay: this.isPay,
       });
     },
     cacheCurrentData() {
       this.saveCurrentTabData();
       this._cachedPrescriptions = JSON.parse(JSON.stringify(this.prescriptions));
       this._cachedPrescriptionDataMap = JSON.parse(JSON.stringify(this.prescriptionDataMap));
+      this._cachedPaystate = this.paystate;
+      this._cachedIsPay = this.isPay;
     },
     restoreCachedData() {
       if (!this._cachedPrescriptions) return false;
       this.prescriptions = this._cachedPrescriptions;
       this.prescriptionDataMap = this._cachedPrescriptionDataMap;
+      this.paystate = this._cachedPaystate || 0;
+      this.isPay = this._cachedIsPay || false;
       this.activeIndex = 0;
       this.loadTabData(0);
       this._cachedPrescriptions = null;
       this._cachedPrescriptionDataMap = null;
+      this._cachedPaystate = null;
+      this._cachedIsPay = null;
       return true;
     },
     loadTabData(index) {
@@ -936,6 +967,9 @@ export default {
         this.totalPrice = data.totalPrice;
         this.currentUnitPrice = data.currentUnitPrice || 0;
         this._manualSingleCount = data._manualSingleCount || false;
+        // 加载处方的支付状态
+        this.paystate = data.paystate || 0;
+        this.isPay = data.isPay || false;
       } else {
         const def = createPrescriptionData();
         this.detailTables = def.detailTables;
@@ -962,6 +996,14 @@ export default {
         }
       });
     },
+    // 判断处方是否已付费
+    isPrescriptionPaid(index) {
+      const data = this.prescriptionDataMap[index];
+      if (data) {
+        return data.isPay || data.paystate == 1;
+      }
+      return false;
+    },
     switchTab(index) {
       if (this.activeIndex === index) return;
       this.saveCurrentTabData();
@@ -1569,8 +1611,15 @@ export default {
         其他详情: "detailOther",
       };
 
-      return this.prescriptions.map((p, index) => {
-        const d = this.prescriptionDataMap[index] || createPrescriptionData();
+      // 过滤掉已付费的处方(与中药处方逻辑保持一致)
+      return this.prescriptions
+        .map((p, originalIndex) => ({ p, originalIndex }))
+        .filter(({ originalIndex }) => {
+          const data = this.prescriptionDataMap[originalIndex];
+          return !data || (!data.isPay && data.paystate != 1);
+        })
+        .map(({ p, originalIndex }) => {
+        const d = this.prescriptionDataMap[originalIndex] || createPrescriptionData();
 
         const detailPoint = [];
         const detailMeridian = [];
@@ -1621,7 +1670,7 @@ export default {
           useExplain: d.operationGuide || "",
           command: d.command || "",
           pointMatchGuide: d.pointMatchGuide || "",
-          seqn: index + 1,
+          seqn: originalIndex + 1,
           ownerType: this.ownerType || "1",
           detailPoint,
           detailMeridian,
@@ -1750,6 +1799,8 @@ export default {
           totalPrice: "0.00",
           currentUnitPrice: unitPrice,
           _manualSingleCount: singleNumber !== "0",
+          paystate: item.paystate || 0, // 从接口数据中获取支付状态
+          isPay: item.isPay || false,
         };
       });
 
@@ -1844,6 +1895,12 @@ export default {
           flex-shrink: 0;
         }
 
+        img {
+          width: 20px;
+          margin-left: 8px;
+          flex-shrink: 0;
+        }
+
         .l_active {
           color: #5386f6;
         }

+ 49 - 33
src/views/diagnosis/Prescribing.vue

@@ -1503,7 +1503,7 @@ export default {
       // 就诊记录转方
       else if (query.recipeID) await this.getRecipeDataByid(this.$route.query.recipeID);
       // 适宜技术病历转方
-      else if (query.suitRecordId) await this.suitTechRecordTurn(query.suitRecordId);
+      else if (query.suitRecordId) await this.suitTechRecordTurn(query.suitRecordId,this.getPatiensInfo.pid);
       // 处方管理 适宜技术转方
       // else if (query.suitRecipeId) await this.suitRecipeIdTurn(query.suitRecipeId);
       // 名医名方 —> 名医医案
@@ -2155,8 +2155,16 @@ export default {
         return [];
       }
 
-      // 校验操作指南
-      const hasOperationGuide = acupointTable.prescriptions.every((_, index) => {
+      // 过滤掉已付费的处方
+      const unpaidPrescriptions = acupointTable.prescriptions
+        .map((p, index) => ({ p, index }))
+        .filter(({ index }) => {
+          const data = acupointTable.prescriptionDataMap[index];
+          return !data || (!data.isPay && data.paystate != 1);
+        });
+
+      // 校验操作指南(只检查未付费的处方)
+      const hasOperationGuide = unpaidPrescriptions.every(({ index }) => {
         const d = acupointTable.prescriptionDataMap[index];
         return d && d.operationGuide && d.operationGuide.trim();
       });
@@ -2165,8 +2173,8 @@ export default {
         return [];
       }
 
-      // 校验单次数量
-      const hasSingleCount = acupointTable.prescriptions.every((_, index) => {
+      // 校验单次数量(只检查未付费的处方)
+      const hasSingleCount = unpaidPrescriptions.every(({ index }) => {
         const d = acupointTable.prescriptionDataMap[index];
         return d && d.singleCount > 0;
       });
@@ -2175,11 +2183,6 @@ export default {
         return [];
       }
 
-      // 已支付则跳过
-      if (acupointTable.paystate == 1) {
-        return [];
-      }
-
       // 获取治疗列表(每个prescription对应一个治疗项)
       const treatmentList = acupointTable.buildTreatmentList();
       if (!treatmentList || treatmentList.length === 0) {
@@ -2191,8 +2194,8 @@ export default {
       // sourceId和accordPid都传recordid(患者pid)
       const recordid = this.getPatiensInfo.pid || "";
 
-      const result = acupointTable.prescriptions.map((p, index) => {
-        const treatmentItem = treatmentList[index];
+      const result = unpaidPrescriptions.map(({ p, index }, treatmentIndex) => {
+        const treatmentItem = treatmentList[treatmentIndex];
         const d = acupointTable.prescriptionDataMap[index] || {};
 
         // 计算该项目的总金额
@@ -2618,20 +2621,6 @@ export default {
           westernDiag: techData.westernDiag || "",
         };
 
-        // 处方状态
-        if (this.getEditPreNo()) {
-          if (techData.revierwstate == 1) {
-            acupointTable.prescribed = 0;
-            acupointTable.paystate = 0;
-          } else {
-            acupointTable.prescribed = techData.prescribed || 0;
-            acupointTable.paystate = techData.paystate || 0;
-          }
-        } else {
-          acupointTable.prescribed = techData.prescribed || 0;
-          acupointTable.paystate = techData.paystate || 0;
-        }
-
         // 西医主诊断(只读,接口返回)和建议诊断(用户输入)
         this.westernDiag = techData.westernDiag || '';
         // 建议诊断候选(后端返回的全部)→ 规范化成对象数组,并预填充 name 映射
@@ -2663,18 +2652,39 @@ export default {
           return acc;
         }, []);
         // [临时诊断] 看治疗项各字段值(嘱托/金额等),定位完删除                                                                               
-        console.log('[assignRecipe3诊断] 治疗项0 完整数据:', mergedTreatmentList[0]);  
+        console.log(mergedTreatmentList,'[assignRecipe3诊断] 治疗项0 完整数据:', mergedTreatmentList[0]);  
         // 使用 loadFromServerData 加载合并后的治疗列表数据
         if (mergedTreatmentList.length > 0) {
           acupointTable.loadFromServerData(mergedTreatmentList);
         }
 
-        // 嘱托(command)在处方级(technologies[i].command),loadFromServerData 按治疗项取不到,补设到组件
+        // 处方状态(必须在 loadFromServerData 之后设置,因为 loadFromServerData 会调用 loadTabData 覆盖 paystate)
+        if (this.getEditPreNo()) {
+          if (techData.revierwstate == 1) {
+            acupointTable.prescribed = 0;
+            acupointTable.paystate = 0;
+          } else {
+            acupointTable.prescribed = techData.prescribed || 0;
+            acupointTable.paystate = techData.paystate || 0;
+          }
+        } else {
+          acupointTable.prescribed = techData.prescribed || 0;
+          acupointTable.paystate = techData.paystate || 0;
+        }
+
+        // 嘱托(command)和支付状态(paystate)在处方级(technologies[i]),loadFromServerData 按治疗项取不到,补设到组件
         const _prescriptionCommand = techData.command || "";
         acupointTable.command = _prescriptionCommand;
         if (acupointTable.prescriptionDataMap) {
           Object.keys(acupointTable.prescriptionDataMap).forEach(idx => {
             acupointTable.prescriptionDataMap[idx].command = _prescriptionCommand;
+            // 为每个处方设置支付状态
+            const numIdx = Number(idx);
+            console.log('设置支付状态', { idx, numIdx, dataArrayItem: dataArray[numIdx], paystate: dataArray[numIdx]?.paystate });
+            if (dataArray[numIdx]) {
+              acupointTable.prescriptionDataMap[idx].paystate = dataArray[numIdx].paystate || 0;
+              acupointTable.prescriptionDataMap[idx].isPay = dataArray[numIdx].isPay || false;
+            }
           });
         }
 
@@ -3455,6 +3465,7 @@ export default {
         preId: id,
         visitId: JSON.parse(sessionStorage.getItem("patiensInfo")).pid
       });
+      console.log(res, "支付状态");
       if (res.ResultCode == 0) {
         // 跟据id 回显
         let children = this.$children.filter(item => {
@@ -3585,6 +3596,8 @@ export default {
       };
       let res = await getRecipePriview(params).catch(err => {
         loading.close();
+        // 保存失败时恢复保存按钮状态
+        this.$refs.suitScience && this.$refs.suitScience.saveDone();
       });
       if (res.ResultCode == 0) {
         loading.close();
@@ -3602,6 +3615,10 @@ export default {
           })
         );
         this.showPriview = true;
+      } else {
+        // 保存失败时恢复保存按钮状态
+        loading.close();
+        this.$refs.suitScience && this.$refs.suitScience.saveDone();
       }
     },
 
@@ -3627,9 +3644,7 @@ export default {
         }
         this.contentTabs[0].check = res.Data.zhongyao.length > 0;
         this.contentTabs[1].check = res.Data.zhongchengyao.chengDetail !== null;
-        // 适宜技术回显:后端字段由 technology(单数对象) 改为 technologies(复数/数组),兼容旧字段
-        // const _techRaw = res.Data.technologies != null ? res.Data.technologies : res.Data.technology;
-        // const techList = Array.isArray(_techRaw) ? _techRaw : (_techRaw ? [_techRaw] : []);
+        // 适宜技术回显
         this.contentTabs[2].check = res.Data.technologies.length > 0;
 
         this.container_i = Math.max(this.contentTabs.findIndex(item => item.check), 0);
@@ -3707,7 +3722,7 @@ console.log(res, "处方回显数据==处方管理",res.Data.type);
       }
     },
     // 适宜技术病历转方回显(getRecipeBySuitTech,入参 recordId=来源就诊记录id)
-    async suitTechRecordTurn(recordId) {
+    async suitTechRecordTurn(recordId,visitId) {
       const loading = this.$loading({
         lock: true,
         text: '正在处理转方数据',
@@ -3715,7 +3730,8 @@ console.log(res, "处方回显数据==处方管理",res.Data.type);
         background: 'rgba(0, 0, 0, 0.7)',
       });
       try {
-        const res = await getRecipeBySuitTech({ recordId });
+        console.log('转方就诊id', recordId, "就诊id",visitId);
+        const res = await getRecipeBySuitTech({ recordId ,visitId});
         console.log('适宜技术病历转方回显', res);
         if (res.ResultCode === 0 && res.Data) {
           console.log('获取数据', res.Data);