Edit multiple Employee group added
This commit is contained in:
@@ -66,9 +66,6 @@ public class ClassificationEmployee : EntityBase
|
||||
/// <summary>
|
||||
/// ویرایش پرسنل طرح
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <param name="classificationSchemeId"></param>
|
||||
/// <param name="classificationGroupId"></param>
|
||||
/// <param name="classificationGroupJobId"></param>
|
||||
public void Edit(long classificationGroupId, long classificationGroupJobId)
|
||||
@@ -77,4 +74,20 @@ public class ClassificationEmployee : EntityBase
|
||||
ClassificationGroupJobId = classificationGroupJobId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش گروه های چندگانه پرسنل طرح
|
||||
/// </summary>
|
||||
/// <param name="classificationGroupId"></param>
|
||||
/// <param name="classificationGroupJobId"></param>
|
||||
/// <param name="startGroupDate"></param>
|
||||
/// <param name="endGroupDate"></param>
|
||||
public void EditMultipleGroupMember(long classificationGroupId, long classificationGroupJobId, DateTime startGroupDate, DateTime? endGroupDate)
|
||||
{
|
||||
ClassificationGroupId = classificationGroupId;
|
||||
ClassificationGroupJobId = classificationGroupJobId;
|
||||
StartGroupDate = startGroupDate;
|
||||
if (endGroupDate.HasValue)
|
||||
EndGroupDate = endGroupDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,5 +21,5 @@ public interface IClassificationEmployeeRepository : IRepository<long, Classific
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ClassificationEmployee> GetEmployeeMemberizeData(long employeeId);
|
||||
Task<List<EditEmployeeGroupList>> GetEmployeeMemberizeData(long employeeId);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.ClassificationScheme;
|
||||
/// <summary>
|
||||
/// ویرایش گروه پرسنل
|
||||
/// </summary>
|
||||
public class EditEmployeeGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// آیا گروه بندی پرسنل چند گانه است
|
||||
/// </summary>
|
||||
public bool HasMultipleGroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی طرح
|
||||
/// </summary>
|
||||
public long SchemeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست گروه های پرسنل
|
||||
/// </summary>
|
||||
public List<EditEmployeeGroupList> EditEmployeeGroupLists { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// لیست گروه های طرح
|
||||
/// </summary>
|
||||
public List<ClassificationGroupList> ClassificationGroupList { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست گروه های پرسنل
|
||||
/// </summary>
|
||||
public class EditEmployeeGroupList
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی کارگاه
|
||||
/// </summary>
|
||||
public long WorkshopId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// آی دی گروه
|
||||
/// </summary>
|
||||
public long ClassificationGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی شغل
|
||||
/// </summary>
|
||||
public long ClassificationGroupJobId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع استفاده از گروه
|
||||
/// </summary>
|
||||
public DateTime? StartGroupDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان استفاده از گروه
|
||||
/// </summary>
|
||||
public DateTime? EndGroupDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع استفاده از گروه
|
||||
/// </summary>
|
||||
public string StartGroupDateFa { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان استفاده از گروه
|
||||
/// </summary>
|
||||
public string EndGroupDateFa { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آیا حذف شده است
|
||||
/// </summary>
|
||||
public bool IsRemoved { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -142,12 +142,19 @@ public interface IClassificationSchemeApplication
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> EditGroupMember(AddEmployeeToGroup command);
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره ویرایش گروه چندگانه پرسنل
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> EditMultipleGroupMember(List<EditEmployeeGroupList> command);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات عضویتی پرسنل در گروه
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
Task<AddEmployeeToGroup> GetEmployeeMemberizeData(long employeeId);
|
||||
Task<EditEmployeeGroup> GetEmployeeMemberizeData(long employeeId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -380,20 +380,73 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<OperationResult> EditMultipleGroupMember(List<EditEmployeeGroupList> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
foreach (var item in command)
|
||||
{
|
||||
#region Validation
|
||||
|
||||
if (item.ClassificationGroupId == 0)
|
||||
return op.Failed("لطفا گروه را انتخاب کنید");
|
||||
|
||||
if (item.ClassificationGroupJobId == 0)
|
||||
return op.Failed("لطفا سمت را انتخاب کنید");
|
||||
|
||||
if (!item.StartGroupDateFa.TryToGeorgianDateTime(out var startDate))
|
||||
{
|
||||
string startDateFaild = "تاریخ شروع" + item.StartGroupDateFa + "صحیح نمیباشد";
|
||||
return op.Failed(startDateFaild);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.EndGroupDateFa))
|
||||
{
|
||||
if (!item.EndGroupDateFa.TryToGeorgianDateTime(out var endDate))
|
||||
{
|
||||
string endDateFaild = "تاریخ پایان" + item.EndGroupDateFa + "صحیح نمیباشد";
|
||||
return op.Failed(endDateFaild);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
foreach (var item in command)
|
||||
{
|
||||
var edit = _classificationEmployeeRepository.Get(item.Id);
|
||||
|
||||
if(string.IsNullOrWhiteSpace(item.EndGroupDateFa))
|
||||
{
|
||||
edit.EditMultipleGroupMember(item.ClassificationGroupId, item.ClassificationGroupJobId, item.StartGroupDateFa.ToGeorgianDateTime(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
edit.EditMultipleGroupMember(item.ClassificationGroupId, item.ClassificationGroupJobId, item.StartGroupDateFa.ToGeorgianDateTime(), item.EndGroupDateFa.ToGeorgianDateTime());
|
||||
}
|
||||
|
||||
await _classificationEmployeeRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات عضویتی پرسنل در گروه
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<AddEmployeeToGroup> GetEmployeeMemberizeData(long employeeId)
|
||||
public async Task<EditEmployeeGroup> GetEmployeeMemberizeData(long employeeId)
|
||||
{
|
||||
var result = new AddEmployeeToGroup();
|
||||
var result = new EditEmployeeGroup();
|
||||
var res = await _classificationEmployeeRepository.GetEmployeeMemberizeData(employeeId);
|
||||
result.EmployeeId = employeeId;
|
||||
result.GroupId = res.ClassificationGroupId;
|
||||
result.JobId = res.ClassificationGroupJobId;
|
||||
result.Id = res.id;
|
||||
|
||||
if (res.Any())
|
||||
{
|
||||
result.HasMultipleGroup = res.Count > 1;
|
||||
result.EditEmployeeGroupLists = res;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
|
||||
@@ -183,9 +183,20 @@ public class ClassificationEmployeeRepository : RepositoryBase<long, Classificat
|
||||
/// </summary>
|
||||
/// <param name="employeeId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ClassificationEmployee> GetEmployeeMemberizeData(long employeeId)
|
||||
public async Task<List<EditEmployeeGroupList>> GetEmployeeMemberizeData(long employeeId)
|
||||
{
|
||||
return await _context.ClassificationEmployees.FirstOrDefaultAsync(x => x.EmployeeId == employeeId);
|
||||
return await _context.ClassificationEmployees.Where(x => x.EmployeeId == employeeId).Select(x=> new EditEmployeeGroupList
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
ClassificationGroupId = x.ClassificationGroupId,
|
||||
ClassificationGroupJobId = x.ClassificationGroupJobId,
|
||||
StartGroupDate = x.StartGroupDate,
|
||||
EndGroupDate = x.EndGroupDate,
|
||||
StartGroupDateFa = x.StartGroupDate.HasValue ? x.StartGroupDate.ToFarsi() : "",
|
||||
EndGroupDateFa = x.EndGroupDate.HasValue ? x.EndGroupDate.ToFarsi() : "",
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -414,18 +414,40 @@ public class ClassificationSchemeModel : PageModel
|
||||
/// <returns></returns>
|
||||
public IActionResult OnGetEditGroupMember(long employeeId, long schemeId, string employeeFullName)
|
||||
{
|
||||
var model = new AddEmployeeToGroup();
|
||||
|
||||
var groups = _classificationSchemeApplication.GetGroups(schemeId).GetAwaiter().GetResult();
|
||||
var employeeMemberizeData = _classificationSchemeApplication.GetEmployeeMemberizeData(employeeId).GetAwaiter().GetResult();
|
||||
|
||||
model.SchemeId = schemeId;
|
||||
model.EmployeeId = employeeId;
|
||||
model.EmployeeFullName = employeeFullName;
|
||||
model.ClassificationGroupList = groups;
|
||||
model.GroupId = employeeMemberizeData.GroupId;
|
||||
model.JobId = employeeMemberizeData.JobId;
|
||||
model.Id = employeeMemberizeData.Id;
|
||||
return Partial("_ClassificationPartials/EditGroupMember", model);
|
||||
//اگر یک گروه داشت
|
||||
if (!employeeMemberizeData.HasMultipleGroup)
|
||||
{
|
||||
var model = new AddEmployeeToGroup();
|
||||
|
||||
|
||||
model.SchemeId = schemeId;
|
||||
model.EmployeeId = employeeId;
|
||||
model.EmployeeFullName = employeeFullName;
|
||||
|
||||
if (!employeeMemberizeData.EditEmployeeGroupLists.Any())
|
||||
return Partial("_ClassificationPartials/EditGroupMember", model);
|
||||
|
||||
model.ClassificationGroupList = groups;
|
||||
model.GroupId = employeeMemberizeData.EditEmployeeGroupLists.FirstOrDefault()!.ClassificationGroupId;
|
||||
model.JobId = employeeMemberizeData.EditEmployeeGroupLists.FirstOrDefault()!.ClassificationGroupJobId;
|
||||
model.Id = employeeMemberizeData.EditEmployeeGroupLists.FirstOrDefault()!.Id; ;
|
||||
return Partial("_ClassificationPartials/EditGroupMember", model);
|
||||
}
|
||||
//اگر چند گروه داشت
|
||||
var multipleModel = new EditEmployeeGroup();
|
||||
multipleModel.EmployeeId = employeeId;
|
||||
multipleModel.SchemeId = schemeId;
|
||||
multipleModel.EmployeeFullName = employeeFullName;
|
||||
multipleModel.EditEmployeeGroupLists = employeeMemberizeData.EditEmployeeGroupLists;
|
||||
multipleModel.ClassificationGroupList = groups;
|
||||
|
||||
|
||||
|
||||
return Partial("_ClassificationPartials/EditMultipleGroupMember", multipleModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -452,6 +474,28 @@ public class ClassificationSchemeModel : PageModel
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// ذخیره ویرایش گروه چندگانه پرسنل
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public IActionResult OnPostEditMultipleGroupMember([FromBody] List<EditEmployeeGroupList> command)
|
||||
{
|
||||
var result = _classificationSchemeApplication.EditMultipleGroupMember(command).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccedded)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = false,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = true,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -510,7 +554,7 @@ public class ClassificationSchemeModel : PageModel
|
||||
string mathModel = "";
|
||||
var employeeMemberizeData = _classificationSchemeApplication.GetEmployeeMemberizeData(employeeId).GetAwaiter().GetResult();
|
||||
|
||||
var groupId = employeeMemberizeData.GroupId;
|
||||
var groupId = employeeMemberizeData.EditEmployeeGroupLists.FirstOrDefault()!.ClassificationGroupId;
|
||||
var group = _classificationSchemeApplication.GetGroups(schemeId).GetAwaiter().GetResult();
|
||||
var groupNo = group.FirstOrDefault(x => x.GroupId == groupId)!.GroupNo;
|
||||
var groupSalaryData = _classificationSchemeApplication.GetEditSalariesData(schemeId, startDate, endDate).GetAwaiter()
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
.modal .modal-dialog .modal-content {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
width: 276px;
|
||||
left: 47%;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
@using CompanyManagment.App.Contracts.GroupPlanJobItem
|
||||
@model CompanyManagment.App.Contracts.ClassificationScheme.EditEmployeeGroup
|
||||
@Html.AntiForgeryToken()
|
||||
@{
|
||||
|
||||
<style>
|
||||
|
||||
.modal .modal-dialog .modal-content {
|
||||
padding-bottom: 10px !important;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
padding: 0.5rem 1rem !important; /* کوچکتر کردن فاصله */
|
||||
margin-top: -10px; /* کمی بالا آوردن */
|
||||
}
|
||||
|
||||
.modal .modal-dialog .modal-content {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.modal-title{
|
||||
width: 276px;
|
||||
left: 47%;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">افزودن پرسنل به گروه</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="بستن">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="row m-t-10">
|
||||
<h5 class="modal-title">@Model.EmployeeFullName</h5>
|
||||
</div>
|
||||
<div class="card shadow-sm border-0" style="margin-top: 31px;">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="lineDiv"></div>
|
||||
@foreach (var groupItem in @Model.EditEmployeeGroupLists)
|
||||
{
|
||||
<div class="row m-t-10">
|
||||
<div class="col-md-6 mb-3">
|
||||
|
||||
<select id="groupList" data-selectGroup-id="@groupItem.Id" data-selectGroupJobId="@groupItem.ClassificationGroupJobId" asp-for="@groupItem.ClassificationGroupId" class="form-select form-control" onchange="selectGroup(this)">
|
||||
<option value="0">انتخاب گروه</option>
|
||||
@foreach (var item in Model.ClassificationGroupList)
|
||||
{
|
||||
<option value="@item.GroupId" data-groupno="@item.GroupNo"><span>گروه</span><span> </span><span>@item.GroupNo</span></option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
|
||||
<select id="jobList" data-selectjob-id="@groupItem.Id" asp-for="@groupItem.ClassificationGroupJobId" class="form-select form-control">
|
||||
<option value="0">انتخاب سمت</option>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row m-t-10">
|
||||
<div class="col-xs-12 col-md-6 mb-3">
|
||||
<label class="form-label">تاریخ شروع</label>
|
||||
<input data-startdate-id="@groupItem.Id" type="text" asp-for="@groupItem.StartGroupDateFa" class="form-control date-input" data-val="false" />
|
||||
<span asp-validation-for="@groupItem.StartGroupDateFa" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 mb-3">
|
||||
<label class="form-label">تاریخ پایان</label>
|
||||
<input data-enddate-id="@groupItem.Id" type="text" asp-for="@groupItem.EndGroupDateFa" class="form-control date-input" data-val="false" />
|
||||
<span asp-validation-for="@groupItem.EndGroupDateFa" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="lineDiv"></div>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" asp-for="SchemeId" value="@Model.SchemeId" />
|
||||
<input type="hidden" asp-for="EmployeeId" value="@Model.EmployeeId" />
|
||||
|
||||
<div class="modal-footer border-0">
|
||||
<button type="button" onclick="saveBtn()" class="btn btn-success px-4 rounded-pill">ذخیره</button>
|
||||
<button type="button" class="btn btn-outline-secondary px-4 rounded-pill" data-dismiss="modal">بستن</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".date-input").mask("0000/00/00");
|
||||
let schemeId = '@Model.SchemeId';
|
||||
|
||||
|
||||
// روی همه سلکتهایی که data-selectGroup-id دارند اجرا میکنیم
|
||||
$('select[data-selectGroup-id]').each(function () {
|
||||
const $groupSelect = $(this);
|
||||
const selectGroupId = $groupSelect.data('selectgroup-id');
|
||||
const $jobSelect = $(`select[data-selectjob-id="${selectGroupId}"]`);
|
||||
const selectGroupJobId = $groupSelect.attr('data-selectGroupJobId');
|
||||
|
||||
// گرفتن مقدار انتخابشده
|
||||
const groupId = $groupSelect.val();
|
||||
|
||||
// اگر مقدار گروه 0 نبود، بریم سراغ واکشی سمتها
|
||||
if (groupId && groupId !== "0") {
|
||||
const url = `/Admin/Company/Workshops/ClassificationScheme?handler=JobList&schemeId=${schemeId}&groupId=${groupId}`;
|
||||
|
||||
$.get(url, function (data) {
|
||||
$jobSelect.empty();
|
||||
$jobSelect.append('<option value="0">انتخاب سمت</option>');
|
||||
|
||||
data.jobs.forEach(item => {
|
||||
const selected = (item.jobId == selectGroupJobId) ? 'selected="selected"' : '';
|
||||
$jobSelect.append(`
|
||||
<option ${selected} value="${item.jobId}"
|
||||
data-jobname="${item.jobName}"
|
||||
data-jobcode="${item.jobCode}">
|
||||
${item.jobCode} - ${item.jobName}
|
||||
</option>
|
||||
`);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function selectGroup(element) {
|
||||
let schemeId = '@Model.SchemeId';
|
||||
const $groupSelect = $(element);
|
||||
const selectGroupId = $groupSelect.data('selectgroup-id');
|
||||
const $jobSelect = $(`select[data-selectjob-id="${selectGroupId}"]`);
|
||||
const groupId = $groupSelect.val();
|
||||
const selectGroupJobId = $groupSelect.attr('data-selectGroupJobId');
|
||||
if (!groupId || groupId === "0") {
|
||||
$jobSelect.empty().append('<option value="0">انتخاب سمت</option>');
|
||||
return;
|
||||
}
|
||||
|
||||
const url = `/Admin/Company/Workshops/ClassificationScheme?handler=JobList&schemeId=${schemeId}&groupId=${groupId}`;
|
||||
|
||||
$.get(url, function (data) {
|
||||
$jobSelect.empty();
|
||||
$jobSelect.append('<option value="0">انتخاب سمت</option>');
|
||||
|
||||
data.jobs.forEach(item => {
|
||||
const selected = (item.jobId == selectGroupJobId) ? 'selected="selected"' : '';
|
||||
$jobSelect.append(`
|
||||
<option ${selected} value="${item.jobId}"
|
||||
data-jobname="${item.jobName}"
|
||||
data-jobcode="${item.jobCode}">
|
||||
${item.jobCode} - ${item.jobName}
|
||||
</option>
|
||||
`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function saveBtn() {
|
||||
|
||||
var command = [];
|
||||
$('select[data-selectgroup-id]').each(function () {
|
||||
const $groupSelect = $(this);
|
||||
const selectGroupId = $groupSelect.data('selectgroup-id');
|
||||
const $jobSelect = $(`select[data-selectjob-id="${selectGroupId}"]`);
|
||||
const startDate = $(`input[data-startdate-id="${selectGroupId}"]`).val();
|
||||
const endDate = $(`input[data-enddate-id="${selectGroupId}"]`).val();
|
||||
|
||||
// گرفتن option انتخابشده از هر select
|
||||
const $selectedGroupOption = $groupSelect.find('option:selected');
|
||||
const $selectedJobOption = $jobSelect.find('option:selected');
|
||||
|
||||
// حالا میتونی هم value هم متن هم data-* رو بخونی
|
||||
const groupId = $selectedGroupOption.val();
|
||||
const groupText = $selectedGroupOption.text();
|
||||
// const groupNo = $selectedGroupOption.data('groupno');
|
||||
|
||||
const jobId = $selectedJobOption.val();
|
||||
|
||||
if (groupId == 0) {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم', "گروه را انتخاب کنید");
|
||||
return;
|
||||
}
|
||||
|
||||
if (jobId == 0) {
|
||||
const alarm = ' سمت' + ' ' + groupText + ' ' + 'را انتخاب کنید '
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم', alarm);
|
||||
return;
|
||||
}
|
||||
// const jobText = $selectedJobOption.text();
|
||||
// const jobName = $selectedJobOption.data('jobname');
|
||||
// const jobCode = $selectedJobOption.data('jobcode');
|
||||
|
||||
// console.log(`GroupId = ${groupId} JobId = ${jobId} selectGroupId = ${selectGroupId} startDate = ${startDate} endDate = ${endDate}`);
|
||||
|
||||
const editEmployeeGroupList = {
|
||||
id: Number(selectGroupId),
|
||||
employeeId: '@Model.EmployeeId',
|
||||
schemeId: '@Model.SchemeId',
|
||||
classificationGroupId: Number(groupId),
|
||||
classificationGroupJobId: Number(jobId),
|
||||
StartGroupDateFa: startDate,
|
||||
endGroupDateFa: endDate,
|
||||
};
|
||||
// console.log(editEmployeeGroupList);
|
||||
command.push(editEmployeeGroupList);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var urlAjaxToSave = '@Url.Page("/Company/Workshops/ClassificationScheme", "EditMultipleGroupMember")';
|
||||
|
||||
$.ajax({
|
||||
|
||||
type: 'POST',
|
||||
url: urlAjaxToSave,
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
data: JSON.stringify(command),
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
if(response.isSuccess){
|
||||
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
|
||||
$('.close').click();
|
||||
|
||||
setTimeout(function () {
|
||||
$('#addEmployeesTab').click();
|
||||
|
||||
|
||||
|
||||
}, 1000);
|
||||
}else{
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
|
||||
}
|
||||
|
||||
},
|
||||
failure: function (response) {
|
||||
//console.log(5, response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user