This commit is contained in:
dev01 2022-12-05 18:35:27 +08:00
commit 9aa7efcb6d
7 changed files with 340 additions and 75 deletions

View File

@ -4,9 +4,12 @@
<h1 class="p-2 mb-0">帳號與權限管理</h1>
<div class="row mt-5">
<ul class="nav nav-tabs w-100" role="tablist">
<li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#tab_borders_icons-1" role="tab"><i class="fal fa-user mr-1"></i> 帳號管理</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-2" role="tab"><i class="fal fa-users mr-1"></i> 群組管理</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-3" role="tab"><i class="fal fa-cog mr-1"></i> 群組權限</a> </li>
<li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#tab_borders_icons-1"
role="tab"><i class="fal fa-user mr-1"></i> 帳號管理</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-2"
role="tab"><i class="fal fa-users mr-1"></i> 群組管理</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-3"
role="tab"><i class="fal fa-cog mr-1"></i> 群組權限</a> </li>
</ul>
<div class="tab-content border border-top-0 p-3 w-100">
<div class="tab-pane fade show active" id="tab_borders_icons-1" role="tabpanel">
@ -35,7 +38,8 @@
<div class="col-auto"> <a href="#" class="btn btn-info">搜尋</a> </div>
</div>
<div class="frame-wrap">
<div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal" data-target="#accManModal">+ 新增</a> </div>
<div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
data-target="#accManModal">+ 新增</a> </div>
<table id="accManTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
@ -51,7 +55,8 @@
<div class="col-auto"> <a href="#" class="btn btn-info">搜尋</a> </div>
</div>
<div class="frame-wrap">
<div class="mb-3"> <a href="#" class="btn btn-success">+ 新增</a> </div>
<div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
data-target="#groupModal">+ 新增</a> </div>
<table id="rolManTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
@ -67,7 +72,8 @@
</div>
</div>
<div class="frame-wrap">
<div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal" data-target="#modal-center-users">+ 加入可用功能</a> </div>
<div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
data-target="#modal-center-users">+ 加入可用功能</a> </div>
<table id="rolAuthTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
@ -77,6 +83,7 @@
</div>
</div>
</main>
<!-- Modal center Add -->
<div class="modal fade" id="accManModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
@ -95,7 +102,8 @@
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpEmail">Email</label>
<input type="email" id="inpEmail" name="inpEmail" class="form-control" placeholder="Email">
<input type="email" id="inpEmail" name="inpEmail" class="form-control"
placeholder="Email">
</div>
</div>
<div class="col-md-6">
@ -109,7 +117,8 @@
<label class="form-label" for="inpAcc">帳號</label>
<input type="text" id="inpAcc" name="inpAcc" class="form-control">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="inpSameEmail" name="inpSameEmail" />
<input type="checkbox" class="custom-control-input" id="inpSameEmail"
name="inpSameEmail" />
<label class="custom-control-label text-white" for="inpSameEmail">與email相同</label>
</div>
</div>
@ -138,6 +147,38 @@
</div>
</div>
<!-- Modal group Add -->
<div class="modal fade" id="groupModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
群組基本資料新增 / 修改
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<form id="accManForm">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="groupName">名稱</label>
<input type="text" id="groupName" name="groupName" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
<button type="submit" class="btn btn-primary" id="accManSendBtn" e-prevent>儲存</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal center 設備權限 -->
<div class="modal fade" id="modal-center-cog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
@ -268,6 +309,23 @@
</div>
</div>
</div>
<!-- delete modal -->
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-footer">
<h4 class="mr-auto">確定刪除?</h4>
<button type="button" class="btn btn-primary" id="confirmDelBtn" aria-label="OK" e-prevent>
確定
</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" aria-label="No">
取消
</div>
</div>
</div>
</div>
<script>
var rolAuthTable = null;
$(function () {
@ -334,8 +392,8 @@
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
btnDiv.append(creBtnHtml("修改", "accManEdiBtn" + data, null, ["btn", "btn-info"]));
btnDiv.append(creBtnHtml("刪除", "accManDelBtn" + data, null, ["btn", "btn-danger"]));
btnDiv.append(creBtnHtml("修改", "accManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManModal" }));
btnDiv.append(creBtnHtml("刪除", "accManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
},
@ -380,8 +438,8 @@
"data": "layer",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
btnDiv.append(creBtnHtml("修改", "rolManEdiBtn" + data, null, ["btn", "btn-info"]));
btnDiv.append(creBtnHtml("刪除", "rolManDelBtn" + data, null, ["btn", "btn-danger"]));
btnDiv.append(creBtnHtml("修改", "rolManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#groupModal" }));
btnDiv.append(creBtnHtml("刪除", "rolManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
},
@ -446,7 +504,7 @@
"data": "userinfo_guid",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn", null, ["btn", "btn-danger"]));
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
},
@ -496,8 +554,8 @@
if ($(form).valid()) {
let url = baseApiUrl + "/User/SaveUser";
let sendData = {
Id:0,
Account:$("#inpAcc").val(),
Id: 0,
Account: $("#inpAcc").val(),
Name: $("#inpName").val(),
Email: $("#inpEmail").val(),
Phone: $("#inpPhone").val(),
@ -515,4 +573,4 @@
}
})
}
</script>
</script>

View File

@ -8,10 +8,14 @@
<div class="row bg-dark p-2">
<div class="col-auto">
<div class="btn-group">
<button type="button" class="btn btn-secondary waves-effect waves-themed">建築</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">電力管線</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">水力管線</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed">控制系統</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" key="建築">
建築</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" key="電力管線">
電力管線</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" ket="水力管線">
水力管線</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" key="控制系統">
控制系統</button>
</div>
</div>
@ -63,7 +67,8 @@
<div class="row">
<div class="mb-3">
<a href="#" class="btn btn-success" data-toggle="modal" data-target="#uploadPicture">+ 上傳</a>
<a href="#" id="upload" class="btn btn-success" data-toggle="modal" data-target="#uploadPicture">+
上傳</a>
</div>
<table class="table table-bordered table-striped text-center m-0">
@ -86,7 +91,7 @@
</main>
<!-- Upload Picture modal -->
<!-- upload modal -->
<div class="modal fade" id="uploadPicture" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
@ -94,29 +99,26 @@
<h4 class="modal-title">
圖資上傳
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<form id="uploadForm">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="picNum">圖號</label>
<input type="text" id="picNum" name="picNum" class="form-control">
<label class="form-label" for="upPicNum">圖號</label>
<input type="text" id="upPicNum" name="upPicNum" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpName">圖名</label>
<input type="text" id="inpName" name="inpName" class="form-control">
<label class="form-label" for="upPicName">圖名</label>
<input type="text" id="upPicName" name="upPicName" class="form-control">
</div>
</div>
<div class="col-md-6 mt-3">
<div class="form-group">
<label class="form-label" for="example-select">主要類別</label>
<select class="form-control" id="example-select select2bs4">
<label class="form-label" for="upSelMain">主要類別</label>
<select class="form-control" id="upSelMain">
<option>建築</option>
<option>電力控制</option>
<option>水力控制</option>
@ -126,8 +128,8 @@
</div>
<div class="col-md-6 mt-3">
<div class="form-group">
<label class="form-label" for="example-select">子類別</label>
<select class="form-control" id="example-select select2bs4">
<label class="form-label" for="upSelSub">子類別</label>
<select class="form-control" id="upSelSub">
<option>施工詳圖</option>
<option>設備規範</option>
<option>工程介面圖說</option>
@ -141,46 +143,119 @@
<label>原設計</label>
</div>
<div class="col-md-12">
<input id="myDesignDiagram" type="file" style="display:none" />
<label for="myDesignDiagram" type="button" class="file-upload btn btn-info"
<input id="upMyDesignDiagram" type="file" style="display:none" />
<label for="upMyDesignDiagram" type="button" class="file-upload btn btn-info"
style="cursor : pointer ">上傳檔案</label>
<div id='forDesignDiagram' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
<div id='upForDesignDiagram' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
</div>
<div id="designDiagram" class="col-md-12 ml-3"></div>
<div id="upDesignDiagram" class="col-md-12 ml-3"></div>
<div class="col-md-12 mt-3">
<label>竣工圖</label>
</div>
<div class="col-md-12">
<input id="myAsBuilt" type="file" style="display:none" />
<label for="myAsBuilt" type="button" class="file-upload btn btn-info"
<input id="upMyAsBuilt" type="file" style="display:none" />
<label for="upMyAsBuilt" type="button" class="file-upload btn btn-info"
style="cursor : pointer ">上傳檔案</label>
<div id='forAsBuilt' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
<div id='upForAsBuilt' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
</div>
<div id="asBuiltDrawing" class="col-md-12 ml-3"></div>
<div id="upAsBuiltDrawing" class="col-md-12 ml-3"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
<button type="submit" class="btn btn-primary" id="accManSendBtn" e-prevent>儲存</button>
<button type="submit" class="btn btn-primary" id="accManSendBtn">儲存</button>
<button type="button" class="btn btn-danger" id="close" data-dismiss="modal">取消</button>
</div>
</form>
</div>
</div>
</div>
<!-- edit modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
編輯
</h4>
</div>
<form id="editForm">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="editPicNum">圖號</label>
<input type="text" id="editPicNum" name="editPicNum" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="editPicName">圖名</label>
<input type="text" id="editPicName" name="editPicName" class="form-control">
</div>
</div>
<div class="col-md-12 mt-6">
<label>原設計</label>
</div>
<div class="col-md-12">
<input id="editMyDesignDiagram" type="file" style="display:none" />
<label for="editMyDesignDiagram" type="button" class="file-upload btn btn-info"
style="cursor : pointer ">上傳檔案</label>
<div id='editForDesignDiagram' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
</div>
<div id="editDesignDiagram" class="col-md-12 ml-3"></div>
<div class="col-md-12 mt-3">
<label>竣工圖</label>
</div>
<div class="col-md-12">
<input id="editMyAsBuilt" type="file" style="display:none" />
<label for="editMyAsBuilt" type="button" class="file-upload btn btn-info"
style="cursor : pointer ">上傳檔案</label>
<div id='editForAsBuilt' class="col-sm-12 forimage mt-2 offset-3 p-0"></div>
</div>
<div id="editAsBuiltDrawing" class="col-md-12 ml-3"></div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" id="accManSendBtn">儲存</button>
<button type="button" class="btn btn-danger" id="close" data-dismiss="modal">取消</button>
</div>
</form>
</div>
</div>
</div>
<!-- delete modal -->
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-footer">
<h4 class="mr-auto">確定刪除?</h4>
<button type="button" class="btn btn-primary" id="confirmDelBtn" aria-label="OK" e-prevent>
確定
</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" aria-label="No">
取消
</div>
</div>
</div>
</div>
<script>
$(function () {
initList();
})
// 讀取列表資料
function initList() {
let sendData = {
building_tag: pageAct.buiTag
}
objSendData.Data = sendData;
let url = baseApiUrl + "/GraphManage/GraManList";
let url = baseApiUrl + "/GraphManage/SaveGraMan";
function success(res) {
console.log("查看", res);
let strHtml = ``;
$.each(res, function (index, val) {
@ -190,8 +265,8 @@
<td>${res.code}</td>
<td>${res.code}</td>
<td>
<a href="#" class="btn btn-info">編輯</a>
<a href="#" class="btn btn-danger">刪除</a>
<a href="#" class="btn btn-primary mr-2" id="edit" data-toggle="modal" data-target="#editModal">編輯</a>
<a href="#" class="btn btn-danger" id="del" data-toggle="modal" data-target="#delModal">刪除</a>
</td>
</tr>`;
});
@ -201,28 +276,79 @@
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}
// 新增資料
onEvent('click', '#accManSendBtn', function () {
let url = baseApiUrl + "/GraphManage/SaveGraMan";
pageAct.opeFirmId = $(this).parent().data('id')
objSendData.Data = { id: pageAct.opeFirmId };
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
pageAct.opeFirmAct = 'edit';
selSysMain(res.data.device_system_category_layer2);
$('#uploadForm input[id=picNum]').val(res.data.name);
$('#uploadForm input[id=picName]').val(res.data.contact_person);
$('#uploadForm select[id=selMain]').val(res.data.device_system_category_layer2).change();
$('#uploadForm select[id=selSub]').val(res.data.device_system_category_layer3).change();
$('#uploadForm input[id=myDesignDiagram]').val(res.data.phone);
$('#uploadForm input[id=myAsBuilt]').val(res.data.email);
}
}, null, "POST").send()
});
// 取上傳檔名
$("#myDesignDiagram").on("change", function (e) {
$("#upMyDesignDiagram").on("change", function (e) {
let fileHelper = new YourTeam.Utility.File();
let fileName = this.files[0].name;
strHtml = `<small>${fileName}</small>`;
$('#designDiagram').html(strHtml);
$('#upDesignDiagram').html(strHtml);
});
// 取上傳檔名
$("#myAsBuilt").on("change", function (e) {
$("#upMyAsBuilt").on("change", function (e) {
let fileHelper = new YourTeam.Utility.File();
let fileName = this.files[0].name;
strHtml = `<small>${fileName}</small>`;
$('#asBuiltDrawing').html(strHtml);
$('#upAsBuiltDrawing').html(strHtml);
});
// 全選功能
function check_all(obj, cName) {
var checkboxs = document.getElementsByName(cName);
for (var i = 0; i < checkboxs.length; i++) { checkboxs[i].checked = obj.checked; }
}
// 編輯
$("#edit").click(function () {
$("#editPicNum").val() = $("#upPicNum").data();
console.log($("#editPicNum").val());
});
// 刪除資料
onEvent('click', '#del', function () {
pageAct.opeRecId = null;
pageAct.opeFirmId = $(this).parent().data('id');
});
onEvent('click', '#del', function () {
objSendData.Data = { id: pageAct.opeFirmId ?? pageAct.opeRecId };
let url = baseApiUrl + "/operation/" + (pageAct.work_type == null ? "DelOpeFirm" : "DelOpeRecord");
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
//toast_ok(common.AddSuc);
//$("#delModal").modal("hide");
$("#confirmDelCanBtn").click();
// refTable();
}
}, null, "DELETE").send();
});
</script>

View File

@ -31,13 +31,13 @@
</div>
<div class="col-auto">
<div class="form-group">
<input class="form-control" id="startdate" type="date" name="date" value="">
<input class="form-control" id="startdate" data-val="" type="date" name="date" value="">
<input class="form-control" id="getmonth" type="month" style="display: none"/>
</div>
</div>
<div class="col-auto" id="enddate" style="display: none">
<div class="form-group">
<input class="form-control" type="date" name="date" value="">
<input class="form-control" type="date" data-val="" name="date" value="">
</div>
</div>
<div class="col-auto">
@ -71,7 +71,7 @@
var historyTable = null;
$(function () {
initList();
$(loadEle).Loading("close");
// default list filter
initApp.listFilter($('#js_default_list'), $('#js_default_list_filter'));
// custom response message
@ -90,9 +90,34 @@
onEvent('change', '#startdate', function () {
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
console.log(today);
console.log(ytd);
if ($(this).val() == today) {
if (pageAct.dateType == 'range') {
if ($('#startdate').val() > $('#enddate input').val() && ($('#startdate').val() != "" && $('#enddate input').val() != "")) {
$('#startdate').val($('#startdate').data('val'));
toast_error('不可選擇大於結束時間');
}
else {
$('#startdate').data('val', $('#startdate').val());
$('#enddate input').data('val', $('#enddate input').val());
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-dark');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-dark');
if ($('#startdate').val() == $('#enddate input').val()) {
if ($('#startdate').val() == today) {
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).addClass('btn-dark');
}
else if ($('#startdate').val() == ytd) {
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-dark');
}
}
}
}
else if ($(this).val() == today) {
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).addClass('btn-dark');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
@ -104,13 +129,37 @@
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-dark');
}
else {
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-dark');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).removClass('btn-dark');
}
});
onEvent('change', '#enddate input', function () {
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
if ($('#startdate').val() > $('#enddate input').val() && ($('#startdate').val() != "" && $('#enddate input').val() != "")) {
$('#enddate input').val($('#enddate input').data('val'));
toast_error('不可選擇大於結束時間');
}
else {
$('#startdate').data('val', $('#startdate').val());
$('#enddate input').data('val', $('#enddate input').val());
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-dark');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-dark');
if ($('#startdate').val() == $('#enddate input').val()) {
if ($('#startdate').val() == today) {
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('today', this)"]`).addClass('btn-dark');
}
else if ($('#startdate').val() == ytd) {
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-dark');
}
}
}
});
});
function initList() {
@ -283,7 +332,9 @@
$('#enddate').css('display', 'block');
$('#getmonth').css('display', 'none');
$('#startdate').val(now);
$('#startdate').data('val', now);
$('#enddate input').val(tmr);
$('#enddate input').data('val', tmr);
}
else if (type == "month") {
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-dark');

View File

@ -19,12 +19,12 @@
</div>
<div class="col-auto">
<div class="form-group">
<input class="form-control" id="startdate" type="date" name="date" value="">
<input class="form-control" id="startdate" data-val="" type="date" name="date" value="">
</div>
</div>
<div class="col-auto">
<div class="form-group">
<input class="form-control" id="enddate" type="date" name="date" value="">
<input class="form-control" id="enddate" type="date" data-val="" name="date" value="">
</div>
</div>
<div class="col-auto" style="display: none">
@ -572,23 +572,50 @@
pageAct.startdate = startdate;
pageAct.enddate = enddate;
if (dateType == 'tdy') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date'));
}
else if (dateType == 'ytd') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date'));
if ($('#startdate').val() > $('#enddate').val()) {
$('#startdate').val($('#startdate').data('val'));
$('#enddate').val($('#enddate').data('val'));
toast_error('不可選擇大於結束時間');
}
else {
$(`[onclick^=setDate]`).removeClass('btn-dark');
$(`[onclick^=setDate]`).addClass('btn-secondary');
}
let today = displayDate(new Date(new Date().setDate(new Date().getDate())), 'date').replaceAll('/', '-');
let ytd = displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date').replaceAll('/', '-')
refTable();
if (dateType == 'tdy') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date'));
$('#startdate').val(today);
$('#startdate').data('val', today);
$('#enddate').val(today);
$('#enddate').data('val', today);
}
else if (dateType == 'ytd') {
pageAct.startdate = new Date(displayDate(new Date(new Date().setDate(new Date().getDate() - 1)), 'date'));
$('#startdate').val(ytd);
$('#startdate').data('val', ytd);
$('#enddate').val(ytd);
$('#enddate').data('val', ytd);
}
else {
$(`[onclick^=setDate]`).removeClass('btn-dark');
$(`[onclick^=setDate]`).addClass('btn-secondary');
if ($('#startdate').val() == $('#enddate').val()) {
if ($('#startdate').val() == today)
$(`[onclick="setDate('tdy')"]`).click();
else if ($('#startdate').val() == ytd)
$(`[onclick="setDate('ytd')"]`).click();
}
$('#startdate').data('val', $('#startdate').val());
$('#enddate').data('val', $('#enddate').val());
}
refTable();
}
}
function initDate() {
$('#startdate').val(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date').replaceAll('/', '-'));
$('#enddate').val(displayDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'date').replaceAll('/', '-'));
//$('#startdate').val(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date').replaceAll('/', '-'));
//$('#enddate').val(displayDate(new Date(new Date().setDate(new Date().getDate())), 'date').replaceAll('/', '-'));
$(`[onclick="setDate('tdy')"]`).click();
}
function clearPageAct() {

View File

@ -2084,6 +2084,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
"n4js/historybaja",
"lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle",
"lib/jquery-validation/dist/jquery.validate",
"lib/jquery-validation/dist/additional-methods.min",
"lib/jquery-validation/dist/localization/messages_zh_TW",
], loadedMasterPack);
}
/**