Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
csbr-daop
/
fe-data-trusted-space
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
361267e4
authored
2026-02-06 10:37:27 +0800
by
lihua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改下载报告
1 parent
1416702f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
17 deletions
src/api/modules/dataAnonymization.ts
src/views/data_anonymization/anonResultReportView.vue
src/views/data_anonymization/anonTaskCreate.vue
src/views/data_anonymization/components/anonResultAnalysis.vue
tsconfig.json
src/api/modules/dataAnonymization.ts
View file @
361267e
...
...
@@ -149,6 +149,9 @@ export const dataSourceTypeList = [{
},
{
value
:
2
,
label
:
'文件导入'
},
{
value
:
3
,
label
:
'文件夹'
}];
/** 获取数据库选择列表 */
...
...
@@ -341,3 +344,10 @@ export const exportAnonReport = (params) => request({
method
:
'post'
,
responseType
:
'blob'
})
export
const
htmlToWord
=
(
params
)
=>
request
({
url
:
`
${
import
.
meta
.
env
.
VITE_APP_ANONYMIZATION_BASEURL
}
/anon-task/download/html-to-word`
,
method
:
'postJsonD'
,
data
:
params
,
responseType
:
'blob'
})
\ No newline at end of file
...
...
src/views/data_anonymization/anonResultReportView.vue
View file @
361267e
...
...
@@ -8,12 +8,14 @@ import {
getAnonAnalyzePageData
,
getAnonAnalyzeResult
,
getAnonTaskDetail
,
htmlToWord
,
}
from
'@/api/modules/dataAnonymization'
;
import
{
changeNum
,
download
}
from
'@/utils/common'
;
import
{
ElMessage
}
from
'element-plus'
;
import
anonResultAnalysis
from
'./components/anonResultAnalysis.vue'
;
import
{
commonPageConfig
}
from
'@/utils/enum'
;
import
{
calcColumnWidth
}
from
'@/utils'
;
import
html2canvas
from
'html2canvas'
;
const
route
=
useRoute
();
const
router
=
useRouter
();
...
...
@@ -52,6 +54,8 @@ const originResultTableFieldColumn = ref({});
/** 结果分析中的字段表格数据 */
const
resultData
:
any
=
ref
([]);
/** 全部未分页的数据,下载word时使用。 */
const
fullResultData
:
any
=
ref
([]);
/** 结果分析中的字段信息 */
const
analysisResultTableFields
:
any
=
ref
([]);
...
...
@@ -100,16 +104,30 @@ watch(
}
);
const
getAnalysisResultPageData
=
()
=>
{
const
getAnalysisResultPageData
=
(
isFull
=
false
)
=>
{
analysisResultLoading
.
value
=
true
;
getAnonAnalyzePageData
({
pageIndex
:
pageInfo
.
value
.
curr
,
pageSize
:
pageInfo
.
value
.
limit
,
pageSize
:
isFull
?
-
1
:
pageInfo
.
value
.
limit
,
taskExecGuid
:
taskExecGuid
.
value
,
}).
then
((
res
:
any
)
=>
{
analysisResultLoading
.
value
=
false
;
if
(
res
?.
code
==
proxy
.
$passCode
)
{
pageInfo
.
value
.
rows
=
if
(
isFull
)
{
fullResultData
.
value
=
[];
res
.
data
?.
records
?.
forEach
(
d
=>
{
let
obj
=
{};
analysisResultTableFields
.
value
.
forEach
(
t
=>
{
obj
[
t
.
enName
]
=
d
.
fieldValue
?.[
t
.
enName
];
});
obj
[
'equivalenceClassNum'
]
=
changeNum
(
d
.
equivalenceClassNum
||
0
,
0
);
obj
[
'reIdentifyRisk'
]
=
changeNum
(
d
.
reIdentifyRisk
||
0
,
2
);
obj
[
'isGtThreshold'
]
=
d
.
isGtThreshold
;
fullResultData
.
value
.
push
(
obj
);
});
resultData
.
value
=
fullResultData
.
value
.
slice
(
0
,
pageInfo
.
value
.
limit
);
pageInfo
.
value
.
rows
=
fullResultData
.
value
.
length
;
}
else
{
resultData
.
value
=
[];
res
.
data
?.
records
?.
forEach
(
d
=>
{
let
obj
=
{};
...
...
@@ -122,30 +140,82 @@ const getAnalysisResultPageData = () => {
resultData
.
value
.
push
(
obj
);
});
pageInfo
.
value
.
rows
=
res
.
data
?.
totalRows
??
0
;
}
}
else
{
proxy
.
$ElMessage
.
error
(
res
.
msg
);
}
})
}
const
isWordStyle
=
ref
(
false
);
/** 下载评估报告 */
const
transfer
=
()
=>
{
isWordStyle
.
value
=
true
;
}
const
domClone
:
any
=
ref
(
null
);
const
resultReportRef
=
ref
();
const
convertHtml2Img
=
(
dom
,
domClone
)
=>
{
const
element
=
<
HTMLElement
>
dom
.
querySelector
(
'.kpi-content'
)
if
(
!
element
)
{
return
Promise
.
resolve
();
}
return
html2canvas
(
element
,
{
allowTaint
:
true
,
useCORS
:
true
,
scale
:
2
,
}).
then
((
canvas
:
any
)
=>
{
document
.
documentElement
.
scrollTop
=
0
;
document
.
body
.
scrollTop
=
0
;
element
.
parentNode
&&
((
<
HTMLElement
>
element
.
parentNode
).
scrollTop
=
0
);
let
url
=
canvas
.
toDataURL
(
'image/jpeg'
);
let
img
=
document
.
createElement
(
'img'
);
if
(
url
)
{
// img.src = url.split(',')[1];
img
.
src
=
url
;
img
.
width
=
620
;
img
.
height
=
265
;
img
.
crossOrigin
=
'Anonymous'
;
}
const
copyElement
=
<
HTMLElement
>
domClone
.
querySelector
(
'.kpi-content'
)
copyElement
.
parentNode
?.
replaceChild
(
img
,
copyElement
);
})
}
const
loadingText
=
ref
(
''
);
const
getHTML
=
(
reportResultContent
)
=>
{
let
html
=
reportResultContent
;
html
=
html
.
replace
(
/"/g
,
"'"
);
return
html
;
};
const
downloadWord
=
()
=>
{
if
(
downPromise
.
value
)
{
return
;
}
downPromise
.
value
=
exportAnonReport
({
taskGuid
:
route
.
query
.
guid
,
execGuid
:
taskExecGuid
.
value
}).
then
((
res
:
any
)
=>
{
downPromise
.
value
=
null
;
let
dom
=
domClone
.
value
||
(
domClone
.
value
=
document
.
createElement
(
'div'
));
let
report
=
resultReportRef
.
value
?.
report
;
dom
.
innerHTML
=
report
?.
innerHTML
;
resultDataLoading
.
value
=
true
;
loadingText
.
value
=
'报告正在下载中,请勿关闭浏览器...'
;
downPromise
.
value
=
convertHtml2Img
(
report
,
dom
).
then
(()
=>
{
htmlToWord
({
html
:
encodeURIComponent
(
`<div>
${
getHTML
(
dom
.
innerHTML
)}
</div>`
)
}).
then
((
res
:
any
)
=>
{
downPromise
.
value
=
null
loadingText
.
value
=
''
;
resultDataLoading
.
value
=
false
;
if
(
res
&&
!
res
.
msg
)
{
download
(
res
,
(
route
.
query
.
taskName
||
oldAnonTaskValueInfo
.
value
.
taskName
)
+
'_匿名化评估报告.docx'
,
'word'
)
}
else
{
res
?.
msg
&&
ElMessage
.
error
(
res
?.
msg
);
}
})
}).
catch
(()
=>
{
downPromise
.
value
=
null
;
})
})
;
}
onMounted
(()
=>
{
...
...
@@ -165,7 +235,7 @@ onBeforeMount(() => {
analysisResultInfo
.
value
=
res
.
data
||
{};
analysisResultTableFields
.
value
=
res
.
data
?.
column
||
[];
pageInfo
.
value
.
curr
=
1
;
getAnalysisResultPageData
();
getAnalysisResultPageData
(
true
);
}
else
{
res
?.
msg
&&
proxy
.
$ElMessage
.
error
(
res
.
msg
);
}
...
...
@@ -182,13 +252,24 @@ onBeforeMount(() => {
</
script
>
<
template
>
<div
class=
"table_tool_wrap"
v-loading=
"resultDataLoading"
ref=
"containerRef"
>
<el-button
style=
"margin-bottom: 8px;"
type=
"primary"
@
click=
"transfer"
v-preReClick
>
下载评估报告
</el-button>
<anonResultAnalysis
:show-title=
"true"
:analysis-result-info=
"analysisResultInfo"
:analysis-result-loading=
"analysisResultLoading"
:analysis-result-table-fields=
"analysisResultTableFields"
:old-anon-task-value-info=
"oldAnonTaskValueInfo"
:container-width=
"containerWidth"
:origin-result-table-field-column=
"originResultTableFieldColumn"
:page-info=
"pageInfo"
:result-data=
"resultData"
@
page-change=
"pageChange"
></anonResultAnalysis>
<div
class=
"table_tool_wrap"
v-loading=
"resultDataLoading"
ref=
"containerRef"
:element-loading-text=
"loadingText"
>
<el-button
v-show=
"!isWordStyle"
style=
"margin-bottom: 8px;"
type=
"primary"
@
click=
"transfer"
v-preReClick
>
生成Word评估报告
</el-button>
<div
v-show=
"isWordStyle"
style=
"margin-bottom: 8px;"
>
<el-button
@
click=
"isWordStyle = false"
>
返回
</el-button>
<el-button
type=
"primary"
@
click=
"downloadWord"
>
下载评估报告
</el-button>
</div>
<anonResultAnalysis
ref=
"resultReportRef"
:show-title=
"true"
:analysis-result-info=
"analysisResultInfo"
:isWordStyle=
"isWordStyle"
:style=
"isWordStyle ?
{
height: 'calc(100% - 36px)',
'overflow-y': 'auto',
'margin-right': '-16px',
'padding-right': '16px',
width: 'auto'
} : null" :analysis-result-loading="analysisResultLoading"
:analysis-result-table-fields="analysisResultTableFields" :old-anon-task-value-info="oldAnonTaskValueInfo"
:container-width="containerWidth" :origin-result-table-field-column="originResultTableFieldColumn"
:page-info="pageInfo" :result-data="resultData" :fullResultData="fullResultData" @page-change="pageChange">
</anonResultAnalysis>
</div>
</
template
>
...
...
src/views/data_anonymization/anonTaskCreate.vue
View file @
361267e
This diff is collapsed.
Click to expand it.
src/views/data_anonymization/components/anonResultAnalysis.vue
View file @
361267e
This diff is collapsed.
Click to expand it.
tsconfig.json
View file @
361267e
{
"compilerOptions"
:
{
"noUnusedLocals"
:
true
,
"noUnusedParameters"
:
true
,
"target"
:
"ESNext"
,
"useDefineForClassFields"
:
true
,
"module"
:
"ESNext"
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment