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
1a551fca
authored
2025-09-22 16:09:10 +0800
by
lihua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
泛化文件数据显示
1 parent
df370175
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
39 deletions
src/api/modules/dataAnonymization.ts
src/views/data_anonymization/generalizeFileEdit.vue
src/api/modules/dataAnonymization.ts
View file @
1a551fc
...
...
@@ -98,6 +98,13 @@ export const updateGeneralizeFile = (data) => request({
data
})
/** 获取泛化文件解析结果 */
export
const
parseGeneralizeFileData
=
(
data
)
=>
request
({
url
:
`
${
import
.
meta
.
env
.
VITE_APP_ANONYMIZATION_BASEURL
}
/generalize-file/parse-file`
,
method
:
'post'
,
data
})
/** --------- 敏感数据识别接口 ------------------- */
...
...
src/views/data_anonymization/generalizeFileEdit.vue
View file @
1a551fc
...
...
@@ -5,6 +5,7 @@ import {
getGeneralizeFileDetail
,
updateGeneralizeFile
,
deleteGeneralizeFile
,
parseGeneralizeFileData
,
}
from
'@/api/modules/dataAnonymization'
;
import
{
parseAndDecodeUrl
,
...
...
@@ -106,47 +107,63 @@ const fileTableData: any = ref([]);
const
parseFileData
=
(
fileRaw
)
=>
{
fileFieldLoading
.
value
=
true
;
fileRaw
.
arrayBuffer
().
then
((
f
)
=>
{
const
wb
=
XLSX
.
read
(
f
,
{
raw
:
false
,
cellDates
:
true
});
const
sheet
=
wb
.
Sheets
[
wb
.
SheetNames
[
0
]];
const
json
:
any
[]
=
XLSX
.
utils
.
sheet_to_json
(
sheet
,
{
header
:
1
});
if
(
json
.
length
==
0
)
{
fileTableFields
.
value
=
[];
fileTableData
.
value
=
[];
}
else
{
fileTableFields
.
value
=
json
[
0
]?.
map
((
j
,
index
)
=>
{
return
{
index
:
index
,
enName
:
j
+
''
,
chName
:
j
+
''
,
dataType
:
'varchar'
}
})
||
[];
if
(
json
.
length
>
1
)
{
fileTableData
.
value
=
json
.
slice
(
1
,
51
).
map
((
info
,
row
)
=>
{
let
object
=
{};
json
[
0
].
forEach
((
name
,
col
)
=>
{
if
(
info
[
col
]
===
""
||
info
[
col
]
==
null
)
{
object
[
name
]
=
info
[
col
];
}
else
{
var
cellRef
=
XLSX
.
utils
.
encode_cell
({
r
:
row
+
1
,
c
:
col
});
var
cell
=
sheet
[
cellRef
];
object
[
name
]
=
cell
.
w
||
info
[
col
];
let
isNum
=
cell
.
t
==
'n'
;
if
(
isNum
&&
fileTableFields
.
value
[
col
].
dataType
!=
'int'
)
{
fileTableFields
.
value
[
col
].
dataType
=
'int'
;
}
}
});
return
object
;
let
file
=
fileFormItems
.
value
[
0
].
default
;
parseGeneralizeFileData
({
name
:
file
[
0
]?.
name
,
url
:
file
[
0
]?.
url
}).
then
((
res
:
any
)
=>
{
fileFieldLoading
.
value
=
false
;
if
(
res
?.
code
==
proxy
.
$passCode
)
{
let
result
=
res
.
data
?.
fileDataRQVOS
||
[];
let
resultFields
=
res
.
data
?.
sheetHeader
||
[];
fileRaw
.
arrayBuffer
().
then
((
f
)
=>
{
const
wb
=
XLSX
.
read
(
f
,
{
raw
:
false
,
cellDates
:
true
});
}
else
{
fileTableData
.
value
=
[];
}
const
sheet
=
wb
.
Sheets
[
wb
.
SheetNames
[
0
]];
const
json
:
any
[]
=
XLSX
.
utils
.
sheet_to_json
(
sheet
,
{
header
:
1
});
if
(
json
.
length
==
0
)
{
fileTableFields
.
value
=
[];
fileTableData
.
value
=
[];
}
else
{
fileTableFields
.
value
=
resultFields
?.
map
((
j
,
index
)
=>
{
return
{
index
:
index
,
enName
:
j
.
enName
+
''
,
chName
:
j
.
chName
+
''
,
dataType
:
'varchar'
}
})
||
[];
if
(
json
.
length
>
1
)
{
json
.
slice
(
1
,
20
).
map
((
info
,
row
)
=>
{
let
object
=
{};
json
[
0
].
forEach
((
name
,
col
)
=>
{
if
(
info
[
col
]
===
""
||
info
[
col
]
==
null
)
{
object
[
name
]
=
info
[
col
];
}
else
{
var
cellRef
=
XLSX
.
utils
.
encode_cell
({
r
:
row
+
1
,
c
:
col
});
var
cell
=
sheet
[
cellRef
];
object
[
name
]
=
cell
.
w
||
info
[
col
];
let
isNum
=
cell
.
t
==
'n'
;
if
(
isNum
&&
fileTableFields
.
value
[
col
].
dataType
!=
'int'
)
{
fileTableFields
.
value
[
col
].
dataType
=
'int'
;
}
}
});
return
object
;
});
fileTableData
.
value
=
result
.
slice
(
0
,
50
)?.
map
(
d
=>
{
return
d
.
fileData
||
{};
})
}
else
{
fileTableData
.
value
=
[];
}
}
fileFieldLoading
.
value
=
false
;
});
}
else
{
proxy
.
$ElMessage
.
error
(
res
.
msg
);
}
fileFieldLoading
.
value
=
false
;
});
}
...
...
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