นำเข้าหน้าจอ เพิ่ม แก้ไข ลบ แบบข้อตกลง

This commit is contained in:
Nakorn Rientrakrunchai
2021-02-02 15:59:55 +07:00
parent 95277cedea
commit 91c6ecd5a1
20 changed files with 2298 additions and 7 deletions

View File

@@ -0,0 +1,227 @@
var eva_evaluation_operating_agreement_editMode = "CREATE";
var eva_evaluation_operating_agreement_API = "/api/eva_evaluation_operating_agreement/";
//================= Search Customizaiton =========================================
function eva_evaluation_operating_agreement_GetSearchParameter() {
var eva_evaluation_operating_agreementSearchObject = new Object();
eva_evaluation_operating_agreementSearchObject.create_evaluation_detail_id = getUrlParameter("id");
return eva_evaluation_operating_agreementSearchObject;
}
function eva_evaluation_operating_agreement_FeedDataToSearchForm(data) {
$("#s_eva_evaluation_operating_agreement_create_evaluation_detail_id").val(data.create_evaluation_detail_id);
}
//================= Form Data Customizaiton =========================================
function eva_evaluation_operating_agreement_FeedDataToForm(data) {
$("#eva_evaluation_operating_agreement_id").val(data.id);
$("#eva_evaluation_operating_agreement_create_evaluation_detail_id").val(data.create_evaluation_detail_id);
$("#eva_evaluation_operating_agreement_mission_no").val(data.mission_no);
$("#eva_evaluation_operating_agreement_mission_detail").val(data.mission_detail);
$("#eva_evaluation_operating_agreement_target").val(data.target);
$("#eva_evaluation_operating_agreement_indicators").val(data.indicators);
}
function eva_evaluation_operating_agreement_GetFromForm() {
var eva_evaluation_operating_agreementObject = new Object();
eva_evaluation_operating_agreementObject.id = $("#eva_evaluation_operating_agreement_id").val();
eva_evaluation_operating_agreementObject.create_evaluation_detail_id = getUrlParameter("id");
eva_evaluation_operating_agreementObject.mission_no = $("#eva_evaluation_operating_agreement_mission_no").val();
eva_evaluation_operating_agreementObject.mission_detail = $("#eva_evaluation_operating_agreement_mission_detail").val();
eva_evaluation_operating_agreementObject.target = $("#eva_evaluation_operating_agreement_target").val();
eva_evaluation_operating_agreementObject.indicators = $("#eva_evaluation_operating_agreement_indicators").val();
return eva_evaluation_operating_agreementObject;
}
function eva_evaluation_operating_agreement_InitialForm(s) {
var successFunc = function (result) {
eva_evaluation_operating_agreement_FeedDataToForm(result);
eva_evaluation_operating_agreement_FeedDataToSearchForm(result);
if (s) {
// Incase model popup
$("#eva_evaluation_operating_agreementModel").modal("show");
}
endLoad();
};
startLoad();
AjaxGetRequest(apisite + eva_evaluation_operating_agreement_API + "GetBlankItem", successFunc, AlertDanger);
}
//================= Form Mode Setup and Flow =========================================
function eva_evaluation_operating_agreement_GoCreate() {
// Incase model popup
eva_evaluation_operating_agreement_SetCreateForm(true);
// Incase open new page
//window_open(appsite + "/eva_evaluation_operating_agreementView/eva_evaluation_operating_agreement_d");
}
function eva_evaluation_operating_agreement_GoEdit(a) {
// Incase model popup
eva_evaluation_operating_agreement_SetEditForm(a);
// Incase open new page
//window_open(appsite + "/eva_evaluation_operating_agreementView/eva_evaluation_operating_agreement_d?id=" + a);
}
function eva_evaluation_operating_agreement_SetEditForm(a) {
var successFunc = function (result) {
eva_evaluation_operating_agreement_editMode = "UPDATE";
eva_evaluation_operating_agreement_FeedDataToForm(result);
$("#eva_evaluation_operating_agreementModel").modal("show");
endLoad();
};
startLoad();
AjaxGetRequest(apisite + eva_evaluation_operating_agreement_API + a, successFunc, AlertDanger);
}
function eva_evaluation_operating_agreement_SetCreateForm(s) {
eva_evaluation_operating_agreement_editMode = "CREATE";
eva_evaluation_operating_agreement_InitialForm(s);
}
function eva_evaluation_operating_agreement_RefreshTable() {
// Incase model popup
eva_evaluation_operating_agreement_DoSearch();
// Incase open new page
//window.parent.eva_evaluation_operating_agreement_DoSearch();
}
//================= Update and Delete =========================================
var eva_evaluation_operating_agreement_customValidation = function (group) {
return "";
};
function eva_evaluation_operating_agreement_PutUpdate() {
if (!ValidateForm('eva_evaluation_operating_agreement', eva_evaluation_operating_agreement_customValidation)) {
return;
}
var data = eva_evaluation_operating_agreement_GetFromForm();
//Update Mode
if (eva_evaluation_operating_agreement_editMode === "UPDATE") {
var successFunc1 = function (result) {
$("#eva_evaluation_operating_agreementModel").modal("hide");
AlertSuccess(result.code + " " + result.message);
eva_evaluation_operating_agreement_RefreshTable();
endLoad();
};
startLoad();
AjaxPutRequest(apisite + eva_evaluation_operating_agreement_API + data.id, data, successFunc1, AlertDanger);
}
// Create mode
else {
var successFunc2 = function (result) {
$("#eva_evaluation_operating_agreementModel").modal("hide");
AlertSuccess(result.code + " " + result.message);
eva_evaluation_operating_agreement_RefreshTable();
endLoad();
};
startLoad();
AjaxPostRequest(apisite + eva_evaluation_operating_agreement_API, data, successFunc2, AlertDanger);
}
}
function eva_evaluation_operating_agreement_GoDelete(a) {
if (confirm('คุณต้องการลบข้อมูล ใช่หรือไม่?')) {
var successFunc = function (result) {
$("#eva_evaluation_operating_agreementModel").modal("hide");
AlertSuccess(result.code + " " + result.message);
eva_evaluation_operating_agreement_RefreshTable();
endLoad();
};
startLoad();
AjaxDeleteRequest(apisite + eva_evaluation_operating_agreement_API + a, null, successFunc, AlertDanger);
}
}
//================= Data Table =========================================
var eva_evaluation_operating_agreementTableV;
var eva_evaluation_operating_agreement_setupTable = function (result) {
tmp = '"';
eva_evaluation_operating_agreementTableV = $('#eva_evaluation_operating_agreementTable').DataTable({
"processing": true,
"serverSide": false,
"data": result,
//"select": {
// "style": 'multi'
//},
"columns": [
//{ "data": "" },
{ "data": "id" },
{ "data": "mission_no" },
{ "data": "mission_detail" },
{ "data": "target" },
{ "data": "indicators" },
],
"columnDefs": [
{
"targets": 0, //1,
"data": "id",
"render": function (data, type, row, meta) {
return "<button type='button' class='btn btn-warning btn-sm' onclick='javascript:eva_evaluation_operating_agreement_GoEdit(" + tmp + data + tmp + ")'><i class='fa fa-pencil'></i></button> <button type='button' class='btn btn-danger btn-sm' onclick='javascript:eva_evaluation_operating_agreement_GoDelete(" + tmp + data + tmp + ")'><i class='fa fa-trash-o '></i></button> ";
}
},
//{
// targets: 0,
// data: "",
// defaultContent: '',
// orderable: false,
// className: 'select-checkbox'
//}
],
"language": {
"url": appsite + "/DataTables-1.10.16/thai.json"
},
"paging": true,
"searching": false
});
endLoad();
};
function eva_evaluation_operating_agreement_InitiateDataTable() {
startLoad();
var p = $.param(eva_evaluation_operating_agreement_GetSearchParameter());
AjaxGetRequest(apisite + "/api/eva_evaluation_operating_agreement/GetListBySearch?" + p, eva_evaluation_operating_agreement_setupTable, AlertDanger);
}
function eva_evaluation_operating_agreement_DoSearch() {
var p = $.param(eva_evaluation_operating_agreement_GetSearchParameter());
var eva_evaluation_operating_agreement_reload = function (result) {
eva_evaluation_operating_agreementTableV.destroy();
eva_evaluation_operating_agreement_setupTable(result);
endLoad();
};
startLoad();
AjaxGetRequest(apisite + "/api/eva_evaluation_operating_agreement/GetListBySearch?" + p, eva_evaluation_operating_agreement_reload, AlertDanger);
}
function eva_evaluation_operating_agreement_GetSelect(f) {
var eva_evaluation_operating_agreement_selectitem = [];
$.each(eva_evaluation_operating_agreementTableV.rows('.selected').data(), function (key, value) {
eva_evaluation_operating_agreement_selectitem.push(value[f]);
});
alert(eva_evaluation_operating_agreement_selectitem);
}
//================= File Upload =========================================
//================= Multi-Selection Function =========================================