匿名化处理接口联调2
Showing
5 changed files
with
66 additions
and
8 deletions
| 1 | const useDataAnonymizationStore = defineStore( | 1 | const useDataAnonymizationStore = defineStore( |
| 2 | // 资产目录guid | 2 | // 资产目录guid |
| 3 | "isRefresh", | 3 | 'isRefresh', |
| 4 | () => { | 4 | () => { |
| 5 | const isRefresh = ref<boolean>(false); | 5 | const isRefresh = ref<boolean>(false); |
| 6 | function setIsRefresh(v: boolean) { | 6 | function setIsRefresh(v: boolean) { |
| 7 | isRefresh.value = v; | 7 | isRefresh.value = v; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | const isAnonPageRefresh = ref<boolean>(false); | ||
| 11 | function setIsAnonPageRefresh(v: boolean) { | ||
| 12 | isAnonPageRefresh.value = v; | ||
| 13 | } | ||
| 14 | |||
| 10 | return { | 15 | return { |
| 11 | isRefresh, | 16 | isRefresh, |
| 17 | isAnonPageRefresh, | ||
| 12 | setIsRefresh, | 18 | setIsRefresh, |
| 19 | setIsAnonPageRefresh, | ||
| 13 | }; | 20 | }; |
| 14 | } | 21 | } |
| 15 | ); | 22 | ); | ... | ... |
| ... | @@ -38,6 +38,7 @@ const tableFields: any = ref([]); | ... | @@ -38,6 +38,7 @@ const tableFields: any = ref([]); |
| 38 | 38 | ||
| 39 | const pageInfo: any = ref({ | 39 | const pageInfo: any = ref({ |
| 40 | ...commonPageConfig, | 40 | ...commonPageConfig, |
| 41 | rows: 0, | ||
| 41 | }) | 42 | }) |
| 42 | 43 | ||
| 43 | const getData = () => { | 44 | const getData = () => { |
| ... | @@ -61,6 +62,7 @@ const getData = () => { | ... | @@ -61,6 +62,7 @@ const getData = () => { |
| 61 | }); | 62 | }); |
| 62 | tableData.value.push(obj); | 63 | tableData.value.push(obj); |
| 63 | }); | 64 | }); |
| 65 | pageInfo.value.rows = res.data?.totalRows ?? 0; | ||
| 64 | } else { | 66 | } else { |
| 65 | ElMessage.error(res.msg); | 67 | ElMessage.error(res.msg); |
| 66 | } | 68 | } |
| ... | @@ -128,6 +130,7 @@ watch(() => props.execGuid, (val) => { | ... | @@ -128,6 +130,7 @@ watch(() => props.execGuid, (val) => { |
| 128 | if (res.code == proxy.$passCode) { | 130 | if (res.code == proxy.$passCode) { |
| 129 | let column = res.data?.column || {}; | 131 | let column = res.data?.column || {}; |
| 130 | tableFields.value = column; | 132 | tableFields.value = column; |
| 133 | pageInfo.value.curr = 1; | ||
| 131 | getData(); | 134 | getData(); |
| 132 | } else { | 135 | } else { |
| 133 | ElMessage.error(res.msg); | 136 | ElMessage.error(res.msg); |
| ... | @@ -210,7 +213,7 @@ const exportData = () => { | ... | @@ -210,7 +213,7 @@ const exportData = () => { |
| 210 | <el-button v-show="props.isPage" style="margin-bottom: 8px;" type="primary" @click="exportData" | 213 | <el-button v-show="props.isPage" style="margin-bottom: 8px;" type="primary" @click="exportData" |
| 211 | v-preReClick>导出数据</el-button> | 214 | v-preReClick>导出数据</el-button> |
| 212 | <el-table ref="tableRef" v-show="tableFields.length" :data="tableData" :highlight-current-row="true" stripe border | 215 | <el-table ref="tableRef" v-show="tableFields.length" :data="tableData" :highlight-current-row="true" stripe border |
| 213 | tooltip-effect="light" height="100%" row-key="guid" :style="{ width: '100%', height: 'calc(100% - 64px)' }"> | 216 | tooltip-effect="light" height="100%" row-key="guid" :style="{ width: '100%', height: !props.isPage ? 'calc(100% - 34px)' : 'calc(100% - 64px)' }"> |
| 214 | <template v-for="(item, index) in (tableFields || [])"> | 217 | <template v-for="(item, index) in (tableFields || [])"> |
| 215 | <el-table-column :label="item.chName" :width="item.dataType === 'datetime' | 218 | <el-table-column :label="item.chName" :width="item.dataType === 'datetime' |
| 216 | ? TableColumnWidth.DATETIME | 219 | ? TableColumnWidth.DATETIME | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -12,6 +12,7 @@ import { | ... | @@ -12,6 +12,7 @@ import { |
| 12 | validateAnonRule, | 12 | validateAnonRule, |
| 13 | } from '@/api/modules/dataAnonymization'; | 13 | } from '@/api/modules/dataAnonymization'; |
| 14 | import { useValidator } from '@/hooks/useValidator'; | 14 | import { useValidator } from '@/hooks/useValidator'; |
| 15 | import { cloneDeep } from 'lodash-es'; | ||
| 15 | 16 | ||
| 16 | const props = defineProps({ | 17 | const props = defineProps({ |
| 17 | fieldTypeList: { | 18 | fieldTypeList: { |
| ... | @@ -460,7 +461,7 @@ const drawerBtnClick = async (btn, info) => { | ... | @@ -460,7 +461,7 @@ const drawerBtnClick = async (btn, info) => { |
| 460 | proxy.$ElMessage.error('K匿名泛化与脱敏规则不能同时为空'); | 461 | proxy.$ElMessage.error('K匿名泛化与脱敏规则不能同时为空'); |
| 461 | return; | 462 | return; |
| 462 | } | 463 | } |
| 463 | if ((info.fieldTypeCode == 'int' || info.fieldTypeCode == 'decimal' || info.fieldTypeCode == 'tinyint')) { | 464 | if (!(info.fieldTypeCode == 'int' || info.fieldTypeCode == 'decimal' || info.fieldTypeCode == 'tinyint')) { |
| 464 | if (info.desensitiveRuleCode == 'ROUNDING') { | 465 | if (info.desensitiveRuleCode == 'ROUNDING') { |
| 465 | proxy.$ElMessage.error('数值类型字段的脱敏规则不能设置取整'); | 466 | proxy.$ElMessage.error('数值类型字段的脱敏规则不能设置取整'); |
| 466 | return; | 467 | return; |
| ... | @@ -1037,7 +1038,7 @@ const getStepTwoConfigInfo = async () => { | ... | @@ -1037,7 +1038,7 @@ const getStepTwoConfigInfo = async () => { |
| 1037 | await privacyFormRef.value?.ruleFormRef?.validate(); | 1038 | await privacyFormRef.value?.ruleFormRef?.validate(); |
| 1038 | // 验证通过 | 1039 | // 验证通过 |
| 1039 | return { | 1040 | return { |
| 1040 | anonPrivacyMode: privacyFormRef.value?.formInline, | 1041 | anonPrivacyMode: cloneDeep(privacyFormRef.value?.formInline), |
| 1041 | anonTaskRules: ruleModelTableInfo.value.data | 1042 | anonTaskRules: ruleModelTableInfo.value.data |
| 1042 | }; | 1043 | }; |
| 1043 | } catch (error) { | 1044 | } catch (error) { |
| ... | @@ -1046,8 +1047,43 @@ const getStepTwoConfigInfo = async () => { | ... | @@ -1046,8 +1047,43 @@ const getStepTwoConfigInfo = async () => { |
| 1046 | } | 1047 | } |
| 1047 | } | 1048 | } |
| 1048 | 1049 | ||
| 1050 | /** 字段改变,可能是切换了表,需要清空规则配置。判断 第一步到第二步时,如果字段列表中与字段脱敏规则中的字段不匹配,应清空,并同时清空T接近字段。 */ | ||
| 1051 | const updateNextStepRules = () => { | ||
| 1052 | let deleteFieldNames: string[] = []; | ||
| 1053 | ruleModelTableInfo.value.data = ruleModelTableInfo.value.data.filter(rule => { | ||
| 1054 | if (!props.fieldNameList?.some(v => v.enName == rule.fieldName)) { | ||
| 1055 | deleteFieldNames.push(rule.fieldName); | ||
| 1056 | return false; | ||
| 1057 | } | ||
| 1058 | return true; | ||
| 1059 | }); | ||
| 1060 | if (deleteFieldNames?.length) { | ||
| 1061 | let optionsList = ruleModelTableInfo.value.data?.map(v => { | ||
| 1062 | return { | ||
| 1063 | fieldName: v.fieldName, | ||
| 1064 | fieldChName: v.fieldChName | ||
| 1065 | } | ||
| 1066 | }) || []; | ||
| 1067 | privacyFormItems.value[2].children[0].options = optionsList; | ||
| 1068 | privacyFormItems.value[3].children[0].options = optionsList; | ||
| 1069 | let formInline = privacyFormRef.value?.formInline; | ||
| 1070 | privacyFormItems.value.forEach((item, index) => { | ||
| 1071 | item.default = formInline[item.field]; | ||
| 1072 | if (item.default == 'Y') { | ||
| 1073 | item.children?.forEach(child => { | ||
| 1074 | child.default = formInline[child.field]; | ||
| 1075 | if ((child.field == 'tcFieldName' || child.field == 'ldFieldName') && deleteFieldNames.includes(child.default)) { | ||
| 1076 | child.default = '' | ||
| 1077 | } | ||
| 1078 | }); | ||
| 1079 | } | ||
| 1080 | }) | ||
| 1081 | } | ||
| 1082 | } | ||
| 1083 | |||
| 1049 | defineExpose({ | 1084 | defineExpose({ |
| 1050 | getStepTwoConfigInfo | 1085 | getStepTwoConfigInfo, |
| 1086 | updateNextStepRules | ||
| 1051 | }) | 1087 | }) |
| 1052 | 1088 | ||
| 1053 | </script> | 1089 | </script> | ... | ... |
| ... | @@ -12,7 +12,9 @@ import { | ... | @@ -12,7 +12,9 @@ import { |
| 12 | deleteAnonTask, | 12 | deleteAnonTask, |
| 13 | } from '@/api/modules/dataAnonymization'; | 13 | } from '@/api/modules/dataAnonymization'; |
| 14 | import { useValidator } from '@/hooks/useValidator'; | 14 | import { useValidator } from '@/hooks/useValidator'; |
| 15 | import useDataAnonymizationStore from "@/store/modules/dataAnonymization"; | ||
| 15 | 16 | ||
| 17 | const anonymizationStore = useDataAnonymizationStore(); | ||
| 16 | const router = useRouter() | 18 | const router = useRouter() |
| 17 | const { proxy } = getCurrentInstance() as any; | 19 | const { proxy } = getCurrentInstance() as any; |
| 18 | const { required } = useValidator(); | 20 | const { required } = useValidator(); |
| ... | @@ -70,8 +72,8 @@ const tableInfo = ref({ | ... | @@ -70,8 +72,8 @@ const tableInfo = ref({ |
| 70 | width: 180, | 72 | width: 180, |
| 71 | fixed: 'right', | 73 | fixed: 'right', |
| 72 | btns: (scope) => { | 74 | btns: (scope) => { |
| 73 | return [ { | 75 | return [{ |
| 74 | label: "编辑", value: "edit", disabled: scope.row.status == 'R', click: (scope) => { | 76 | label: "编辑", value: "edit", click: (scope) => { |
| 75 | router.push({ | 77 | router.push({ |
| 76 | name: 'anonTaskCreate', | 78 | name: 'anonTaskCreate', |
| 77 | query: { | 79 | query: { |
| ... | @@ -92,11 +94,12 @@ const tableInfo = ref({ | ... | @@ -92,11 +94,12 @@ const tableInfo = ref({ |
| 92 | }); | 94 | }); |
| 93 | } | 95 | } |
| 94 | }, { | 96 | }, { |
| 95 | label: "删除", value: "delete", disabled: scope.row.status == 'R', click: (scope) => { | 97 | label: "删除", value: "delete", click: (scope) => { |
| 96 | proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => { | 98 | proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => { |
| 97 | let guids = [scope.row.guid]; | 99 | let guids = [scope.row.guid]; |
| 98 | deleteAnonTask(guids).then((res: any) => { | 100 | deleteAnonTask(guids).then((res: any) => { |
| 99 | if (res?.code == proxy.$passCode) { | 101 | if (res?.code == proxy.$passCode) { |
| 102 | page.value.curr = 1; | ||
| 100 | getTableData(); | 103 | getTableData(); |
| 101 | proxy.$ElMessage({ | 104 | proxy.$ElMessage({ |
| 102 | type: "success", | 105 | type: "success", |
| ... | @@ -169,8 +172,17 @@ const handleCreate = () => { | ... | @@ -169,8 +172,17 @@ const handleCreate = () => { |
| 169 | 172 | ||
| 170 | onBeforeMount(() => { | 173 | onBeforeMount(() => { |
| 171 | toSearch({}); | 174 | toSearch({}); |
| 175 | anonymizationStore.setIsAnonPageRefresh(false); | ||
| 172 | }) | 176 | }) |
| 173 | 177 | ||
| 178 | onActivated(() => { | ||
| 179 | if (anonymizationStore.isAnonPageRefresh) {//如果是首次加载,则不需要调用 | ||
| 180 | page.value.curr = 1; | ||
| 181 | getTableData(); | ||
| 182 | anonymizationStore.setIsAnonPageRefresh(false); | ||
| 183 | } | ||
| 184 | }); | ||
| 185 | |||
| 174 | </script> | 186 | </script> |
| 175 | 187 | ||
| 176 | <template> | 188 | <template> | ... | ... |
-
Please register or sign in to post a comment