Commit 002f472e by 纪旭 韦

人员字典标签下载只显示开启的列头

parent 2126f8d4
......@@ -164,8 +164,8 @@ public ApiResponse GetReportPersonTag(int hospitalId, int allotId)
var relust = reportGlobalService.GetReportPersonTag(hospitalId, allotId);
return new ApiResponse(ResponseType.OK, new
{
relust.ColHeaders,
relust.Data
relust.handsonTable.ColHeaders,
relust.handsonTable.Data
});
}
/// <summary>
......@@ -179,13 +179,13 @@ public ApiResponse GetReportPersonTag(int hospitalId, int allotId)
public ActionResult DownloadReportPersonTag(int hospitalId, int allotId)
{
var result = reportGlobalService.GetReportPersonTag(hospitalId, allotId).Data;
var (result, colHeaders) = reportGlobalService.GetReportPersonTag(hospitalId, allotId);
var ser = JsonHelper.Serialize(result);
var rows = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var filepath = reportGlobalService.ReportPersonTagDownload(rows, "人员标签");
var filepath = reportGlobalService.ReportPersonTagDownload(rows, colHeaders, "人员标签");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......
......@@ -544,7 +544,7 @@ private T GetCellValue<T>(IRow row, List<string> columns, string key)
#region 人员、科室标签配置
public HandsonTable GetReportPersonTag(int hospitalId, int allotId)
public (HandsonTable handsonTable, List<string> colHeaders) GetReportPersonTag(int hospitalId, int allotId)
{
var hos = _hospitalRepository.GetEntity(t => t.ID == hospitalId);
var columnHeaders = _computeService.CustomColumnHeaders(hos, "/result/all_employee");
......@@ -590,7 +590,7 @@ select new
Tag5 = t?.Tag5,
}).Distinct()?.ToList();
if (data == null || !data.Any()) return result;
if (data == null || !data.Any()) return (result,null);
var users = new List<sys_user>();
if (hos?.IsOwnerQuery == 1)
......@@ -630,10 +630,10 @@ select new
if (columns.Contains(t.Data))
t.ReadOnly = true;
});
return result;
return (result, result.ColHeaders.ToList());
}
public string ReportPersonTagDownload(List<Dictionary<string, object>> rows, string title)
public string ReportPersonTagDownload(List<Dictionary<string, object>> rows, List<string> colHeaders, string title)
{
var data = new List<Dictionary<string, object>>();
foreach (var obj in rows)
......@@ -662,17 +662,16 @@ public string ReportPersonTagDownload(List<Dictionary<string, object>> rows, str
{
worksheet.SetValue(1, 1, title);
var headList = data.FirstOrDefault().ToList();
for (int col = 0; col < headList.Count; col++)
for (int col = 0; col < colHeaders.Count; col++)
{
worksheet.SetValue(2, col + 1, headList[col].Key);
worksheet.SetValue(2, col + 1, colHeaders[col]);
}
for (int col = 0; col < headList.Count; col++)
for (int col = 0; col < colHeaders.Count; col++)
{
for (int row = 0; row < data.Count(); row++)
{
var temp = data.ElementAt(row);
var value = temp[headList[col].Key] != null ? temp[headList[col].Key].ToString() : temp[headList[col].Key];
var value = temp[colHeaders[col]] != null ? temp[colHeaders[col]].ToString() : temp[colHeaders[col]];
worksheet.Cells[row + 3, col + 1].Value = value;
}
......@@ -689,10 +688,10 @@ public string ReportPersonTagDownload(List<Dictionary<string, object>> rows, str
worksheet.Cells[row, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
}
}
worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, colHeaders.Count].Merge = true;
worksheet.Cells[1, 1, 1, colHeaders.Count].Style.Font.Bold = true;
worksheet.Cells[1, 1, 1, colHeaders.Count].Style.Font.Size = 16;
worksheet.Cells[2, 1, 2, colHeaders.Count].Style.Font.Bold = true;
worksheet.Row(1).Height = 24;
worksheet.View.FreezePanes(3, 1);
worksheet.Cells.AutoFitColumns();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment