125 lines
5.2 KiB
JavaScript
125 lines
5.2 KiB
JavaScript
function rep_eva03_ClearForm(i, blankItem) {
|
|
var data = blankItem;
|
|
$("#rep_eva03_id_" + i).val("");
|
|
DropDownClearFormAndFeedWithData($("#rep_eva03_position_type_id_" + i), blankItem, "id", "external_name", "item_position_type_id", data.position_type_id);
|
|
|
|
}
|
|
|
|
function rep_eva03_FeedDataToForm(data, i, blankItem) {
|
|
$("#rep_eva03_id_" + i).val(data.id);
|
|
DropDownClearFormAndFeedWithData($("#rep_eva03_position_type_id_" + i), blankItem, "id", "external_name", "item_position_type_id", data.position_type_id);
|
|
|
|
}
|
|
|
|
function rep_eva03_GetFromForm(obj, i) {
|
|
var rep_eva03Object = new Object();
|
|
rep_eva03Object.id = obj.find("#rep_eva03_id_" + i).val();
|
|
rep_eva03Object.position_type_id = obj.find("#rep_eva03_position_type_id_" + i).val();
|
|
|
|
rep_eva03Object.active_mode = obj.find("#isActive_" + i + "_rep_eva03").val();
|
|
return rep_eva03Object;
|
|
}
|
|
|
|
function rep_eva03_Save(id) {
|
|
//Insert rep_eva03 List
|
|
var rep_eva03 = [];
|
|
$('#rep_eva03Body tr').each(function () {
|
|
var i = $(this).find("#rowCount").text();
|
|
var eachrep_eva03 = rep_eva03_GetFromForm($(this), i);
|
|
rep_eva03.push(eachrep_eva03);
|
|
});
|
|
|
|
var successFunc = function (result) {
|
|
AlertSuccess("ปรับปรุงข้อมูลเรียบร้อยแล้ว");
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxPutRequest(apisite + '/api/rep_eva03/UpdateMultiple', rep_eva03, successFunc, AlertDanger);
|
|
}
|
|
|
|
function rep_eva03_Get(a, blankItem) {
|
|
|
|
$('#rep_eva03Body').empty();
|
|
|
|
var successFunc = function (response) {
|
|
//console.log(response);
|
|
$.each(response, function (i, data) {
|
|
var tag = '<tr>';
|
|
tag += '<td><label id="rowCount">' + (i + 1) + '</label><input type="hidden" id="isActive_' + (i + 1) + '_rep_eva03" value="1" /></td>';
|
|
tag += '<td><input class="form-control" type="hidden" id="rep_eva03_id_' + (i + 1)+'" /></td>';
|
|
tag += '<td><select class="form-control" id="rep_eva03_position_type_id_' + (i + 1) +'"></select></td>';
|
|
|
|
tag += '<td><a href="javascript:;" class="btn btn-danger btn-sm" onclick="javascript:rep_eva03_Removerep_eva03(this)" id="removeBtn"><i class="fa fa-trash-o" style="color:white;"></i></a><a href="javascript:;" class="btn btn-primary btn-sm" onclick="javascript:rep_eva03_Restorerep_eva03(this)" style="display: none;" id="restoreBtn"><i class="fa fa-upload" style="color:white;"></i></a></td>';
|
|
tag += '</tr>';
|
|
$('#rep_eva03Body').append($(tag));
|
|
rep_eva03_FeedDataToForm(data, (i + 1), blankItem);
|
|
});
|
|
rep_eva03_Summary();
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + "/api/rep_eva03", successFunc, AlertDanger);
|
|
//AjaxGetRequest(apisite + '/api/rep_eva03/GetListByposition_type_id/' + a, successFunc, AlertDanger);
|
|
|
|
}
|
|
|
|
function rep_eva03_Add() {
|
|
var successFunc = function (result) {
|
|
var i = $("#rep_eva03Body tr").length;
|
|
var tag = '<tr>';
|
|
tag += '<td><label id="rowCount">' + (i + 1) + '</label><input type="hidden" id="isActive_' + (i + 1) + '_rep_eva03" value="1" /></td>';
|
|
tag += '<td><input class="form-control" type="hidden" id="rep_eva03_id_' + (i + 1)+'" /></td>';
|
|
tag += '<td><select class="form-control" id="rep_eva03_position_type_id_' + (i + 1) +'"></select></td>';
|
|
|
|
tag += '<td><a href="javascript:;" class="btn btn-danger btn-sm" onclick="javascript:rep_eva03_Removerep_eva03(this)" id="removeBtn"><i class="fa fa-trash-o" style="color:white;"></i></a><a href="javascript:;" class="btn btn-primary btn-sm" onclick="javascript:rep_eva03_Restorerep_eva03(this)" style="display: none;" id="restoreBtn"><i class="fa fa-upload" style="color:white;"></i></a></td>';
|
|
tag += '</tr>';
|
|
|
|
$('#rep_eva03Body').append($(tag));
|
|
rep_eva03_ClearForm(i + 1, result);
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + "/api/rep_eva03/" + "GetBlankItem", successFunc, AlertDanger);
|
|
}
|
|
|
|
function rep_eva03_Removerep_eva03(e) {
|
|
if (confirm('กรุณากดตกลง เพื่อยืนยันการลบ?')) {
|
|
$(e).closest('tr').find("input,select,textarea").attr('disabled', true);
|
|
$(e).closest('tr').find("input,select,textarea").css({ opacity: '0.5' });
|
|
$(e).hide();
|
|
$(e).closest('tr').find("#restoreBtn").show();
|
|
$(e).closest('tr').find("input").first().val("0");
|
|
console.log($(e).closest('tr').find("input").first().val());
|
|
rep_eva03_Summary();
|
|
}
|
|
}
|
|
|
|
function rep_eva03_Restorerep_eva03(e) {
|
|
if (confirm('กรุณากดตกลง เพื่อยืนยันการกู้คืน?')) {
|
|
$(e).closest('tr').find("input,select,textarea").attr('disabled', false);
|
|
$(e).closest('tr').find("input,select,textarea").css({ opacity: '1' });
|
|
$(e).hide();
|
|
$(e).closest('tr').find("#removeBtn").show();
|
|
$(e).closest('tr').find("input").first().val("1");
|
|
console.log($(e).closest('tr').find("input").first().val());
|
|
rep_eva03_Summary();
|
|
}
|
|
}
|
|
|
|
function rep_eva03_Summary() {
|
|
var sum = 0;
|
|
$(".input_score").each(function () {
|
|
sum += +$(this).val();
|
|
});
|
|
$("#score_label").text("ผลรวม: " + sum);
|
|
}
|
|
|
|
function rep_eva03_InitialForm(id) {
|
|
var successFunc = function (result) {
|
|
rep_eva03_Get('', result);
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + "/api/rep_eva03/" + "GetBlankItem", successFunc, AlertDanger);
|
|
}
|