แก้ไข OP 2651

This commit is contained in:
Nakorn Rientrakrunchai
2020-07-21 16:08:46 +07:00
parent 13dc865ad1
commit 764cd3c398
13 changed files with 153 additions and 79 deletions

View File

@@ -59,12 +59,12 @@ namespace TodoAPI2.Controllers
/// <returns>Return Get specific item by id</returns>
/// <response code="200">Returns the item</response>
/// <response code="500">Error Occurred</response>
[HttpGet("{id}")]
[HttpGet("{id}/{path}")]
[ProducesResponseType(typeof(eva_create_evaluation_detail_processWithSelectionViewModel), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(500)]
//[ValidateAntiForgeryToken]
public IActionResult Get(int id)
public IActionResult Get(int id, string path)
{
try
{
@@ -74,7 +74,7 @@ namespace TodoAPI2.Controllers
{
var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]);
var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid));
var result = _repository.GetWithSelection(id, e.id);
var result = _repository.GetWithSelection(id, e.id, path);
return Ok(result);
}
@@ -142,7 +142,7 @@ namespace TodoAPI2.Controllers
{
var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]);
var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid));
return Ok(_repository.GetListBycreate_evaluation_id(create_evaluation_id, e.id));
return Ok(_repository.GetListBycreate_evaluation_id(create_evaluation_id, e.id, HttpContext.Request.Path));
}
else
{
@@ -179,7 +179,7 @@ namespace TodoAPI2.Controllers
{
var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]);
var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid));
return Ok(_repository.GetListBySearch(model, e.id));
return Ok(_repository.GetListBySearch(model, e.id, model.path));
}
else
{

View File

@@ -12,10 +12,10 @@ namespace TodoAPI2.Models
{
public interface Ieva_create_evaluation_detail_processService
{
List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id);
List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id);
List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id, string path);
List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id, string path);
eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id);
eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id, string path);
eva_create_evaluation_detail_processWithSelectionViewModel GetBlankItem();

View File

@@ -22,6 +22,7 @@ namespace TodoAPI2.Models
public string search_employee_fullname { get; set; }
public string path { get; set; }
}
}

View File

@@ -56,7 +56,7 @@ namespace TodoAPI2.Models
#region Public Functions
#region Query Functions
public eva_create_evaluation_detail_processWithSelectionViewModel Get(int id, int? emp_id)
public eva_create_evaluation_detail_processWithSelectionViewModel Get(int id, int? emp_id, string path)
{
var allemp = emp.GetListByemployee_type(null, null);
@@ -112,13 +112,13 @@ namespace TodoAPI2.Models
m_eva_create_evaluation_detail_process.chief,
fk_eva_create_evaluationResult10.employee_id,
fk_eva_create_evaluationResult10.supervisor1_id,
fk_eva_create_evaluationResult10.supervisor2_id),
fk_eva_create_evaluationResult10.supervisor2_id, path),
role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief,
m_eva_create_evaluation_detail_process.chief,
fk_eva_create_evaluationResult10.employee_id,
fk_eva_create_evaluationResult10.supervisor1_id,
fk_eva_create_evaluationResult10.supervisor2_id),
fk_eva_create_evaluationResult10.supervisor2_id, path),
remark_hrm_work_record = fk_external_employee.remark_hrm_work_record,
@@ -130,9 +130,9 @@ namespace TodoAPI2.Models
return data[0];
}
public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id)
public eva_create_evaluation_detail_processWithSelectionViewModel GetWithSelection(int id, int? emp_id, string path)
{
var item = Get(id, emp_id);
var item = Get(id, emp_id, path);
item.item_org_id = ext.GetDepartmentData();
item.item_level_score = (from i in _repository.Context.eva_level_score
orderby i.min_score
@@ -151,14 +151,14 @@ namespace TodoAPI2.Models
return i;
}
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id)
public List<eva_create_evaluation_detail_processViewModel> GetListBycreate_evaluation_id(int? create_evaluation_id, int? emp_id, string path)
{
var model = new eva_create_evaluation_detail_processSearchModel();
model.create_evaluation_id = create_evaluation_id;
return GetListBySearch(model, emp_id);
return GetListBySearch(model, emp_id, path);
}
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id)
public List<eva_create_evaluation_detail_processViewModel> GetListBySearch(eva_create_evaluation_detail_processSearchModel model, int? emp_id, string path)
{
var allemp = emp.GetListByemployee_type(null, null);
@@ -221,17 +221,19 @@ namespace TodoAPI2.Models
status_supervisor1A = m_eva_create_evaluation_detail_process.status_supervisor1A,
status_supervisor2A = m_eva_create_evaluation_detail_process.status_supervisor2A,
role_code = getRoleCode(emp_id, m_eva_create_evaluation_detail_process.chief,
role_code = getRoleCodeSearch(emp_id, m_eva_create_evaluation_detail_process.chief,
m_eva_create_evaluation_detail_process.chief,
fk_eva_create_evaluationResult10.employee_id,
fk_eva_create_evaluationResult10.supervisor1_id,
fk_eva_create_evaluationResult10.supervisor2_id),
fk_eva_create_evaluationResult10.supervisor2_id,
m_eva_create_evaluation_detail_process.status_chief
),
role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief,
m_eva_create_evaluation_detail_process.chief,
fk_eva_create_evaluationResult10.employee_id,
fk_eva_create_evaluationResult10.supervisor1_id,
fk_eva_create_evaluationResult10.supervisor2_id),
fk_eva_create_evaluationResult10.supervisor2_id, path),
isActive = m_eva_create_evaluation_detail_process.isActive,
Created = m_eva_create_evaluation_detail_process.created,
@@ -242,9 +244,10 @@ namespace TodoAPI2.Models
return data;
}
private string getRoleCode(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A)
private string getRoleCode(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path)
{
if (emp_id == chief) return "1";
if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && path == "d2") return "2";
else if (emp_id == chief) return "1";
else if (emp_id == supervisor1) return "1";
else if (emp_id == supervisor2) return "2";
else if (emp_id == supervisor1A) return "3";
@@ -252,11 +255,23 @@ namespace TodoAPI2.Models
return "";
}
private string getRoleName(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A)
private string getRoleCodeSearch(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string status_chief)
{
if (emp_id == chief) return "ผู้ประเมิน";
if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && status_chief=="Y") return "2";
else if (emp_id == chief) return "1";
else if (emp_id == supervisor1) return "1";
else if (emp_id == supervisor2) return "2";
else if (emp_id == supervisor1A) return "3";
else if (emp_id == supervisor2A) return "4";
return "";
}
private string getRoleName(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path)
{
if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && path == "d2") return "ผู้ประเมินสูงสุด";
else if (emp_id == chief) return "ผู้ประเมิน";
else if (emp_id == supervisor1) return "ผู้ประเมิน";
else if (emp_id == supervisor2) return "ผู้ประเมินสูสุด";
else if (emp_id == supervisor2) return "ผู้ประเมินสูสุด";
else if (emp_id == supervisor1A) return "ผู้บังคับบัญชาเหนือขึ้นไป";
else if (emp_id == supervisor2A) return "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)";
return "";

View File

@@ -94,7 +94,7 @@ namespace TodoAPI2.Models
from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty()
where 1==1
where 1 == 1
//&& (m_eva_create_evaluation_detail_review01.id == model.id || !model.id.HasValue)
&& (m_eva_create_evaluation_detail_review01.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
@@ -132,7 +132,7 @@ namespace TodoAPI2.Models
orderby i.id descending
select i).Take(1).ToList();
if(x.Count > 0)
if (x.Count > 0)
{
newkey = x[0].id + 1;
}
@@ -161,6 +161,10 @@ namespace TodoAPI2.Models
where k.id == model.id
select k).FirstOrDefault();
var current_eva = (from k in _repository.Context.eva_create_evaluation
where k.id == current_detail.create_evaluation_id
select k).FirstOrDefault();
if (current_detail.status_chief == "Y")
{
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
@@ -172,6 +176,13 @@ namespace TodoAPI2.Models
existingEntity.supervisor1_remark = model.supervisor1_remark;
existingEntity.supervisor1_date = DateTime.Now;
if (current_eva.employee_id == current_detail.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน
{
existingEntity.supervisor2 = model.supervisor1;
existingEntity.supervisor2_result = "Y";
existingEntity.supervisor2_remark = model.supervisor1_remark;
existingEntity.supervisor2_date = DateTime.Now;
}
var updated = _repository.Update(id, existingEntity);
return Get(updated.id);
@@ -182,7 +193,7 @@ namespace TodoAPI2.Models
public string UpdateMultiple(List<eva_create_evaluation_detail_review01InputModel> model)
{
foreach(var i in model)
foreach (var i in model)
{
if (i.active_mode == "1" && i.id.HasValue) // update
{

View File

@@ -88,7 +88,7 @@ namespace TodoAPI2.Models
from m_eva_create_evaluation_detail_status in _repository.Context.eva_create_evaluation_detail
where 1==1
where 1 == 1
//&& (m_eva_create_evaluation_detail_status.id == model.id || !model.id.HasValue)
&& (m_eva_create_evaluation_detail_status.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue)
@@ -126,7 +126,7 @@ namespace TodoAPI2.Models
orderby i.id descending
select i).Take(1).ToList();
if(x.Count > 0)
if (x.Count > 0)
{
newkey = x[0].id + 1;
}
@@ -149,6 +149,11 @@ namespace TodoAPI2.Models
public eva_create_evaluation_detail_statusViewModel Update(int id, eva_create_evaluation_detail_statusInputModel model)
{
var existingEntity = _repository.Get(id);
var current_eva = (from k in _repository.Context.eva_create_evaluation
where k.id == existingEntity.create_evaluation_id
select k).FirstOrDefault();
if (existingEntity != null)
{
existingEntity.create_evaluation_id = model.create_evaluation_id;
@@ -158,6 +163,11 @@ namespace TodoAPI2.Models
existingEntity.status_supervisor1A = model.status_supervisor1A;
existingEntity.status_supervisor2A = model.status_supervisor2A;
if (current_eva.employee_id == existingEntity.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน
{
if(existingEntity.status_chief == "Y") existingEntity.status_supervisor = existingEntity.status_chief;
}
var updated = _repository.Update(id, existingEntity);
return Get(updated.id);
}
@@ -167,7 +177,7 @@ namespace TodoAPI2.Models
public string UpdateMultiple(List<eva_create_evaluation_detail_statusInputModel> model)
{
foreach(var i in model)
foreach (var i in model)
{
if (i.active_mode == "1" && i.id.HasValue) // update
{

View File

@@ -202,6 +202,10 @@ namespace TodoAPI2.Models
where k.id == existingEntity.create_evaluation_detail_id
select k).FirstOrDefault();
var current_eva = (from k in _repository.Context.eva_create_evaluation
where k.id == current_detail.create_evaluation_id
select k).FirstOrDefault();
if (current_detail.status_chief == "Y")
{
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
@@ -214,8 +218,18 @@ namespace TodoAPI2.Models
//existingEntity.weight = i.weight;
existingEntity.score = i.score;
existingEntity.sumary = i.sumary;
if(current_eva.employee_id == current_detail.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน
{
existingEntity.score2 = i.score;
existingEntity.sumary2 = i.sumary;
}
//else // เป็นคนละคน (แต่ดึงค่า default ไปใส่ให้)
//{
// existingEntity.score2 = i.score;
// existingEntity.sumary2 = i.sumary;
//}
existingEntity.target_score1 = i.target_score1;
existingEntity.target_score2 = i.target_score2;
existingEntity.target_score3 = i.target_score3;

View File

@@ -197,6 +197,10 @@ namespace TodoAPI2.Models
where k.id == existingEntity.create_evaluation_detail_id
select k).FirstOrDefault();
var current_eva = (from k in _repository.Context.eva_create_evaluation
where k.id == current_detail.create_evaluation_id
select k).FirstOrDefault();
if (current_detail.status_chief == "Y")
{
throw new Exception("ผู้ประเมิน ส่งแบบประเมินไปแล้ว บันทึกไม่ได้");
@@ -207,6 +211,18 @@ namespace TodoAPI2.Models
//existingEntity.weight = i.weight;
existingEntity.score = i.score;
existingEntity.sumary = i.sumary;
if (current_eva.employee_id == current_detail.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน
{
existingEntity.score2 = i.score;
existingEntity.sumary2 = i.sumary;
}
//else // เป็นคนละคน (แต่ดึงค่า default ไปใส่ให้)
//{
// existingEntity.score2 = i.score;
// existingEntity.sumary2 = i.sumary;
//}
existingEntity.target_score1 = i.target_score1;
existingEntity.target_score2 = i.target_score2;
existingEntity.target_score3 = i.target_score3;

View File

@@ -475,6 +475,8 @@
<button id="btnb02" type="button" class="btn btn-submit" onclick="javascript:saveStatus('next2')">ส่งแบบประเมิน</button>
<button id="btnb03" type="button" class="btn btn-submit" onclick="javascript:saveStatus('back2')">ตีกลับแบบประเมิน</button>
@*<button id="btnb03A" type="button" class="btn btn-submit" onclick="javascript:saveStatus('back2')">ตีกลับแบบประเมิน</button>*@
</div>
</div>
</section>

View File

@@ -885,7 +885,7 @@
<param name="logger"></param>
<param name="inemp"></param>
</member>
<member name="M:TodoAPI2.Controllers.eva_create_evaluation_detail_processController.Get(System.Int32)">
<member name="M:TodoAPI2.Controllers.eva_create_evaluation_detail_processController.Get(System.Int32,System.String)">
<summary>
Get specific item by id
</summary>

View File

@@ -10,6 +10,8 @@ eva_create_evaluation_detail_processSearchObject.org_id = $("#s_eva_create_evalu
eva_create_evaluation_detail_processSearchObject.search_employee_code = $("#s_eva_create_evaluation_detail_process_search_employee_code").val();
eva_create_evaluation_detail_processSearchObject.search_employee_fullname = $("#s_eva_create_evaluation_detail_process_search_employee_fullname").val();
eva_create_evaluation_detail_processSearchObject.path = "d";
return eva_create_evaluation_detail_processSearchObject;
}
@@ -234,11 +236,13 @@ var eva_create_evaluation_detail_process_setupTable = function (result) {
function eva_create_evaluation_detail_process_InitiateDataTable() {
startLoad();
AjaxGetRequest(apisite + "/api/eva_create_evaluation_detail_process/GetListBySearch", eva_create_evaluation_detail_process_setupTable, AlertDanger);
var p = $.param(eva_create_evaluation_detail_process_GetSearchParameter());
AjaxGetRequest(apisite + "/api/eva_create_evaluation_detail_process/GetListBySearch?"+p, eva_create_evaluation_detail_process_setupTable, AlertDanger);
}
function eva_create_evaluation_detail_process_DoSearch() {
var p = $.param(eva_create_evaluation_detail_process_GetSearchParameter());
console.log(p);
var eva_create_evaluation_detail_process_reload = function (result) {
eva_create_evaluation_detail_processTableV.destroy();
eva_create_evaluation_detail_process_setupTable(result);

View File

@@ -91,11 +91,11 @@ function eva_create_evaluation_detail_process_SetEditForm(a) {
var successFunc = function (result) {
eva_create_evaluation_detail_process_editMode = "UPDATE";
eva_create_evaluation_detail_process_FeedDataToForm(result);
//setPageByRoleAndStatus(result.role_code, result.status_self, result.status_chief, result.status_supervisor);
setPageByRoleAndStatus(result.role_code, result.status_self, result.status_chief, result.status_supervisor);
endLoad();
};
startLoad();
AjaxGetRequest(apisite + eva_create_evaluation_detail_process_API + a, successFunc, AlertDanger);
AjaxGetRequest(apisite + eva_create_evaluation_detail_process_API + a+"/d", successFunc, AlertDanger);
}
function eva_create_evaluation_detail_process_SetCreateForm() {

View File

@@ -94,7 +94,8 @@ function eva_create_evaluation_detail_process_SetEditForm(a) {
endLoad();
};
startLoad();
AjaxGetRequest(apisite + eva_create_evaluation_detail_process_API + a, successFunc, AlertDanger);
console.log(apisite + eva_create_evaluation_detail_process_API + a+"/d2");
AjaxGetRequest(apisite + eva_create_evaluation_detail_process_API + a+"/d2", successFunc, AlertDanger);
}
function eva_create_evaluation_detail_process_SetCreateForm() {