update project filiter
parent
26e7543bde
commit
633fa6d0b3
|
|
@ -866,6 +866,40 @@ namespace Journeys_WantHome.Controllers
|
|||
|
||||
string project_year = obj["year"].ToString();
|
||||
string project_month = obj["month"].ToString();
|
||||
string is_filiter = obj["is_filiter"].ToString();
|
||||
string start = obj["start"].ToString();
|
||||
string end = obj["end"].ToString();
|
||||
string isExec = obj["isExec"].ToString();
|
||||
|
||||
|
||||
if (is_filiter == "Y") {
|
||||
string dateString = "";
|
||||
string exeString = "";
|
||||
|
||||
if (start != "" && end != "") {
|
||||
start = start.Replace("/", "");
|
||||
end = end.Replace("/", "");
|
||||
|
||||
dateString = " and ((CONVERT(NVARCHAR, project_year) + RIGHT('00' + CONVERT(NVARCHAR, project_month), 2)) >= '" + start + "') and ((CONVERT(NVARCHAR, project_year) + RIGHT('00' + CONVERT(NVARCHAR, project_month), 2)) <= '" + end + "' ) ";
|
||||
}
|
||||
|
||||
if (isExec != "A") {
|
||||
exeString = " and project_isExec = '" + isExec + "' ";
|
||||
}
|
||||
|
||||
string sqlString = "select * from project where 1=1 " + dateString + exeString + " order by project_modifydate desc ";
|
||||
|
||||
List<project> projects = conn.Query<project>(sqlString).ToList();
|
||||
foreach (project item in projects)
|
||||
{
|
||||
ret.projectList.Add(new projectDetail(item));
|
||||
}
|
||||
|
||||
ret.ret = "yes";
|
||||
|
||||
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
|
||||
if (project_year == "")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,62 @@
|
|||
<p class="text-muted"> </p><!-- /title -->
|
||||
</header><!-- /.page-title-bar -->
|
||||
|
||||
<div class="page-section">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<!-- #accordion2 -->
|
||||
<div id="accordion1" class="card-expansion">
|
||||
<!-- .card -->
|
||||
<div class="card card-expansion-item expanded">
|
||||
<div class="card-header border-0" id="headingOne1">
|
||||
<button id="adv-search-btn" class="btn btn-reset d-flex justify-content-between w-100" data-toggle="collapse" data-target="#collapseOne1" aria-expanded="false" aria-controls="collapseOne1"><span>進階搜尋</span> <span class="collapse-indicator"><i class="fa fa-fw fa-chevron-down"></i></span></button>
|
||||
</div>
|
||||
<div>
|
||||
<div id="collapseOne1" class="collapse" aria-labelledby="headingOne1" data-parent="#accordion1">
|
||||
<div class="card-body pt-0">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="dateStart">起</label>
|
||||
<input id="dateStart" type="text" class="form-control flatpickr-input active" data-toggle="flatpickr" data-date-format="m.y" data-monthselect="true" readonly="readonly">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="dateEnd">迄</label>
|
||||
<input id="dateEnd" type="text" class="form-control flatpickr-input active" data-toggle="flatpickr" data-date-format="m.y" data-monthselect="true" readonly="readonly">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label class="d-block">狀況</label>
|
||||
<div class="custom-control custom-control-inline custom-radio">
|
||||
<input type="radio" class="custom-control-input" name="rdGroup1[]" id="rd1" value="Y"> <label class="custom-control-label" for="rd1">執行</label>
|
||||
</div>
|
||||
<div class="custom-control custom-control-inline custom-radio">
|
||||
<input type="radio" class="custom-control-input" name="rdGroup1[]" id="rd2" value="N"> <label class="custom-control-label" for="rd2">未執行</label>
|
||||
</div>
|
||||
<div class="custom-control custom-control-inline custom-radio">
|
||||
<input type="radio" class="custom-control-input" name="rdGroup1[]" id="rd3" value="A" checked=""> <label class="custom-control-label" for="rd3">全部</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button type="button" id="filiterBtn" class="btn btn-primary">篩選</button>
|
||||
<button type="button" id="resetBtn" class="btn btn-danger">重設</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- .page-section -->
|
||||
<div class="page-section">
|
||||
<button type="button" id="projectNewModal" class="btn btn-primary btn-floated" title="Add new client"><i class="fa fa-plus"></i></button>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,113 @@ $(document).ready(function () {
|
|||
loadPrm();
|
||||
loadyearmonth();
|
||||
|
||||
flatpickr("#dateStart", {
|
||||
"plugins": [
|
||||
new monthSelectPlugin({
|
||||
shorthand: true, //defaults to false
|
||||
dateFormat: "Y/m", //defaults to "F Y"
|
||||
altFormat: "Y M", //defaults to "F Y"
|
||||
theme: "light" // defaults to "light"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
flatpickr("#dateEnd", {
|
||||
"plugins": [
|
||||
new monthSelectPlugin({
|
||||
shorthand: true, //defaults to false
|
||||
dateFormat: "Y/m", //defaults to "F Y"
|
||||
altFormat: "Y M", //defaults to "F Y"
|
||||
theme: "light" // defaults to "light"
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
$('#resetBtn').on('click', function () {
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/projectList",
|
||||
type: "post",
|
||||
data: null,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var obj = data.projectList;
|
||||
if (data.ret == "yes") {
|
||||
$('#adv-search-btn').trigger('click');
|
||||
|
||||
$('#dateStart').val('');
|
||||
$('#dateEnd').val('');
|
||||
|
||||
|
||||
|
||||
$('#dt-responsive').dataTable().fnClearTable();
|
||||
if (data.projectList.length > 0) {
|
||||
|
||||
$('#dt-responsive').dataTable().fnAddData(data.projectList);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#filiterBtn').on('click', function () {
|
||||
var start = $('#dateStart').val();
|
||||
var end = $('#dateEnd').val();
|
||||
var isExec = $('input[name="rdGroup1[]"]:checked').val();
|
||||
|
||||
if (!((start == "" && end == "") || (start != "" && end != ""))) {
|
||||
alert('起訖時間未輸入完全!');
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
is_filiter: 'Y',
|
||||
start: start,
|
||||
end: end,
|
||||
isExec: isExec
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/Api/projectList",
|
||||
type: "post",
|
||||
data: formData,
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var obj = data.projectList;
|
||||
if (data.ret == "yes") {
|
||||
|
||||
$('#dt-responsive').dataTable().fnClearTable();
|
||||
if (data.projectList.length > 0) {
|
||||
|
||||
$('#dt-responsive').dataTable().fnAddData(data.projectList);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
alert(data.message);
|
||||
|
||||
if (data.err_code == "99999") {
|
||||
location.href = "/Root/Login";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('網路或伺服器發生錯誤,請稍後重試!');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#projectSaveBtn').on('click', function () {
|
||||
var method = $('#method').val();
|
||||
var project_isPrm = $('input:radio[name="project_isExec[]"]:checked').val();
|
||||
|
|
|
|||
Loading…
Reference in New Issue