Quellcode durchsuchen

选择药品:请勿重复添加药品 判断添加 判断本身药品 逻辑

cc12458 vor 1 Jahr
Ursprung
Commit
6a7674db37
2 geänderte Dateien mit 10 neuen und 18 gelöschten Zeilen
  1. 5 9
      src/components/ChineseMedicine.vue
  2. 5 9
      src/components/MedicineAccord.vue

+ 5 - 9
src/components/ChineseMedicine.vue

@@ -1804,13 +1804,9 @@ export default {
     // 表一 选中药品
     chooseDis1(scope, index, item, from = "now") {
       let totalData = this.recipe_tabs[this.recipe_tabs_c].totalTableD;
-      let isHas = false;
-      totalData.forEach(item1 => {
-        if (item1.medid === item.pid) {
-          isHas = true;
-        }
-      });
-      if (isHas) {
+      const i = totalData.findIndex(t => t.medid === item.pid);
+      const oneself = i === scope.row.id - 1;
+      if (i !== -1 && !oneself) {
         this.$message.warning("请勿重复添加药品");
         clearTimeout(medicineBlurTimer);
         let index = scope.row.id ? scope.row.id - 1 : 0;
@@ -1825,10 +1821,10 @@ export default {
         name: item.ypmc,
         spec: item.gg, // 规格
         // dose: "", // 剂量
-        dose: scope.row.color == "red" ? scope.row.dose : "",
+        dose: scope.row.color === "red" || oneself ? scope.row.dose : "",
         unit: item.dw, // 单位
         usage:
-          scope.row.color == "red"
+          oneself ? scope.row.usage : scope.row.color === "red"
             ? this.usageList[0].key
             : scope.row.usage || item.usagestr || this.usageList[0].key, // 用法
         //usage: "",

+ 5 - 9
src/components/MedicineAccord.vue

@@ -1289,13 +1289,9 @@ export default {
     },// 表一 选中药品
     chooseDis1(scope, index, item, from = "now") {
       let totalData = this.recipe_tabs[this.recipe_tabs_c].totalTableD;
-      let isHas = false;
-      totalData.forEach(item1 => {
-        if (item1.medid === item.pid) {
-          isHas = true;
-        }
-      });
-      if (isHas) {
+      const i = totalData.findIndex(t => t.medid === item.pid);
+      const oneself = i === scope.row.id - 1;
+      if (i !== -1 && !oneself) {
         this.$message.warning("请勿重复添加药品");
         clearTimeout(medicineBlurTimer);
         let index = scope.row.id ? scope.row.id - 1 : 0;
@@ -1310,10 +1306,10 @@ export default {
         name: item.ypmc,
         spec: item.gg, // 规格
         // dose: "", // 剂量
-        dose: scope.row.color == "red" ? scope.row.dose : "",
+        dose: scope.row.color === "red" || oneself ? scope.row.dose : "",
         unit: item.dw, // 单位
         usage:
-          scope.row.color == "red"
+          oneself ? scope.row.usage : scope.row.color === "red"
             ? this.usageList[0].key
             : scope.row.usage || item.usagestr || this.usageList[0].key, // 用法
         //usage: "",