Browse Source

证书日期选择问题和按钮文字更新

ellisran 1 year ago
parent
commit
3d4c308f0d
2 changed files with 19 additions and 4 deletions
  1. 18 3
      app/public/js/profile_cert.js
  2. 1 1
      app/view/tender/cert_modal.ejs

+ 18 - 3
app/public/js/profile_cert.js

@@ -42,12 +42,17 @@ $(document).ready(function() {
                                     if (oldVal === '') {
                                         res.clear();
                                     } else {
+                                        const showDate = [];
+                                        for (const v of oldVal.split(' ~ ')) {
+                                            showDate.push(new Date(v));
+                                        }
                                         res.selectDate(new Date(oldVal));
                                     }
                                     return;
                                 }
                             }
-                        } else if(val !== oldVal) {
+                        }
+                        if(val !== oldVal) {
                             const data = {
                                 id: res.$el.parents('.one-cert').data('cid'),
                                 jxid: res.$el.parents('.one-jx').data('jxid'),
@@ -133,7 +138,11 @@ $(document).ready(function() {
         const defaultValue = $(this).val(); // 获取当前元素的 value 属性作为默认值
         if (defaultValue) {
             // 初始化日期选择器,并设置默认值
-            $(this).datepicker().data('datepicker').selectDate(new Date(defaultValue));
+            const showDate = [];
+            for (const v of defaultValue.split(' ~ ')) {
+                showDate.push(new Date(v));
+            }
+            $(this).datepicker().data('datepicker').selectDate(showDate);
         }
     });
     $('body .jx-date').datepicker({
@@ -145,6 +154,7 @@ $(document).ready(function() {
                 res.$el.attr('readOnly', false);
                 const val = res.$el.val();
                 const oldVal = res.$el.attr('data-old-date') || '';
+                console.log(val, oldVal);
                 // 日期格式判断
                 if (val !== '') {
                     const valArr = val.split(' ~ ');
@@ -155,12 +165,17 @@ $(document).ready(function() {
                             if (oldVal === '') {
                                 res.clear();
                             } else {
+                                const showDate = [];
+                                for (const v of oldVal.split(' ~ ')) {
+                                    showDate.push(new Date(v));
+                                }
                                 res.selectDate(new Date(oldVal));
                             }
                             return;
                         }
                     }
-                } else if(val !== oldVal) {
+                }
+                if(val !== oldVal) {
                     const data = {
                         id: res.$el.parents('.one-cert').data('cid'),
                         jxid: res.$el.parents('.one-jx').data('jxid'),

+ 1 - 1
app/view/tender/cert_modal.ejs

@@ -60,7 +60,7 @@
             <div class="modal-footer d-flex justify-content-between">
                 <div class="ml-auto">
                     <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
-                    <button type="button" class="btn btn-sm btn-primary" id="add_cert_btn">添加</button>
+                    <button type="button" class="btn btn-sm btn-primary" id="add_cert_btn">确认</button>
                 </div>
             </div>
         </div>