Browse Source

修复计量期日期区间问题

laiguoran 3 years ago
parent
commit
ede7bd9569
2 changed files with 4 additions and 4 deletions
  1. 2 2
      app/public/js/measure_stage.js
  2. 2 2
      app/view/measure/stage_modal.ejs

+ 2 - 2
app/public/js/measure_stage.js

@@ -185,8 +185,8 @@ function checkValidForm() {
     const date = $('#add-qi input[name="date"]').val();
     const period = $('#add-qi input[name="period"]').val();
     const startDate = period.split('~')[0];
-    const endDate = period.split('~')[1];
-    if (startDate.indexOf(date) === -1 && endDate.indexOf(date) === -1) {
+    const endDate = period.split('~')[1] ? period.split('~')[1] : null;
+    if ((startDate.indexOf(date) === -1 && !endDate) || (startDate.indexOf(date) === -1 && endDate && endDate.indexOf(date) === -1)) {
         toastr.error('所选日期与当前月份不匹配,请重新选择');
         $('#add-qi input[name="period"]').parents('.form-group').find('.text-danger').remove();
         $('#add-qi input[name="period"]').parents('.form-group').append('<small class="text-danger">所选日期与当前月份不匹配,请重新选择</small>');

+ 2 - 2
app/view/measure/stage_modal.ejs

@@ -142,8 +142,8 @@
         const date = $('#edit-date').val();
         const period = $('#edit-period').val();
         const startDate = period.split('~')[0];
-        const endDate = period.split('~')[1];
-        if (startDate.indexOf(date) === -1 && endDate.indexOf(date) === -1) {
+        const endDate = period.split('~')[1] ? period.split('~')[1] : null;
+        if ((startDate.indexOf(date) === -1 && !endDate) || (startDate.indexOf(date) === -1 && endDate && endDate.indexOf(date) === -1)) {
             toastr.error('所选日期与当前月份不匹配,请重新选择');
             $('#edit-period').parents('.form-group').find('.text-danger').remove();
             $('#edit-period').parents('.form-group').append('<small class="text-danger">所选日期与当前月份不匹配,请重新选择</small>');