2aa70cc4 by lihua

匿名化处理接口联调2

1 parent fd5bd230
const useDataAnonymizationStore = defineStore(
// 资产目录guid
"isRefresh",
'isRefresh',
() => {
const isRefresh = ref<boolean>(false);
function setIsRefresh(v: boolean) {
isRefresh.value = v;
}
const isAnonPageRefresh = ref<boolean>(false);
function setIsAnonPageRefresh(v: boolean) {
isAnonPageRefresh.value = v;
}
return {
isRefresh,
isAnonPageRefresh,
setIsRefresh,
setIsAnonPageRefresh,
};
}
);
......
......@@ -38,6 +38,7 @@ const tableFields: any = ref([]);
const pageInfo: any = ref({
...commonPageConfig,
rows: 0,
})
const getData = () => {
......@@ -61,6 +62,7 @@ const getData = () => {
});
tableData.value.push(obj);
});
pageInfo.value.rows = res.data?.totalRows ?? 0;
} else {
ElMessage.error(res.msg);
}
......@@ -128,6 +130,7 @@ watch(() => props.execGuid, (val) => {
if (res.code == proxy.$passCode) {
let column = res.data?.column || {};
tableFields.value = column;
pageInfo.value.curr = 1;
getData();
} else {
ElMessage.error(res.msg);
......@@ -210,7 +213,7 @@ const exportData = () => {
<el-button v-show="props.isPage" style="margin-bottom: 8px;" type="primary" @click="exportData"
v-preReClick>导出数据</el-button>
<el-table ref="tableRef" v-show="tableFields.length" :data="tableData" :highlight-current-row="true" stripe border
tooltip-effect="light" height="100%" row-key="guid" :style="{ width: '100%', height: 'calc(100% - 64px)' }">
tooltip-effect="light" height="100%" row-key="guid" :style="{ width: '100%', height: !props.isPage ? 'calc(100% - 34px)' : 'calc(100% - 64px)' }">
<template v-for="(item, index) in (tableFields || [])">
<el-table-column :label="item.chName" :width="item.dataType === 'datetime'
? TableColumnWidth.DATETIME
......
......@@ -12,6 +12,7 @@ import {
validateAnonRule,
} from '@/api/modules/dataAnonymization';
import { useValidator } from '@/hooks/useValidator';
import { cloneDeep } from 'lodash-es';
const props = defineProps({
fieldTypeList: {
......@@ -460,7 +461,7 @@ const drawerBtnClick = async (btn, info) => {
proxy.$ElMessage.error('K匿名泛化与脱敏规则不能同时为空');
return;
}
if ((info.fieldTypeCode == 'int' || info.fieldTypeCode == 'decimal' || info.fieldTypeCode == 'tinyint')) {
if (!(info.fieldTypeCode == 'int' || info.fieldTypeCode == 'decimal' || info.fieldTypeCode == 'tinyint')) {
if (info.desensitiveRuleCode == 'ROUNDING') {
proxy.$ElMessage.error('数值类型字段的脱敏规则不能设置取整');
return;
......@@ -1037,7 +1038,7 @@ const getStepTwoConfigInfo = async () => {
await privacyFormRef.value?.ruleFormRef?.validate();
// 验证通过
return {
anonPrivacyMode: privacyFormRef.value?.formInline,
anonPrivacyMode: cloneDeep(privacyFormRef.value?.formInline),
anonTaskRules: ruleModelTableInfo.value.data
};
} catch (error) {
......@@ -1046,8 +1047,43 @@ const getStepTwoConfigInfo = async () => {
}
}
/** 字段改变,可能是切换了表,需要清空规则配置。判断 第一步到第二步时,如果字段列表中与字段脱敏规则中的字段不匹配,应清空,并同时清空T接近字段。 */
const updateNextStepRules = () => {
let deleteFieldNames: string[] = [];
ruleModelTableInfo.value.data = ruleModelTableInfo.value.data.filter(rule => {
if (!props.fieldNameList?.some(v => v.enName == rule.fieldName)) {
deleteFieldNames.push(rule.fieldName);
return false;
}
return true;
});
if (deleteFieldNames?.length) {
let optionsList = ruleModelTableInfo.value.data?.map(v => {
return {
fieldName: v.fieldName,
fieldChName: v.fieldChName
}
}) || [];
privacyFormItems.value[2].children[0].options = optionsList;
privacyFormItems.value[3].children[0].options = optionsList;
let formInline = privacyFormRef.value?.formInline;
privacyFormItems.value.forEach((item, index) => {
item.default = formInline[item.field];
if (item.default == 'Y') {
item.children?.forEach(child => {
child.default = formInline[child.field];
if ((child.field == 'tcFieldName' || child.field == 'ldFieldName') && deleteFieldNames.includes(child.default)) {
child.default = ''
}
});
}
})
}
}
defineExpose({
getStepTwoConfigInfo
getStepTwoConfigInfo,
updateNextStepRules
})
</script>
......
......@@ -12,7 +12,9 @@ import {
deleteAnonTask,
} from '@/api/modules/dataAnonymization';
import { useValidator } from '@/hooks/useValidator';
import useDataAnonymizationStore from "@/store/modules/dataAnonymization";
const anonymizationStore = useDataAnonymizationStore();
const router = useRouter()
const { proxy } = getCurrentInstance() as any;
const { required } = useValidator();
......@@ -70,8 +72,8 @@ const tableInfo = ref({
width: 180,
fixed: 'right',
btns: (scope) => {
return [ {
label: "编辑", value: "edit", disabled: scope.row.status == 'R', click: (scope) => {
return [{
label: "编辑", value: "edit", click: (scope) => {
router.push({
name: 'anonTaskCreate',
query: {
......@@ -92,11 +94,12 @@ const tableInfo = ref({
});
}
}, {
label: "删除", value: "delete", disabled: scope.row.status == 'R', click: (scope) => {
label: "删除", value: "delete", click: (scope) => {
proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => {
let guids = [scope.row.guid];
deleteAnonTask(guids).then((res: any) => {
if (res?.code == proxy.$passCode) {
page.value.curr = 1;
getTableData();
proxy.$ElMessage({
type: "success",
......@@ -169,8 +172,17 @@ const handleCreate = () => {
onBeforeMount(() => {
toSearch({});
anonymizationStore.setIsAnonPageRefresh(false);
})
onActivated(() => {
if (anonymizationStore.isAnonPageRefresh) {//如果是首次加载,则不需要调用
page.value.curr = 1;
getTableData();
anonymizationStore.setIsAnonPageRefresh(false);
}
});
</script>
<template>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!