edit and transfer employee to group chnage valistion and set remove icon
This commit is contained in:
@@ -11,7 +11,8 @@ namespace _0_Framework.Domain;
|
||||
public interface IRepository<TKey, T> where T:class
|
||||
{
|
||||
T Get(TKey id);
|
||||
List<T> Get();
|
||||
List<T> Get();
|
||||
Task<List<T>> GetListByIdList(List<TKey> ids);
|
||||
void Create(T entity);
|
||||
Task CreateAsync(T entity);
|
||||
bool ExistsIgnoreQueryFilter(Expression<Func<T, bool>> expression);
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace _0_Framework.InfraStructure
|
||||
{
|
||||
return _context.Set<T>().ToList();
|
||||
}
|
||||
|
||||
public async Task<List<T>> GetListByIdList(List<TKey> ids)
|
||||
{
|
||||
return await _context.Set<T>().Where(e => ids.Contains(EF.Property<TKey>(e, "id"))).ToListAsync();
|
||||
}
|
||||
public void Remove(T entity)
|
||||
{
|
||||
_context.Set<T>().Remove(entity);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ClassificationEmployee : EntityBase
|
||||
/// <param name="classificationGroupJobId"></param>
|
||||
/// <param name="startGroupDate"></param>
|
||||
/// <param name="endGroupDate"></param>
|
||||
public ClassificationEmployee(long workshopId, long employeeId, long classificationSchemeId, long classificationGroupId, long classificationGroupJobId, DateTime? startGroupDate, DateTime? endGroupDate)
|
||||
public ClassificationEmployee(long workshopId, long employeeId, long classificationSchemeId, long classificationGroupId, long classificationGroupJobId, DateTime? startGroupDate)
|
||||
{
|
||||
WorkshopId = workshopId;
|
||||
EmployeeId = employeeId;
|
||||
@@ -23,7 +23,7 @@ public class ClassificationEmployee : EntityBase
|
||||
ClassificationGroupId = classificationGroupId;
|
||||
ClassificationGroupJobId = classificationGroupJobId;
|
||||
StartGroupDate = startGroupDate;
|
||||
EndGroupDate = endGroupDate;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,13 +82,12 @@ public class ClassificationEmployee : EntityBase
|
||||
/// <param name="classificationGroupJobId"></param>
|
||||
/// <param name="startGroupDate"></param>
|
||||
/// <param name="endGroupDate"></param>
|
||||
public void EditMultipleGroupMember(long classificationGroupId, long classificationGroupJobId, DateTime startGroupDate, DateTime? endGroupDate)
|
||||
public void EditMultipleGroupMember(long classificationGroupId, long classificationGroupJobId, DateTime startGroupDate)
|
||||
{
|
||||
ClassificationGroupId = classificationGroupId;
|
||||
ClassificationGroupJobId = classificationGroupJobId;
|
||||
StartGroupDate = startGroupDate;
|
||||
if (endGroupDate.HasValue)
|
||||
EndGroupDate = endGroupDate;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,4 +30,13 @@ public interface IClassificationEmployeeRepository : IRepository<long, Classific
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task CreateTransferRange(List<ClassificationEmployee> command);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// حذف پرسنل از گروه از سمت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveRangeByEdit(List<ClassificationEmployee> command);
|
||||
|
||||
}
|
||||
@@ -353,7 +353,7 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
|
||||
|
||||
var create = new ClassificationEmployee(scheme.WorkshopId, command.EmployeeId, command.SchemeId,
|
||||
command.GroupId, command.JobId, scheme.ExecutionDateGr, null);
|
||||
command.GroupId, command.JobId, scheme.ExecutionDateGr);
|
||||
await _classificationEmployeeRepository.CreateAsync(create);
|
||||
await _classificationEmployeeRepository.SaveChangesAsync();
|
||||
|
||||
@@ -388,6 +388,7 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
if (command.Count < 1)
|
||||
return op.Failed("هیچ انتقالی ایجاد نشده است");
|
||||
var oldGroupsMemberize = await _classificationEmployeeRepository.GetEmployeeMemberizeData(command[0].EmployeeId);
|
||||
var scheme = await _classificationSchemeRepository.GetClassificationScheme(oldGroupsMemberize[0].SchemeId);
|
||||
var newStartDateList = new List<DateTime>();
|
||||
foreach (var item in command)
|
||||
{
|
||||
@@ -405,13 +406,17 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
return op.Failed(startDateFaild);
|
||||
}
|
||||
|
||||
if (item.StartGroupDateFa.Substring(8, 2) != "01")
|
||||
return op.Failed("تاریخ شروع فقط می تواند یکم هر ماه باشد");
|
||||
|
||||
if (newStartDateList.Any(x => x == startDate))
|
||||
return op.Failed(" تاریخ انتقال وارد شده با تاریخ های قبل تداخل دارد");
|
||||
return op.Failed($"تاریخ انتقال {item.StartGroupDateFa} با تاریخ های قبل تداخل دارد");
|
||||
newStartDateList.Add(startDate);
|
||||
|
||||
if (oldGroupsMemberize.Any(x => x.StartGroupDate >= startDate))
|
||||
return op.Failed(" تاریخ انتقال وارد شده با تاریخ های قبل تداخل دارد");
|
||||
|
||||
if (oldGroupsMemberize.Any(x => x.StartGroupDate == startDate))
|
||||
return op.Failed($"تاریخ انتقال {item.StartGroupDateFa} با تاریخ های قبل تداخل دارد");
|
||||
if (startDate < scheme.ExecutionDateGr)
|
||||
return op.Failed($"تاریخ انتقال {item.StartGroupDateFa} کوچکتر از تاریخ شروع طرح : {scheme.ExecutionDateFa} است");
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -423,10 +428,10 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
var edit = _classificationEmployeeRepository.Get(lastRecord.Id);
|
||||
var firstNewRcord = newStartDateList.MinBy(x => x);
|
||||
|
||||
edit.EditMultipleGroupMember(lastRecord.ClassificationGroupId, lastRecord.ClassificationGroupJobId, lastRecord.StartGroupDate.Value, firstNewRcord.AddDays(-1));
|
||||
edit.EditMultipleGroupMember(lastRecord.ClassificationGroupId, lastRecord.ClassificationGroupJobId, lastRecord.StartGroupDate.Value);
|
||||
|
||||
}
|
||||
var scheme = _classificationSchemeRepository.GetClassificationScheme(command[0].SchemeId).GetAwaiter().GetResult();
|
||||
|
||||
|
||||
|
||||
newStartDateList = newStartDateList.OrderByDescending(x => x).ToList();
|
||||
@@ -435,7 +440,7 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
|
||||
var c = command.FirstOrDefault(x => x.StartGroupDateFa == lastNewRecord.ToFarsi());
|
||||
var create = new ClassificationEmployee(scheme.WorkshopId, c.EmployeeId, c.SchemeId,
|
||||
c.ClassificationGroupId, c.ClassificationGroupJobId, lastNewRecord.Date, null);
|
||||
c.ClassificationGroupId, c.ClassificationGroupJobId, lastNewRecord.Date);
|
||||
await _classificationEmployeeRepository.CreateAsync(create);
|
||||
newStartDateList.Remove(lastNewRecord);
|
||||
var createList = new List<ClassificationEmployee>();
|
||||
@@ -443,7 +448,7 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
{
|
||||
var commandEdit = command.FirstOrDefault(x => x.StartGroupDateFa == item.ToFarsi());
|
||||
var createCommand = new ClassificationEmployee(scheme.WorkshopId, commandEdit.EmployeeId, commandEdit.SchemeId,
|
||||
commandEdit.ClassificationGroupId, commandEdit.ClassificationGroupJobId, item, lastNewRecord.AddDays(-1));
|
||||
commandEdit.ClassificationGroupId, commandEdit.ClassificationGroupJobId, item);
|
||||
createList.Add(createCommand);
|
||||
lastNewRecord = item;
|
||||
}
|
||||
@@ -466,6 +471,11 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
public async Task<OperationResult> EditMultipleGroupMember(List<EditEmployeeGroupList> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var zeroItem = command.First(x => x.Id == 0);
|
||||
var oldGroupsMemberize = await _classificationEmployeeRepository.GetEmployeeMemberizeData(zeroItem.EmployeeId);
|
||||
var scheme = await _classificationSchemeRepository.GetClassificationScheme(zeroItem.SchemeId);
|
||||
command = command.Where(x=>x.Id != 0).ToList();
|
||||
var newStartDateList = new List<DateTime>();
|
||||
foreach (var item in command)
|
||||
{
|
||||
#region Validation
|
||||
@@ -481,16 +491,15 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
string startDateFaild = "تاریخ شروع" + " " + item.StartGroupDateFa + " " + "صحیح نمیباشد";
|
||||
return op.Failed(startDateFaild);
|
||||
}
|
||||
if (item.StartGroupDateFa.Substring(8, 2) != "01")
|
||||
return op.Failed("تاریخ شروع فقط می تواند یکم هر ماه باشد");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(item.EndGroupDateFa))
|
||||
{
|
||||
if (!item.EndGroupDateFa.TryToGeorgianDateTime(out var endDate))
|
||||
{
|
||||
string endDateFaild = "تاریخ پایان" + item.EndGroupDateFa + "صحیح نمیباشد";
|
||||
return op.Failed(endDateFaild);
|
||||
}
|
||||
}
|
||||
if (oldGroupsMemberize.Any(x=>x.StartGroupDate == startDate && x.Id != item.Id))
|
||||
return op.Failed($"تاریخ {item.StartGroupDateFa} با تاریخ های قبل یا بعد از خود تداخل دارد");
|
||||
|
||||
if (startDate < scheme.ExecutionDateGr)
|
||||
return op.Failed($"تاریخ انتقال {item.StartGroupDateFa} کوچکتر از تاریخ شروع طرح : {scheme.ExecutionDateFa} است");
|
||||
newStartDateList.Add(startDate);
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -499,13 +508,23 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
var edit = _classificationEmployeeRepository.Get(item.Id);
|
||||
|
||||
|
||||
edit.EditMultipleGroupMember(item.ClassificationGroupId, item.ClassificationGroupJobId, item.StartGroupDateFa.ToGeorgianDateTime(), null);
|
||||
edit.EditMultipleGroupMember(item.ClassificationGroupId, item.ClassificationGroupJobId, item.StartGroupDateFa.ToGeorgianDateTime());
|
||||
|
||||
|
||||
|
||||
await _classificationEmployeeRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
var removeItemIdList = command.Select(x => x.Id).ToList();
|
||||
var toBeRemove = removeItemIdList.Any() ? oldGroupsMemberize.Where(x=> !removeItemIdList.Contains(x.Id)).Select(x=>x.Id).ToList() : oldGroupsMemberize.Select(x=>x.Id).ToList();
|
||||
if (toBeRemove.Any())
|
||||
{
|
||||
var getRemoveList =await _classificationEmployeeRepository.GetListByIdList(toBeRemove);
|
||||
|
||||
await _classificationEmployeeRepository.RemoveRangeByEdit(getRemoveList);
|
||||
}
|
||||
|
||||
await _classificationEmployeeRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@ public class ClassificationEmployeeRepository : RepositoryBase<long, Classificat
|
||||
{
|
||||
Id = x.id,
|
||||
WorkshopId = x.WorkshopId,
|
||||
SchemeId = x.ClassificationSchemeId,
|
||||
ClassificationGroupId = x.ClassificationGroupId,
|
||||
ClassificationGroupJobId = x.ClassificationGroupJobId,
|
||||
StartGroupDate = x.StartGroupDate,
|
||||
@@ -196,7 +197,7 @@ public class ClassificationEmployeeRepository : RepositoryBase<long, Classificat
|
||||
StartGroupDateFa = x.StartGroupDate.HasValue ? x.StartGroupDate.ToFarsi() : "",
|
||||
EndGroupDateFa = x.EndGroupDate.HasValue ? x.EndGroupDate.ToFarsi() : "",
|
||||
|
||||
}).ToListAsync();
|
||||
}).OrderBy(x=>x.StartGroupDate).ToListAsync();
|
||||
|
||||
|
||||
}
|
||||
@@ -207,4 +208,15 @@ public class ClassificationEmployeeRepository : RepositoryBase<long, Classificat
|
||||
await _context.AddRangeAsync(command);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// حذف پرسنل از گروه از سمت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RemoveRangeByEdit(List<ClassificationEmployee> command)
|
||||
{
|
||||
_context.RemoveRange(command);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,20 @@
|
||||
.date-input {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button.rounded-pill {
|
||||
border-radius: 5px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div style="max-width: 88%;margin: 0 auto;">
|
||||
<div style="max-width: 88%;margin: 0 auto7
|
||||
<div class="col-xs-12" style="float: unset;">
|
||||
<div class="handle-title">
|
||||
<h3 id="titleHead">تنظیمات طرح طبقه بندی مشاغل <span style="color: #eb3434"> > @Model.WorkshopName</span></h3>
|
||||
<h3 id="titleHead">تنظیمات طرح طبقه بندی مشاغل <span style="color: #a4884b"> > @Model.WorkshopName</span></h3>
|
||||
<a asp-page="./index" class="btn btn-rounded" type="button">
|
||||
<span>بازگشت</span>
|
||||
</a>
|
||||
|
||||
@@ -418,25 +418,25 @@ public class ClassificationSchemeModel : PageModel
|
||||
var groups = _classificationSchemeApplication.GetGroups(schemeId).GetAwaiter().GetResult();
|
||||
var employeeMemberizeData = _classificationSchemeApplication.GetEmployeeMemberizeData(employeeId).GetAwaiter().GetResult();
|
||||
|
||||
//اگر یک گروه داشت
|
||||
if (!employeeMemberizeData.HasMultipleGroup)
|
||||
{
|
||||
var model = new AddEmployeeToGroup();
|
||||
////اگر یک گروه داشت
|
||||
//if (!employeeMemberizeData.HasMultipleGroup)
|
||||
//{
|
||||
// var model = new AddEmployeeToGroup();
|
||||
|
||||
|
||||
model.SchemeId = schemeId;
|
||||
model.EmployeeId = employeeId;
|
||||
model.EmployeeFullName = employeeFullName;
|
||||
// model.SchemeId = schemeId;
|
||||
// model.EmployeeId = employeeId;
|
||||
// model.EmployeeFullName = employeeFullName;
|
||||
|
||||
if (!employeeMemberizeData.EditEmployeeGroupLists.Any())
|
||||
return Partial("_ClassificationPartials/EditGroupMember", model);
|
||||
// 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);
|
||||
}
|
||||
// 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;
|
||||
@@ -456,24 +456,24 @@ public class ClassificationSchemeModel : PageModel
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public IActionResult OnPostEditGroupMember(AddEmployeeToGroup command)
|
||||
{
|
||||
//public IActionResult OnPostEditGroupMember(AddEmployeeToGroup command)
|
||||
//{
|
||||
|
||||
var result = _classificationSchemeApplication.EditGroupMember(command).GetAwaiter().GetResult();
|
||||
if (!result.IsSuccedded)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = false,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = true,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
// var result = _classificationSchemeApplication.EditGroupMember(command).GetAwaiter().GetResult();
|
||||
// if (!result.IsSuccedded)
|
||||
// {
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = false,
|
||||
// message = result.Message,
|
||||
// });
|
||||
// }
|
||||
// return new JsonResult(new
|
||||
// {
|
||||
// isSuccess = true,
|
||||
// message = result.Message,
|
||||
// });
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره ویرایش گروه های چندگانه پرسنل
|
||||
|
||||
@@ -619,8 +619,8 @@
|
||||
if (item.hasGroup)
|
||||
{
|
||||
DataTableHtml += `
|
||||
<span class="icon-span edit-group-member" style="padding: 4px;font-size: 11px;">
|
||||
<a onclick="editGroupMember(${item.employeeId}, '${item.fullName}')" >
|
||||
<span onclick="editGroupMember(${item.employeeId}, '${item.fullName}')" class="icon-span edit-group-member" style="padding: 4px;font-size: 11px;">
|
||||
<a>
|
||||
<span class="job-btn-text">ویرایش</span>
|
||||
<svg width="19" height="18" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="11" cy="11" r="8.25" stroke="white" />
|
||||
@@ -630,8 +630,8 @@
|
||||
</a>
|
||||
</span>`;
|
||||
DataTableHtml += `
|
||||
<span class="icon-span transfer-group-member" style="padding: 4px;font-size: 11px;">
|
||||
<a onclick="transferToNewGroup(${item.employeeId}, '${item.fullName}')" >
|
||||
<span onclick="transferToNewGroup(${item.employeeId}, '${item.fullName}')" class="icon-span transfer-group-member" style="padding: 4px;font-size: 11px;">
|
||||
<a>
|
||||
<span class="job-btn-text">انتقال</span>
|
||||
<svg width="19" height="18" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="11" cy="11" r="8.25" stroke="white" />
|
||||
@@ -644,8 +644,8 @@
|
||||
else
|
||||
{
|
||||
DataTableHtml += `
|
||||
<span class="icon-span add-to-group" style="padding: 4px 18px;font-size: 11px;">
|
||||
<a onclick="addToGroup(${item.employeeId}, '${item.fullName}')">
|
||||
<span onclick="addToGroup(${item.employeeId}, '${item.fullName}')" class="icon-span add-to-group" style="padding: 4px 18px;font-size: 11px;">
|
||||
<a >
|
||||
<span class="job-btn-text">افزودن به گروه</span>
|
||||
<svg width="19" height="18" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="11" cy="11" r="8.25" stroke="white" />
|
||||
|
||||
@@ -93,8 +93,8 @@
|
||||
}
|
||||
<div class="col-12 col-md-3 align-items-center" style="float:left; direction:ltr">
|
||||
|
||||
<a
|
||||
style="border-radius:5px;" href="#showmodal=@Url.Page("./ClassificationScheme", "CreateScheme" ,new {workshopId = @Model.WorkshopId})" >
|
||||
<a href="#"
|
||||
style="border-radius:5px;" >
|
||||
<span class="icon-span" style="background-color:#ddd3e0">
|
||||
<svg width="19" height="18" fill="none" xmlns="http://www.w3.org/2000/svg" >
|
||||
<rect width="18.5047" height="18.5047" transform="translate(0.523438 0.523438)" fill="#DDD3E0"></rect>
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
@model CompanyManagment.App.Contracts.ClassificationScheme.AddEmployeeToGroup
|
||||
@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>
|
||||
|
||||
<div class="row m-t-10">
|
||||
<div class="col-md-6 mb-3">
|
||||
|
||||
<select id="groupList" asp-for="GroupId" 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" asp-for="JobId" class="form-select form-control">
|
||||
<option value="0">انتخاب سمت</option>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div id="groupHiddenInputs">
|
||||
</div>
|
||||
|
||||
<div id="jobHiddenInputs">
|
||||
</div>
|
||||
</div>
|
||||
<div class="lineDiv"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="hidden" name="firstCheckjobId" value="@Model.JobId"/>
|
||||
<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() {
|
||||
|
||||
let schemeId = '@Model.SchemeId';
|
||||
|
||||
const groupSelect = document.getElementById("groupList");
|
||||
|
||||
let jobId = '@Model.JobId';
|
||||
|
||||
const groupId = groupSelect.options[groupSelect.selectedIndex].value;
|
||||
var url = `/Admin/Company/Workshops/ClassificationScheme?handler=JobList&schemeId=${schemeId}&groupId=${groupId}`;
|
||||
|
||||
|
||||
|
||||
$.get(url, function (data) {
|
||||
// فرض بر این است که data.jobs یک آرایه از آبجکتهایی مثل { jobId, jobName, jobCode } باشد
|
||||
const jobList = $("#jobList");
|
||||
jobList.empty(); // پاک کردن آیتمهای قبلی
|
||||
jobList.append('<option value="0">انتخاب سمت</option>');
|
||||
|
||||
data.jobs.forEach(item => {
|
||||
|
||||
if(item.jobId == jobId){
|
||||
jobList.append(`<option selected="selected" value="${item.jobId}" data-jobname="${item.jobName}" data-jobcode="${item.jobCode}">
|
||||
${item.jobCode} - ${item.jobName}
|
||||
</option>`);
|
||||
}else{
|
||||
jobList.append(`<option value="${item.jobId}" data-jobname="${item.jobName}" data-jobcode="${item.jobCode}">
|
||||
${item.jobCode} - ${item.jobName}
|
||||
</option>`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function selectGroup(selectElement) {
|
||||
const selectedOption = selectElement.options[selectElement.selectedIndex];
|
||||
const groupId = selectedOption.value;
|
||||
// const groupNo = selectedOption.getAttribute("data-groupno");
|
||||
// $('#groupHiddenInputs').html('');
|
||||
// const inputs =`
|
||||
// <input type="hidden" name="GroupId" value="${groupId}" />
|
||||
|
||||
// `;
|
||||
// $('#groupHiddenInputs').append(inputs);
|
||||
let schemeId = '@Model.SchemeId';
|
||||
var url = `/Admin/Company/Workshops/ClassificationScheme?handler=JobList&schemeId=${schemeId}&groupId=${groupId}`;
|
||||
|
||||
console.log("Request URL:", url);
|
||||
|
||||
$.get(url, function (data) {
|
||||
// فرض بر این است که data.jobs یک آرایه از آبجکتهایی مثل { jobId, jobName, jobCode } باشد
|
||||
const jobList = $("#jobList");
|
||||
jobList.empty(); // پاک کردن آیتمهای قبلی
|
||||
jobList.append('<option value="0">انتخاب سمت</option>');
|
||||
|
||||
data.jobs.forEach(item => {
|
||||
jobList.append(
|
||||
`<option value="${item.jobId}" data-jobname="${item.jobName}" data-jobcode="${item.jobCode}">
|
||||
${item.jobCode} - ${item.jobName}
|
||||
</option>`
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// function selectJob(selectElement) {
|
||||
|
||||
// const selectedOption = selectElement.options[selectElement.selectedIndex];
|
||||
// const jobId = selectedOption.value;
|
||||
// // const jobname = selectedOption.getAttribute("data-jobname");
|
||||
// // const jobcode = selectedOption.getAttribute("data-jobcode");
|
||||
|
||||
// $('#jobHiddenInputs').html('');
|
||||
// const inputs =`
|
||||
// <input type="hidden" name="jobId" value="${jobId}" />
|
||||
|
||||
// `;
|
||||
// $('#jobHiddenInputs').append(inputs);
|
||||
|
||||
|
||||
// }
|
||||
|
||||
function saveBtn() {
|
||||
const groupSelect = document.getElementById("groupList");
|
||||
const jobSelect = document.getElementById("jobList");
|
||||
|
||||
const groupId = groupSelect.options[groupSelect.selectedIndex].value;
|
||||
const jobId = jobSelect.options[jobSelect.selectedIndex].value;
|
||||
|
||||
if (groupId == 0) {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم', "گروه را انتخاب کنید");
|
||||
return;
|
||||
}
|
||||
|
||||
if (jobId == 0) {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم', "سمت را انتخاب کنید");
|
||||
return;
|
||||
}
|
||||
|
||||
const command = {
|
||||
employeeId: '@Model.EmployeeId',
|
||||
schemeId: '@Model.SchemeId',
|
||||
id : '@Model.Id',
|
||||
groupId: Number(groupId),
|
||||
jobId: Number(jobId),
|
||||
};
|
||||
|
||||
|
||||
var urlAjaxToSave = '@Url.Page("/Company/Workshops/ClassificationScheme", "EditGroupMember")';
|
||||
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: urlAjaxToSave,
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
data: command,
|
||||
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>
|
||||
|
||||
|
||||
@@ -22,6 +22,15 @@
|
||||
width: 276px;
|
||||
left: 47%;
|
||||
}
|
||||
|
||||
.icon-sapan-delete {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 2px;
|
||||
border-radius: 5px;
|
||||
padding: 7px;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@@ -50,7 +59,7 @@
|
||||
@foreach (var groupItem in @Model.EditEmployeeGroupLists)
|
||||
{
|
||||
|
||||
<div class="row m-t-10">
|
||||
<div class="row m-t-10 tr-transfer">
|
||||
|
||||
<div class="col-xs-6 col-md-4 mb-3">
|
||||
|
||||
@@ -70,13 +79,30 @@
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-4 mb-3">
|
||||
<div class="col-xs-11 col-md-3 mb-3">
|
||||
|
||||
|
||||
<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-1 col-md-1">
|
||||
<a onclick="removeTr(this)"
|
||||
style="border-radius:5px; cursor:pointer;">
|
||||
<span class="icon-sapan-delete" style="background-color:#ddd3e0">
|
||||
<svg width="21" height="21" fill="none" xmlns="http://www.w3.org/2000/svg" >
|
||||
<rect width="18.5047" height="18.5047" transform="translate(0.523438 0.523438)" fill="#DDD3E0"></rect>
|
||||
<path d="M7.84814 11.7031L7.84814 9.39004" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M11.7031 11.7031L11.7031 9.39004" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M2.83643 5.53125H16.7149V5.53125C16.0652 5.53125 15.7403 5.53125 15.4745 5.60604C14.8039 5.79477 14.2799 6.31884 14.0911 6.98943C14.0163 7.25518 14.0163 7.58007 14.0163 8.22985V11.5546C14.0163 13.4402 14.0163 14.383 13.4305 14.9688C12.8448 15.5546 11.902 15.5546 10.0163 15.5546H9.53502C7.64941 15.5546 6.7066 15.5546 6.12081 14.9688C5.53502 14.383 5.53502 13.4402 5.53502 11.5546V8.22985C5.53502 7.58007 5.53502 7.25518 5.46023 6.98943C5.27151 6.31884 4.74744 5.79477 4.07685 5.60604C3.8111 5.53125 3.48621 5.53125 2.83643 5.53125V5.53125Z" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M7.84799 3.22434C7.84799 3.22434 8.2335 2.45312 9.77556 2.45312C11.3176 2.45312 11.7031 3.22415 11.7031 3.22415" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
</svg>
|
||||
</span>
|
||||
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -139,7 +165,10 @@
|
||||
});
|
||||
|
||||
|
||||
|
||||
function removeTr(selectElement){
|
||||
$(selectElement).closest('.tr-transfer').remove();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -228,6 +257,12 @@
|
||||
});
|
||||
|
||||
if(!groupOrJobEmpty){
|
||||
const editEmployeeGroupList = {
|
||||
id: 0,
|
||||
employeeId: '@Model.EmployeeId',
|
||||
schemeId: '@Model.SchemeId',
|
||||
};
|
||||
command.push(editEmployeeGroupList);
|
||||
var urlAjaxToSave = '@Url.Page("/Company/Workshops/ClassificationScheme", "EditMultipleGroupMember")';
|
||||
|
||||
$.ajax({
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
let appendData = '';
|
||||
|
||||
appendData += `<div class="row m-t-10 tr-tranfer">`;
|
||||
appendData += `<div class="row m-t-10 tr-transfer">`;
|
||||
appendData += `<div class="col-xs-6 col-md-4 mb-3">`;
|
||||
appendData += `<select name="classificationGroupId" class="form-select form-control" onchange="selectGroup(this)">`;
|
||||
appendData += `<option value="0">انتخاب گروه</option>`;
|
||||
@@ -195,8 +195,8 @@
|
||||
<input data-startdate-id="" placeholder="تاریخ انتقال" type="text" name=StartGroupDateFa" class="form-control date-input" data-val="false" />
|
||||
</div>
|
||||
<div class="col-xs-1 col-md-1">
|
||||
<a
|
||||
style="border-radius:5px;">
|
||||
<a onclick="removeTr(this)"
|
||||
style="border-radius:5px; cursor:pointer;">
|
||||
<span class="icon-sapan-delete" style="background-color:#ddd3e0">
|
||||
<svg width="21" height="21" fill="none" xmlns="http://www.w3.org/2000/svg" >
|
||||
<rect width="18.5047" height="18.5047" transform="translate(0.523438 0.523438)" fill="#DDD3E0"></rect>
|
||||
@@ -210,16 +210,17 @@
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="lineDiv" style="margin-top: 43px;"> </div>
|
||||
</div>
|
||||
|
||||
<div class="lineDiv">
|
||||
|
||||
|
||||
</div>`;
|
||||
`;
|
||||
|
||||
$('#transfer').append(appendData);
|
||||
}
|
||||
|
||||
function removeTr(selectElement){
|
||||
$(selectElement).closest('.tr-transfer').remove();
|
||||
|
||||
}
|
||||
|
||||
function selectGroup(selectElement) {
|
||||
let schemeId = '@Model.SchemeId';
|
||||
@@ -260,7 +261,7 @@
|
||||
const command = [];
|
||||
let rowValid = true;
|
||||
|
||||
$('.tr-tranfer').each(function () {
|
||||
$('.tr-transfer').each(function () {
|
||||
const $row = $(this);
|
||||
|
||||
const groupId = $row.find('select[name="classificationGroupId"]').val();
|
||||
|
||||
Reference in New Issue
Block a user