| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { useI18n } from 'vue-i18n' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { useUserStore } from '@/store/modules/user' |
| | | import { useAuth } from '@/hooks/core/useAuth' |
| | |
| | | createOperationRecordSearchState, |
| | | getOperationRecordPaginationKey, |
| | | getOperationRecordReportColumns, |
| | | getOperationRecordReportTitle, |
| | | mergeOperationRecordDetail, |
| | | normalizeOperationRecordRow, |
| | | OPERATION_RECORD_REPORT_TITLE |
| | | normalizeOperationRecordRow |
| | | } from './operationRecordPage.helpers' |
| | | import { createOperationRecordTableColumns } from './operationRecordTable.columns' |
| | | import OperationRecordDetailDrawer from './modules/operation-record-detail-drawer.vue' |
| | | |
| | | defineOptions({ name: 'OperationRecord' }) |
| | | |
| | | const { t } = useI18n() |
| | | const userStore = useUserStore() |
| | | const { hasAuth } = useAuth() |
| | | |
| | |
| | | const detailLoading = ref(false) |
| | | const detailData = ref({}) |
| | | const selectedRows = ref([]) |
| | | const reportTitle = OPERATION_RECORD_REPORT_TITLE |
| | | const reportTitle = computed(() => getOperationRecordReportTitle(t)) |
| | | const reportQueryParams = computed(() => buildOperationRecordSearchParams(searchForm.value)) |
| | | const reportColumns = getOperationRecordReportColumns() |
| | | const reportColumns = computed(() => getOperationRecordReportColumns(t)) |
| | | |
| | | const searchItems = computed(() => [ |
| | | { |
| | | label: '关键字', |
| | | label: t('table.keyword'), |
| | | key: 'condition', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入名称空间' |
| | | placeholder: t('pages.system.operationRecord.search.conditionPlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '接口地址', |
| | | label: t('pages.system.operationRecord.table.url'), |
| | | key: 'url', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入接口地址' |
| | | placeholder: t('pages.system.operationRecord.search.urlPlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '客户端IP', |
| | | label: t('pages.system.operationRecord.table.clientIp'), |
| | | key: 'clientIp', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入客户端IP' |
| | | placeholder: t('pages.system.operationRecord.search.clientIpPlaceholder') |
| | | } |
| | | }, |
| | | { |
| | | label: '结果', |
| | | label: t('pages.system.operationRecord.table.result'), |
| | | key: 'result', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: '成功', value: 1 }, |
| | | { label: '失败', value: 0 } |
| | | { label: t('pages.system.operationRecord.result.success'), value: 1 }, |
| | | { label: t('pages.system.operationRecord.result.failed'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '开始日期', |
| | | label: t('pages.system.operationRecord.search.timeStart'), |
| | | key: 'timeStart', |
| | | type: 'date', |
| | | props: { |
| | |
| | | } |
| | | }, |
| | | { |
| | | label: '结束日期', |
| | | label: t('pages.system.operationRecord.search.timeEnd'), |
| | | key: 'timeEnd', |
| | | type: 'date', |
| | | props: { |
| | |
| | | |
| | | async function handleDelete(row) { |
| | | try { |
| | | await ElMessageBox.confirm(`确定要删除操作日志「${row.namespace || row.id}」吗?`, '删除确认', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }) |
| | | await ElMessageBox.confirm( |
| | | t('crud.confirm.deleteMessage', { |
| | | entity: t('pages.system.operationRecord.entity'), |
| | | label: row.namespace || row.id |
| | | }), |
| | | t('crud.confirm.deleteTitle'), |
| | | { |
| | | confirmButtonText: t('common.confirm'), |
| | | cancelButtonText: t('common.cancel'), |
| | | type: 'warning' |
| | | } |
| | | ) |
| | | await fetchDeleteOperationRecord(row.id) |
| | | ElMessage.success('删除成功') |
| | | ElMessage.success(t('crud.messages.deleteSuccess')) |
| | | await refreshRemove() |
| | | } catch (error) { |
| | | if (error !== 'cancel') { |
| | | ElMessage.error(error?.message || '删除失败') |
| | | ElMessage.error(error?.message || t('crud.messages.deleteFailed')) |
| | | } |
| | | } |
| | | } |
| | |
| | | paginationKey: getOperationRecordPaginationKey(), |
| | | columnsFactory: () => |
| | | createOperationRecordTableColumns({ |
| | | t, |
| | | handleView: openDetail, |
| | | handleDelete: hasAuth('delete') ? handleDelete : null |
| | | }) |
| | |
| | | resolvePrintRecords, |
| | | buildPreviewRows: (records) => buildOperationRecordPrintRows(records), |
| | | buildPreviewMeta: (rows) => ({ |
| | | reportTitle, |
| | | reportTitle: reportTitle.value, |
| | | reportDate: new Date().toLocaleDateString('zh-CN'), |
| | | printedAt: new Date().toLocaleString('zh-CN', { hour12: false }), |
| | | operator: userStore.getUserInfo?.name || userStore.getUserInfo?.username || '', |
| | |
| | | } catch (error) { |
| | | detailDrawerVisible.value = false |
| | | detailData.value = {} |
| | | ElMessage.error(error?.message || '获取操作日志详情失败') |
| | | ElMessage.error(error?.message || t('pages.system.operationRecord.messages.detailFailed')) |
| | | } finally { |
| | | detailLoading.value = false |
| | | } |