项目初始化
This commit is contained in:
122
web/src/views/backend/security/dataRecycle/index.vue
Normal file
122
web/src/views/backend/security/dataRecycle/index.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div class="default-main ba-table-box">
|
||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||
|
||||
<!-- 表格顶部菜单 -->
|
||||
<TableHeader
|
||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('security.dataRecycle.Rule name') })"
|
||||
/>
|
||||
|
||||
<!-- 表格 -->
|
||||
<!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
|
||||
<Table ref="tableRef" />
|
||||
|
||||
<!-- 表单 -->
|
||||
<PopupForm />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, useTemplateRef } from 'vue'
|
||||
import baTableClass from '/@/utils/baTable'
|
||||
import { add, url } from '/@/api/backend/security/dataRecycle'
|
||||
import PopupForm from './popupForm.vue'
|
||||
import Table from '/@/components/table/index.vue'
|
||||
import TableHeader from '/@/components/table/header/index.vue'
|
||||
import { defaultOptButtons } from '/@/components/table'
|
||||
import { baTableApi } from '/@/api/common'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({
|
||||
name: 'security/dataRecycle',
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
const tableRef = useTemplateRef('tableRef')
|
||||
|
||||
const baTable = new baTableClass(
|
||||
new baTableApi(url),
|
||||
{
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', operator: false },
|
||||
{ label: 'ID', prop: 'id', align: 'center', operator: '=', operatorPlaceholder: t('Id'), width: 70 },
|
||||
{ label: t('security.dataRecycle.Rule name'), prop: 'name', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||
{
|
||||
label: t('security.dataRecycle.controller'),
|
||||
prop: 'controller',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('Connection'),
|
||||
prop: 'connection',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycle.data sheet'),
|
||||
prop: 'data_table',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycle.Data table primary key'),
|
||||
prop: 'primary_key',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
label: t('State'),
|
||||
prop: 'status',
|
||||
align: 'center',
|
||||
render: 'tag',
|
||||
custom: { 0: 'danger', 1: 'success' },
|
||||
replaceValue: { 0: t('Disable'), 1: t('security.dataRecycle.Deleting monitoring') },
|
||||
},
|
||||
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||
{ label: t('Create time'), prop: 'create_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||
{
|
||||
label: t('Operate'),
|
||||
align: 'center',
|
||||
width: '130',
|
||||
render: 'buttons',
|
||||
buttons: defaultOptButtons(['edit', 'delete']),
|
||||
operator: false,
|
||||
},
|
||||
],
|
||||
dblClickNotEditColumn: [undefined, 'status'],
|
||||
},
|
||||
{
|
||||
defaultItems: {
|
||||
status: 1,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// 获取控制器和数据表数据
|
||||
baTable.before.toggleForm = ({ operate }) => {
|
||||
if (operate == 'Add' || operate == 'Edit') {
|
||||
baTable.form.loading = true
|
||||
add().then((res) => {
|
||||
baTable.form.extend!.controllerList = res.data.controllers
|
||||
baTable.form.loading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.table.ref = tableRef.value
|
||||
baTable.mount()
|
||||
baTable.getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
152
web/src/views/backend/security/dataRecycle/popupForm.vue
Normal file
152
web/src/views/backend/security/dataRecycle/popupForm.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<!-- 对话框表单 -->
|
||||
<el-dialog
|
||||
class="ba-operate-dialog"
|
||||
:close-on-click-modal="false"
|
||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
||||
@close="baTable.toggleForm"
|
||||
>
|
||||
<template #header>
|
||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
||||
<div
|
||||
class="ba-operate-form"
|
||||
:class="'ba-' + baTable.form.operate + '-form'"
|
||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
||||
>
|
||||
<el-form
|
||||
v-if="!baTable.form.loading"
|
||||
ref="formRef"
|
||||
@keyup.enter="baTable.onSubmit(formRef)"
|
||||
:model="baTable.form.items"
|
||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||
:label-width="baTable.form.labelWidth + 'px'"
|
||||
:rules="rules"
|
||||
>
|
||||
<FormItem
|
||||
:label="t('security.dataRecycle.Rule name')"
|
||||
type="string"
|
||||
v-model="baTable.form.items!.name"
|
||||
prop="name"
|
||||
:placeholder="t('security.dataRecycle.The rule name helps to identify deleted data later')"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.dataRecycle.controller')"
|
||||
type="select"
|
||||
v-model="baTable.form.items!.controller"
|
||||
prop="controller"
|
||||
:input-attr="{ content: baTable.form.extend!.controllerList }"
|
||||
:placeholder="t('security.dataRecycle.The data collection mechanism will monitor delete operations under this controller')"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('Database connection')"
|
||||
v-model="baTable.form.items!.connection"
|
||||
type="remoteSelect"
|
||||
:block-help="t('Database connection help')"
|
||||
:input-attr="{
|
||||
pk: 'key',
|
||||
field: 'key',
|
||||
remoteUrl: getDatabaseConnectionListUrl,
|
||||
valueOnClear: '',
|
||||
}"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.dataRecycle.Corresponding data sheet')"
|
||||
type="remoteSelect"
|
||||
v-model="baTable.form.items!.data_table"
|
||||
:key="baTable.form.items!.connection"
|
||||
:input-attr="{
|
||||
pk: 'table',
|
||||
field: 'comment',
|
||||
params: {
|
||||
connection: baTable.form.items!.connection,
|
||||
samePrefix: 1,
|
||||
excludeTable: ['area', 'token', 'captcha', 'admin_group_access', 'user_money_log', 'user_score_log'],
|
||||
},
|
||||
remoteUrl: getTableListUrl,
|
||||
onRow: onTableChange,
|
||||
}"
|
||||
prop="data_table"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.dataRecycle.Data table primary key')"
|
||||
type="string"
|
||||
v-model="baTable.form.items!.primary_key"
|
||||
prop="primary_key"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('State')"
|
||||
type="radio"
|
||||
v-model="baTable.form.items!.status"
|
||||
prop="status"
|
||||
:input-attr="{
|
||||
border: true,
|
||||
content: { 0: t('Disable'), 1: t('Enable') },
|
||||
}"
|
||||
/>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
||||
<el-button @click="baTable.toggleForm('')">{{ t('Cancel') }}</el-button>
|
||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, inject, useTemplateRef } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type baTableClass from '/@/utils/baTable'
|
||||
import FormItem from '/@/components/formItem/index.vue'
|
||||
import type { FormItemRule } from 'element-plus'
|
||||
import { buildValidatorData } from '/@/utils/validate'
|
||||
import { getTablePk, getTableListUrl, getDatabaseConnectionListUrl } from '/@/api/common'
|
||||
import { useConfig } from '/@/stores/config'
|
||||
|
||||
const config = useConfig()
|
||||
const formRef = useTemplateRef('formRef')
|
||||
const baTable = inject('baTable') as baTableClass
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||
name: [buildValidatorData({ name: 'required', title: t('security.dataRecycle.Rule name') })],
|
||||
controller: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
trigger: 'change',
|
||||
message: t('Please select field', { field: t('security.dataRecycle.controller') }),
|
||||
}),
|
||||
],
|
||||
data_table: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
trigger: 'change',
|
||||
message: t('Please select field', { field: t('security.dataRecycle.data sheet') }),
|
||||
}),
|
||||
],
|
||||
primary_key: [buildValidatorData({ name: 'required', trigger: 'change', title: t('security.dataRecycle.Data table primary key') })],
|
||||
})
|
||||
|
||||
const onTableChange = () => {
|
||||
if (!baTable.form.items!.data_table) return
|
||||
getTablePk(baTable.form.items!.data_table, baTable.form.items!.connection).then((res) => {
|
||||
baTable.form.items!.primary_key = res.data.pk
|
||||
baTable.form.defaultItems!.primary_key = res.data.pk
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ba-el-radio {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
216
web/src/views/backend/security/dataRecycleLog/index.vue
Normal file
216
web/src/views/backend/security/dataRecycleLog/index.vue
Normal file
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<div class="default-main ba-table-box">
|
||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||
|
||||
<!-- 表格顶部菜单 -->
|
||||
<TableHeader
|
||||
:buttons="['refresh', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('security.dataRecycleLog.Rule name') })"
|
||||
>
|
||||
<el-popconfirm
|
||||
@confirm="onRestoreAction"
|
||||
:confirm-button-text="t('security.dataRecycleLog.restore')"
|
||||
:cancel-button-text="t('Cancel')"
|
||||
confirmButtonType="success"
|
||||
:title="t('security.dataRecycleLog.Are you sure to restore the selected records?')"
|
||||
:disabled="baTable.table.selection!.length > 0 ? false : true"
|
||||
>
|
||||
<template #reference>
|
||||
<div class="mlr-12">
|
||||
<el-tooltip :content="t('security.dataRecycleLog.Restore the selected record to the original data table')" placement="top">
|
||||
<el-button
|
||||
v-blur
|
||||
:disabled="baTable.table.selection!.length > 0 ? false : true"
|
||||
class="table-header-operate"
|
||||
type="success"
|
||||
>
|
||||
<Icon color="#ffffff" name="el-icon-RefreshRight" />
|
||||
<span class="table-header-operate-text">{{ t('security.dataRecycleLog.restore') }}</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</TableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
|
||||
<Table />
|
||||
|
||||
<!-- 表单 -->
|
||||
<InfoDialog />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { provide, onMounted } from 'vue'
|
||||
import baTableClass from '/@/utils/baTable'
|
||||
import { info, restore, url } from '/@/api/backend/security/dataRecycleLog'
|
||||
import InfoDialog from './info.vue'
|
||||
import Table from '/@/components/table/index.vue'
|
||||
import TableHeader from '/@/components/table/header/index.vue'
|
||||
import { defaultOptButtons } from '/@/components/table'
|
||||
import { baTableApi } from '/@/api/common'
|
||||
import { buildJsonToElTreeData } from '/@/utils/common'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({
|
||||
name: 'security/dataRecycleLog',
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
let optButtons: OptButton[] = [
|
||||
{
|
||||
render: 'tipButton',
|
||||
name: 'info',
|
||||
title: 'Info',
|
||||
text: '',
|
||||
type: 'primary',
|
||||
icon: 'fa fa-search-plus',
|
||||
class: 'table-row-info',
|
||||
disabledTip: false,
|
||||
click: (row: TableRow) => {
|
||||
infoButtonClick(row[baTable.table.pk!])
|
||||
},
|
||||
},
|
||||
{
|
||||
render: 'confirmButton',
|
||||
name: 'restore',
|
||||
title: 'security.dataRecycleLog.restore',
|
||||
text: '',
|
||||
type: 'success',
|
||||
icon: 'el-icon-RefreshRight',
|
||||
class: 'table-row-edit',
|
||||
popconfirm: {
|
||||
confirmButtonText: t('security.dataRecycleLog.restore'),
|
||||
cancelButtonText: t('Cancel'),
|
||||
confirmButtonType: 'success',
|
||||
title: t('security.dataRecycleLog.Are you sure to restore the selected records?'),
|
||||
},
|
||||
disabledTip: false,
|
||||
click: (row: TableRow) => {
|
||||
onRestore([row[baTable.table.pk!]])
|
||||
},
|
||||
},
|
||||
]
|
||||
optButtons = optButtons.concat(defaultOptButtons(['delete']))
|
||||
const baTable = new baTableClass(new baTableApi(url), {
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', operator: false },
|
||||
{ label: t('Id'), prop: 'id', align: 'center', operator: '=', operatorPlaceholder: t('Id'), width: 70 },
|
||||
{
|
||||
label: t('security.dataRecycleLog.Operation administrator'),
|
||||
prop: 'admin.nickname',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycleLog.Recycling rule name'),
|
||||
prop: 'recycle.name',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycleLog.controller'),
|
||||
prop: 'recycle.controller_as',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('Connection'),
|
||||
prop: 'connection',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycleLog.data sheet'),
|
||||
prop: 'data_table',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycleLog.DeletedData'),
|
||||
prop: 'data',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('security.dataRecycleLog.Arbitrary fragment fuzzy query'),
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{ label: 'IP', prop: 'ip', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||
{
|
||||
show: false,
|
||||
label: 'User Agent',
|
||||
prop: 'useragent',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{
|
||||
label: t('security.dataRecycleLog.Delete time'),
|
||||
prop: 'create_time',
|
||||
align: 'center',
|
||||
render: 'datetime',
|
||||
sortable: 'custom',
|
||||
operator: 'RANGE',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
label: t('Operate'),
|
||||
align: 'center',
|
||||
width: 120,
|
||||
render: 'buttons',
|
||||
buttons: optButtons,
|
||||
operator: false,
|
||||
},
|
||||
],
|
||||
dblClickNotEditColumn: [undefined],
|
||||
})
|
||||
|
||||
// 利用双击单元格前钩子重写双击操作
|
||||
baTable.before.onTableDblclick = ({ row }) => {
|
||||
infoButtonClick(row[baTable.table.pk!])
|
||||
return false
|
||||
}
|
||||
|
||||
const onRestore = (ids: string[]) => {
|
||||
restore(ids).then(() => {
|
||||
baTable.onTableHeaderAction('refresh', {})
|
||||
})
|
||||
}
|
||||
|
||||
const onRestoreAction = () => {
|
||||
onRestore(baTable.getSelectionIds())
|
||||
}
|
||||
|
||||
const infoButtonClick = (id: string) => {
|
||||
baTable.form.extend!['info'] = {}
|
||||
baTable.form.operate = 'Info'
|
||||
baTable.form.loading = true
|
||||
info(id).then((res) => {
|
||||
res.data.row.data = res.data.row.data
|
||||
? [{ label: t('security.dataRecycleLog.Click to expand'), children: buildJsonToElTreeData(res.data.row.data) }]
|
||||
: []
|
||||
baTable.form.extend!['info'] = res.data.row
|
||||
baTable.form.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.mount()
|
||||
baTable.getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table-header-operate {
|
||||
margin-left: 12px;
|
||||
}
|
||||
</style>
|
||||
93
web/src/views/backend/security/dataRecycleLog/info.vue
Normal file
93
web/src/views/backend/security/dataRecycleLog/info.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<el-dialog class="ba-operate-dialog" :model-value="baTable.form.operate ? true : false" @close="baTable.toggleForm">
|
||||
<template #header>
|
||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">{{ t('Info') }}</div>
|
||||
</template>
|
||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
||||
<div class="ba-operate-form" :class="'ba-' + baTable.form.operate + '-form'">
|
||||
<el-descriptions v-if="!isEmpty(baTable.form.extend!.info)" :column="2" border>
|
||||
<el-descriptions-item :label="t('Id')">
|
||||
{{ baTable.form.extend!.info.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.Operation administrator')">
|
||||
{{ baTable.form.extend!.info.admin?.nickname + '(' + baTable.form.extend!.info.admin?.username + ')' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.Recycling rule name')">
|
||||
{{ baTable.form.extend!.info.recycle?.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('Connection')">
|
||||
{{ baTable.form.extend!.info.connection }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.data sheet')">
|
||||
{{ baTable.form.extend!.info.data_table }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.Data table primary key')">
|
||||
{{ baTable.form.extend!.info.primary_key }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.Operator IP')">
|
||||
{{ baTable.form.extend!.info.ip }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.dataRecycleLog.Delete time')">
|
||||
{{ timeFormat(baTable.form.extend!.info.create_time) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :width="120" :span="2" label="User Agent">
|
||||
{{ baTable.form.extend!.info.useragent }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :width="120" :span="2" :label="t('security.dataRecycleLog.Deleted data')" label-class-name="color-red">
|
||||
<el-tree class="table-el-tree" :data="baTable.form.extend!.info.data" :props="{ label: 'label', children: 'children' }" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<el-button v-blur @click="onRestore(baTable.form.extend!.info.id)" type="success">
|
||||
<Icon color="#ffffff" name="el-icon-RefreshRight" />
|
||||
<span class="table-header-operate-text">{{ t('security.dataRecycleLog.restore') }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type BaTable from '/@/utils/baTable'
|
||||
import { timeFormat } from '/@/utils/common'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { restore } from '/@/api/backend/security/dataRecycleLog'
|
||||
|
||||
const baTable = inject('baTable') as BaTable
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const onRestore = (id: string) => {
|
||||
ElMessageBox.confirm(t('security.dataRecycleLog.Are you sure to restore the selected records?'), '', {
|
||||
confirmButtonText: t('security.dataRecycleLog.restore'),
|
||||
cancelButtonText: t('Cancel'),
|
||||
})
|
||||
.then(() => {
|
||||
restore([id]).then(() => {
|
||||
baTable.toggleForm()
|
||||
baTable.onTableHeaderAction('refresh', {})
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.color-red) {
|
||||
color: var(--el-color-danger) !important;
|
||||
}
|
||||
.table-el-tree {
|
||||
:deep(.el-tree-node) {
|
||||
white-space: unset;
|
||||
}
|
||||
:deep(.el-tree-node__content) {
|
||||
display: block;
|
||||
align-items: unset;
|
||||
height: unset;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
113
web/src/views/backend/security/sensitiveData/index.ts
Normal file
113
web/src/views/backend/security/sensitiveData/index.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import baTableClass from '/@/utils/baTable'
|
||||
import type { baTableApi } from '/@/api/common'
|
||||
import { getTableFieldList } from '/@/api/common'
|
||||
import { add } from '/@/api/backend/security/sensitiveData'
|
||||
import { uuid } from '/@/utils/random'
|
||||
|
||||
export interface DataFields {
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export class sensitiveDataClass extends baTableClass {
|
||||
constructor(api: baTableApi, table: BaTable, form: BaTableForm = {}, before: BaTableBefore = {}, after: BaTableAfter = {}) {
|
||||
super(api, table, form, before, after)
|
||||
}
|
||||
|
||||
// 重写编辑
|
||||
getEditData = (id: string) => {
|
||||
this.form.loading = true
|
||||
this.form.items = {}
|
||||
return this.api.edit({ id: id }).then((res) => {
|
||||
const fields: string[] = []
|
||||
const dataFields: DataFields[] = []
|
||||
for (const key in res.data.row.data_fields) {
|
||||
fields.push(key)
|
||||
dataFields.push({
|
||||
name: key,
|
||||
value: res.data.row.data_fields[key] ?? '',
|
||||
})
|
||||
}
|
||||
|
||||
this.form.items!.connection = res.data.row.connection ? res.data.row.connection : ''
|
||||
this.form.extend!.controllerList = res.data.controllers
|
||||
|
||||
if (res.data.row.data_table) {
|
||||
this.onTableChange(res.data.row.data_table)
|
||||
if (this.form.extend!.parentRef) this.form.extend!.parentRef.setDataFields(dataFields)
|
||||
}
|
||||
|
||||
res.data.row.data_fields = fields
|
||||
this.form.loading = false
|
||||
this.form.items = res.data.row
|
||||
})
|
||||
}
|
||||
|
||||
onConnectionChange = () => {
|
||||
this.form.extend!.fieldList = {}
|
||||
this.form.extend!.fieldSelect = {}
|
||||
this.form.extend!.fieldSelectKey = uuid()
|
||||
|
||||
this.form.items!.data_table = ''
|
||||
this.form.items!.data_fields = []
|
||||
if (this.form.extend!.parentRef) this.form.extend!.parentRef.setDataFields([])
|
||||
}
|
||||
|
||||
// 数据表改变事件
|
||||
onTableChange = (table: string) => {
|
||||
this.form.extend = Object.assign(this.form.extend!, {
|
||||
fieldLoading: true,
|
||||
fieldList: {},
|
||||
fieldSelect: {},
|
||||
fieldSelectKey: uuid(),
|
||||
})
|
||||
|
||||
this.form.items!.data_fields = []
|
||||
if (this.form.extend!.parentRef) this.form.extend!.parentRef.setDataFields([])
|
||||
|
||||
getTableFieldList(table, true, this.form.items!.connection).then((res) => {
|
||||
this.form.items!.primary_key = res.data.pk
|
||||
this.form.defaultItems!.primary_key = res.data.pk
|
||||
|
||||
const fieldSelect: anyObj = {}
|
||||
for (const key in res.data.fieldList) {
|
||||
fieldSelect[key] = (key ? key + ' - ' : '') + res.data.fieldList[key]
|
||||
}
|
||||
|
||||
this.form.extend = Object.assign(this.form.extend!, {
|
||||
fieldLoading: false,
|
||||
fieldList: res.data.fieldList,
|
||||
fieldSelect: fieldSelect,
|
||||
fieldSelectKey: uuid(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写打开表单方法
|
||||
*/
|
||||
toggleForm = (operate = '', operateIds: string[] = []) => {
|
||||
if (this.form.ref) {
|
||||
this.form.ref.resetFields()
|
||||
}
|
||||
|
||||
if (this.form.extend!.parentRef) this.form.extend!.parentRef.setDataFields([])
|
||||
|
||||
if (operate == 'Edit') {
|
||||
if (!operateIds.length) {
|
||||
return false
|
||||
}
|
||||
this.getEditData(operateIds[0])
|
||||
} else if (operate == 'Add') {
|
||||
this.form.loading = true
|
||||
add().then((res) => {
|
||||
this.form.extend!.controllerList = res.data.controllers
|
||||
this.form.items = Object.assign({}, this.form.defaultItems)
|
||||
this.form.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
this.form.operate = operate
|
||||
this.form.operateIds = operateIds
|
||||
}
|
||||
}
|
||||
125
web/src/views/backend/security/sensitiveData/index.vue
Normal file
125
web/src/views/backend/security/sensitiveData/index.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="default-main ba-table-box">
|
||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||
|
||||
<!-- 表格顶部菜单 -->
|
||||
<TableHeader
|
||||
:buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('security.sensitiveData.controller') })"
|
||||
/>
|
||||
|
||||
<!-- 表格 -->
|
||||
<!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
|
||||
<Table ref="tableRef" />
|
||||
|
||||
<!-- 表单 -->
|
||||
<PopupForm ref="formRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, useTemplateRef } from 'vue'
|
||||
import { sensitiveDataClass } from './index'
|
||||
import { url } from '/@/api/backend/security/sensitiveData'
|
||||
import PopupForm from './popupForm.vue'
|
||||
import Table from '/@/components/table/index.vue'
|
||||
import TableHeader from '/@/components/table/header/index.vue'
|
||||
import { defaultOptButtons } from '/@/components/table'
|
||||
import { baTableApi } from '/@/api/common'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({
|
||||
name: 'security/dataRecycle',
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
const formRef = useTemplateRef('formRef')
|
||||
const tableRef = useTemplateRef('tableRef')
|
||||
|
||||
const baTable = new sensitiveDataClass(
|
||||
new baTableApi(url),
|
||||
{
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', operator: false },
|
||||
{ label: 'ID', prop: 'id', align: 'center', operator: '=', operatorPlaceholder: t('Id'), width: 70 },
|
||||
{ label: t('security.sensitiveData.Rule name'), prop: 'name', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||
{
|
||||
label: t('security.sensitiveData.controller'),
|
||||
prop: 'controller',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('Connection'),
|
||||
prop: 'connection',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveData.data sheet'),
|
||||
prop: 'data_table',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveData.Data table primary key'),
|
||||
prop: 'primary_key',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveData.Sensitive fields'),
|
||||
prop: 'data_fields',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
render: 'tags',
|
||||
},
|
||||
{
|
||||
label: t('State'),
|
||||
prop: 'status',
|
||||
align: 'center',
|
||||
render: 'tag',
|
||||
custom: { 0: 'danger', 1: 'success' },
|
||||
replaceValue: { 0: t('Disable'), 1: t('security.sensitiveData.Modifying monitoring') },
|
||||
},
|
||||
{ label: t('Update time'), prop: 'update_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||
{ label: t('Create time'), prop: 'create_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
||||
{
|
||||
label: t('Operate'),
|
||||
align: 'center',
|
||||
width: '130',
|
||||
render: 'buttons',
|
||||
buttons: defaultOptButtons(['edit', 'delete']),
|
||||
operator: false,
|
||||
},
|
||||
],
|
||||
dblClickNotEditColumn: [undefined],
|
||||
},
|
||||
{
|
||||
defaultItems: {
|
||||
status: 1,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
baTable.before.onSubmit = () => {
|
||||
baTable.form.items!.fields = formRef.value?.getDataFields()
|
||||
}
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.form.extend!.parentRef = formRef.value
|
||||
baTable.table.ref = tableRef.value
|
||||
baTable.mount()
|
||||
baTable.getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
229
web/src/views/backend/security/sensitiveData/popupForm.vue
Normal file
229
web/src/views/backend/security/sensitiveData/popupForm.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<!-- 对话框表单 -->
|
||||
<el-dialog
|
||||
class="ba-operate-dialog"
|
||||
:close-on-click-modal="false"
|
||||
:model-value="['Add', 'Edit'].includes(baTable.form.operate!)"
|
||||
@close="baTable.toggleForm"
|
||||
>
|
||||
<template #header>
|
||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
|
||||
{{ baTable.form.operate ? t(baTable.form.operate) : '' }}
|
||||
</div>
|
||||
</template>
|
||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
||||
<div
|
||||
class="ba-operate-form"
|
||||
:class="'ba-' + baTable.form.operate + '-form'"
|
||||
:style="config.layout.shrink ? '' : 'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
|
||||
>
|
||||
<el-form
|
||||
v-if="!baTable.form.loading"
|
||||
ref="formRef"
|
||||
@keyup.enter="baTable.onSubmit(formRef)"
|
||||
:model="baTable.form.items"
|
||||
:label-position="config.layout.shrink ? 'top' : 'right'"
|
||||
:label-width="baTable.form.labelWidth + 'px'"
|
||||
:rules="rules"
|
||||
>
|
||||
<FormItem
|
||||
:label="t('security.sensitiveData.Rule name')"
|
||||
type="string"
|
||||
v-model="baTable.form.items!.name"
|
||||
prop="name"
|
||||
:placeholder="t('security.sensitiveData.The rule name helps to identify the modified data later')"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.sensitiveData.controller')"
|
||||
type="select"
|
||||
v-model="baTable.form.items!.controller"
|
||||
prop="controller"
|
||||
:input-attr="{ content: baTable.form.extend!.controllerList }"
|
||||
:placeholder="
|
||||
t('security.sensitiveData.The data listening mechanism will monitor the modification operations under this controller')
|
||||
"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('Database connection')"
|
||||
v-model="baTable.form.items!.connection"
|
||||
type="remoteSelect"
|
||||
:block-help="t('Database connection help')"
|
||||
:input-attr="{
|
||||
pk: 'key',
|
||||
field: 'key',
|
||||
remoteUrl: getDatabaseConnectionListUrl,
|
||||
onChange: baTable.onConnectionChange,
|
||||
valueOnClear: '',
|
||||
}"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.sensitiveData.Corresponding data sheet')"
|
||||
type="remoteSelect"
|
||||
v-model="baTable.form.items!.data_table"
|
||||
:key="baTable.form.items!.connection"
|
||||
:input-attr="{
|
||||
pk: 'table',
|
||||
field: 'comment',
|
||||
params: {
|
||||
connection: baTable.form.items!.connection,
|
||||
samePrefix: 1,
|
||||
excludeTable: ['area', 'token', 'captcha', 'admin_group_access', 'admin_log', 'user_money_log', 'user_score_log'],
|
||||
},
|
||||
remoteUrl: getTableListUrl,
|
||||
onChange: baTable.onTableChange,
|
||||
}"
|
||||
prop="data_table"
|
||||
/>
|
||||
<FormItem
|
||||
:label="t('security.sensitiveData.Data table primary key')"
|
||||
type="string"
|
||||
v-model="baTable.form.items!.primary_key"
|
||||
prop="primary_key"
|
||||
/>
|
||||
<template v-if="!isEmpty(baTable.form.extend!.fieldSelect)">
|
||||
<hr class="form-hr" />
|
||||
|
||||
<FormItem
|
||||
:label="t('security.sensitiveData.Sensitive fields')"
|
||||
type="selects"
|
||||
v-model="baTable.form.items!.data_fields"
|
||||
:key="baTable.form.extend!.fieldSelectKey"
|
||||
prop="data_fields"
|
||||
:input-attr="{
|
||||
onChange: onFieldChange,
|
||||
content: baTable.form.extend!.fieldSelect,
|
||||
}"
|
||||
v-loading="baTable.form.extend!.fieldLoading"
|
||||
/>
|
||||
|
||||
<FormItem
|
||||
v-for="(item, idx) in state.dataFields"
|
||||
:key="idx"
|
||||
:label="item.name"
|
||||
type="string"
|
||||
v-model="item.value"
|
||||
:tip="t('security.sensitiveData.Filling in field notes helps you quickly identify fields later')"
|
||||
/>
|
||||
|
||||
<hr class="form-hr" />
|
||||
</template>
|
||||
<FormItem
|
||||
:label="t('State')"
|
||||
type="radio"
|
||||
v-model="baTable.form.items!.status"
|
||||
prop="status"
|
||||
:input-attr="{
|
||||
border: true,
|
||||
content: { 0: t('Disable'), 1: t('Enable') },
|
||||
}"
|
||||
/>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
|
||||
<el-button @click="baTable.toggleForm('')">{{ t('Cancel') }}</el-button>
|
||||
<el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
|
||||
{{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, inject, useTemplateRef } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { sensitiveDataClass, DataFields } from './index'
|
||||
import FormItem from '/@/components/formItem/index.vue'
|
||||
import type { FormItemRule } from 'element-plus'
|
||||
import { buildValidatorData } from '/@/utils/validate'
|
||||
import { useConfig } from '/@/stores/config'
|
||||
import { getTableListUrl, getDatabaseConnectionListUrl } from '/@/api/common'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
|
||||
const config = useConfig()
|
||||
const formRef = useTemplateRef('formRef')
|
||||
const baTable = inject('baTable') as sensitiveDataClass
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const state: {
|
||||
dataFields: DataFields[]
|
||||
} = reactive({
|
||||
dataFields: [],
|
||||
})
|
||||
|
||||
const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||
name: [buildValidatorData({ name: 'required', title: t('security.sensitiveData.Rule name') })],
|
||||
controller: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
trigger: 'change',
|
||||
message: t('Please select field', { field: t('security.sensitiveData.controller') }),
|
||||
}),
|
||||
],
|
||||
data_table: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
trigger: 'change',
|
||||
message: t('Please select field', { field: t('security.sensitiveData.data sheet') }),
|
||||
}),
|
||||
],
|
||||
primary_key: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
trigger: 'change',
|
||||
title: t('security.sensitiveData.Data table primary key'),
|
||||
}),
|
||||
],
|
||||
data_fields: [
|
||||
buildValidatorData({
|
||||
name: 'required',
|
||||
message: t('Please select field', { field: t('security.sensitiveData.Sensitive fields') }),
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
/**
|
||||
* 敏感数据字段更新
|
||||
* 保留原始输入,而又需要去掉已删除的字段
|
||||
*/
|
||||
const onFieldChange = (val: string[]) => {
|
||||
let dataFields: DataFields[] = []
|
||||
for (const key in val) {
|
||||
let exist: boolean | DataFields = false
|
||||
for (const k in state.dataFields) {
|
||||
if (state.dataFields[k].name == val[key]) {
|
||||
exist = state.dataFields[k]
|
||||
}
|
||||
}
|
||||
dataFields[key] = exist ? exist : { name: val[key], value: baTable.form.extend!.fieldList[val[key]] ?? '' }
|
||||
}
|
||||
state.dataFields = dataFields
|
||||
}
|
||||
|
||||
const getDataFields = () => {
|
||||
return state.dataFields
|
||||
}
|
||||
|
||||
const setDataFields = (dataFields: DataFields[]) => {
|
||||
state.dataFields = dataFields
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getDataFields,
|
||||
setDataFields,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ba-el-radio {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.form-hr {
|
||||
border-color: #dcdfe6;
|
||||
border-style: solid;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
229
web/src/views/backend/security/sensitiveDataLog/index.vue
Normal file
229
web/src/views/backend/security/sensitiveDataLog/index.vue
Normal file
@@ -0,0 +1,229 @@
|
||||
<template>
|
||||
<div class="default-main ba-table-box">
|
||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
||||
|
||||
<!-- 表格顶部菜单 -->
|
||||
<TableHeader
|
||||
:buttons="['refresh', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
||||
:quick-search-placeholder="t('Quick search placeholder', { fields: t('security.sensitiveDataLog.Rule name') })"
|
||||
>
|
||||
<el-popconfirm
|
||||
@confirm="onRollbackAction"
|
||||
:confirm-button-text="t('security.sensitiveDataLog.RollBACK')"
|
||||
:cancel-button-text="t('Cancel')"
|
||||
confirmButtonType="success"
|
||||
:title="t('security.sensitiveDataLog.Are you sure you want to rollback the record?')"
|
||||
:disabled="baTable.table.selection!.length > 0 ? false : true"
|
||||
>
|
||||
<template #reference>
|
||||
<div class="mlr-12">
|
||||
<el-tooltip :content="t('security.sensitiveDataLog.Rollback the selected record to the original data table')" placement="top">
|
||||
<el-button
|
||||
v-blur
|
||||
:disabled="baTable.table.selection!.length > 0 ? false : true"
|
||||
class="table-header-operate"
|
||||
type="success"
|
||||
>
|
||||
<Icon size="16" color="#ffffff" name="fa fa-sign-in" />
|
||||
<span class="table-header-operate-text">{{ t('security.sensitiveDataLog.RollBACK') }}</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</TableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
|
||||
<Table />
|
||||
|
||||
<!-- 表单 -->
|
||||
<InfoDialog />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { provide, onMounted } from 'vue'
|
||||
import baTableClass from '/@/utils/baTable'
|
||||
import { info, rollback, url } from '/@/api/backend/security/sensitiveDataLog'
|
||||
import InfoDialog from './info.vue'
|
||||
import Table from '/@/components/table/index.vue'
|
||||
import TableHeader from '/@/components/table/header/index.vue'
|
||||
import { defaultOptButtons } from '/@/components/table'
|
||||
import { baTableApi } from '/@/api/common'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
defineOptions({
|
||||
name: 'security/sensitiveDataLog',
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
let optButtons: OptButton[] = [
|
||||
{
|
||||
render: 'tipButton',
|
||||
name: 'info',
|
||||
title: 'Info',
|
||||
text: '',
|
||||
type: 'primary',
|
||||
icon: 'fa fa-search-plus',
|
||||
class: 'table-row-info',
|
||||
disabledTip: false,
|
||||
click: (row: TableRow) => {
|
||||
infoButtonClick(row[baTable.table.pk!])
|
||||
},
|
||||
},
|
||||
{
|
||||
render: 'confirmButton',
|
||||
name: 'rollback',
|
||||
title: 'security.sensitiveDataLog.RollBACK',
|
||||
text: '',
|
||||
type: 'success',
|
||||
icon: 'fa fa-sign-in',
|
||||
class: 'table-row-edit',
|
||||
popconfirm: {
|
||||
confirmButtonText: t('security.sensitiveDataLog.RollBACK'),
|
||||
cancelButtonText: t('Cancel'),
|
||||
confirmButtonType: 'success',
|
||||
title: t('security.sensitiveDataLog.Are you sure you want to rollback the record?'),
|
||||
},
|
||||
disabledTip: false,
|
||||
click: (row: TableRow) => {
|
||||
onRollback([row[baTable.table.pk!]])
|
||||
},
|
||||
},
|
||||
]
|
||||
optButtons = optButtons.concat(defaultOptButtons(['delete']))
|
||||
const baTable = new baTableClass(new baTableApi(url), {
|
||||
column: [
|
||||
{ type: 'selection', align: 'center', operator: false },
|
||||
{ label: t('Id'), prop: 'id', align: 'center', operator: '=', operatorPlaceholder: t('Id'), width: 70 },
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Operation administrator'),
|
||||
prop: 'admin.nickname',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Rule name'),
|
||||
prop: 'sensitive.name',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.controller'),
|
||||
prop: 'sensitive.controller_as',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('Connection'),
|
||||
prop: 'connection',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.data sheet'),
|
||||
prop: 'data_table',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Modify line'),
|
||||
prop: 'id_value',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Modification'),
|
||||
prop: 'data_comment',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Before modification'),
|
||||
prop: 'before',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{
|
||||
label: t('security.sensitiveDataLog.After modification'),
|
||||
prop: 'after',
|
||||
align: 'center',
|
||||
operator: 'LIKE',
|
||||
operatorPlaceholder: t('Fuzzy query'),
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
{ label: 'IP', prop: 'ip', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
||||
{
|
||||
label: t('security.sensitiveDataLog.Modification time'),
|
||||
prop: 'create_time',
|
||||
align: 'center',
|
||||
render: 'datetime',
|
||||
sortable: 'custom',
|
||||
operator: 'RANGE',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
label: t('Operate'),
|
||||
align: 'center',
|
||||
width: 120,
|
||||
render: 'buttons',
|
||||
buttons: optButtons,
|
||||
operator: false,
|
||||
},
|
||||
],
|
||||
dblClickNotEditColumn: [undefined],
|
||||
})
|
||||
|
||||
// 利用双击单元格前钩子重写双击操作
|
||||
baTable.before.onTableDblclick = ({ row }) => {
|
||||
infoButtonClick(row[baTable.table.pk!])
|
||||
return false
|
||||
}
|
||||
|
||||
const onRollback = (ids: string[]) => {
|
||||
rollback(ids).then(() => {
|
||||
baTable.onTableHeaderAction('refresh', {})
|
||||
})
|
||||
}
|
||||
|
||||
const onRollbackAction = () => {
|
||||
onRollback(baTable.getSelectionIds())
|
||||
}
|
||||
|
||||
const infoButtonClick = (id: string) => {
|
||||
baTable.form.extend!['info'] = {}
|
||||
baTable.form.operate = 'Info'
|
||||
baTable.form.loading = true
|
||||
info(id).then((res) => {
|
||||
baTable.form.extend!['info'] = res.data.row
|
||||
baTable.form.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
provide('baTable', baTable)
|
||||
|
||||
onMounted(() => {
|
||||
baTable.mount()
|
||||
baTable.getData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table-header-operate {
|
||||
margin-left: 12px;
|
||||
}
|
||||
.table-header-operate-text {
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
128
web/src/views/backend/security/sensitiveDataLog/info.vue
Normal file
128
web/src/views/backend/security/sensitiveDataLog/info.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<el-dialog class="ba-operate-dialog" :model-value="baTable.form.operate ? true : false" @close="baTable.toggleForm">
|
||||
<template #header>
|
||||
<div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">{{ t('Info') }}</div>
|
||||
</template>
|
||||
<el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
|
||||
<div class="ba-operate-form" :class="'ba-' + baTable.form.operate + '-form'">
|
||||
<el-descriptions v-if="!isEmpty(baTable.form.extend!.info)" :column="2" border>
|
||||
<el-descriptions-item :width="120" :span="2" :label="t('security.sensitiveDataLog.Rule name')">
|
||||
{{ baTable.form.extend!.info.sensitive?.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('Id')">
|
||||
{{ baTable.form.extend!.info.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Operation administrator')">
|
||||
{{ baTable.form.extend!.info.admin?.nickname + '(' + baTable.form.extend!.info.admin?.username + ')' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('Connection')">
|
||||
{{ baTable.form.extend!.info.connection }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.data sheet')">
|
||||
{{ baTable.form.extend!.info.data_table }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Modification time')">
|
||||
{{ timeFormat(baTable.form.extend!.info.create_time) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Operator IP')">
|
||||
{{ baTable.form.extend!.info.ip }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Data table primary key')">
|
||||
{{ baTable.form.extend!.info.primary_key + '=' + baTable.form.extend!.info.id_value }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Modified item')">
|
||||
{{
|
||||
baTable.form.extend!.info.data_field +
|
||||
(baTable.form.extend!.info.data_comment ? '(' + baTable.form.extend!.info.data_comment + ')' : '')
|
||||
}}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.Before modification')" label-class-name="color-red">
|
||||
<div class="info-content">{{ baTable.form.extend!.info.before }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('security.sensitiveDataLog.After modification')" label-class-name="color-red">
|
||||
<div class="info-content">{{ baTable.form.extend!.info.after }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :width="120" :span="2" label="User Agent">
|
||||
{{ baTable.form.extend!.info.useragent }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="diff-box">
|
||||
<div class="diff-box-title">{{ t('security.sensitiveDataLog.Modification comparison') }}</div>
|
||||
<code-diff
|
||||
diffStyle="char"
|
||||
:old-string="baTable.form.extend!.info.before ?? ''"
|
||||
:new-string="baTable.form.extend!.info.after ?? ''"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<el-button v-blur @click="onRollback(baTable.form.extend!.info.id)" type="success">
|
||||
<Icon size="16" color="#ffffff" name="fa fa-sign-in" />
|
||||
<span class="table-header-operate-text">{{ t('security.sensitiveDataLog.RollBACK') }}</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type BaTable from '/@/utils/baTable'
|
||||
import { timeFormat } from '/@/utils/common'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { rollback } from '/@/api/backend/security/sensitiveDataLog'
|
||||
import { CodeDiff } from 'v-code-diff'
|
||||
|
||||
const baTable = inject('baTable') as BaTable
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const onRollback = (id: string) => {
|
||||
ElMessageBox.confirm(t('security.sensitiveDataLog.Are you sure you want to rollback the record?'), '', {
|
||||
confirmButtonText: t('security.sensitiveDataLog.RollBACK'),
|
||||
cancelButtonText: t('Cancel'),
|
||||
})
|
||||
.then(() => {
|
||||
rollback([id]).then(() => {
|
||||
baTable.toggleForm()
|
||||
baTable.onTableHeaderAction('refresh', {})
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.color-red) {
|
||||
color: var(--el-color-danger) !important;
|
||||
}
|
||||
.table-el-tree {
|
||||
:deep(.el-tree-node) {
|
||||
white-space: unset;
|
||||
}
|
||||
:deep(.el-tree-node__content) {
|
||||
display: block;
|
||||
align-items: unset;
|
||||
height: unset;
|
||||
}
|
||||
}
|
||||
.info-content {
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
.table-header-operate-text {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.diff-box :deep(.d2h-file-wrapper) {
|
||||
border: 1px solid #ebeef5;
|
||||
}
|
||||
.diff-box-title {
|
||||
display: flex;
|
||||
font-weight: bold;
|
||||
line-height: 40px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user