Commit 299375a8 authored by 张伯涛's avatar 张伯涛

数据安全--脱敏算法

parent b142d4c1
import { getAllRoleList } from '@/api/system/role/role';
import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { useMessage } from '@/hooks/web/useMessage';
import { changeFlagApi } from '@/api/system/user/user';
// 引入开关组件
type CheckedType = boolean | string | number;
/** 列表筛选项*/
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '',
component: 'Input',
colProps: { span: 4 },
componentProps: {
placeholder: '搜索算法',
},
},
{
field: 'flag',
label: ' ',
component: 'Select',
colProps: { span: 4 },
componentProps: {
placeholder: '来源',
options: [
{ label: '预置', value: '预置' },
{ label: '自定义', value: '自定义' },
],
},
},
];
/** 列表展示字段*/
export const columns: BasicColumn[] = [
{
title: '名称',
dataIndex: 'name',
width: 120,
},
{
title: '函数名',
dataIndex: 'functionName',
width: 120,
},
{
title: '算法描述',
dataIndex: 'algorithmDes',
width: 120,
},
{
title: '来源',
dataIndex: 'source',
width: 140,
},
{
title: '拥有者',
dataIndex: 'owner',
width: 140,
},
{
title: '创建时间',
dataIndex: 'createDate',
width: 180,
},
{
title: '更新时间',
dataIndex: 'updateDate',
width: 180,
},
];
/** 新增编辑表单字段*/
export const formSchema: any[] = [
{
field: 'name',
label: '名称',
component: 'Input',
rules: [
{
required: true,
message: '请输入名称',
},
],
},
{
field: 'functionName',
label: '函数名',
component: 'Input',
rules: [
{
required: true,
message: '请输入函数名',
},
],
},
{
field: 'algorithmDes',
label: '算法描述',
component: 'Input',
rules: [
{
required: true,
message: '请输入算法描述',
},
],
},
{
field: 'params',
label: '参数',
component: 'Select',
componentProps: {
options: [
{ label: 'STRING', value: 'STRING' },
{ label: 'INT', value: 'INT' },
],
},
rules: [
{
required: true,
message: '请选择敏感类型',
},
],
},
{
field: 'describe',
component: 'InputTextArea',
label: '参数描述',
componentProps: {
placeholder: '请输入参数描述',
rows: 1,
},
},
{
field: 'achieveMethod',
component: 'Checkbox',
label: '实现方式',
colProps: {
span: 8,
},
renderComponentContent: 'API',
},
]
<template>
<BasicModal width="40%" v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { formSchema } from './desensitizationAlgorithm.data';
import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { lg: 24, md: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
// 通过id获取行详情信息
// 塞值
setFieldsValue({
...data.record,
});
}
});
const getTitle = computed(() => (!unref(isUpdate) ? '新建脱敏算法' : '编辑脱敏算法'));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
// TODO custom api
closeModal();
emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>
<template> <template>
<div>脱敏算法 <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
</div> <BasicTable @register="registerTable" :searchInfo="searchInfo">
</template> <template #toolbar>
<a-button type="primary" @click="handleCreate">新增</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
label: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</template>
</BasicTable>
<sensitiveRulesModal @register="registerModal" @success="handleSuccess" />
</PageWrapper>
</template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { PageWrapper } from '@/components/Page';
import { useMessage } from '@/hooks/web/useMessage';
import { useModal } from '@/components/Modal';
import sensitiveRulesModal from './desensitizationAlgorithmModal.vue';
</script> import { columns, searchFormSchema } from './desensitizationAlgorithm.data';
import {tableList} from "@/views/dataSecurity/desensitizationAlgorithm/mock";
import { useRoute, onBeforeRouteLeave } from 'vue-router';
import { router } from '@/router';
defineOptions({ name: 'sensitiveRules' });
const { createMessage } = useMessage();
const route = useRoute();
const [registerModal, { openModal }] = useModal();
const [registerResetPassword, { openModal: openResetPasswordModal }] = useModal();
const [registerImport, { openModal: openImportModal }] = useModal();
const searchInfo = reactive<Recordable>({});
const [registerTable, { reload, updateTableDataRecord, getSearchInfo, getForm }] = useTable({
title: '脱敏算法',
api: async (params) => {
console.log(params)
const response = {
pageNu: "1",
pageSize: "10",
pages: "1",
total: tableList.length,
code:'',
message:'',
data: tableList,
};
return { ...response};
},
rowKey: 'id',
columns,
formConfig: {
labelWidth: 10,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
<style scoped> },
useSearchForm: true,
showTableSetting: false,
bordered: true,
handleSearchInfoFn(info) {
console.log('handleSearchInfoFn', info);
return info;
},
actionColumn: {
width: 120,
title: '操作',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
/** 新增按钮*/
function handleCreate() {
openModal(true, {
isUpdate: false,
});
}
/** 编辑按钮*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
});
}
</style> /** 重置密码弹窗确定按钮*/
/** 删除按钮*/
function handleDelete(record: Recordable) {
console.log(record);
createMessage.success('删除成功!');
reload();
}
/** 新增/编辑成功*/
function handleSuccess({ isUpdate, values }) {
if (isUpdate) {
// 演示不刷新表格直接更新内部数据。
// 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
const result = updateTableDataRecord(values.id, values);
console.log(result);
reload();
} else {
reload();
}
}
onMounted(() => {
});
</script>
export const tableList: any[] = [
{
"name" : "Blur",
"functionName" : "blur",
"algorithmDes" : "将整数或小数混淆...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "random",
"functionName" : "random",
"algorithmDes" : "返回一个介于x和y...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "Blur",
"functionName" : "blur",
"algorithmDes" : "将整数或小数混淆...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "random",
"functionName" : "random",
"algorithmDes" : "返回一个介于x和y...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "Blur",
"functionName" : "blur",
"algorithmDes" : "将整数或小数混淆...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "random",
"functionName" : "random",
"algorithmDes" : "返回一个介于x和y...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "Blur",
"functionName" : "blur",
"algorithmDes" : "将整数或小数混淆...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "random",
"functionName" : "random",
"algorithmDes" : "返回一个介于x和y...",
"source" : "自定义",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
]
...@@ -44,7 +44,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data ...@@ -44,7 +44,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
}); });
const getTitle = computed(() => (!unref(isUpdate) ? '新建安全分级' : '编辑安全分级')); const getTitle = computed(() => (!unref(isUpdate) ? '新建敏感规则' : '编辑敏感规则'));
......
...@@ -44,7 +44,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data ...@@ -44,7 +44,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
}); });
const getTitle = computed(() => (!unref(isUpdate) ? '新建安全分级' : '编辑安全分级')); const getTitle = computed(() => (!unref(isUpdate) ? '新建敏感类型' : '编辑敏感类型'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment