Commit bc64a5b4 authored by 张伯涛's avatar 张伯涛

数据安全--安全分级

parent 64692b3e
<template> <template>
<div>安全分级</div> <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
</template> <BasicTable @register="registerTable" :searchInfo="searchInfo">
<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>
<safetyLevelModal @register="registerModal" @success="handleSuccess" />
</PageWrapper>
</template>
<script lang="ts" setup> <script lang="ts" setup>
</script> 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 safetyLevelModal from './safetyLevelModal.vue';
import { columns, searchFormSchema } from './safety.data';
import {tableList} from "@/views/dataSecurity/safetyLevel/mock";
import { useRoute, onBeforeRouteLeave } from 'vue-router';
import { router } from '@/router';
defineOptions({ name: 'safetyLevelManage' });
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,
};
<style scoped> return { ...response};
},
rowKey: 'id',
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
resetFunc: () => {
searchInfo.deptId = '';
},
},
useSearchForm: false,
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(() => {
});
onBeforeRouteLeave((to, from, next) => {
});
</script>
export const tableList: any[] = [
{
"name" : "G1",
"sort" : "333",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "拒绝",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "2",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "脱敏",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "3",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "拒绝",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "44",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "脱敏",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "5",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "放行",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "12",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "拒绝",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "87",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "脱敏",
"owner" : "放行",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "33",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "脱敏",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
{
"name" : "G1",
"sort" : "65",
"describe" : "重要数据:数据得安全属性",
"protectAction" : "放行",
"owner" : "admin",
"createDate" : "2024-10-24 10:04:04",
"updateDate" : "2024-10-24 10:04:04",
},
]
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[] = [
];
/** 列表展示字段*/
export const columns: BasicColumn[] = [
{
title: '名称',
dataIndex: 'name',
width: 120,
},
{
title: '优先级排序',
dataIndex: 'sort',
width: 120,
},
{
title: '描述',
dataIndex: 'describe',
width: 120,
},
{
title: '推荐保护动作',
dataIndex: 'protectAction',
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: 'sort',
label: '优先级排序',
component: 'Input',
rules: [
{
required: true,
message: '请输入优先级排序',
},
],
},
{
field: 'describe',
component: 'InputTextArea',
label: '描述',
componentProps: {
placeholder: '请输入描述',
rows: 4,
},
},
{
field: 'protectAction',
label: '推荐保护动作',
component: 'Select',
componentProps: {
options: [
{ label: '脱敏', value: '脱敏' },
{ label: '放行', value: '放行' },
{ label: '拒绝', value: '拒绝' },
],
},
rules: [
{
required: true,
message: '请选择推荐保护动作',
},
],
},
]
<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 './safety.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>
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