Bläddra i källkod

添加tab的增删,显示判断、切换判断等

reaper 4 år sedan
förälder
incheckning
6d6ffab806

+ 2 - 2
src/components/knowledgeExtra/AddAssess/index.vue

@@ -753,7 +753,7 @@ export default {
       let valid1 = new Promise((resolve, reject) => {
         this.$refs["scaleFormRef"].validate((valid, object, err) => {
           if (valid) {
-            resolve();
+            resolve(true);
           } else {
             reject("c",object);
             this.$emit("scrollTo",20);
@@ -764,7 +764,7 @@ export default {
       let valid2 = new Promise((resolve, reject) => {
         this.$refs["ScoreResultsRef"].validate((valid,object) => {
           if (valid) {
-            resolve();
+            resolve(true);
           } else {
             reject("c",object);
             return false;

+ 244 - 154
src/components/knowledgeExtra/AddDevKnow.vue

@@ -56,53 +56,72 @@
             }}</el-form-item>
           </div>
         </el-form>
-
-        <div class="tabs">
-          <div
-            class="tabs_pane"
-            :style="
-              tabActive == 'one' ? { color: '#fff', background: '#00c7da' } : ''
-            "
-            @click="tabActiveChange('one')"
-            v-if="staticTabShow"
-          >
-            静态信息
-            <img
-              @click.stop="AssesTabSHow = true"
-              src="@/images/tab_add.png"
-              alt=""
-              v-if="!AssesTabSHow && AssesComSHow"
-            />
-            <img
+        <div class="tabs_box">
+          <div class="tabs">
+            <div
+              class="tabs_pane"
+              :style="
+                tabActive == 'one'
+                  ? { color: '#fff', background: '#00c7da' }
+                  : ''
+              "
+              @click="tabActiveChange('one')"
+              v-if="staticTabShow"
+            >
+              静态信息
+              <img
+                @click.stop="AssesTabSHow = true"
+                src="@/images/tab_add.png"
+                alt=""
+                v-if="!AssesTabSHow && AssesComSHow"
+              />
+              <img
+                v-if="AssesTabSHow && AssesComSHow"
+                @click.stop="closeStaticTab"
+                src="@/images/tab_close.png"
+                alt=""
+              />
+            </div>
+            <div
+              class="tabs_pane"
+              :style="
+                tabActive == 'two'
+                  ? { color: '#fff', background: '#00c7da' }
+                  : ''
+              "
+              @click="tabActiveChange('two')"
               v-if="AssesTabSHow && AssesComSHow"
-              @click.stop="closeStaticTab"
-              src="@/images/tab_close.png"
-              alt=""
-            />
+            >
+              评估内容
+              <img
+                v-if="!staticTabShow"
+                @click.stop="staticTabShow = true"
+                src="@/images/tab_add.png"
+                alt=""
+              />
+              <img
+                v-if="staticTabShow"
+                @click.stop="closeAssesTab"
+                src="@/images/tab_close.png"
+                alt=""
+              />
+            </div>
           </div>
           <div
-            class="tabs_pane"
-            :style="
-              tabActive == 'two' ? { color: '#fff', background: '#00c7da' } : ''
-            "
-            @click="tabActiveChange('two')"
-            v-if="AssesTabSHow && AssesComSHow"
+            class="tabs_msg"
+            v-if="tabErrMsg && staticTabShow && AssesTabSHow && AssesComSHow"
           >
-            评估内容
-            <img
-              v-if="!staticTabShow"
-              @click.stop="staticTabShow = true"
-              src="@/images/tab_add.png"
-              alt=""
-            />
-            <img
-              v-if="staticTabShow"
-              @click.stop="closeAssesTab"
-              src="@/images/tab_close.png"
-              alt=""
-            />
+            <div>
+              <img src="@/images/msg_close.png" alt="" />
+            </div>
+            <span
+              >{{
+                tabErrMsg
+              }}标签内有未填写项目,请填写完整或者删除该标签!</span
+            >
           </div>
         </div>
+
         <p class="line"></p>
         <div
           class="tab_box_left"
@@ -241,6 +260,7 @@ export default {
   },
   data() {
     return {
+      tabErrMsg: null,
       staticTabShow: true,
       AssesTabSHow: true,
       staticComShow: true,
@@ -396,21 +416,26 @@ export default {
                 data.name + (data.typeName ? "(" + data.typeName + ")" : "");
               this.form.selectedTerm =
                 data.name + (data.typeName ? "(" + data.typeName + ")" : "");
-              this.form.prags =
-                data &&
-                data.details.map((it) => {
-                  return {
-                    title: it.title,
-                    position: this.mapStringToNum(it.contentType),
-                    content: it.content.replace(
-                      /{imageUrlPrefix}/g,
-                      config.imgHost
-                    ),
-                    // isReason:it.isReason,
-                    text: it.text,
-                    disabled: true
-                  };
-                });
+              if (data.details.length) {
+                this.form.prags =
+                  data &&
+                  data.details.map((it) => {
+                    return {
+                      title: it.title,
+                      position: this.mapStringToNum(it.contentType),
+                      content: it.content.replace(
+                        /{imageUrlPrefix}/g,
+                        config.imgHost
+                      ),
+                      // isReason:it.isReason,
+                      text: it.text,
+                      disabled: true
+                    };
+                  });
+              } else {
+                this.staticTabShow = false;
+                this.tabActiveChange("two");
+              }
             }
           }
         })
@@ -474,10 +499,12 @@ export default {
     closeStaticTab() {
       this.staticTabShow = false;
       this.tabActiveChange("two");
+      this.tabErrMsg = null;
     },
     closeAssesTab() {
       this.AssesTabSHow = false;
       this.tabActiveChange("one");
+      this.tabErrMsg = null;
     },
     scrollTo(value) {
       let div = this.$refs["elscrollbar"].$refs["wrap"];
@@ -490,6 +517,7 @@ export default {
       if (type == "two") {
         this.$refs.assessRef.resizeTable();
       }
+      this.tabErrMsg = null;
     },
     handleClear() {
       this.form.selectedTermName = "";
@@ -507,7 +535,8 @@ export default {
       this.isShowTip = false;
     },
     changeWord(newVal) {
-      console.log(newVal, '选中');
+      this.tabErrMsg = null;
+      console.log(newVal, "选中");
       if (newVal.typeName == "量表") {
         this.AssesComSHow = true;
       } else {
@@ -694,8 +723,10 @@ export default {
     async submitForm() {
       let all = [];
       let goOn = true,
-          it = null;
-        let outIsVia = true; // 外层验证是否通过
+        it = null;
+      let viewHeight = 0; // 定位到表单校验的高度
+      let viewHeightArr = []; // 表单校验出错高度的所有数组
+      let outIsVia = true; // 外层验证是否通过
       if (this.staticTabShow) {
         if (this.isSuccessUpload === 1) {
           this.warning("文件上传中,请稍等");
@@ -704,14 +735,13 @@ export default {
         let flagVal = this.formVal(); // 额外的表单校验
         if (flagVal === false) return;
         //验证外层表单
-        
 
         let fvalidate = new Promise((resolve, reject) => {
           //wanglei 添加promise
           this.$refs.groups &&
             this.$refs.groups.validate((valid, object) => {
               if (valid) {
-                resolve();
+                resolve(true);
               } else {
                 reject("f", object);
                 return false;
@@ -722,7 +752,7 @@ export default {
           //wanglei 添加promise
           this.$refs.groups1.validate((valid, object) => {
             if (valid) {
-              resolve();
+              resolve(true);
             } else {
               reject("f", object);
               return false;
@@ -732,27 +762,26 @@ export default {
         // end....
         //验证段落表单
         // return;
-        let viewHeight = 0; // 定位到表单校验的高度
-        let viewHeightArr = []; // 表单校验出错高度的所有数组
-        let fvalidate3 = null;
+        all = [fvalidate, fvalidate1];
         if (this.form.typeId !== 82 && this.form.typeId !== 83) {
-          fvalidate3 = new Promise((resolve, reject) => {
-            for (let i = 0; i < this.$refs.subForm.length; i++) {
-              it = this.$refs.subForm[i];
-              viewHeight += it.$el.offsetHeight;
-              it.$refs.form.validate((valid, object) => {
-                if (!valid) {
-                  reject("f", object);
-                  goOn = false;
-                  viewHeightArr.push(viewHeight);
-                } else {
-                  resolve();
-                }
-              });
-            }
-          });
+          for (let i = 0; i < this.$refs.subForm.length; i++) {
+            all.push(
+              new Promise((resolve, reject) => {
+                it = this.$refs.subForm[i];
+                viewHeight += it.$el.offsetHeight;
+                it.$refs.form.validate((valid, object) => {
+                  if (!valid) {
+                    reject("f", object);
+                    goOn = false;
+                    viewHeightArr.push(viewHeight);
+                  } else {
+                    resolve(true);
+                  }
+                });
+              })
+            );
+          }
         }
-        all = [fvalidate, fvalidate1, fvalidate3];
       }
 
       // 表单验证
@@ -760,27 +789,57 @@ export default {
       if (this.$refs.assessRef) {
         all.push(...this.$refs.assessRef.assessCommit());
       }
-      await Promise.all(all)
-        .then(() => {
-          console.log("3.5");
-        })
-        .catch((err, obj) => {
-          console.log("obj", err);
-          // 跳转到未校验通过的tab页
-          if (err == "f") {
-            this.tabActive = "one";
-          } else if (err == "c") {
-            this.tabActive = "two";
-          }
+      console.log("all", all);
+      // await Promise.all(all)
+      //   .then(() => {
+      //     console.log("3.5");
+      //   })
+      //   .catch((err, obj) => {
+      //     console.log("obj", err, obj);
+      //     // 跳转到未校验通过的tab页
+      //     if (err == "f") {
+      //       this.tabActive = "one";
+      //       this.tabErrMsg = `"静态知识"`;
+      //     } else if (err == "c") {
+      //       this.tabActive = "two";
+      //       this.tabErrMsg = `"评估内容"`;
+      //     }
+      //     if (this.staticTabShow) {
+      //       goOn = false;
+      //       outIsVia = false;
+      //     }
+      //   });
+      // console.log(viewHeightArr,'viewHeightArr');
+      // 批量处理Promise返回
+      let transferedPromises = (promises) => {
+        // 返回一个处理之后的promise数组
+        return promises.map((promise) => {
+          return promise.then((res) => res).catch((err) => err);
+        });
+      };
+      let promiseArr = transferedPromises(all);
+      await Promise.all(promiseArr).then((resArr) => {
+        console.log(resArr);
+        let cErrIndex = resArr.findIndex((item) => item == "c");
+        let fErrIndex = resArr.findIndex((item) => item == "f");
+        if (cErrIndex != -1 && fErrIndex != -1) {
           if (this.staticTabShow) {
             goOn = false;
             outIsVia = false;
           }
-        });
-      // console.log(viewHeightArr,'viewHeightArr');
-      if (this.staticTabShow) {
-        console.log("????");
-        if (!goOn) {
+          this.tabActive = "one";
+          this.tabErrMsg = `"静态知识"和"评估内容"`;
+        } else if (cErrIndex != -1 && fErrIndex == -1) {
+          this.tabActive = "two";
+          this.tabErrMsg = `"评估内容"`;
+        } else if (cErrIndex == -1 && fErrIndex != -1) {
+          this.tabActive = "one";
+          this.tabErrMsg = `"静态知识"`;
+        }
+      });
+
+      if (!goOn) {
+        if (this.staticTabShow) {
           var div = this.$refs["elscrollbar"].$refs["wrap"];
           if (outIsVia) {
             // 外层校验通过,跳转至下层校验具体位置
@@ -793,72 +852,74 @@ export default {
               div.scrollTop = 0;
             });
           }
-          return;
         }
+        return;
       }
 
       //通过必填验证,提交保存
 
       let param = [];
       // const item = this.form.prags;
-      if (this.staticTabShow) {
-        if (this.form.typeId === 82 || this.form.typeId === 83) {
-          if (this.form.fileList.length === 0) {
-            this.warning("文件未上传,不存储数据");
-            return;
-          }
-          param.push(
-            Object.assign(
-              {},
-              {
-                position: this.form.typeId === 82 ? "8" : "9",
-                conceptId: this.form.conceptId,
-                title: this.form.fileTitle,
-                orderNo: 0,
-                content: JSON.stringify(this.form.fileList[0])
-              }
-            )
-          );
-        } else {
-          let data = this.form.prags,
-            tempArr = [],
-            paramsAll = {},
-            types = this.form.typeId;
-          for (let i = 0; i < data.length; i++) {
-            let obj = {};
-            obj.content = data[i].content;
-            obj.text = data[i].text;
-            obj.conceptId = data[i].conceptId;
-            obj.orderNo = i;
-            obj.title = data[i].title;
-            obj.contentType = data[i].position.join(",");
-            tempArr.push(obj);
-          }
-          paramsAll.clinicalPathwayName =
-            types == 1 ? this.form.titleChange : "";
-          paramsAll.id = this.conceptId;
-          paramsAll.name = this.form.name;
-          paramsAll.noticeName =
-            types == 3 || types == 4 || types == 5 || types == 6
-              ? this.form.titleChange
-              : "";
-          paramsAll.type = this.form.typeId;
+
+      if (this.form.typeId === 82 || this.form.typeId === 83) {
+        if (this.form.fileList.length === 0) {
+          this.warning("文件未上传,不存储数据");
+          return;
+        }
+        param.push(
+          Object.assign(
+            {},
+            {
+              position: this.form.typeId === 82 ? "8" : "9",
+              conceptId: this.form.conceptId,
+              title: this.form.fileTitle,
+              orderNo: 0,
+              content: JSON.stringify(this.form.fileList[0])
+            }
+          )
+        );
+      } else {
+        // if (this.staticTabShow) {
+        // }
+        let data = this.form.prags,
+          tempArr = [],
+          paramsAll = {},
+          types = this.form.typeId;
+        for (let i = 0; i < data.length; i++) {
+          let obj = {};
+          obj.content = data[i].content;
+          obj.text = data[i].text;
+          obj.conceptId = data[i].conceptId;
+          obj.orderNo = i;
+          obj.title = data[i].title;
+          obj.contentType = data[i].position.join(",");
+          tempArr.push(obj);
+        }
+        paramsAll.clinicalPathwayName = types == 1 ? this.form.titleChange : "";
+        paramsAll.id = this.conceptId;
+        paramsAll.name = this.form.name;
+        paramsAll.noticeName =
+          types == 3 || types == 4 || types == 5 || types == 6
+            ? this.form.titleChange
+            : "";
+        paramsAll.type = this.form.typeId;
+        if (this.staticTabShow) {
           paramsAll.details = tempArr;
-          param = paramsAll;
+        } else {
+          paramsAll.details = null;
+        }
+        param = paramsAll;
+        // 评估内容的数据
+        if (this.AssesComSHow) {
+          const assessParam = this.$refs.assessRef.formtParams();
+          param.scale = assessParam;
+          param.scale.conceptId = this.toAssesTermId;
+          const userInfo = localStorage.getItem("userLoginDTO");
+          param.scale.modifier = userInfo.linkman;
         }
       }
 
       // this.showSaveDialog(param,'是否'+(this.isEdit?'修改':'保存')+'该静态知识?');
-
-      // 评估内容的数据
-      if (this.AssesComSHow) {
-        const assessParam = this.$refs.assessRef.formtParams();
-        param.scale = assessParam;
-        param.scale.conceptId = this.toAssesTermId;
-        const userInfo = localStorage.getItem("userLoginDTO");
-        param.scale.modifier = userInfo.linkman;
-      }
-
       console.log("param-------");
       console.dir(param);
       return;
@@ -1130,14 +1191,43 @@ export default {
 .container_top {
   display: flex;
   padding: 20px 30px;
+}
+.tabs_box {
+  display: flex;
   align-items: center;
+  .tabs_msg {
+    margin-left: 180px;
+    width: 502px;
+    height: 30px;
+    background: #fff1f0;
+    border-radius: 4px;
+    border: 1px solid #fde2e2;
+    display: flex;
+    align-items: center;
+    padding-left: 20px;
+    margin-top: -10px;
+    div {
+      width: 15px;
+      height: 15px;
+      margin-top: -3px;
+      margin-right: 10px;
+      img {
+        width: 100%;
+        height: 100%;
+      }
+    }
+    span {
+      color: #f56c6d;
+      line-height: 21px;
+      font-size: 14px;
+    }
+  }
 }
 .tabs {
   display: flex;
-  margin: 15px 30px 0 30px;
+  margin: 0px 30px;
   font-size: 14px;
   height: 31px;
-  border-bottom: 1px solid #e6e6e6;
   .tabs_pane {
     position: relative;
     width: 92px;