Explorar el Código

同步两个请求

xiezhiming hace 8 meses
padre
commit
77101835c6
Se han modificado 2 ficheros con 101 adiciones y 65 borrados
  1. 99 64
      src/js/qcScore.js
  2. 2 1
      webpack.config.js

+ 99 - 64
src/js/qcScore.js

@@ -245,40 +245,48 @@ $(function () {
     });
   }
   function getRecordDetailUpdate() {
-    post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
-      if (res.data.code === '0') {
-        const data = res.data.data;
-        const { beHospital, result, msg, checkStatus, drgs } = data;
-        // global_check = checkStatus
-        // const info=Object.assign(beHospital,result);
-        // initMenu(JSON.parse(result.menuData));
-        // $(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
-        // global_activeTab=$(".sub-menu .page.active").attr("code");
-        // initPatientInfo(info);
-
-        const pageData = JSON.parse(result.pageData)
-        const list2 = pageData.病案首页
-        const diagList = JSON.parse(list2[0].出院诊断)
-        const operaList = JSON.parse(list2[0].手术信息)
-
-        global_diagList = diagList;
-        global_operaList = operaList;
-
-        initContent(result.pageData);
-
-        initList(msg);
-        initScoreItem(msg);
-        global_flawData = msg;
-        global_flawDataPay = drgs;
-        // setBoxHeight();
-        // changePay()
-        $(`.flaw-table,.content-item`).css('display', 'none')
-        if (global_activeTab === "缺陷总览") {
-          $(".flaw-table").css("display", "block")
+    return new Promise((resolve, reject) => {
+      post(api.getRecordDetail, { 'behospitalCode': global_id }).then(function (res) {
+        if (res.data.code === '0') {
+          const data = res.data.data;
+          const { beHospital, result, msg, checkStatus, drgs } = data;
+          // global_check = checkStatus
+          // const info=Object.assign(beHospital,result);
+          // initMenu(JSON.parse(result.menuData));
+          // $(".subMenu >li:first-child.page,.menu-mini>ul>li:first-child.page").addClass("active");
+          // global_activeTab=$(".sub-menu .page.active").attr("code");
+          // initPatientInfo(info);
+
+          const pageData = JSON.parse(result.pageData)
+          const list2 = pageData.病案首页
+          const diagList = JSON.parse(list2[0].出院诊断)
+          const operaList = JSON.parse(list2[0].手术信息)
+
+          global_diagList = diagList;
+          global_operaList = operaList;
+
+          initContent(result.pageData);
+
+          initList(msg);
+          initScoreItem(msg);
+          global_flawData = msg;
+          global_flawDataPay = drgs;
+          // setBoxHeight();
+          // changePay()
+          $(`.flaw-table,.content-item`).css('display', 'none')
+          if (global_activeTab === "缺陷总览") {
+            $(".flaw-table").css("display", "block")
+          }
+          $(`.content-item[code=${global_activeTab}`).css("display", "block")
+          resolve(true)
+        } else {
+          reject(false)
         }
-        $(`.content-item[code=${global_activeTab}`).css("display", "block")
-      }
-    });
+      }).catch(err => {
+        reject(false)
+      });
+    })
+
   }
   //补录数据,接口来自技术服务部
   function supplementData() {
@@ -301,12 +309,13 @@ $(function () {
   function loading() {
     const str = `
     <div class="loadingBox">
-            <div class="mask"></div>
+            <div class="mask"></div>  
             <img class="loadingImg" src=${loadingImg}  alt="loading" />
         </div>
     `
     $("body", parent.document).append(str)
   }
+
   function hideLoading() {
     $(".loadingBox", parent.document).remove()
   }
@@ -1174,32 +1183,54 @@ $(function () {
       console.log("编辑中");
       $(this).text('保存');
     } else {
+      // 打开遮罩防止多次点击
+      loading()
       switch (global_activeTab) {
         case "病案首页":
           saveOrUpdate().then((res) => {
-            getRecordDetailUpdate()
-            $.alerModal({ "message": "保存成功", type: "tip", time: '1000', win: true });
-            isEditing[global_activeTab] = false
-            $(this).text('编辑');
+
+            getRecordDetailUpdate().then(res => {
+              hideLoading()
+              $.alerModal({ "message": "保存成功", type: "tip", time: '1000', win: true });
+              isEditing[global_activeTab] = false
+              $(this).text('编辑');
+            })
+
           }).catch(err => {
+            hideLoading()
             $.alerModal({ "message": err, type: "tip", time: '1000', win: 'default' });
           })
           break
         case "入院记录":
-          admissionRecordUpdate()
-          $(this).text('编辑');
+
+          admissionRecordUpdate().then(res => {
+            hideLoading()
+            $(this).text('编辑');
+          })
+
           break
         case "首次病程录":
           firstRecordUpdate().then(res => {
-            getRecordDetailUpdate()
-            $.alerModal({ "message": "保存成功", type: "tip", time: '1000', win: true });
-            isEditing[global_activeTab] = false
-            $(this).text('编辑');
+
+            getRecordDetailUpdate().then(res => {
+              hideLoading()
+              $.alerModal({ "message": "保存成功", type: "tip", time: '1000', win: true });
+              isEditing[global_activeTab] = false
+              $(this).text('编辑');
+            }).catch(err => {
+
+            })
+
+
+
           }).catch(err => {
+            hideLoading()
             $.alerModal({ "message": err, type: "tip", time: '1000', win: 'default' });
+
           })
           break
         default:
+          hideLoading()
           isEditing[global_activeTab] = false
           $(this).text('编辑');
       }
@@ -1221,22 +1252,26 @@ $(function () {
       return String(value).padStart(2, '0');
     }
 
-    const date = new Date(dateStr)
-    if (!isNaN(date.getTime())) {
-      const year = date.getFullYear()
-      const month = fillZero(date.getMonth())
-      const day = fillZero(date.getDate())
-      const hour = fillZero(date.getHours())
-      const minute = fillZero(date.getMinutes())
-      const second = fillZero(date.getSeconds())
-      return `${year}-${month}-${day} ${hour}:${minute}:${second}`
-    } else {
-      validateFirstRecordUpdate = false
-      // 清除alerModal
-      $('.divModal').empty()
-      $.alerModal({ "message": dateName + "格式不正确", type: "tip", time: '1000', win: 'default' });
-      return ""
+    if (dateStr) {
+      const date = new Date(dateStr)
+      if (!isNaN(date.getTime())) {
+        const year = date.getFullYear()
+        const month = fillZero(date.getMonth())
+        const day = fillZero(date.getDate())
+        const hour = fillZero(date.getHours())
+        const minute = fillZero(date.getMinutes())
+        const second = fillZero(date.getSeconds())
+        return `${year}-${month}-${day} ${hour}:${minute}:${second}`
+      } else {
+        hideLoading()
+        validateFirstRecordUpdate = false
+        // 清除alerModal,防止多个重叠
+        $('.divModal').remove()
+        $.alerModal({ "message": dateName + "格式不正确", type: "tip", time: '2000', win: 'default' });
+        return ""
+      }
     }
+    return ""
 
   }
 
@@ -1720,7 +1755,7 @@ $(function () {
     /** 出院诊断 */
     const leaveDiags = addLeaveDiags()
     /** 住院手术 */
-    const operations = addoperations()
+    const operations = addOperations()
 
     let param = {
       "dockModeType": "3",
@@ -1926,16 +1961,16 @@ $(function () {
         }
 
         leaveDiagsArray.push(diagsObj)
-        i = i + 1
+        i += 1
       }
     });
     return leaveDiagsArray
   }
   /**
    * 取表格里的数据-手术情况
-   * @return {} operationsArry 表格的数据
+   * @returns {} operationsArry 表格的数据
   */
-  function addoperations() {
+  function addOperations() {
     let operationsArry = []
     let i = 0//顺序号
     $('.opera-table tbody tr').each(function (rowIndex) {//遍历每一行
@@ -1974,7 +2009,7 @@ $(function () {
         operationObj.anaesthesiaName = $(this).find('td').eq(9).text()
         operationObj.anaesthesiaDoctor = $(this).find('td').eq(10).text()
         operationsArry.push(operationObj)
-        i = i + 1
+        i += 1
       }
 
     });

+ 2 - 1
webpack.config.js

@@ -7,7 +7,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
 const webpack = require('webpack');
 const glob = require('glob');
-const proxyHost = "http://173.18.12.195:5858";
+// const proxyHost = "http://173.18.12.195:5858";
+const proxyHost = "http://172.16.8.60:5858";
 // const proxyHost = "http://173.18.12.195:5656";
 // const proxyHost = "http://192.168.2.241:5858";
 // const proxyHost = "http://192.168.4.222:5858";