😎同步更新(1、table增加动态列功能 2、优化更新记录时间 3、优化dict特性)
This commit is contained in:
parent
01274ae603
commit
143c4992ff
@ -40,19 +40,13 @@ public class DictAttribute : ValidationAttribute, ITransient
|
||||
// 是否忽略空字符串
|
||||
if (AllowEmptyStrings && string.IsNullOrEmpty(valueAsString)) return ValidationResult.Success;
|
||||
|
||||
// 查询缓存中是否存在
|
||||
var cacheServiceProvider = validationContext.GetRequiredService<SysCacheService>();
|
||||
var sysDictDataServiceProvider = validationContext.GetRequiredService<SysDictDataService>();
|
||||
var dictDataList = sysDictDataServiceProvider.GetDataList(DictTypeCode).Result;
|
||||
|
||||
string cacheKey = $"{CacheConst.KeyDict}{DictTypeCode}";
|
||||
var dictDataList = cacheServiceProvider.Get<HashSet<SysDictData>>(cacheKey);
|
||||
if (dictDataList == null)
|
||||
{
|
||||
dictDataList = sysDictDataServiceProvider.GetDataList(DictTypeCode).Result.ToHashSet();
|
||||
cacheServiceProvider.Set(cacheKey, dictDataList);
|
||||
}
|
||||
// 使用HashSet来提高查找效率
|
||||
var dictCodes = new HashSet<string>(dictDataList.Select(u => u.Code));
|
||||
|
||||
if (!dictDataList.Select(u => u.Code).ToHashSet().Contains(valueAsString))
|
||||
if (!dictCodes.Contains(valueAsString))
|
||||
return new ValidationResult($"提示:{ErrorMessage}|字典【{DictTypeCode}】不包含【{valueAsString}】!");
|
||||
else
|
||||
return ValidationResult.Success;
|
||||
|
||||
@ -173,11 +173,17 @@ public class SysDictDataService : IDynamicApiController, ITransient
|
||||
[DisplayName("根据字典类型编码获取字典值集合")]
|
||||
public async Task<List<SysDictData>> GetDataList(string code)
|
||||
{
|
||||
return await _sysDictDataRep.Context.Queryable<SysDictType>()
|
||||
.LeftJoin<SysDictData>((u, a) => u.Id == a.DictTypeId)
|
||||
.Where((u, a) => u.Code == code && u.Status == StatusEnum.Enable && a.Status == StatusEnum.Enable)
|
||||
.OrderBy((u, a) => new { a.OrderNo, a.Code })
|
||||
.Select((u, a) => a).ToListAsync();
|
||||
var dictDataList = _sysCacheService.Get<List<SysDictData>>($"{CacheConst.KeyDict}{code}");
|
||||
if (dictDataList == null)
|
||||
{
|
||||
dictDataList = await _sysDictDataRep.Context.Queryable<SysDictType>()
|
||||
.LeftJoin<SysDictData>((u, a) => u.Id == a.DictTypeId)
|
||||
.Where((u, a) => u.Code == code && u.Status == StatusEnum.Enable && a.Status == StatusEnum.Enable)
|
||||
.OrderBy((u, a) => new { a.OrderNo, a.Code })
|
||||
.Select((u, a) => a).ToListAsync();
|
||||
_sysCacheService.Set($"{CacheConst.KeyDict}{code}", dictDataList);
|
||||
}
|
||||
return dictDataList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -447,12 +447,7 @@ const switchFixed = () => {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (props.defaultSort) {
|
||||
state.page.field = props.defaultSort.prop;
|
||||
state.page.order = props.defaultSort.order;
|
||||
}
|
||||
state.page.pageSize = props.config.pageSize ?? 10;
|
||||
const refreshColumns = () => {
|
||||
state.oldColumns = JSON.parse(JSON.stringify(props.columns));
|
||||
state.columns = props.columns;
|
||||
for (let item of state.columns) {
|
||||
@ -465,6 +460,15 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (props.defaultSort) {
|
||||
state.page.field = props.defaultSort.prop;
|
||||
state.page.order = props.defaultSort.order;
|
||||
}
|
||||
state.page.pageSize = props.config.pageSize ?? 10;
|
||||
refreshColumns();
|
||||
handleList();
|
||||
});
|
||||
|
||||
@ -475,7 +479,7 @@ defineExpose({
|
||||
toggleSelection,
|
||||
getTableData,
|
||||
setTableData,
|
||||
switchFixed,
|
||||
refreshColumns,
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
</template>
|
||||
<div class="commit">
|
||||
<el-timeline style="max-width: 600px" v-if="state.list.length > 0">
|
||||
<el-timeline-item v-for="(item, index) in state.list" :key="index" :timestamp="item.commit.committer.date">
|
||||
<el-timeline-item v-for="(item, index) in state.list" :key="index" :timestamp="item.commit.committer.date.replace(/[T+]/g, ' ')">
|
||||
<el-link :href="item.html_url" target="_blank"> {{ item.commit.message }}</el-link>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user