修改数据日志全局组件,并添加自动代码生成模板
This commit is contained in:
@ -1,159 +0,0 @@
|
||||
<template>
|
||||
<div >
|
||||
<a-modal
|
||||
:width="1150"
|
||||
v-model:visible="visible"
|
||||
title="数据日志"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<a-table :style="{ padding: '0 5px'}" :columns="columns" :data-source="data" :scroll="{y: 400}" :pagination="false" :row-key="record => record.id"/>
|
||||
</a-modal>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { getDataLog } from '/@/api/mdm/Bank';
|
||||
import { watch, defineProps, ref, computed, onMounted, onUnmounted, createVNode, reactive, } from 'vue';
|
||||
const columns = [
|
||||
{
|
||||
title: '表名',
|
||||
dataIndex: 'tableName',
|
||||
key: 'tableName',
|
||||
width: 100,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '属性名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 100,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
|
||||
},
|
||||
{
|
||||
title: '操作类型',
|
||||
dataIndex: 'operationType',
|
||||
key: 'operationType',
|
||||
width: 80,
|
||||
sorter: true,
|
||||
customRender: ({ record }) => {
|
||||
let text = record.operationType
|
||||
if (record.operationType == 'INSERT') text='新增'
|
||||
if (record.operationType == 'UPDATE') text='修改'
|
||||
if (record.operationType == 'DELETE') text='删除'
|
||||
return text
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '原数据',
|
||||
dataIndex: 'oldValue',
|
||||
key: 'oldValue',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '新数据',
|
||||
dataIndex: 'newValue',
|
||||
key: 'newValue',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '操作人',
|
||||
dataIndex: 'operatorName',
|
||||
key: 'operatorName',
|
||||
width: 100,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '操作IP',
|
||||
dataIndex: 'operationIp',
|
||||
key: 'operationIp',
|
||||
width: 150,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '操作时间',
|
||||
dataIndex: 'operationTime',
|
||||
key: 'operationTime',
|
||||
width: 170,
|
||||
sorter: true
|
||||
},
|
||||
];
|
||||
// 定义props
|
||||
interface Props {
|
||||
visible: boolean;
|
||||
logId?: string;
|
||||
logPath?: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
logId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
logPath: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
});
|
||||
|
||||
// 定义emit
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'ok', value: string): void;
|
||||
(e: 'cancel'): void;
|
||||
}>();
|
||||
|
||||
// 使用ref来管理visible,因为需要响应式更新
|
||||
const visible = ref(props.visible);
|
||||
|
||||
// 监听props.visible的变化,同步到visible
|
||||
watch(() => props.visible, (newVal) => {
|
||||
visible.value = newVal;
|
||||
console.log(visible.value, 42424)
|
||||
getLogData()
|
||||
});
|
||||
|
||||
// 监听visible的变化,通知父组件更新
|
||||
watch(visible, (newVal) => {
|
||||
console.log(visible.value, 42425)
|
||||
emit('update:visible', newVal);
|
||||
});
|
||||
|
||||
const handleOk = () => {
|
||||
// 可以在这里处理确定按钮的逻辑,然后关闭弹框
|
||||
emit('ok', '来自子组件的消息');
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
console.log(props.logId, 444, props.logPath)
|
||||
interface DataItem {
|
||||
children?: DataItem[];
|
||||
}
|
||||
|
||||
// const data: DataItem[] = [];
|
||||
const data = ref<DataItem[]>([]);
|
||||
|
||||
async function getLogData() {
|
||||
data.value = await getDataLog(props.logId, {},props.logPath)
|
||||
console.log(data.value, 88)
|
||||
}
|
||||
|
||||
onMounted( async() => {
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
const modalVisible = ref(false);
|
||||
const logId = ref('')
|
||||
const logPath = ref('/mdm/bank/datalog');
|
||||
import { DataLog } from '/@/components/pcitc';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
|
||||
|
||||
Reference in New Issue
Block a user