1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| $('#cond').change(function() { var defaultOption = { timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd" }; var startHour = 9; var enableTimePicker = true;
$('.selectDateInput').prop('readonly', 'readonly').val(''); if (!enableTimePicker) { var startOption = { hour: startHour, showHour: false, showMinute: false, timeInput: false, disabled: false, onSelect: function(selectedDateTime) { selectedDateTime = selectedDateTime.split(' ')[0] + " 00:00:00"; var startDate = (new Date(selectedDateTime)); $(this).datetimepicker('setDate', selectedDateTime + " " + startHour + ":00:00"); startDate.setTime(startDate.getTime() + 1000 * 3600 * (24 + startHour) - 1); var endDateStr = startDate.toLocaleString('zh-CN', {hour12: false}) .replace(/\//g, '-') .replace(/\b\d\b/g, '0$&'); $('.selectDateInput:eq(1)').val(endDateStr); } }; $('.selectDateInput:eq(0)').datetimepicker(defaultOption) .datetimepicker('option', startOption);
$('.selectDateInput:eq(1)').datetimepicker() .datetimepicker('option', { disabled: true }); } else { $('.selectDateInput').datetimepicker(defaultOption) .datetimepicker('option', { showHour: true, showMinute: true, timeInput: true, disabled: false, onSelect: null }); } }).trigger('change');
|