瀏覽代碼

创建计量期时,开始截止日期,应该自动跟着计量年月变化

ellisran 2 周之前
父節點
當前提交
2b18dfc777
共有 2 個文件被更改,包括 12 次插入2 次删除
  1. 10 0
      app/public/js/measure_stage.js
  2. 2 2
      app/view/measure/stage_modal.ejs

+ 10 - 0
app/public/js/measure_stage.js

@@ -222,4 +222,14 @@ function checkTableWidth() {
 
 $(function () {
     checkTableWidth();
+    const stagePeriod = $('#stage-period').datepicker({
+    }).data('datepicker');
+    const stageYearmonth = $('#stage-yearmonth').datepicker({
+        onSelect: function (formattedDate, date, inst) {
+            if (!date) return;
+            $('#stage-period').val(`${formattedDate}-01`);
+            stagePeriod.clear();;
+            stagePeriod.selectDate(new Date(date.getFullYear(), date.getMonth(), 1));
+        }
+    }).data('datepicker');
 });

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

@@ -30,11 +30,11 @@
                 </div>
                 <div class="form-group">
                     <label>计量年月<b class="text-danger">*</b></label>
-                    <input class="datepicker-here form-control form-control-sm" autocomplete="off" readonly placeholder="点击选择年月" data-view="months" data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text" name="date" autocomplete="off">
+                    <input class="datepicker-here form-control form-control-sm" id="stage-yearmonth" autocomplete="off" readonly placeholder="点击选择年月" data-view="months" data-min-view="months" data-date-format="yyyy-MM" data-language="zh" type="text" name="date" autocomplete="off">
                 </div>
                 <div class="form-group">
                     <label>开始-截止日期<b class="text-danger">*</b></label>
-                    <input class="datepicker-here form-control form-control-sm" autocomplete="off" readonly placeholder="点击选择时间" data-range="true" data-multiple-dates-separator=" ~ " data-language="zh" type="text" name="period" autocomplete="off">
+                    <input class="datepicker-here form-control form-control-sm" id="stage-period" autocomplete="off" readonly placeholder="点击选择时间" data-range="true" data-multiple-dates-separator=" ~ " data-language="zh" type="text" name="period" autocomplete="off">
                 </div>
             </div>
             <div class="modal-footer">