Skip to content

Commit

Permalink
#65 报表界面支持加载organizations.parent.name数据,支持无限层递归
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlianghui committed Jun 5, 2019
1 parent 57ebde9 commit cd7eb79
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/report/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ let reporter = {
"organization.name": "组织A"
}]
}
支持无限层递归
*/
for(let k in object){
item[`${parentKey}.${k}`] = object[k];
let childKey = `${parentKey}.${k}`;
let childValue = object[k];
if (typeof childValue === "object") {
processChildren(item, childKey, childValue);
}
else{
item[childKey] = childValue;
}
}
}
items.forEach((item) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/report/reports/temp.mrt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ReportVersion":"2019.2.1","ReportGuid":"e18a5c02d50f01f55ef71a64c96b8065","ReportName":"Report","ReportAlias":"Report","ReportFile":"temp.mrt","ReportCreated":"/Date(1559512584000+0800)/","ReportChanged":"/Date(1559512584000+0800)/","EngineVersion":"EngineV2","CalculationMode":"Interpretation","ReportUnit":"Centimeters","PreviewSettings":268435455,"Dictionary":{"DataSources":{"0":{"Ident":"StiDataTableSource","Name":"project_issues","Alias":"问题","Columns":{"0":{"Name":"name","Index":-1,"NameInSource":"name","Alias":"问题标题","Type":"System.String"},"1":{"Name":"organization.name","Index":-1,"NameInSource":"organization.name","Alias":"提报部门.名称","Type":"System.String"}},"NameInSource":"问题按类型统计报表.project_issues"}},"Databases":{"0":{"Ident":"StiJsonDatabase","Name":"问题按类型统计报表","Alias":"问题按类型统计报表","PathData":"/api/report/data/temp"}}},"Pages":{"0":{"Ident":"StiPage","Name":"Page1","Guid":"47bcaf029c0e3c47e55d68b8741289c1","Interaction":{"Ident":"StiInteraction"},"Border":";;2;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiHeaderBand","Name":"Headerproject_issues","ClientRectangle":"0,0.4,19.01,0.8","Interaction":{"Ident":"StiInteraction"},"Border":";;;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiText","Name":"Headerproject_issues_name","Guid":"6aaa4ad48580233c007cc95b785e65d5","ClientRectangle":"0,0,9.6,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"问题标题"},"VertAlignment":"Center","Font":";10;Bold;","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"1":{"Ident":"StiText","Name":"Headerproject_issues_organization_name","Guid":"d5b125d9c89d7be1e2607a8ae5f68e7b","ClientRectangle":"9.6,0,9.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"提报部门.名称"},"VertAlignment":"Center","Font":";10;Bold;","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}}}},"1":{"Ident":"StiDataBand","Name":"Dataproject_issues","ClientRectangle":"0,2,19.01,0.8","Interaction":{"Ident":"StiBandInteraction"},"Border":";;;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiText","Name":"Dataproject_issues_name","Guid":"62775d5bee61cc73f212c323770d8e4e","CanGrow":true,"ClientRectangle":"0,0,9.6,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{project_issues.name}"},"VertAlignment":"Center","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"1":{"Ident":"StiText","Name":"Dataproject_issues_organization_name","Guid":"716bad81a8ae1c20fcceb2d4c1032f91","CanGrow":true,"ClientRectangle":"9.6,0,9.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{project_issues.organization_name}"},"VertAlignment":"Center","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}}},"DataSourceName":"project_issues"}},"PageWidth":21.01,"PageHeight":29.69,"Watermark":{"TextBrush":"solid:50,0,0,0"},"Margins":{"Left":1,"Right":1,"Top":1,"Bottom":1}}}}
{"ReportVersion":"2019.2.1","ReportGuid":"7622f19c18d5a6d45e647c76b372b1ed","ReportName":"Report","ReportAlias":"Report","ReportFile":"temp.mrt","ReportCreated":"/Date(1559570184000+0800)/","ReportChanged":"/Date(1559570184000+0800)/","EngineVersion":"EngineV2","CalculationMode":"Interpretation","ReportUnit":"Centimeters","PreviewSettings":268435455,"Dictionary":{"DataSources":{"0":{"Ident":"StiDataTableSource","Name":"project_issues","Alias":"问题","Columns":{"0":{"Name":"name","Index":-1,"NameInSource":"name","Alias":"问题标题","Type":"System.String"},"1":{"Name":"organization.name","Index":-1,"NameInSource":"organization.name","Alias":"提报部门.名称","Type":"System.String"},"2":{"Name":"organization.parent.name","Index":-1,"NameInSource":"organization.parent.name","Alias":"提报部门.上级部门.名称","Type":"System.String"}},"NameInSource":"问题按类型统计报表.project_issues"}},"Databases":{"0":{"Ident":"StiJsonDatabase","Name":"问题按类型统计报表","Alias":"问题按类型统计报表","PathData":"/api/report/data/temp"}}},"Pages":{"0":{"Ident":"StiPage","Name":"Page1","Guid":"47bcaf029c0e3c47e55d68b8741289c1","Interaction":{"Ident":"StiInteraction"},"Border":";;2;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiHeaderBand","Name":"Headerproject_issues","ClientRectangle":"0,0.4,19.01,0.8","Interaction":{"Ident":"StiInteraction"},"Border":";;;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiText","Name":"Headerproject_issues_name","Guid":"c1ea4b78db020f46220d4249fd2f0076","ClientRectangle":"0,0,6.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"问题标题"},"VertAlignment":"Center","Font":";10;Bold;","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"1":{"Ident":"StiText","Name":"Headerproject_issues_organization_name","Guid":"213735207dc4e20d5030bbc7a17e27c7","ClientRectangle":"6.4,0,6.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"提报部门.名称"},"VertAlignment":"Center","Font":";10;Bold;","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"2":{"Ident":"StiText","Name":"Headerproject_issues_organization_parent_name","Guid":"72cc79349d778dfa28c75e9123dc2429","ClientRectangle":"12.8,0,6.2,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"提报部门.上级部门.名称"},"VertAlignment":"Center","Font":";10;Bold;","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}}}},"1":{"Ident":"StiDataBand","Name":"Dataproject_issues","ClientRectangle":"0,2,19.01,0.8","Interaction":{"Ident":"StiBandInteraction"},"Border":";;;;;;;solid:Black","Brush":"solid:Transparent","Components":{"0":{"Ident":"StiText","Name":"Dataproject_issues_name","Guid":"731f42a35b50344f9eb00c9bd0fd5056","CanGrow":true,"ClientRectangle":"0,0,6.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{project_issues.name}"},"VertAlignment":"Center","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"1":{"Ident":"StiText","Name":"Dataproject_issues_organization_name","Guid":"4925c82c30a8becfb8a519ee53c44ae4","CanGrow":true,"ClientRectangle":"6.4,0,6.4,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{project_issues.organization_name}"},"VertAlignment":"Center","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}},"2":{"Ident":"StiText","Name":"Dataproject_issues_organization_parent_name","Guid":"07d00e82507b0d4a1f22d43defbd16ea","CanGrow":true,"ClientRectangle":"12.8,0,6.2,0.8","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{project_issues.organization_parent_name}"},"VertAlignment":"Center","Border":";;;;;;;solid:Black","Brush":"solid:Transparent","TextBrush":"solid:Black","TextOptions":{"WordWrap":true}}},"DataSourceName":"project_issues"}},"PageWidth":21.01,"PageHeight":29.69,"Watermark":{"TextBrush":"solid:50,0,0,0"},"Margins":{"Left":1,"Right":1,"Top":1,"Bottom":1}}}}
6 changes: 4 additions & 2 deletions packages/report/reports/temp.report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ object_name : project_issues
fields:
- name
- organization.name
- organization.parent.name
filters:
-
- organization
Expand All @@ -13,11 +14,12 @@ filters:
graphql: |
query {
project_issues(filters:"organization eq 'P7XMJMjKoSz4yaK49'") {
_id
name
organization {
_id
name
parent{
name
}
}
}
}
1 change: 1 addition & 0 deletions packages/report/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const formatObjectFields = (report, objectConfig) => {
keys = key.split(".");
if (keys.length > 1) {
// a.b或a.b.c的字段情况
prevKey = null;
tempFieldAlias = keys.map((k) => {
if (prevKey) {
tempReferenceTo = tempField.reference_to
Expand Down

0 comments on commit cd7eb79

Please sign in to comment.