From 44b59c6ce045cc83ec395066019c64d610da4ae7 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 28 May 2024 17:19:28 +0800 Subject: [PATCH] Fixed: Local cache filter parameter error --- .../TagHelpers/TagHelperPlusAbpSelectTagHelperService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EasyAbp.Abp.TagHelperPlus/EasyAbp/Abp/TagHelperPlus/TagHelpers/TagHelperPlusAbpSelectTagHelperService.cs b/src/EasyAbp.Abp.TagHelperPlus/EasyAbp/Abp/TagHelperPlus/TagHelpers/TagHelperPlusAbpSelectTagHelperService.cs index 4059a1d..49e6cfb 100644 --- a/src/EasyAbp.Abp.TagHelperPlus/EasyAbp/Abp/TagHelperPlus/TagHelpers/TagHelperPlusAbpSelectTagHelperService.cs +++ b/src/EasyAbp.Abp.TagHelperPlus/EasyAbp/Abp/TagHelperPlus/TagHelpers/TagHelperPlusAbpSelectTagHelperService.cs @@ -131,7 +131,7 @@ protected virtual string GetScriptCode(TagHelperContext context, EasySelectorAtt var dropdownParent = easySelectorAttribute.RunScriptOnWindowLoad ? "" : $"dropdownParent: $('#{tagId}').parent().parent(),"; - var transport = easySelectorAttribute.EnableCache ? $",transport:function(params,success,failure){{if(!params.data.filter&¶ms.data.skipCount<{tagId.ToCamelCase()}cacheList.length){{return success({{totalCount:{tagId.ToCamelCase()}cacheList.length,{easySelectorAttribute.ItemListPropertyName}:{tagId.ToCamelCase()}cacheList}});}}if(params.data.filter&&{tagId.ToCamelCase()}cacheList.length&¶ms.data.skipCountparams.data.skipCount)return success({{totalCount:params.data.maxResultCount*2,{easySelectorAttribute.ItemListPropertyName}:matchList}});}}if(params.data.skipCount != 0 && {tagId.ToCamelCase()}cacheList.length > params.data.skipCount - params.data.maxResultCount){{params.data.skipCount -= params.data.maxResultCount;}}var $request=$.ajax(params);$request.then((res)=>{{res.{easySelectorAttribute.ItemListPropertyName} = res.{easySelectorAttribute.ItemListPropertyName}.filter(v => {{ return {tagId.ToCamelCase()}cacheList.every(e => e.{easySelectorAttribute.KeyPropertyName} != v.{easySelectorAttribute.KeyPropertyName}); }});{tagId.ToCamelCase()}cacheList = [...{tagId.ToCamelCase()}cacheList, ...res.{easySelectorAttribute.ItemListPropertyName}];success(res);}});$request.fail(failure);return $request;}}" : ""; + var transport = easySelectorAttribute.EnableCache ? $",transport:function(params,success,failure){{if(!params.data.{easySelectorAttribute.FilterParamName}&¶ms.data.skipCount<{tagId.ToCamelCase()}cacheList.length){{return success({{totalCount:{tagId.ToCamelCase()}cacheList.length,{easySelectorAttribute.ItemListPropertyName}:{tagId.ToCamelCase()}cacheList}});}}if(params.data.{easySelectorAttribute.FilterParamName}&&{tagId.ToCamelCase()}cacheList.length&¶ms.data.skipCountparams.data.skipCount)return success({{totalCount:params.data.maxResultCount*2,{easySelectorAttribute.ItemListPropertyName}:matchList}});}}if(params.data.skipCount != 0 && {tagId.ToCamelCase()}cacheList.length > params.data.skipCount - params.data.maxResultCount){{params.data.skipCount -= params.data.maxResultCount;}}var $request=$.ajax(params);$request.then((res)=>{{res.{easySelectorAttribute.ItemListPropertyName} = res.{easySelectorAttribute.ItemListPropertyName}.filter(v => {{ return {tagId.ToCamelCase()}cacheList.every(e => e.{easySelectorAttribute.KeyPropertyName} != v.{easySelectorAttribute.KeyPropertyName}); }});{tagId.ToCamelCase()}cacheList = [...{tagId.ToCamelCase()}cacheList, ...res.{easySelectorAttribute.ItemListPropertyName}];success(res);}});$request.fail(failure);return $request;}}" : ""; var baseUrl = configuration?.BaseUrl; var innerCode = $"$(function () {{ let {tagId.ToCamelCase()}cacheList = [];let currentValues = {_jsonSerializer.Serialize(currentValues)}; function stringMatch(term,candidate){{return candidate&&candidate.toLowerCase().indexOf(term.toLowerCase())>=0}}; function matchCustom(params,data){{if($.trim(params.term)===\"\"){{return data}}if(typeof data.text===\"undefined\"){{return null}}if(stringMatch(params.term,data.text)){{return data}}if(stringMatch(params.term,state.id)){{return data}}return null}}; let select2Item = function (state) {{ return $('' + state.text{subTextContent} + ''); }}; let select2Option = {{ allowClear: true,minimumInputLength:{easySelectorAttribute.MinimumInputLength}, width: \"100%\", matcher: matchCustom, templateResult: select2Item, templateSelection: select2Item,{dropdownParent} ajax: {{ url: '{baseUrl}{easySelectorAttribute.GetListedDataSourceUrl}', dataType: \"json\", delay: {easySelectorAttribute.Delay}, data: function (params) {{ params.page = params.page || 1; return {{ {easySelectorAttribute.FilterParamName}: params.term, skipCount: (params.page - 1) * {easySelectorAttribute.MaxResultCount}, maxResultCount: {easySelectorAttribute.MaxResultCount}, }} }}{transport}, processResults: function (data, params) {{ params.page = params.page || 1; return {{ results: data.{easySelectorAttribute.ItemListPropertyName}.map(function (item) {{ return {{ id: item.{easySelectorAttribute.KeyPropertyName}, text: item.{easySelectorAttribute.TextPropertyName} ?? item.{easySelectorAttribute.AlternativeTextPropertyName} }} }}), pagination: {{ more: (params.page * {easySelectorAttribute.MaxResultCount}) < data.totalCount }} }}; }}, cache: true }}, placeholder: {{ id: '', text: '{placeHolder}' }} }}; $(\"#{tagId}\").select2(select2Option); currentValues && currentValues.values.forEach(function(e) {{ if (!$(\"#{tagId}\").find('option:contains(' + e + ')').length && (e != \"00000000-0000-0000-0000-000000000000\" && e != \"\" && e != \"0\")) abp.ajax({{ type: 'GET', url: '{baseUrl}{easySelectorAttribute.GetSingleDataSourceUrl}'.replace('{{id}}', e), success: function (result) {{ $(\"#{tagId}\").append($('