From db225fea18a88b6e15f2044df01a4e02f68dca1d Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 9 Oct 2025 12:27:20 +0330 Subject: [PATCH 1/4] feat: add "Not Created" tab and implement related functionality in InsuranceList page --- .../Repository/InsuranceListRepository.cs | 38 +-- .../Pages/Company/InsuranceList/Index.cshtml | 5 + .../Company/InsuranceList/Index.cshtml.cs | 5 + .../page/InsuranceList/js/Index.js | 323 ++++++++++++++++-- 4 files changed, 306 insertions(+), 65 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index 1419fd36..9af13e1a 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -342,43 +342,7 @@ public class InsuranceListRepository : RepositoryBase, IIns var acountId = _authHelper.CurrentAccountId(); var workshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId).Select(x => x.WorkshopId); - - #region sample - - //var query = _context.InsuranceListSet - // .Where(x => workshopIds.Contains(x.WorkshopId)) - // .Join(_context.Workshops.Include(x => x.InsuranceWorkshopInfo), - // insurance => insurance.WorkshopId, - // workshop => workshop.id, - // (insurance, workshop) => new { insurance, workshop }) - // .Join(_context.WorkshopEmployers, - // result => result.workshop.id, - // employer => employer.WorkshopId, - // (result, employer) => new InsuranceListViewModel - // { - // Id = result.insurance.id, - // Year = result.insurance.Year, - // MonthNumber = result.insurance.Month, - // Month = result.insurance.Month.GetMonthByNumber(), - // WorkShopId = result.insurance.WorkshopId, - // WorkShopCode = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.InsuranceCode : result.workshop.InsuranceCode, - // WorkShopName = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.WorkshopName : result.workshop.WorkshopFullName, - // TypeOfInsuranceSend = result.workshop.TypeOfInsuranceSend == "NormalList" ? "عادی" : - // result.workshop.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" : - // result.workshop.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "", - // FixedSalary = result.workshop.FixedSalary, - // StrFixedSalary = result.workshop.FixedSalary ? "دارد" : "ندارد", - // EmployerName = result.workshop.InsuranceWorkshopInfo != null ? result.workshop.InsuranceWorkshopInfo.EmployerName : result.workshop.WorkshopFullName, - // Branch = "", - // City = "", - // ConfirmSentlist = result.insurance.ConfirmSentlist, - // IsBlockCantracingParty = "", - // EmployerId = employer.EmployerId, - - // }); - - - #endregion + var query = _context.InsuranceListSet .Where(x => workshopIds.Contains(x.WorkshopId)) diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml index cc37be84..0191e276 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml @@ -320,6 +320,11 @@
+ + +
+
+ + +
+ +
+
+ بازرسی: + ${booleanSvgResponse(item.inspectionDone)} +
+ +
+ بدهی: + ${booleanSvgResponse(item.debtDone)} +
+
+ +
+
+ تاییده کارفرما: + ${booleanSvgResponse(item.employerApproved)} +
+ +
+ ارسال لیست: + ${booleanSvgResponse(item.confirmSentlist, item.employerApprovalStatus)} +
+
+ +
+
+ شعبه تامین اجتماعی: + ${item.branch === `` ? `-` : item.branch} +
+ +
+ لیست مقطوع: + ${item.strFixedSalary} +
+
+ +
+
+ شهرستان: + ${item.city === `` ? `-` : item.city} +
+ +
+ نوع ارسال لیست: + ${item.typeOfInsuranceSend} +
+
+ +
+
+ نام کافرما: + ${item.employerName} +
+
+ +
+ ${generateButtons(item, pathDSKKAR00, pathDSKWOR00)} +
+ +
+
`; + + pageIndexJs++; + }); + } else { + var emptyHtml = ``; + if (pageIndexJs === responseData.length) { + emptyHtml = ` +
+
+ +
اطلاعاتی وجود ندارد.
+
+
`; + } + + html += emptyHtml; + htmlMobile += emptyHtml; + hasMoreData = false; + } + + $("#load-data-html").append(html); + $("#load-data-html-mobile").append(htmlMobile); + }); + } + } $('.btn-search-click').click(function () { urlParamsSearch @@ -207,6 +470,7 @@ async function loadGetTabCounts() { try { var response = await ajaxService.get(ajaxGetTabCountsUrl, searchModel, true); + updateStatus('notStarted', response.notStarted); updateStatus('inProgress', response.inProgress); updateStatus('readyToSendList', response.readyToSendList); @@ -249,7 +513,7 @@ function loadSearchNew(status = 0) { var html = ""; var htmlMobile = ""; - + var paramsUrl = UrlParamsBuilder.readParams([ "year", "month", @@ -277,25 +541,26 @@ function loadSearchNew(status = 0) { }; var b = pageIndexJs % 30; - + if (b === 0 && hasMoreData) { ajaxService.get(ajaxSearchNewUrl, searchModel, false) .then(response => { var responseData = response.data; - if (responseData.length > 0) { + if (responseData.length > 0) { responseData.forEach(function (item) { + var n = pageIndexJs + 1; var pathDSKKAR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKKAR00.dbf"; var pathDSKWOR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKWOR00.dbf"; - + const rowBgClass = item.isBlockCantracingParty === "true" ? "tw-bg-[#b1c3c3] hover:tw-bg-[#bbc6c6]" : item.confirmSentlist - ? "tw-bg-[#d8f5d2] hover:tw-bg-[#c7ebc0]" - : (n % 2 === 0 - ? "tw-bg-[#ecffff] hover:tw-bg-[#C9F0F0]" - : "tw-bg-[#ddf4f4] hover:tw-bg-[#C9F0F0]"); + ? "tw-bg-[#d8f5d2] hover:tw-bg-[#c7ebc0]" + : (n % 2 === 0 + ? "tw-bg-[#ecffff] hover:tw-bg-[#C9F0F0]" + : "tw-bg-[#ddf4f4] hover:tw-bg-[#C9F0F0]"); html += `
@@ -307,7 +572,8 @@ function loadSearchNew(status = 0) {
${item.year}
${convertMonthToString(item.month)}
-
${item.archiveCode}
+
${item.archiveCode}
+
${item.workShopCode}
@@ -389,8 +655,9 @@ function loadSearchNew(status = 0) {
${item.year}
-
${convertMonthToString(item.month)}
-
${item.archiveCode}
+
${convertMonthToString(item.month)}
+
${item.archiveCode}
+
${item.workShopName}
@@ -505,7 +772,7 @@ function loadSearchNew(status = 0) { function generateButtons(item, pathDSKKAR00, pathDSKWOR00) { var html = ''; var htmlMobile = ''; - + var canShowActions = (currentAccountId === 1 && item.confirmSentlist) || !item.confirmSentlist; var isDisabled = item.isBlockCantracingParty === 'true' ? 'disable' : ''; @@ -548,11 +815,11 @@ function generateButtons(item, pathDSKKAR00, pathDSKWOR00) { } //if (item.inspectionDone && item.debtDone && item.employerApproved && item.confirmSentlist) { - //if (item.inspectionDone || item.debtDone || item.employerApproved || item.confirmSentlist) { + if (item.inspectionDone || item.debtDone || item.employerApproved || item.confirmSentlist) { // Confirm List and Print Button if (hasPermission_80215) { html += ` - + @@ -564,7 +831,7 @@ function generateButtons(item, pathDSKKAR00, pathDSKWOR00) { پرینت `; } - //} + } if (item.inspectionDone || item.debtDone || item.employerApproved || item.confirmSentlist) { // Summary List and Print Button @@ -627,7 +894,7 @@ function booleanSvgResponse(bool, employerApprovalStatus) { var isWrittenVerbal = employerApprovalStatus === 1; var svg = ``; - if (bool) { + if (bool) { svg = ` @@ -687,7 +954,7 @@ function convertMonthToString(value) { result = "بدون ماه"; break; } - + return result; } @@ -827,8 +1094,8 @@ searchBoxWorkshop.on('keyup keypress', function (e) { //keyboard Arrow Key Select And Enter liListWorkshop = $('#empWorkshop ul li'); mixContainerAndSerchResultWorkshop.animate({ - scrollTop: $(liListWorkshop.eq(0)).offset().top - containerWorkshop.offset().top + containerWorkshop.scrollTop() - }, + scrollTop: $(liListWorkshop.eq(0)).offset().top - containerWorkshop.offset().top + containerWorkshop.scrollTop() + }, 50); if (e.which === 40) {// if ArrowUp if (countWorkshop > 0 && countWorkshop <= liListWorkshop.length) { @@ -840,8 +1107,8 @@ searchBoxWorkshop.on('keyup keypress', function (e) { if (countWorkshop > 4) { //ScrollDown mixContainerAndSerchResultWorkshop.animate({ - scrollTop: $(liPointerWorkshop).offset().top - containerWorkshop.offset().top + containerWorkshop.scrollTop() - }, + scrollTop: $(liPointerWorkshop).offset().top - containerWorkshop.offset().top + containerWorkshop.scrollTop() + }, 50); } countWorkshop += 1; @@ -984,8 +1251,8 @@ searchBoxEmployer.on('keyup keypress', function (e) { //keyboard Arrow Key Select And Enter liListEmployer = $('#empEmployer ul li'); mixContainerAndSerchResultEmployer.animate({ - scrollTop: $(liListEmployer.eq(0)).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() - }, + scrollTop: $(liListEmployer.eq(0)).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() + }, 50); if (e.which === 40) {// if ArrowUp if (countEmployer > 0 && countEmployer <= liListEmployer.length) { @@ -997,8 +1264,8 @@ searchBoxEmployer.on('keyup keypress', function (e) { if (countEmployer > 4) { //ScrollDown mixContainerAndSerchResultEmployer.animate({ - scrollTop: $(liPointerEmployer).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() - }, + scrollTop: $(liPointerEmployer).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() + }, 50); } countEmployer += 1; @@ -1017,8 +1284,8 @@ searchBoxEmployer.on('keyup keypress', function (e) { liPointerEmployer = liListEmployer.eq(countEmployer); //ScrollUp mixContainerAndSerchResultEmployer.animate({ - scrollTop: $(liPointerEmployer).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() - }, + scrollTop: $(liPointerEmployer).offset().top - containerEmployer.offset().top + containerEmployer.scrollTop() + }, 50); } } From 70164ae4982c46a95325534f625b61f470b3bd67 Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 9 Oct 2025 13:47:43 +0330 Subject: [PATCH 2/4] feat: add "GetNotCreatedWorkshop" method to InsuranceList functionality --- .../InsuranceListAgg/IInsuranceListRepository.cs | 2 ++ .../InsuranceList/IInsuranceListApplication.cs | 3 +++ .../InsuranceListApplication.cs | 5 +++++ .../Repository/InsuranceListRepository.cs | 7 ++++++- .../Pages/Company/InsuranceList/Index.cshtml.cs | 14 ++++++++++---- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs index 1ff57039..75607aaf 100644 --- a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs +++ b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs @@ -67,6 +67,8 @@ public interface IInsuranceListRepository:IRepository Task GetTabCounts(InsuranceListSearchModel searchModel); #endregion + + Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); } diff --git a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs index a93637cb..84f5b3f2 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using _0_Framework.Application; using CompanyManagment.App.Contracts.InsuranceList; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; namespace CompanyManagment.App.Contracts.InsuranceList; @@ -47,4 +48,6 @@ public interface IInsuranceListApplication Task GetTabCounts(InsuranceListSearchModel searchModel); #endregion + + Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 3e5b1d16..14b59841 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -2366,5 +2366,10 @@ public class InsuranceListApplication : IInsuranceListApplication return _insuranceListRepositpry.GetTabCounts(searchModel); } + public async Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) + { + return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index 9af13e1a..cfd0237d 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1569,7 +1569,12 @@ public class InsuranceListRepository : RepositoryBase, IIns } - /// + public Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) + { + throw new NotImplementedException(); + } + + /// /// /// /// diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index 2cc63397..65012021 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -1162,10 +1162,16 @@ public class IndexModel : PageModel }); } - // public IActionResult OnGetNotCreatedWorkshops(InsuranceListSearchModel searchModel) - // { - // - // } + public async Task OnGetNotCreatedWorkshops(InsuranceListSearchModel searchModel) + { + var result =await _insuranceListApplication.GetNotCreatedWorkshop(searchModel); + return new JsonResult(new + { + result + + }); + + } public async Task OnGetTabCounts(InsuranceListSearchModel searchModel) { From 7a58423eb34c3e57b73ec3bac8c2ec9c3cbfced8 Mon Sep 17 00:00:00 2001 From: mahan Date: Thu, 9 Oct 2025 14:30:09 +0330 Subject: [PATCH 3/4] feat: implement "GetNotCreatedWorkshop" method and update related functionality in InsuranceList --- .../InfraStructure/QueryableExtensions.cs | 4 +- .../IInsuranceListRepository.cs | 2 +- .../IInsuranceListApplication.cs | 2 +- .../InsuranceListApplication.cs | 2 +- .../Repository/InsuranceListRepository.cs | 52 ++++++++++++++++++- .../Pages/Company/InsuranceList/Index.cshtml | 1 + .../Company/InsuranceList/Index.cshtml.cs | 2 +- .../page/InsuranceList/js/Index.js | 6 +-- 8 files changed, 60 insertions(+), 11 deletions(-) diff --git a/0_Framework/InfraStructure/QueryableExtensions.cs b/0_Framework/InfraStructure/QueryableExtensions.cs index 8d28d29f..bcfb7bc6 100644 --- a/0_Framework/InfraStructure/QueryableExtensions.cs +++ b/0_Framework/InfraStructure/QueryableExtensions.cs @@ -5,14 +5,14 @@ namespace _0_Framework.InfraStructure; public static class QueryableExtensions { - public static IQueryable ApplyPagination(this IQueryable query, int page, int pageSize) + public static IQueryable ApplyPagination(this IQueryable query, int page, int pageSize = 30) { if (page <= 0) page = 1; if (pageSize <= 0) pageSize = 10; return query.Skip((page - 1) * pageSize).Take(pageSize); } - public static IEnumerable ApplyPagination(this IEnumerable source, int page, int pageSize) + public static IEnumerable ApplyPagination(this IEnumerable source, int page, int pageSize = 30) { if (page <= 0) page = 1; if (pageSize <= 0) pageSize = 10; diff --git a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs index 75607aaf..2e7fda1d 100644 --- a/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs +++ b/Company.Domain/InsuranceListAgg/IInsuranceListRepository.cs @@ -68,7 +68,7 @@ public interface IInsuranceListRepository:IRepository #endregion - Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); + Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); } diff --git a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs index 84f5b3f2..51e29b09 100644 --- a/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs +++ b/CompanyManagment.App.Contracts/InsuranceList/IInsuranceListApplication.cs @@ -49,5 +49,5 @@ public interface IInsuranceListApplication #endregion - Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); + Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.Application/InsuranceListApplication.cs b/CompanyManagment.Application/InsuranceListApplication.cs index 14b59841..2c0e032e 100644 --- a/CompanyManagment.Application/InsuranceListApplication.cs +++ b/CompanyManagment.Application/InsuranceListApplication.cs @@ -2366,7 +2366,7 @@ public class InsuranceListApplication : IInsuranceListApplication return _insuranceListRepositpry.GetTabCounts(searchModel); } - public async Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) + public async Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) { return await _insuranceListRepositpry.GetNotCreatedWorkshop(searchModel); } diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index cfd0237d..c93e2b0c 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1473,6 +1473,7 @@ public class InsuranceListRepository : RepositoryBase, IIns var workshopIds = _context.WorkshopAccounts .Where(a => a.AccountId == acountId) .Select(a => a.WorkshopId); + var query = _context.InsuranceListSet .Where(x => workshopIds.Contains(x.WorkshopId)) .Join(_context.Workshops.Include(x => x.InsuranceWorkshopInfo), @@ -1569,9 +1570,56 @@ public class InsuranceListRepository : RepositoryBase, IIns } - public Task GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) + public async Task> GetNotCreatedWorkshop(InsuranceListSearchModel searchModel) { - throw new NotImplementedException(); + if (string.IsNullOrEmpty(searchModel.Month) || string.IsNullOrEmpty(searchModel.Year) ) + { + return []; + } + var acountId = _authHelper.CurrentAccountId(); + var accountWorkshopIds = _context.WorkshopAccounts.Where(x => x.AccountId == acountId) + .Select(x => x.WorkshopId); + + var insuranceWorkshops = _context.Workshops + .Where(x=>x.InsuranceCode != null && x.InsuranceCode.Length >=10 && accountWorkshopIds.Contains(x.id) && x.IsActiveString== "true"); + + + var existInsurances = _context.InsuranceListSet + .Where(x=>x.Month == searchModel.Month&& x.Year == searchModel.Year).AsQueryable(); + + var notCreatedWorkshop = insuranceWorkshops.Where(w=>!existInsurances.Select(x=>x.WorkshopId).Contains(w.id)); + + var res = await notCreatedWorkshop + .GroupJoin(_context.WorkshopEmployers, + workshop => workshop.id, + workshopEmployer => workshopEmployer.WorkshopId, + (workshop, workshopEmployer) => new { workshop, workshopEmployer }) + .SelectMany(x => x.workshopEmployer.DefaultIfEmpty(), (x, workshopEmployer) => new { x.workshop, workshopEmployer }) + .GroupJoin(_context.Employers, + allResult => allResult.workshopEmployer.EmployerId, + employer => employer.id, + (allResult, employer) => new { allResult.workshop, allResult.workshopEmployer, employer }) + .SelectMany(x => x.employer.DefaultIfEmpty(), (x, employer) => new { x.workshop, x.workshopEmployer, employer }) + .Select(x => new InsuranceListViewModel + { + WorkShopId = x.workshop.id, + WorkShopCode = x.workshop.InsuranceCode, + WorkShopName = x.workshop.InsuranceWorkshopInfo != null ? x.workshop.InsuranceWorkshopInfo.WorkshopName : x.workshop.WorkshopFullName, + EmployerName = x.employer != null ? x.employer.FullName : (x.workshop.InsuranceWorkshopInfo != null ? x.workshop.InsuranceWorkshopInfo.EmployerName : x.workshop.WorkshopFullName), + Year = searchModel.Year, + Month = searchModel.Month, + TypeOfInsuranceSend = x.workshop.TypeOfInsuranceSend == "NormalList" ? "عادی" : + x.workshop.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" : + x.workshop.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "", + FixedSalary = (bool)x.workshop.FixedSalary, + StrFixedSalary = (bool)x.workshop.FixedSalary ? "دارد" : "ندارد", + EmployerId = x.workshopEmployer != null ? x.workshopEmployer.EmployerId : 0, + ArchiveCode = x.workshop.ArchiveCode, + City = x.workshop.City, + }).ApplyPagination(searchModel.PageIndex).ToListAsync(); + + return res; + } /// diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml index 0191e276..63560c20 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml @@ -544,6 +544,7 @@ var ajaxGetTabCountsUrl = `@Url.Page("/Company/InsuranceList/Index", "TabCounts")`; var ajaxSearchNewUrl = `@Url.Page("/Company/InsuranceList/Index", "SearchNew")`; + var ajaxNotCreatedUrl = `@Url.Page("/Company/InsuranceList/Index", "NotCreatedWorkshops")`; var openOperationsModalUrl = `@Url.Page("/Company/InsuranceList/Index", "OperationsModal")`; var editUrl = `#showmodal=@Url.Page("/Company/InsuranceList/Index", "Edit")`; var insuranceSummaryUrl = `#showmodal=@Url.Page("/Company/InsuranceList/Index", "InsuranceSummary")`; diff --git a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs index 65012021..f327b4d5 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Company/InsuranceList/Index.cshtml.cs @@ -1167,7 +1167,7 @@ public class IndexModel : PageModel var result =await _insuranceListApplication.GetNotCreatedWorkshop(searchModel); return new JsonResult(new { - result + data = result }); diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js index a6f2797c..1b8b78fd 100644 --- a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js +++ b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js @@ -125,7 +125,7 @@ $(document).ready(function () { }); function loadNotCreatedData() { var pageIndex = pageIndexJs; - + var html = ""; var htmlMobile = ""; @@ -151,17 +151,17 @@ $(document).ready(function () { //Branch: paramsUrl['branch'], //City: paramsUrl['city'], FixedSalary: paramsUrl['fixed-salary'], - Status: status, PageIndex: pageIndex }; var b = pageIndexJs % 30; if (b === 0 && hasMoreData) { - ajaxService.get(ajaxSearchNewUrl, searchModel, false) + ajaxService.get(ajaxNotCreatedUrl, searchModel, false) .then(response => { var responseData = response.data; + debugger; if (responseData.length > 0) { responseData.forEach(function (item) { From ed5681256d3200f438725ac9060f688086b63068 Mon Sep 17 00:00:00 2001 From: mahan Date: Sat, 11 Oct 2025 13:14:30 +0330 Subject: [PATCH 4/4] feat: enhance "Not Created" tab functionality and improve data loading in InsuranceList --- .../Repository/InsuranceListRepository.cs | 2 +- .../page/InsuranceList/js/Index.js | 244 +++++++++--------- 2 files changed, 127 insertions(+), 119 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs index c93e2b0c..94cc98f4 100644 --- a/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs +++ b/CompanyManagment.EFCore/Repository/InsuranceListRepository.cs @@ -1616,7 +1616,7 @@ public class InsuranceListRepository : RepositoryBase, IIns EmployerId = x.workshopEmployer != null ? x.workshopEmployer.EmployerId : 0, ArchiveCode = x.workshop.ArchiveCode, City = x.workshop.City, - }).ApplyPagination(searchModel.PageIndex).ToListAsync(); + }).Skip(searchModel.PageIndex).Take(30).ToListAsync(); return res; diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js index 1b8b78fd..84bb6e3b 100644 --- a/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js +++ b/ServiceHost/wwwroot/AssetsAdmin/page/InsuranceList/js/Index.js @@ -123,61 +123,118 @@ $(document).ready(function () { default: } }); - function loadNotCreatedData() { - var pageIndex = pageIndexJs; - - var html = ""; - var htmlMobile = ""; + - var paramsUrl = UrlParamsBuilder.readParams([ - "year", - "month", - "workshop-code", - "employee-id", - "workshop-id", - "type-of-insurance", - //"branch", - //"city", - "fixed-salary" - ]); + $('.btn-search-click').click(function () { + urlParamsSearch + .addParam("year", $("#searchModel_Year").val()) + .addParam("month", $("#searchModel_Month").val()) + .addParam("workshop-code", $("#searchModel_WorkShopCode").val()) + .addParam("employee-id", $("#searchModel_EmployerId").val() === "0" ? "" : $("#searchModel_EmployerId").val()) + .addParam("employee-name", $("#empSearchEmployer").val()) + .addParam("workshop-id", $("#searchModel_WorkshopId").val() === "0" ? "" : $("#searchModel_WorkshopId").val()) + .addParam("workshop-name", $("#empSearchWorkshop").val()) + .addParam("type-of-insurance", $("#searchModel_TypeOfInsuranceSend").val()) + //.addParam("branch", $("#searchModel_Branch").val()) + //.addParam("city", $("#searchModel_City").val()) + .addParam("fixed-salary", $("#searchModel_FixedSalary").val()) + .pushState(); - var searchModel = { - Year: paramsUrl['year'] !== "" ? paramsUrl['year'] : year, - Month: paramsUrl['month'] !== "" ? paramsUrl['month'] : month, - WorkShopCode: paramsUrl['workshop-code'], - EmployerId: paramsUrl['employee-id'], - WorkshopId: paramsUrl['workshop-id'], - TypeOfInsuranceSend: paramsUrl['type-of-insurance'], - //Branch: paramsUrl['branch'], - //City: paramsUrl['city'], - FixedSalary: paramsUrl['fixed-salary'], - PageIndex: pageIndex - }; + var $activeTab = $('.tab-bar__tab--active'); + var activeValue = $activeTab.val(); - var b = pageIndexJs % 30; + pageIndexJs = 0; + hasMoreData = true; + $("#load-data-html-mobile").html(''); + $('#load-data-html').html(''); + loadGetTabCounts(); + if(activeValue==="4") + loadNotCreatedData(); + else + loadSearchNew(activeValue); - if (b === 0 && hasMoreData) { - ajaxService.get(ajaxNotCreatedUrl, searchModel, false) - .then(response => { - var responseData = response.data; + $('.btn-clear-filter').removeClass('disable'); + }); - debugger; - if (responseData.length > 0) { - responseData.forEach(function (item) { + $('#closeModal').click(function () { + $('#MainModal').modal('hide'); + }); - var n = pageIndexJs + 1; - var pathDSKKAR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKKAR00.dbf"; - var pathDSKWOR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKWOR00.dbf"; + loadGetTabCounts(); + //loadSearchNew(); + // Active Tabs by Permission and Load Search New Function + let found = false; + $(".tab-bar__tab").removeClass("tab-bar__tab--active"); + $(".tab-bar__tab").each(function () { + var permission = $(this).data("permission"); - const rowBgClass = item.isBlockCantracingParty === "true" - ? "tw-bg-[#b1c3c3] hover:tw-bg-[#bbc6c6]" - : item.confirmSentlist - ? "tw-bg-[#d8f5d2] hover:tw-bg-[#c7ebc0]" - : (n % 2 === 0 - ? "tw-bg-[#ecffff] hover:tw-bg-[#C9F0F0]" - : "tw-bg-[#ddf4f4] hover:tw-bg-[#C9F0F0]"); + if (!found && permissions[permission] === true || permissions[permission] === "true") { + $(this).addClass("tab-bar__tab--active"); - html += ` + var status = parseInt($(this).val()); + if (status === 4) + loadNotCreatedData(); + else + loadSearchNew(status); + + found = true; + } + }); +}); +function loadNotCreatedData() { + var pageIndex = pageIndexJs; + + var html = ""; + var htmlMobile = ""; + + var paramsUrl = UrlParamsBuilder.readParams([ + "year", + "month", + "workshop-code", + "employee-id", + "workshop-id", + "type-of-insurance", + //"branch", + //"city", + "fixed-salary" + ]); + + var searchModel = { + Year: paramsUrl['year'] !== "" ? paramsUrl['year'] : year, + Month: paramsUrl['month'] !== "" ? paramsUrl['month'] : month, + WorkShopCode: paramsUrl['workshop-code'], + EmployerId: paramsUrl['employee-id'], + WorkshopId: paramsUrl['workshop-id'], + TypeOfInsuranceSend: paramsUrl['type-of-insurance'], + //Branch: paramsUrl['branch'], + //City: paramsUrl['city'], + FixedSalary: paramsUrl['fixed-salary'], + PageIndex: pageIndex + }; + + var b = pageIndexJs % 30; + + if (b === 0 && hasMoreData) { + ajaxService.get(ajaxNotCreatedUrl, searchModel, false) + .then(response => { + var responseData = response.data; + + if (responseData.length > 0) { + responseData.forEach(function (item) { + + var n = pageIndexJs + 1; + var pathDSKKAR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKKAR00.dbf"; + var pathDSKWOR00 = item.workShopId + "\\" + item.year + "_" + item.month + "\\DSKWOR00.dbf"; + + const rowBgClass = item.isBlockCantracingParty === "true" + ? "tw-bg-[#b1c3c3] hover:tw-bg-[#bbc6c6]" + : item.confirmSentlist + ? "tw-bg-[#d8f5d2] hover:tw-bg-[#c7ebc0]" + : (n % 2 === 0 + ? "tw-bg-[#ecffff] hover:tw-bg-[#C9F0F0]" + : "tw-bg-[#ddf4f4] hover:tw-bg-[#C9F0F0]"); + + html += `
@@ -223,7 +280,7 @@ $(document).ready(function () {
- ${generateButtons(item, pathDSKKAR00, pathDSKWOR00)} +
@@ -261,7 +318,7 @@ $(document).ready(function () {
`; - htmlMobile += `
+ htmlMobile += `
@@ -353,88 +410,36 @@ $(document).ready(function () {
- ${generateButtons(item, pathDSKKAR00, pathDSKWOR00)} +
`; - pageIndexJs++; - }); - } else { - var emptyHtml = ``; - if (pageIndexJs === responseData.length) { - emptyHtml = ` + pageIndexJs++; + }); + } else { + var emptyHtml = ``; + if (pageIndexJs === responseData.length) { + emptyHtml = `
اطلاعاتی وجود ندارد.
`; - } - - html += emptyHtml; - htmlMobile += emptyHtml; - hasMoreData = false; } - $("#load-data-html").append(html); - $("#load-data-html-mobile").append(htmlMobile); - }); - } + html += emptyHtml; + htmlMobile += emptyHtml; + hasMoreData = false; + } + + $("#load-data-html").append(html); + $("#load-data-html-mobile").append(htmlMobile); + }); } - - $('.btn-search-click').click(function () { - urlParamsSearch - .addParam("year", $("#searchModel_Year").val()) - .addParam("month", $("#searchModel_Month").val()) - .addParam("workshop-code", $("#searchModel_WorkShopCode").val()) - .addParam("employee-id", $("#searchModel_EmployerId").val() === "0" ? "" : $("#searchModel_EmployerId").val()) - .addParam("employee-name", $("#empSearchEmployer").val()) - .addParam("workshop-id", $("#searchModel_WorkshopId").val() === "0" ? "" : $("#searchModel_WorkshopId").val()) - .addParam("workshop-name", $("#empSearchWorkshop").val()) - .addParam("type-of-insurance", $("#searchModel_TypeOfInsuranceSend").val()) - //.addParam("branch", $("#searchModel_Branch").val()) - //.addParam("city", $("#searchModel_City").val()) - .addParam("fixed-salary", $("#searchModel_FixedSalary").val()) - .pushState(); - - var $activeTab = $('.tab-bar__tab--active'); - var activeValue = $activeTab.val(); - - pageIndexJs = 0; - hasMoreData = true; - $("#load-data-html-mobile").html(''); - $('#load-data-html').html(''); - loadGetTabCounts(); - loadSearchNew(activeValue); - - $('.btn-clear-filter').removeClass('disable'); - }); - - $('#closeModal').click(function () { - $('#MainModal').modal('hide'); - }); - - loadGetTabCounts(); - //loadSearchNew(); - // Active Tabs by Permission and Load Search New Function - let found = false; - $(".tab-bar__tab").removeClass("tab-bar__tab--active"); - $(".tab-bar__tab").each(function () { - var permission = $(this).data("permission"); - - if (!found && permissions[permission] === true || permissions[permission] === "true") { - $(this).addClass("tab-bar__tab--active"); - - var status = parseInt($(this).val()); - loadSearchNew(status); - - found = true; - } - }); -}); - +} function removeSearch() { window.location.href = baseUrl; } @@ -498,7 +503,10 @@ $(window).scroll(function () { if ($(window).scrollTop() + $(window).height() > $(document).height() - 600) { var $activeTab = $('.tab-bar__tab--active'); var activeValue = $activeTab.val(); - loadSearchNew(activeValue); + if (activeValue==="4") + loadNotCreatedData(); + else + loadSearchNew(activeValue); } if ($(this).scrollTop() > 100) {