代码评审内容修改
Showing
12 changed files
with
354 additions
and
156 deletions
| ... | @@ -13,6 +13,7 @@ declare module '@vue/runtime-core' { | ... | @@ -13,6 +13,7 @@ declare module '@vue/runtime-core' { |
| 13 | Auth: typeof import('./src/components/Auth/index.vue')['default'] | 13 | Auth: typeof import('./src/components/Auth/index.vue')['default'] |
| 14 | AuthAll: typeof import('./src/components/AuthAll/index.vue')['default'] | 14 | AuthAll: typeof import('./src/components/AuthAll/index.vue')['default'] |
| 15 | CarouselPanel: typeof import('./src/components/CarouselPanel/src/CarouselPanel.vue')['default'] | 15 | CarouselPanel: typeof import('./src/components/CarouselPanel/src/CarouselPanel.vue')['default'] |
| 16 | CommonTable: typeof import('./src/components/CommonTable/src/CommonTable.vue')['default'] | ||
| 16 | ContentWrap: typeof import('./src/components/ContentWrap/src/ContentWrap.vue')['default'] | 17 | ContentWrap: typeof import('./src/components/ContentWrap/src/ContentWrap.vue')['default'] |
| 17 | Copyright: typeof import('./src/components/Copyright/index.vue')['default'] | 18 | Copyright: typeof import('./src/components/Copyright/index.vue')['default'] |
| 18 | Day: typeof import('./src/components/Schedule/component/day.vue')['default'] | 19 | Day: typeof import('./src/components/Schedule/component/day.vue')['default'] | ... | ... |
src/api/apiHander.ts
0 → 100644
| 1 | /** | ||
| 2 | * API响应处理工具函数 | ||
| 3 | * 统一处理API请求的成功/失败逻辑 | ||
| 4 | */ | ||
| 5 | |||
| 6 | interface ApiResponse { | ||
| 7 | code: number; | ||
| 8 | data?: any; | ||
| 9 | msg?: string; | ||
| 10 | } | ||
| 11 | |||
| 12 | export interface ApiHandlerOptions { | ||
| 13 | /* 当前实例的proxy对象(用于获取$passCode和$ElMessage)*/ | ||
| 14 | proxy: any | ||
| 15 | /** 加载状态ref */ | ||
| 16 | loadingRef?: Ref<boolean>; | ||
| 17 | /** 成功回调函数 */ | ||
| 18 | onSuccess?: (res: any) => void; | ||
| 19 | /** 失败回调函数 */ | ||
| 20 | onError?: (res: any) => void; | ||
| 21 | /** 是否显示错误消息,默认true */ | ||
| 22 | showError?: boolean; | ||
| 23 | } | ||
| 24 | |||
| 25 | /** | ||
| 26 | * 统一处理API响应的工具函数 | ||
| 27 | * @param apiPromise API请求Promise | ||
| 28 | * @param options 配置选项 | ||
| 29 | */ | ||
| 30 | export const handleApiResponse = async ( | ||
| 31 | apiPromise: Promise<ApiResponse>, | ||
| 32 | options: ApiHandlerOptions, | ||
| 33 | ) => { | ||
| 34 | const { | ||
| 35 | loadingRef, | ||
| 36 | onSuccess, | ||
| 37 | onError, | ||
| 38 | showError = true, | ||
| 39 | proxy | ||
| 40 | } = options; | ||
| 41 | |||
| 42 | try { | ||
| 43 | // 设置加载状态 | ||
| 44 | if (loadingRef) { | ||
| 45 | loadingRef.value = true; | ||
| 46 | } | ||
| 47 | |||
| 48 | // 执行API请求 | ||
| 49 | const res = await apiPromise; | ||
| 50 | |||
| 51 | // 设置加载状态 | ||
| 52 | if (loadingRef) { | ||
| 53 | loadingRef.value = false; | ||
| 54 | } | ||
| 55 | |||
| 56 | // 判断请求是否成功 | ||
| 57 | if (res?.code == proxy.$passCode) { | ||
| 58 | // 成功回调 | ||
| 59 | onSuccess && onSuccess(res); | ||
| 60 | } else { | ||
| 61 | // 失败处理 | ||
| 62 | const errorMsg = res?.msg || ''; | ||
| 63 | if (showError) { | ||
| 64 | proxy.$ElMessage.error(errorMsg); | ||
| 65 | } | ||
| 66 | onError && onError(res); | ||
| 67 | } | ||
| 68 | } catch (error: any) { | ||
| 69 | // 异常处理 | ||
| 70 | if (loadingRef) { | ||
| 71 | loadingRef.value = false; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | }; |
| ... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
| 2 | * 匿名化管理的接口api文件 | 2 | * 匿名化管理的接口api文件 |
| 3 | */ | 3 | */ |
| 4 | import request from "@/utils/request"; | 4 | import request from "@/utils/request"; |
| 5 | import { handleApiResponse, ApiHandlerOptions } from '../apiHander'; // 导入公共处理方法 | ||
| 5 | 6 | ||
| 6 | /** 获取标签列表。 */ | 7 | /** 获取标签列表。 */ |
| 7 | export const getDataLabelList = (params) => request({ | 8 | export const getDataLabelList = (params) => request({ |
| ... | @@ -246,6 +247,12 @@ export const updateAnonTask = (params) => request({ | ... | @@ -246,6 +247,12 @@ export const updateAnonTask = (params) => request({ |
| 246 | }) | 247 | }) |
| 247 | 248 | ||
| 248 | /** 获取匿名化任务详情 */ | 249 | /** 获取匿名化任务详情 */ |
| 250 | // export const getAnonTaskDetail = (guid, defaultOptions: ApiHandlerOptions) => handleApiResponse(request({ | ||
| 251 | // url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/detail?guid=${guid}`, | ||
| 252 | // method: 'get' | ||
| 253 | // }), defaultOptions) | ||
| 254 | |||
| 255 | /** 获取匿名化任务详情 */ | ||
| 249 | export const getAnonTaskDetail = (guid) => request({ | 256 | export const getAnonTaskDetail = (guid) => request({ |
| 250 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/detail?guid=${guid}`, | 257 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/detail?guid=${guid}`, |
| 251 | method: 'get' | 258 | method: 'get' |
| ... | @@ -265,12 +272,18 @@ export const anonTaskCheck = (params) => request({ | ... | @@ -265,12 +272,18 @@ export const anonTaskCheck = (params) => request({ |
| 265 | }) | 272 | }) |
| 266 | 273 | ||
| 267 | /** 获取匿名化任务分析结果数据 */ | 274 | /** 获取匿名化任务分析结果数据 */ |
| 268 | export const getAnonAnalyzeResult = (execGuid) => request({ | 275 | export const getAnonAnalyzeResult1 = (execGuid) => request({ |
| 269 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/get-anon-analyze?taskExecGuid=${execGuid}`, | 276 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/get-anon-analyze?taskExecGuid=${execGuid}`, |
| 270 | method: 'get' | 277 | method: 'get' |
| 271 | }) | 278 | }) |
| 272 | 279 | ||
| 273 | /** 获取匿名化任务分析结果数据 */ | 280 | /** 获取匿名化任务分析结果数据 */ |
| 281 | export const getAnonAnalyzeResult = (execGuid, defaultOptions: ApiHandlerOptions) => handleApiResponse(request({ | ||
| 282 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/get-anon-analyze?taskExecGuid=${execGuid}`, | ||
| 283 | method: 'get' | ||
| 284 | }), defaultOptions) | ||
| 285 | |||
| 286 | /** 获取匿名化任务分析结果数据 */ | ||
| 274 | export const getLastAnonAnalyzeResult = (execGuid) => request({ | 287 | export const getLastAnonAnalyzeResult = (execGuid) => request({ |
| 275 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/get-anon-analyze?isResult=true&taskExecGuid=${execGuid}`, | 288 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/anon-task/get-anon-analyze?isResult=true&taskExecGuid=${execGuid}`, |
| 276 | method: 'get' | 289 | method: 'get' | ... | ... |
src/components/CommonTable/index.ts
0 → 100644
| 1 | <script lang="ts" setup name="CommonTable"> | ||
| 2 | import { ref, watch, computed } from "vue"; | ||
| 3 | import { TableColumnWidth } from "@/utils/enum"; | ||
| 4 | import { calcColumnWidth } from "@/utils/index"; | ||
| 5 | import Moment from 'moment'; | ||
| 6 | |||
| 7 | const props = defineProps({ | ||
| 8 | data: { | ||
| 9 | type: Array, | ||
| 10 | default: () => [] | ||
| 11 | }, | ||
| 12 | fields: { | ||
| 13 | type: Array, | ||
| 14 | default: () => [] | ||
| 15 | }, | ||
| 16 | loading: { | ||
| 17 | type: Boolean, | ||
| 18 | default: false | ||
| 19 | }, | ||
| 20 | height: { | ||
| 21 | type: String, | ||
| 22 | default: '100%' | ||
| 23 | }, | ||
| 24 | showIndex: { | ||
| 25 | type: Boolean, | ||
| 26 | default: false | ||
| 27 | }, | ||
| 28 | rowKey: { | ||
| 29 | type: String, | ||
| 30 | default: 'guid' | ||
| 31 | }, | ||
| 32 | style: { | ||
| 33 | type: Object, | ||
| 34 | default: () => ({}) | ||
| 35 | } | ||
| 36 | }); | ||
| 37 | |||
| 38 | const originTableFieldColumn = ref({}); | ||
| 39 | |||
| 40 | const getTextAlign = (field) => { | ||
| 41 | if (field.dataType === 'decimal' || field.dataType === 'int' || field.dataType == 'bit' || field.dataType == 'tinyint') { | ||
| 42 | return 'right'; | ||
| 43 | } | ||
| 44 | return 'left' | ||
| 45 | }; | ||
| 46 | |||
| 47 | const formatterPreviewDate = (row, info) => { | ||
| 48 | let enName = info.enName; | ||
| 49 | let v = row[enName]; | ||
| 50 | if (v === 0) { | ||
| 51 | return v; | ||
| 52 | } | ||
| 53 | if (!v || v == 'null') { | ||
| 54 | return '--'; | ||
| 55 | } | ||
| 56 | if (info.dataType === 'datetime') { | ||
| 57 | return Moment(v).format('YYYY-MM-DD HH:mm:ss'); | ||
| 58 | } | ||
| 59 | if (info.dataType === 'date') { | ||
| 60 | if (isNaN(<any>(new Date(v)))) { | ||
| 61 | return Moment(parseInt(v)).format('YYYY-MM-DD'); | ||
| 62 | } else { | ||
| 63 | return Moment(v).format('YYYY-MM-DD'); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | return v; | ||
| 67 | }; | ||
| 68 | |||
| 69 | const calcTableColumnWidth = (data: any[], prop, title, otherWidth = 0) => { | ||
| 70 | let d: any[] = []; | ||
| 71 | data.forEach((dt) => d.push(dt[prop])); | ||
| 72 | return calcColumnWidth( | ||
| 73 | d, | ||
| 74 | title, | ||
| 75 | { | ||
| 76 | fontSize: 14, | ||
| 77 | fontFamily: "SimSun", | ||
| 78 | }, | ||
| 79 | { | ||
| 80 | fontSize: 14, | ||
| 81 | fontFamily: "SimSun", | ||
| 82 | }, | ||
| 83 | otherWidth | ||
| 84 | ); | ||
| 85 | }; | ||
| 86 | |||
| 87 | watch( | ||
| 88 | () => props.data, | ||
| 89 | (val: any[], oldVal) => { | ||
| 90 | if (!props.fields?.length) { | ||
| 91 | originTableFieldColumn.value = {}; | ||
| 92 | return; | ||
| 93 | } | ||
| 94 | originTableFieldColumn.value = {}; | ||
| 95 | props.fields.forEach((field, index) => { | ||
| 96 | originTableFieldColumn.value[field.enName] = calcTableColumnWidth( | ||
| 97 | val?.slice(0, 20) || [], | ||
| 98 | field.enName, | ||
| 99 | field.chName, | ||
| 100 | 24 | ||
| 101 | ); | ||
| 102 | }); | ||
| 103 | }, | ||
| 104 | { | ||
| 105 | deep: true, | ||
| 106 | } | ||
| 107 | ); | ||
| 108 | </script> | ||
| 109 | |||
| 110 | <template> | ||
| 111 | <div class="common-table" v-loading="loading"> | ||
| 112 | <el-table | ||
| 113 | :data="data" | ||
| 114 | :highlight-current-row="true" | ||
| 115 | stripe | ||
| 116 | border | ||
| 117 | tooltip-effect="light" | ||
| 118 | :height="height" | ||
| 119 | :row-key="rowKey" | ||
| 120 | :style="style" | ||
| 121 | > | ||
| 122 | <el-table-column | ||
| 123 | v-if="showIndex" | ||
| 124 | label="序号" | ||
| 125 | type="index" | ||
| 126 | width="56px" | ||
| 127 | align="center" | ||
| 128 | show-overflow-tooltip | ||
| 129 | ></el-table-column> | ||
| 130 | <template v-for="(item, index) in (fields || [])" :key="index"> | ||
| 131 | <el-table-column | ||
| 132 | :label="item.chName" | ||
| 133 | :width="item.dataType === 'datetime' | ||
| 134 | ? TableColumnWidth.DATETIME | ||
| 135 | : item.dataType === 'date' | ||
| 136 | ? TableColumnWidth.DATE | ||
| 137 | : originTableFieldColumn[item.enName] | ||
| 138 | " | ||
| 139 | :align="getTextAlign(item)" | ||
| 140 | :header-align="getTextAlign(item)" | ||
| 141 | :formatter="(row) => formatterPreviewDate(row, item)" | ||
| 142 | :show-overflow-tooltip="true" | ||
| 143 | > | ||
| 144 | </el-table-column> | ||
| 145 | </template> | ||
| 146 | </el-table> | ||
| 147 | <div v-show="!fields.length" class="empty-content"> | ||
| 148 | <img src="@/assets/images/empty-data.png" :style="{ width: '168px', height: '96px' }" /> | ||
| 149 | <div class="empty-text">暂无数据</div> | ||
| 150 | </div> | ||
| 151 | </div> | ||
| 152 | </template> | ||
| 153 | |||
| 154 | <style lang="scss" scoped> | ||
| 155 | .common-table { | ||
| 156 | width: 100%; | ||
| 157 | height: 100%; | ||
| 158 | |||
| 159 | .el-table { | ||
| 160 | display: inline-block; | ||
| 161 | } | ||
| 162 | |||
| 163 | .empty-content { | ||
| 164 | display: flex; | ||
| 165 | align-items: center; | ||
| 166 | justify-content: center; | ||
| 167 | height: 100%; | ||
| 168 | width: 100%; | ||
| 169 | flex-direction: column; | ||
| 170 | |||
| 171 | .empty-text { | ||
| 172 | font-size: 14px; | ||
| 173 | color: #b2b2b2; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | </style> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -133,8 +133,8 @@ const routes: RouteRecordRaw[] = [ | ... | @@ -133,8 +133,8 @@ const routes: RouteRecordRaw[] = [ |
| 133 | children: [ | 133 | children: [ |
| 134 | { | 134 | { |
| 135 | path: '', | 135 | path: '', |
| 136 | name: 'resultProcess', | 136 | name: 'anonResultProcessManage', |
| 137 | component: () => import('@/views/data_anonymization/resultProcess.vue'), | 137 | component: () => import('@/views/data_anonymization/anonResultProcessManage.vue'), |
| 138 | meta: { | 138 | meta: { |
| 139 | title: '匿名化处理', | 139 | title: '匿名化处理', |
| 140 | sidebar: false, | 140 | sidebar: false, | ... | ... |
| ... | @@ -13,6 +13,7 @@ declare module '@vue/runtime-core' { | ... | @@ -13,6 +13,7 @@ declare module '@vue/runtime-core' { |
| 13 | Auth: typeof import('./../components/Auth/index.vue')['default'] | 13 | Auth: typeof import('./../components/Auth/index.vue')['default'] |
| 14 | AuthAll: typeof import('./../components/AuthAll/index.vue')['default'] | 14 | AuthAll: typeof import('./../components/AuthAll/index.vue')['default'] |
| 15 | CarouselPanel: typeof import('./../components/CarouselPanel/src/CarouselPanel.vue')['default'] | 15 | CarouselPanel: typeof import('./../components/CarouselPanel/src/CarouselPanel.vue')['default'] |
| 16 | CommonTable: typeof import('./../components/CommonTable/src/CommonTable.vue')['default'] | ||
| 16 | ContentWrap: typeof import('./../components/ContentWrap/src/ContentWrap.vue')['default'] | 17 | ContentWrap: typeof import('./../components/ContentWrap/src/ContentWrap.vue')['default'] |
| 17 | Copyright: typeof import('./../components/Copyright/index.vue')['default'] | 18 | Copyright: typeof import('./../components/Copyright/index.vue')['default'] |
| 18 | Day: typeof import('./../components/Schedule/component/day.vue')['default'] | 19 | Day: typeof import('./../components/Schedule/component/day.vue')['default'] | ... | ... |
| 1 | <route lang="yaml"> | 1 | <route lang="yaml"> |
| 2 | name: resultProcess | 2 | name: anonResultProcessManage |
| 3 | </route> | 3 | </route> |
| 4 | 4 | ||
| 5 | <script lang="ts" setup name="resultProcess"> | 5 | <script lang="ts" setup name="anonResultProcessManage"> |
| 6 | import TableTools from "@/components/Tools/table_tools.vue"; | 6 | import TableTools from "@/components/Tools/table_tools.vue"; |
| 7 | import { commonPageConfig } from '@/components/PageNav/index'; | 7 | import { commonPageConfig } from '@/components/PageNav/index'; |
| 8 | import { TableColumnWidth } from "@/utils/enum"; | 8 | import { TableColumnWidth } from "@/utils/enum"; |
| ... | @@ -11,14 +11,13 @@ import { | ... | @@ -11,14 +11,13 @@ import { |
| 11 | getAnonTaskList, | 11 | getAnonTaskList, |
| 12 | deleteAnonTask, | 12 | deleteAnonTask, |
| 13 | } from '@/api/modules/dataAnonymization'; | 13 | } from '@/api/modules/dataAnonymization'; |
| 14 | import { useValidator } from '@/hooks/useValidator'; | ||
| 15 | import useDataAnonymizationStore from "@/store/modules/dataAnonymization"; | 14 | import useDataAnonymizationStore from "@/store/modules/dataAnonymization"; |
| 16 | 15 | ||
| 17 | const anonymizationStore = useDataAnonymizationStore(); | 16 | const anonymizationStore = useDataAnonymizationStore(); |
| 18 | const router = useRouter() | 17 | const router = useRouter() |
| 19 | const { proxy } = getCurrentInstance() as any; | 18 | const { proxy } = getCurrentInstance() as any; |
| 20 | const { required } = useValidator(); | ||
| 21 | 19 | ||
| 20 | /** -------------- 搜索栏输入框配置 ------------------------ */ | ||
| 22 | const searchItemList = ref([{ | 21 | const searchItemList = ref([{ |
| 23 | type: "input", | 22 | type: "input", |
| 24 | label: "", | 23 | label: "", |
| ... | @@ -44,6 +43,7 @@ const page = ref({ | ... | @@ -44,6 +43,7 @@ const page = ref({ |
| 44 | dataSource: null | 43 | dataSource: null |
| 45 | }); | 44 | }); |
| 46 | 45 | ||
| 46 | /** ----------------- 表格展示配置信息,及查询数据处理 ----------------- */ | ||
| 47 | const tableInfo = ref({ | 47 | const tableInfo = ref({ |
| 48 | id: 'data-file-table', | 48 | id: 'data-file-table', |
| 49 | fields: [ | 49 | fields: [ |
| ... | @@ -72,64 +72,18 @@ const tableInfo = ref({ | ... | @@ -72,64 +72,18 @@ const tableInfo = ref({ |
| 72 | width: 230, | 72 | width: 230, |
| 73 | fixed: 'right', | 73 | fixed: 'right', |
| 74 | btns: (scope) => { | 74 | btns: (scope) => { |
| 75 | return [{ | 75 | return [{ label: "编辑", value: "edit", disabled: scope.row.isConfirm == 'Y' || scope.row.dataSource == 4, click: tableBtnHandles['edit'] }, { |
| 76 | label: "编辑", value: "edit", disabled: scope.row.isConfirm == 'Y' || scope.row.dataSource == 4, click: (scope) => { | 76 | label: '查看报告', value: 'report', disabled: scope.row.status != 'Y', click: tableBtnHandles['report'] |
| 77 | router.push({ | ||
| 78 | name: 'anonTaskCreate', | ||
| 79 | query: { | ||
| 80 | guid: scope.row.guid, | ||
| 81 | taskName: scope.row.taskName | ||
| 82 | } | ||
| 83 | }); | ||
| 84 | } | ||
| 85 | }, { | ||
| 86 | label: '查看报告', value: 'report', disabled: scope.row.status != 'Y', click: (scope) => { | ||
| 87 | router.push({ | ||
| 88 | name: 'anonResultReportView', | ||
| 89 | query: { | ||
| 90 | guid: scope.row.guid, | ||
| 91 | execGuid: scope.row.lastExecGuid, | ||
| 92 | taskName: scope.row.taskName | ||
| 93 | } | ||
| 94 | }); | ||
| 95 | } | ||
| 96 | }, { | 77 | }, { |
| 97 | label: '查看数据', value: 'view', disabled: scope.row.status != 'Y' || scope.row.handleType == '02', click: (scope) => { | 78 | label: '查看数据', value: 'view', disabled: scope.row.status != 'Y' || scope.row.handleType == '02', click: tableBtnHandles['view'] |
| 98 | router.push({ | ||
| 99 | name: 'anonResultView', | ||
| 100 | query: { | ||
| 101 | guid: scope.row.guid, | ||
| 102 | execGuid: scope.row.lastExecGuid, | ||
| 103 | taskName: scope.row.taskName | ||
| 104 | } | ||
| 105 | }); | ||
| 106 | } | ||
| 107 | }, { | 79 | }, { |
| 108 | label: "删除", value: "delete", disabled: scope.row.isConfirm == 'Y', click: (scope) => { | 80 | label: "删除", value: "delete", click: tableBtnHandles['delete'] |
| 109 | proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => { | ||
| 110 | let guids = [scope.row.guid]; | ||
| 111 | deleteAnonTask(guids).then((res: any) => { | ||
| 112 | if (res?.code == proxy.$passCode) { | ||
| 113 | page.value.curr = 1; | ||
| 114 | getTableData(); | ||
| 115 | proxy.$ElMessage({ | ||
| 116 | type: "success", | ||
| 117 | message: "删除成功", | ||
| 118 | }); | ||
| 119 | } else { | ||
| 120 | proxy.$ElMessage({ | ||
| 121 | type: "error", | ||
| 122 | message: res.msg, | ||
| 123 | }); | ||
| 124 | } | ||
| 125 | }); | ||
| 126 | }) | ||
| 127 | } | ||
| 128 | }] | 81 | }] |
| 129 | } | 82 | } |
| 130 | } | 83 | } |
| 131 | }) | 84 | }) |
| 132 | 85 | ||
| 86 | /** 搜索栏触发搜索 */ | ||
| 133 | const toSearch = (val: any, clear: boolean = false) => { | 87 | const toSearch = (val: any, clear: boolean = false) => { |
| 134 | if (clear) { | 88 | if (clear) { |
| 135 | searchItemList.value.map((item) => (item.default = "")); | 89 | searchItemList.value.map((item) => (item.default = "")); |
| ... | @@ -175,6 +129,58 @@ const tablePageChange = (info) => { | ... | @@ -175,6 +129,58 @@ const tablePageChange = (info) => { |
| 175 | getTableData(); | 129 | getTableData(); |
| 176 | }; | 130 | }; |
| 177 | 131 | ||
| 132 | const tableBtnHandles = { | ||
| 133 | edit: (scope) => { | ||
| 134 | router.push({ | ||
| 135 | name: 'anonTaskCreate', | ||
| 136 | query: { | ||
| 137 | guid: scope.row.guid, | ||
| 138 | taskName: scope.row.taskName | ||
| 139 | } | ||
| 140 | }); | ||
| 141 | }, | ||
| 142 | report: (scope) => { | ||
| 143 | router.push({ | ||
| 144 | name: 'anonResultReportView', | ||
| 145 | query: { | ||
| 146 | guid: scope.row.guid, | ||
| 147 | execGuid: scope.row.lastExecGuid, | ||
| 148 | taskName: scope.row.taskName | ||
| 149 | } | ||
| 150 | }); | ||
| 151 | }, | ||
| 152 | view: (scope) => { | ||
| 153 | router.push({ | ||
| 154 | name: 'anonResultView', | ||
| 155 | query: { | ||
| 156 | guid: scope.row.guid, | ||
| 157 | execGuid: scope.row.lastExecGuid, | ||
| 158 | taskName: scope.row.taskName | ||
| 159 | } | ||
| 160 | }); | ||
| 161 | }, | ||
| 162 | delete: (scope) => { | ||
| 163 | proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => { | ||
| 164 | let guids = [scope.row.guid]; | ||
| 165 | deleteAnonTask(guids).then((res: any) => { | ||
| 166 | if (res?.code == proxy.$passCode) { | ||
| 167 | page.value.curr = 1; | ||
| 168 | getTableData(); | ||
| 169 | proxy.$ElMessage({ | ||
| 170 | type: "success", | ||
| 171 | message: "删除成功", | ||
| 172 | }); | ||
| 173 | } else { | ||
| 174 | proxy.$ElMessage({ | ||
| 175 | type: "error", | ||
| 176 | message: res.msg, | ||
| 177 | }); | ||
| 178 | } | ||
| 179 | }); | ||
| 180 | }) | ||
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 178 | const handleCreate = () => { | 184 | const handleCreate = () => { |
| 179 | router.push({ | 185 | router.push({ |
| 180 | name: 'anonTaskCreate' | 186 | name: 'anonTaskCreate' | ... | ... |
| ... | @@ -228,17 +228,16 @@ onMounted(() => { | ... | @@ -228,17 +228,16 @@ onMounted(() => { |
| 228 | 228 | ||
| 229 | onBeforeMount(() => { | 229 | onBeforeMount(() => { |
| 230 | resultDataLoading.value = true; | 230 | resultDataLoading.value = true; |
| 231 | getAnonAnalyzeResult(taskExecGuid.value).then((res: any) => { | 231 | getAnonAnalyzeResult(taskExecGuid.value, { |
| 232 | resultDataLoading.value = false; | 232 | proxy: proxy, |
| 233 | if (res?.code == proxy.$passCode) { | 233 | loadingRef: resultDataLoading, |
| 234 | analysisResultInfo.value = res.data || {}; | 234 | onSuccess: (res: any) => { |
| 235 | analysisResultInfo.value = res?.data || {}; | ||
| 235 | analysisResultTableFields.value = res.data?.column || []; | 236 | analysisResultTableFields.value = res.data?.column || []; |
| 236 | pageInfo.value.curr = 1; | 237 | pageInfo.value.curr = 1; |
| 237 | getAnalysisResultPageData(true); | 238 | getAnalysisResultPageData(true); |
| 238 | } else { | ||
| 239 | res?.msg && proxy.$ElMessage.error(res.msg); | ||
| 240 | } | 239 | } |
| 241 | }); | 240 | }) |
| 242 | getAnonTaskDetail(taskGuid.value).then((res: any) => { | 241 | getAnonTaskDetail(taskGuid.value).then((res: any) => { |
| 243 | if (res?.code == proxy.$passCode) { | 242 | if (res?.code == proxy.$passCode) { |
| 244 | oldAnonTaskValueInfo.value = res.data || {}; | 243 | oldAnonTaskValueInfo.value = res.data || {}; | ... | ... |
| ... | @@ -9,9 +9,6 @@ import { | ... | @@ -9,9 +9,6 @@ import { |
| 9 | getLastAnonAnalyzeResult, | 9 | getLastAnonAnalyzeResult, |
| 10 | exportAnonExecData, | 10 | exportAnonExecData, |
| 11 | } from "@/api/modules/dataAnonymization"; | 11 | } from "@/api/modules/dataAnonymization"; |
| 12 | import { calcColumnWidth } from "@/utils/index"; | ||
| 13 | import Moment from 'moment'; | ||
| 14 | import { TableColumnWidth } from "@/utils/enum"; | ||
| 15 | import { ElMessage } from "element-plus"; | 12 | import { ElMessage } from "element-plus"; |
| 16 | import { commonPageConfig } from '@/components/PageNav/index'; | 13 | import { commonPageConfig } from '@/components/PageNav/index'; |
| 17 | import { download } from "@/utils/common"; | 14 | import { download } from "@/utils/common"; |
| ... | @@ -69,56 +66,7 @@ const getData = () => { | ... | @@ -69,56 +66,7 @@ const getData = () => { |
| 69 | }); | 66 | }); |
| 70 | } | 67 | } |
| 71 | 68 | ||
| 72 | const getTextAlign = (field) => { | ||
| 73 | if (field.dataType === 'decimal' || field.dataType === 'int' || field.dataType == 'bit' || field.dataType == 'tinyint') { | ||
| 74 | return 'right'; | ||
| 75 | } | ||
| 76 | return 'left' | ||
| 77 | } | ||
| 78 | |||
| 79 | /** otherWidth表示使用标题宽度时添加标题排序图标等宽度 */ | ||
| 80 | const calcTableColumnWidth = (data: any[], prop, title, otherWidth = 0) => { | ||
| 81 | let d: any[] = []; | ||
| 82 | data.forEach((dt) => d.push(dt[prop])); | ||
| 83 | return calcColumnWidth( | ||
| 84 | d, | ||
| 85 | title, | ||
| 86 | { | ||
| 87 | fontSize: 14, | ||
| 88 | fontFamily: "SimSun", | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | fontSize: 14, | ||
| 92 | fontFamily: "SimSun", | ||
| 93 | }, | ||
| 94 | otherWidth | ||
| 95 | ); | ||
| 96 | }; | ||
| 97 | |||
| 98 | /** 每列字段对应的列宽计算结果。 */ | ||
| 99 | const originTableFieldColumn = ref({}); | ||
| 100 | 69 | ||
| 101 | watch( | ||
| 102 | tableData, | ||
| 103 | (val: any[], oldVal) => { | ||
| 104 | if (!tableFields.value?.length) { | ||
| 105 | originTableFieldColumn.value = {}; | ||
| 106 | return; | ||
| 107 | } | ||
| 108 | originTableFieldColumn.value = {}; | ||
| 109 | tableFields.value.forEach((field, index) => { | ||
| 110 | originTableFieldColumn.value[field.enName] = calcTableColumnWidth( | ||
| 111 | val?.slice(0, 20) || [], | ||
| 112 | field.enName, | ||
| 113 | field.chName, | ||
| 114 | 24 | ||
| 115 | ); | ||
| 116 | }); | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | deep: true, | ||
| 120 | } | ||
| 121 | ); | ||
| 122 | 70 | ||
| 123 | watch(() => props.execGuid, (val) => { | 71 | watch(() => props.execGuid, (val) => { |
| 124 | if (!val) { | 72 | if (!val) { |
| ... | @@ -157,27 +105,7 @@ onBeforeMount(() => { | ... | @@ -157,27 +105,7 @@ onBeforeMount(() => { |
| 157 | }); | 105 | }); |
| 158 | }); | 106 | }); |
| 159 | 107 | ||
| 160 | const formatterPreviewDate = (row, info) => { | 108 | |
| 161 | let enName = info.enName; | ||
| 162 | let v = row[enName]; | ||
| 163 | if (v === 0) { | ||
| 164 | return v; | ||
| 165 | } | ||
| 166 | if (!v || v == 'null') { | ||
| 167 | return '--'; | ||
| 168 | } | ||
| 169 | if (info.dataType === 'datetime') { | ||
| 170 | return Moment(v).format('YYYY-MM-DD HH:mm:ss'); | ||
| 171 | } | ||
| 172 | if (info.dataType === 'date') { | ||
| 173 | if (isNaN(<any>(new Date(v)))) { | ||
| 174 | return Moment(parseInt(v)).format('YYYY-MM-DD'); | ||
| 175 | } else { | ||
| 176 | return Moment(v).format('YYYY-MM-DD'); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | return v; | ||
| 180 | }; | ||
| 181 | 109 | ||
| 182 | const pageChange = (info) => { | 110 | const pageChange = (info) => { |
| 183 | pageInfo.value.curr = Number(info.curr); | 111 | pageInfo.value.curr = Number(info.curr); |
| ... | @@ -212,19 +140,14 @@ const exportData = () => { | ... | @@ -212,19 +140,14 @@ const exportData = () => { |
| 212 | <div class="table_tool_wrap" v-loading="tableDataLoading"> | 140 | <div class="table_tool_wrap" v-loading="tableDataLoading"> |
| 213 | <el-button v-show="props.isPage" style="margin-bottom: 8px;" type="primary" @click="exportData" | 141 | <el-button v-show="props.isPage" style="margin-bottom: 8px;" type="primary" @click="exportData" |
| 214 | v-preReClick>导出数据</el-button> | 142 | v-preReClick>导出数据</el-button> |
| 215 | <el-table ref="tableRef" v-show="tableFields.length" :data="tableData" :highlight-current-row="true" stripe border | 143 | <CommonTable |
| 216 | tooltip-effect="light" height="100%" row-key="guid" :style="{ width: '100%', height: !props.isPage ? 'calc(100% - 34px)' : 'calc(100% - 64px)' }"> | 144 | v-show="tableFields.length" |
| 217 | <template v-for="(item, index) in (tableFields || [])"> | 145 | :data="tableData" |
| 218 | <el-table-column :label="item.chName" :width="item.dataType === 'datetime' | 146 | :fields="tableFields" |
| 219 | ? TableColumnWidth.DATETIME | 147 | :loading="tableDataLoading" |
| 220 | : item.dataType === 'date' | 148 | :height="'100%'" |
| 221 | ? TableColumnWidth.DATE | 149 | :style="{ width: '100%', height: !props.isPage ? 'calc(100% - 34px)' : 'calc(100% - 64px)' }" |
| 222 | : originTableFieldColumn[item.enName] | 150 | /> |
| 223 | " :align="getTextAlign(item)" :header-align="getTextAlign(item)" | ||
| 224 | :formatter="(row) => formatterPreviewDate(row, item)" :show-overflow-tooltip="true"> | ||
| 225 | </el-table-column> | ||
| 226 | </template> | ||
| 227 | </el-table> | ||
| 228 | <div v-show="!tableFields.length" class="empty-content"> | 151 | <div v-show="!tableFields.length" class="empty-content"> |
| 229 | <img src="../../assets/images/empty-data.png" :style="{ width: '168px', height: '96px' }" /> | 152 | <img src="../../assets/images/empty-data.png" :style="{ width: '168px', height: '96px' }" /> |
| 230 | <div class="empty-text">暂无数据</div> | 153 | <div class="empty-text">暂无数据</div> | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -98,7 +98,7 @@ | ... | @@ -98,7 +98,7 @@ |
| 98 | </div> | 98 | </div> |
| 99 | </div> | 99 | </div> |
| 100 | <div class="result-title">重标识风险表</div> | 100 | <div class="result-title">重标识风险表</div> |
| 101 | <el-table ref="tableRef" v-show="analysisResultTableFields.length" :data="resultData" | 101 | <el-table ref="tableRef" v-show="analysisResultTableFields?.length" :data="resultData" |
| 102 | v-loading="analysisResultLoading" :highlight-current-row="true" stripe border tooltip-effect="light" | 102 | v-loading="analysisResultLoading" :highlight-current-row="true" stripe border tooltip-effect="light" |
| 103 | height="100%" row-key="guid" :style="{ width: '100%', height: '280px' }"> | 103 | height="100%" row-key="guid" :style="{ width: '100%', height: '280px' }"> |
| 104 | <el-table-column label="等价类" type="index" width="68px" align="center" show-overflow-tooltip> | 104 | <el-table-column label="等价类" type="index" width="68px" align="center" show-overflow-tooltip> |
| ... | @@ -127,14 +127,14 @@ | ... | @@ -127,14 +127,14 @@ |
| 127 | <el-table-column label="判断重风险是否大于门限阈值" prop="isGtThreshold" width="130" align="left" fixed="right" | 127 | <el-table-column label="判断重风险是否大于门限阈值" prop="isGtThreshold" width="130" align="left" fixed="right" |
| 128 | show-overflow-tooltip></el-table-column> | 128 | show-overflow-tooltip></el-table-column> |
| 129 | </el-table> | 129 | </el-table> |
| 130 | <div v-show="!analysisResultTableFields.length" class="empty-content"> | 130 | <div v-show="!analysisResultTableFields?.length" class="empty-content"> |
| 131 | <img src="../../../assets/images/empty-data.png" :style="{ width: '168px', height: '96px' }" /> | 131 | <img src="../../../assets/images/empty-data.png" :style="{ width: '168px', height: '96px' }" /> |
| 132 | <div class="empty-text">暂无数据</div> | 132 | <div class="empty-text">暂无数据</div> |
| 133 | </div> | 133 | </div> |
| 134 | <div v-show="analysisResultTableFields.length" class="result-table-desc">门限阈值的取值:完全公开共享数据发布,取值 | 134 | <div v-show="analysisResultTableFields?.length" class="result-table-desc">门限阈值的取值:完全公开共享数据发布,取值 |
| 135 | 1/20;受控公开共享数据发布,取值 | 135 | 1/20;受控公开共享数据发布,取值 |
| 136 | 1/5;领地公开共享数据发布,取值 1/3</div> | 136 | 1/5;领地公开共享数据发布,取值 1/3</div> |
| 137 | <PageNav v-show="analysisResultTableFields.length" :class="[pageInfo.type]" :pageInfo="pageInfo" | 137 | <PageNav v-show="analysisResultTableFields?.length" :class="[pageInfo.type]" :pageInfo="pageInfo" |
| 138 | @pageChange="pageChange" /> | 138 | @pageChange="pageChange" /> |
| 139 | <div class="row-two-main" style="margin-top: 12px;"> | 139 | <div class="row-two-main" style="margin-top: 12px;"> |
| 140 | <div class="table-one"> | 140 | <div class="table-one"> |
| ... | @@ -394,7 +394,7 @@ const props = defineProps({ | ... | @@ -394,7 +394,7 @@ const props = defineProps({ |
| 394 | }, | 394 | }, |
| 395 | analysisResultTableFields: { | 395 | analysisResultTableFields: { |
| 396 | type: Array, | 396 | type: Array, |
| 397 | default: [], | 397 | default: <any>[], |
| 398 | }, | 398 | }, |
| 399 | originResultTableFieldColumn: { | 399 | originResultTableFieldColumn: { |
| 400 | type: Object, | 400 | type: Object, | ... | ... |
-
Please register or sign in to post a comment