泛化文件数据显示
Showing
2 changed files
with
28 additions
and
4 deletions
| ... | @@ -98,6 +98,13 @@ export const updateGeneralizeFile = (data) => request({ | ... | @@ -98,6 +98,13 @@ export const updateGeneralizeFile = (data) => request({ |
| 98 | data | 98 | data |
| 99 | }) | 99 | }) |
| 100 | 100 | ||
| 101 | /** 获取泛化文件解析结果 */ | ||
| 102 | export const parseGeneralizeFileData = (data) => request({ | ||
| 103 | url: `${import.meta.env.VITE_APP_ANONYMIZATION_BASEURL}/generalize-file/parse-file`, | ||
| 104 | method: 'post', | ||
| 105 | data | ||
| 106 | }) | ||
| 107 | |||
| 101 | 108 | ||
| 102 | /** --------- 敏感数据识别接口 ------------------- */ | 109 | /** --------- 敏感数据识别接口 ------------------- */ |
| 103 | 110 | ... | ... |
| ... | @@ -5,6 +5,7 @@ import { | ... | @@ -5,6 +5,7 @@ import { |
| 5 | getGeneralizeFileDetail, | 5 | getGeneralizeFileDetail, |
| 6 | updateGeneralizeFile, | 6 | updateGeneralizeFile, |
| 7 | deleteGeneralizeFile, | 7 | deleteGeneralizeFile, |
| 8 | parseGeneralizeFileData, | ||
| 8 | } from '@/api/modules/dataAnonymization'; | 9 | } from '@/api/modules/dataAnonymization'; |
| 9 | import { | 10 | import { |
| 10 | parseAndDecodeUrl, | 11 | parseAndDecodeUrl, |
| ... | @@ -106,6 +107,15 @@ const fileTableData: any = ref([]); | ... | @@ -106,6 +107,15 @@ const fileTableData: any = ref([]); |
| 106 | 107 | ||
| 107 | const parseFileData = (fileRaw) => { | 108 | const parseFileData = (fileRaw) => { |
| 108 | fileFieldLoading.value = true; | 109 | fileFieldLoading.value = true; |
| 110 | let file = fileFormItems.value[0].default; | ||
| 111 | parseGeneralizeFileData({ | ||
| 112 | name: file[0]?.name, | ||
| 113 | url: file[0]?.url | ||
| 114 | }).then((res: any) => { | ||
| 115 | fileFieldLoading.value = false; | ||
| 116 | if (res?.code == proxy.$passCode) { | ||
| 117 | let result = res.data?.fileDataRQVOS || []; | ||
| 118 | let resultFields = res.data?.sheetHeader || []; | ||
| 109 | fileRaw.arrayBuffer().then((f) => { | 119 | fileRaw.arrayBuffer().then((f) => { |
| 110 | const wb = XLSX.read(f, { | 120 | const wb = XLSX.read(f, { |
| 111 | raw: false, cellDates: true | 121 | raw: false, cellDates: true |
| ... | @@ -116,16 +126,16 @@ const parseFileData = (fileRaw) => { | ... | @@ -116,16 +126,16 @@ const parseFileData = (fileRaw) => { |
| 116 | fileTableFields.value = []; | 126 | fileTableFields.value = []; |
| 117 | fileTableData.value = []; | 127 | fileTableData.value = []; |
| 118 | } else { | 128 | } else { |
| 119 | fileTableFields.value = json[0]?.map((j, index) => { | 129 | fileTableFields.value = resultFields?.map((j, index) => { |
| 120 | return { | 130 | return { |
| 121 | index: index, | 131 | index: index, |
| 122 | enName: j + '', | 132 | enName: j.enName + '', |
| 123 | chName: j + '', | 133 | chName: j.chName + '', |
| 124 | dataType: 'varchar' | 134 | dataType: 'varchar' |
| 125 | } | 135 | } |
| 126 | }) || []; | 136 | }) || []; |
| 127 | if (json.length > 1) { | 137 | if (json.length > 1) { |
| 128 | fileTableData.value = json.slice(1, 51).map((info, row) => { | 138 | json.slice(1, 20).map((info, row) => { |
| 129 | let object = {}; | 139 | let object = {}; |
| 130 | json[0].forEach((name, col) => { | 140 | json[0].forEach((name, col) => { |
| 131 | if (info[col] === "" || info[col] == null) { | 141 | if (info[col] === "" || info[col] == null) { |
| ... | @@ -142,12 +152,19 @@ const parseFileData = (fileRaw) => { | ... | @@ -142,12 +152,19 @@ const parseFileData = (fileRaw) => { |
| 142 | }); | 152 | }); |
| 143 | return object; | 153 | return object; |
| 144 | }); | 154 | }); |
| 155 | fileTableData.value = result.slice(0, 50)?.map(d => { | ||
| 156 | return d.fileData || {}; | ||
| 157 | }) | ||
| 145 | } else { | 158 | } else { |
| 146 | fileTableData.value = []; | 159 | fileTableData.value = []; |
| 147 | } | 160 | } |
| 148 | } | 161 | } |
| 149 | fileFieldLoading.value = false; | 162 | fileFieldLoading.value = false; |
| 150 | }); | 163 | }); |
| 164 | } else { | ||
| 165 | proxy.$ElMessage.error(res.msg); | ||
| 166 | } | ||
| 167 | }); | ||
| 151 | } | 168 | } |
| 152 | 169 | ||
| 153 | const uploadFileChange = (file) => { | 170 | const uploadFileChange = (file) => { | ... | ... |
-
Please register or sign in to post a comment