fix: dbms数据行编辑

This commit is contained in:
meilin.huang
2024-02-01 12:05:41 +08:00
parent eee08be2cc
commit 6be0ea6aed

View File

@@ -9,12 +9,9 @@
:required="column.nullable != 'YES' && !column.isPrimaryKey && !column.isIdentity" :required="column.nullable != 'YES' && !column.isPrimaryKey && !column.isIdentity"
> >
<template #label> <template #label>
<span class="pointer" :title="`${column.columnType} | ${column.columnComment}`">
{{ column.columnName }} {{ column.columnName }}
<el-tooltip :content="`${column.columnType} | ${column.columnComment}`" placement="top"> </span>
<el-icon>
<question-filled />
</el-icon>
</el-tooltip>
</template> </template>
<ColumnFormItem <ColumnFormItem
@@ -36,7 +33,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watch } from 'vue'; import { ref, watch, onMounted } from 'vue';
import ColumnFormItem from './ColumnFormItem.vue'; import ColumnFormItem from './ColumnFormItem.vue';
import { DbInst } from '../../db'; import { DbInst } from '../../db';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
@@ -65,13 +62,23 @@ const dataForm: any = ref(null);
let oldValue = null as any; let oldValue = null as any;
onMounted(() => {
setOldValue();
});
watch(visible, (newValue) => { watch(visible, (newValue) => {
// 空对象则为insert操作无需记录旧值 if (newValue) {
if (newValue && Object.keys(modelValue.value).length > 0) { setOldValue();
oldValue = Object.assign({}, modelValue.value);
} }
}); });
const setOldValue = () => {
// 空对象则为insert操作否则为update
if (Object.keys(modelValue.value).length > 0) {
oldValue = Object.assign({}, modelValue.value);
}
};
const closeDialog = () => { const closeDialog = () => {
visible.value = false; visible.value = false;
modelValue.value = {}; modelValue.value = {};