新增业务打印绑定功能,整合打印模板与业务数据的映射配置,优化打印数据生成逻辑。新增免密接口,支持桌面端打印模板的查询与列表展示,提升用户体验和系统的实时数据同步能力。同时,重构相关控制器以增强系统的可维护性和扩展性。
This commit is contained in:
@@ -244,8 +244,10 @@ public static class NativePrintRenderService
|
||||
double fs, string fw, string color, string align, double lh,
|
||||
double designY, double pageHeightMm, int totalPages, bool bandRepeat = false)
|
||||
{
|
||||
var type = ReadAsString(el["type"], "text");
|
||||
var bindField = ReadAsString(el["bindField"]);
|
||||
var type = ReadAsString(el["type"], "text");
|
||||
// 设计器默认 bindField 为空字符串 "",须视为「未绑定」,否则误走数据分支导致标题等只剩空串
|
||||
var bindFieldRaw = ReadAsString(el["bindField"]);
|
||||
var bindField = string.IsNullOrWhiteSpace(bindFieldRaw) ? null : bindFieldRaw.Trim();
|
||||
string text;
|
||||
|
||||
if (type == "date")
|
||||
@@ -258,7 +260,8 @@ public static class NativePrintRenderService
|
||||
}
|
||||
else if (bindField != null)
|
||||
{
|
||||
text = ResolveField(data, bindField)?.ToString() ?? ReadAsString(el["text"], string.Empty);
|
||||
// 已绑定数据字段:缺键或解析不到时留空,不回退到画布上的设计占位 text(否则会误显示「采购订单」等)
|
||||
text = ResolveField(data, bindField)?.ToString() ?? string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -291,10 +294,11 @@ public static class NativePrintRenderService
|
||||
private static string RenderQrCode(JsonNode el, JsonObject data, string posStyle, double w, double h,
|
||||
bool bandRepeat = false, double designY = 0, double pageHeightMm = 0, int totalPages = 1)
|
||||
{
|
||||
var bindField = ReadAsString(el["bindField"]);
|
||||
var value = ReadAsString(el["value"], string.Empty);
|
||||
var bindFieldRaw = ReadAsString(el["bindField"]);
|
||||
var bindField = string.IsNullOrWhiteSpace(bindFieldRaw) ? null : bindFieldRaw.Trim();
|
||||
var value = ReadAsString(el["value"], string.Empty);
|
||||
if (bindField != null)
|
||||
value = ResolveField(data, bindField)?.ToString() ?? value;
|
||||
value = ResolveField(data, bindField)?.ToString() ?? string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
|
||||
|
||||
string inner;
|
||||
@@ -332,10 +336,11 @@ public static class NativePrintRenderService
|
||||
private static string RenderBarcode(JsonNode el, JsonObject data, string posStyle, double w, double h,
|
||||
bool bandRepeat = false, double designY = 0, double pageHeightMm = 0, int totalPages = 1)
|
||||
{
|
||||
var bindField = ReadAsString(el["bindField"]);
|
||||
var value = ReadAsString(el["value"], string.Empty);
|
||||
var bindFieldRaw = ReadAsString(el["bindField"]);
|
||||
var bindField = string.IsNullOrWhiteSpace(bindFieldRaw) ? null : bindFieldRaw.Trim();
|
||||
var value = ReadAsString(el["value"], string.Empty);
|
||||
if (bindField != null)
|
||||
value = ResolveField(data, bindField)?.ToString() ?? value;
|
||||
value = ResolveField(data, bindField)?.ToString() ?? string.Empty;
|
||||
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
|
||||
|
||||
// 从元素配置取格式/显示文字开关;元素未设时按 Code128 + 显示文字默认
|
||||
@@ -714,10 +719,11 @@ public static class NativePrintRenderService
|
||||
private static string RenderImage(JsonNode el, JsonObject data, string posStyle,
|
||||
bool bandRepeat = false, double designY = 0, double pageHeightMm = 0, int totalPages = 1)
|
||||
{
|
||||
var bindField = ReadAsString(el["bindField"]);
|
||||
var src = ReadAsString(el["src"], string.Empty);
|
||||
var bindFieldRaw = ReadAsString(el["bindField"]);
|
||||
var bindField = string.IsNullOrWhiteSpace(bindFieldRaw) ? null : bindFieldRaw.Trim();
|
||||
var src = ReadAsString(el["src"], string.Empty);
|
||||
if (bindField != null)
|
||||
src = ResolveField(data, bindField)?.ToString() ?? src;
|
||||
src = ResolveField(data, bindField)?.ToString() ?? string.Empty;
|
||||
var fit = ReadAsString(el["fit"], "contain");
|
||||
var objFit = fit switch { "fill" => "fill", "cover" => "cover", _ => "contain" };
|
||||
var inner = $"<img src=\"{EscapeHtml(src)}\" style=\"width:100%;height:100%;object-fit:{objFit};\" />";
|
||||
@@ -1147,7 +1153,7 @@ public static class NativePrintRenderService
|
||||
// 解析原始值
|
||||
string rawValue;
|
||||
if (!string.IsNullOrWhiteSpace(cell.BindField))
|
||||
rawValue = ResolveField(data, cell.BindField!)?.ToString() ?? cell.Text;
|
||||
rawValue = ResolveField(data, cell.BindField!)?.ToString() ?? string.Empty;
|
||||
else
|
||||
rawValue = cell.Text;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user