fix 修复 excel 表达式字典 下拉框导出格式错误
This commit is contained in:
parent
591331b70c
commit
3d406c2d07
@ -20,6 +20,7 @@ import org.dromara.common.core.exception.ServiceException;
|
|||||||
import org.dromara.common.core.service.DictService;
|
import org.dromara.common.core.service.DictService;
|
||||||
import org.dromara.common.core.utils.SpringUtils;
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
import org.dromara.common.core.utils.StreamUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
import org.dromara.common.excel.annotation.ExcelEnumFormat;
|
||||||
|
|
||||||
@ -99,15 +100,16 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
|||||||
ExcelDictFormat format = field.getDeclaredAnnotation(ExcelDictFormat.class);
|
ExcelDictFormat format = field.getDeclaredAnnotation(ExcelDictFormat.class);
|
||||||
String dictType = format.dictType();
|
String dictType = format.dictType();
|
||||||
String converterExp = format.readConverterExp();
|
String converterExp = format.readConverterExp();
|
||||||
if (StrUtil.isNotBlank(dictType)) {
|
if (StringUtils.isNotBlank(dictType)) {
|
||||||
// 如果传递了字典名,则依据字典建立下拉
|
// 如果传递了字典名,则依据字典建立下拉
|
||||||
Collection<String> values = Optional.ofNullable(dictService.getAllDictByDictType(dictType))
|
Collection<String> values = Optional.ofNullable(dictService.getAllDictByDictType(dictType))
|
||||||
.orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType)))
|
.orElseThrow(() -> new ServiceException(String.format("字典 %s 不存在", dictType)))
|
||||||
.values();
|
.values();
|
||||||
options = new ArrayList<>(values);
|
options = new ArrayList<>(values);
|
||||||
} else if (StrUtil.isNotBlank(converterExp)) {
|
} else if (StringUtils.isNotBlank(converterExp)) {
|
||||||
// 如果指定了确切的值,则直接解析确切的值
|
// 如果指定了确切的值,则直接解析确切的值
|
||||||
options = StrUtil.split(converterExp, format.separator(), true, true);
|
List<String> strList = StringUtils.splitList(converterExp, format.separator());
|
||||||
|
options = StreamUtils.toList(strList, s -> StringUtils.split(s, "=")[1]);
|
||||||
}
|
}
|
||||||
} else if (field.isAnnotationPresent(ExcelEnumFormat.class)) {
|
} else if (field.isAnnotationPresent(ExcelEnumFormat.class)) {
|
||||||
// 否则如果指定了@ExcelEnumFormat,则使用枚举的逻辑
|
// 否则如果指定了@ExcelEnumFormat,则使用枚举的逻辑
|
||||||
|
Loading…
x
Reference in New Issue
Block a user