浏览代码

添加首次病程录时间的验证

xiezhiming 8 月之前
父节点
当前提交
fe708ce135
共有 1 个文件被更改,包括 45 次插入14 次删除
  1. 45 14
      src/js/qcScore.js

+ 45 - 14
src/js/qcScore.js

@@ -1207,9 +1207,37 @@ $(function () {
     $(this).parents(".content-item").find('p, .embed-table .table-1 td, .opera-table td,.embed-table .table-2 td,.inner-table td').attr('contenteditable', isEditing[global_activeTab]);
   });
 
+  /**验证首次病程录更新*/
+  let validateFirstRecordUpdate = true
+  /**时间格式化*/
+  function dateFormat(dateName, dateStr) {
+    function fillZero(value) {
+      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.getDate())
+      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 ""
+    }
+
+  }
 
   /**首次病程录更新*/
   function firstRecordUpdate() {
+    validateFirstRecordUpdate = true
+
     /**病人住院ID*/
     const behospitalCode = global_id
     /**医院ID*/
@@ -1225,7 +1253,7 @@ $(function () {
     /**床号*/
     const bedNo = $('#anchor2030 p').text()
     /**病历日期*/
-    const recordDate = $('#anchor2027 p').text().trim() + ":00"
+    const recordDate = dateFormat("病历日期", $('#anchor2027 p').text())
     /** 标题 */
     const recTitle = '';
     /** 主诉 */
@@ -1251,11 +1279,11 @@ $(function () {
     /** 记录医生 */
     const recDoctor = $('#anchor1986 p').text();
     /** 记录时间 */
-    const recDate = $('#anchor1988 p').text().trim() + ":00";
+    const recDate = dateFormat("记录时间", $('#anchor1988 p').text())
     /** 审核医生 */
     const auditDoctor = $('#anchor1989 p').text();
     /** 审核时间 */
-    const auditDate = $('#anchor1992 p').text().trim() + ":00";
+    const auditDate = dateFormat("审核时间", $('#anchor1992 p').text())
     /** 主诊医生 */
     const chiefDoctor = $('#anchor2025 p').text();
     /** 发热 */
@@ -1267,7 +1295,7 @@ $(function () {
     /** 成瘾药物 */
     const addiMedication = $('#anchor2034 p').text();
     /** 入院时间 */
-    const behospitalDate = $('#anchor2027 p').text().trim() + ":00";
+    const behospitalDate = dateFormat("入院时间", $('#anchor2027 p').text());
 
     const params = {
       "behospitalCode": behospitalCode,            // 入院编码
@@ -1302,17 +1330,20 @@ $(function () {
     };
 
     return new Promise((resolve, reject) => {
-      post(api.editFirstRecordInfos, params).then(res => {
-        if (res.data.code === '0') {
-          resolve(true)
-        } else {
-          reject(res.data.msg)
-        }
-      }).catch(err => {
-        reject(err.msg)
-      })
+      if (validateFirstRecordUpdate) {
+        post(api.editFirstRecordInfos, params).then(res => {
+          if (res.data.code === '0') {
+            resolve(true)
+          } else {
+            reject(res.data.msg)
+          }
+        }).catch(err => {
+          reject(err.msg)
+        })
+      } else {
+        // reject("验证失败")
+      }
     })
-
   }
 
   /**保存入院记录数据更新*/