fix bugs chọn được mốc thời gian chồng chéo
This commit is contained in:
parent
463fa90f8a
commit
aa1144da08
|
@ -48,7 +48,7 @@ $config = [
|
||||||
],
|
],
|
||||||
'assetManager' => [
|
'assetManager' => [
|
||||||
'class' => 'app\\components\\AssetManager',
|
'class' => 'app\\components\\AssetManager',
|
||||||
'appendVersion' => '1.0.6',
|
'appendVersion' => '1.0.11',
|
||||||
'bundles' => [
|
'bundles' => [
|
||||||
'dmstr\web\AdminLteAsset' => [
|
'dmstr\web\AdminLteAsset' => [
|
||||||
'skin' => 'skin-blue',
|
'skin' => 'skin-blue',
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
<div class="form-group col-md-4 col-md-push-2">
|
<div class="form-group col-md-4 col-md-push-2">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">Từ</div>
|
<div class="input-group-addon">Từ</div>
|
||||||
<input type='text' value="{$f|date_format:"%H:%M:%S %d/%m/%Y"}" class="form-control time-picker" name='FromTime' readonly="">
|
<input type='text' value="{$f|date_format:"%H:%M:%S %d/%m/%Y"}" class="form-control time-picker" name='FromTime'>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4 col-md-push-2">
|
<div class="form-group col-md-4 col-md-push-2">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">Đến</div>
|
<div class="input-group-addon">Đến</div>
|
||||||
<input type='text' value="{$t|date_format:"%H:%M:%S %d/%m/%Y"}" class="form-control time-picker" name='ToTime' readonly="">
|
<input type='text' value="{$t|date_format:"%H:%M:%S %d/%m/%Y"}" class="form-control time-picker" name='ToTime'>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-md-push-2">
|
<div class="col-md-2 col-md-push-2">
|
||||||
|
|
|
@ -74,6 +74,10 @@ function saveCurrentPos() {
|
||||||
alert("Mốc thời gian lựa chọn chưa đúng!");
|
alert("Mốc thời gian lựa chọn chưa đúng!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!checkTime(currentID)) {
|
||||||
|
alert("Các mốc thời gian trong ngày không được phép chồng chéo!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (f !== "00:00" || t !== "00:00") {
|
if (f !== "00:00" || t !== "00:00") {
|
||||||
var html = `<span style="cursor: pointer;" onclick="openFormTimePicker(this);" data-id="` + currentID + `">` + f + ` - ` + t + `</span>`;
|
var html = `<span style="cursor: pointer;" onclick="openFormTimePicker(this);" data-id="` + currentID + `">` + f + ` - ` + t + `</span>`;
|
||||||
$("#data-" + currentID).html(html);
|
$("#data-" + currentID).html(html);
|
||||||
|
@ -87,6 +91,35 @@ function saveCurrentPos() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkTime(currentID) {
|
||||||
|
var fCheck = convertTime($("input[name='From" + currentID + "']").val());
|
||||||
|
var tCheck = convertTime($("input[name='To" + currentID + "']").val());
|
||||||
|
|
||||||
|
var currentDay = currentID.substring(0, 3);
|
||||||
|
var currentIdx = currentID.substring(3);
|
||||||
|
var others = [];
|
||||||
|
if (currentIdx == 1)
|
||||||
|
others = [2, 3];
|
||||||
|
if (currentIdx == 2)
|
||||||
|
others = [1, 3];
|
||||||
|
if (currentIdx == 3)
|
||||||
|
others = [1, 2];
|
||||||
|
|
||||||
|
for (var i = 0; i < others.length; i++) {
|
||||||
|
var f = convertTime($("input[name='From" + currentDay + others[i] + "']").val());
|
||||||
|
var t = convertTime($("input[name='To" + currentDay + others[i] + "']").val());
|
||||||
|
if (fCheck > f && fCheck < t)
|
||||||
|
return false;
|
||||||
|
if (tCheck > f && tCheck < t)
|
||||||
|
return false;
|
||||||
|
if (f > fCheck && f < tCheck)
|
||||||
|
return false;
|
||||||
|
if (t > fCheck && t < tCheck)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function convertTime(time) {
|
function convertTime(time) {
|
||||||
var split = time.split(":");
|
var split = time.split(":");
|
||||||
return parseInt(split[0]) * 60 + parseInt(split[1]);
|
return parseInt(split[0]) * 60 + parseInt(split[1]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user