fix: #1918 在包含delete_at的情况下,数据源自动过滤软删除数据

This commit is contained in:
pixelmaxQM
2024-10-31 20:10:06 +08:00
parent 3452eafe4f
commit 41ba7ad6a5
6 changed files with 46 additions and 21 deletions
@@ -457,6 +457,7 @@ const getDBTableList = async () => {
const dbColumnList = ref([])
const selectDB = async (val,isInit) => {
middleDate.value.dataSource.hasDeletedAt = false
middleDate.value.dataSource.table = val
const res = await getColumn({
businessDB: middleDate.value.dataSource.dbName,
@@ -465,13 +466,18 @@ const selectDB = async (val,isInit) => {
if (res.code === 0) {
let list = res.data.columns; // 确保这里正确获取到 tables 数组
dbColumnList.value = list.map(item => ({
columnName: item.columnName,
value: item.columnName,
type: item.dataType,
isPrimary: item.primaryKey,
comment: item.columnComment
}));
dbColumnList.value = list.map(item => {
if(item.columnName === 'deleted_at'){
middleDate.value.dataSource.hasDeletedAt = true
}
return{
columnName: item.columnName,
value: item.columnName,
type: item.dataType,
isPrimary: item.primaryKey,
comment: item.columnComment
}
});
if (dbColumnList.value.length > 0 && !isInit) {
middleDate.value.dataSource.label = dbColumnList.value[0].columnName
middleDate.value.dataSource.value = dbColumnList.value[0].columnName
+9 -3
View File
@@ -1020,10 +1020,12 @@ const fieldTemplate = {
fieldIndexType: '',
dictType: '',
dataSource: {
dbName: '',
association:1,
table: '',
label: '',
value: ''
value: '',
hasDeletedAt: false
}
}
const route = useRoute()
@@ -1116,10 +1118,12 @@ const editAndAddField = (item) => {
addFlag.value = 'edit'
if(!item.dataSource){
item.dataSource = {
dbName: '',
association:1,
table: '',
label: '',
value: ''
value: '',
hasDeletedAt: false
}
}
bk.value = JSON.parse(JSON.stringify(item))
@@ -1344,10 +1348,12 @@ const getColumnFunc = async() => {
excel: false,
desc: true,
dataSource: {
dbName: '',
association:1,
table: '',
label: '',
value: ''
value: '',
hasDeletedAt: false
}
})
}