新增查詢表單號

This commit is contained in:
b110212000 2021-08-25 11:39:41 +08:00
parent 0cceff37f6
commit 0119387496
3 changed files with 123 additions and 10 deletions

View File

@ -219,6 +219,7 @@ namespace SolarPower.Models
public string Range { get; set; } //取得搜尋範圍
public string StartTime { get; set; } //起始日期
public string EndTime { get; set; } //結束日期
public byte Status { get; set; }//狀態
}
/// <summary>

View File

@ -213,7 +213,7 @@ namespace SolarPower.Repository.Implement
FROM operation_record opr
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
LEFT JOIN user u ON opr.WorkPersonId = u.ID
WHERE opr.Deleted = 0
WHERE opr.Deleted = 0 AND opr.Status = {filter.Status}
AND ps.Id IN @PowerStationIds";
if (!string.IsNullOrEmpty(filter.Range))
@ -234,14 +234,14 @@ namespace SolarPower.Repository.Implement
{
sql += @" AND opr.WorkType IN (0, 1)";
sql += @" UNION";
sql += @" SELECT
sql += @$" SELECT
opr.*,
ps.Name AS PowerStationName,
u.Name AS WorkPersonName
FROM operation_record opr
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
LEFT JOIN user u ON opr.WorkPersonId = u.ID
WHERE opr.Deleted = 0
WHERE opr.Deleted = 0 AND opr.Status = {filter.Status}
AND ps.Id IN @PowerStationIds
AND opr.WorkType = 2";
if (!string.IsNullOrEmpty(filter.Range))

View File

@ -24,8 +24,8 @@
<div class="row mb-3 d-flex justify-content-start px-3">
<div class="pr-3">
<div class="btn-group btn-group-md">
<button type="button" class="btn btn-success waves-effect waves-themed" onclick="CheckStatus(0)" id="button0">完成</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="CheckStatus(1)" id="button1">未完成</button>
<button type="button" class="btn btn-success waves-effect waves-themed status-type" onclick="CheckStatus(1,this)">完成</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed status-type" onclick="CheckStatus(0,this)">未完成</button>
</div>
</div>
<div class="pr-3">
@ -44,6 +44,14 @@
<input class="form-control" id="date-range" type="text" name="date" value="">
</div>
</div>
<div class="pr-5" >
<div class="form-group">
<input class="form-control" id="FormNum" type="text" value="" placeholder="表單號">
</div>
</div>
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Search()">表單號查詢</button>
</div>
</div>
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
@ -257,7 +265,8 @@
var datepicker;
var AllpoweridsType = true;
var AllidsType = true;
var status = true;
var status = 1; //1:完成 0:未完成
var Searchtype = false;
//#region Array.Remove
Array.prototype.remove = function (val) {
@ -456,6 +465,7 @@
d.PowerStationIds = powerids;
d.WorkType = Type;
d.Range = $('#date-range').val();
d.status = status;
},
"dataSrc": function (rel) {
if (rel.data.code == "9999") {
@ -468,8 +478,20 @@
if (data == null || data.length == 0) {
this.data = [];
}
return data;
var realdata;
if (Searchtype) {
realdata = new Array(0);
$.each(this.data, function (index, val) {
var num = $('#FormNum').val();
if (val.formId == ("<a href='javascript:;' class='waves-effect waves-themed mb-3 mr-2 edit-btn'>" + num + "</a>")) {
realdata.push(val);
}
});
Searchtype = false;
} else {
realdata = this.data;
}
return realdata;
}
},
"error": function (xhr, error, thrown) {
@ -568,6 +590,77 @@
})
operationRecodeTable.ajax.reload();
}
function Allcity2() {
var Newpowerids = new Array(0);
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
if (AllidsType) {
document.getElementById(cityid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids = [];
powerids = [];
}
else {
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
}
});
if (AllidsType) {
AllidsType = false;
AllpoweridsType = false;
} else {
AllidsType = true;
}
var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='col-2 mb-2 custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
if (AllpoweridsType) {
AllpoweridsType = false;
} else {
AllpoweridsType = true;
}
powerids = [];
$.each(Allpowerids, function (index, val) {
if (AllpoweridsType) {
$('#check_' + val).prop("checked", true);
powerids.push(val);
} else {
$('#check_' + val).prop("checked", false);
powerids = [];
}
})
operationRecodeTable.ajax.reload();
})
}
//#endregion
//#region 電站全選
@ -658,7 +751,7 @@
//#endregion
//#region 點擊圖片放大
//#region 點擊圖片放大
$('#operation_recode_table').on("click", "img.img-zoom", function () {
var _this = $(this);//將當前的pimg元素作為_this傳入函式
imgShow("#img-zoom-outer-div", "#innerdiv", "#bigimg", _this);
@ -734,7 +827,6 @@
});
//#endregion
//#region 表單驗證
$("#recode-form").validate({
rules: {
@ -1038,5 +1130,25 @@
$('#date-range').trigger('change');
}
//#endregion
//#region 改狀態
function CheckStatus(type, e) {
status = type;
if ($(".status-type").hasClass("btn-success")) {
$(".status-type").removeClass("btn-success").addClass("btn-secondary");
}
$(e).removeClass("btn-secondary").addClass("btn-success");
operationRecodeTable.ajax.reload();
}
//#endregion
function Search() {
Searchtype = true;
AllidsType = false;
AllpoweridsType = false;
Allcity2();
//operationRecodeTable.ajax.reload();
}
</script>
}