mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
feat: 数据库表格数据表头支持展示备注
This commit is contained in:
2
mayfly_go_web/.gitignore
vendored
2
mayfly_go_web/.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
/dist
|
/dist
|
||||||
|
*.lock
|
||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
"splitpanes": "^3.1.5",
|
"splitpanes": "^3.1.5",
|
||||||
"sql-formatter": "^14.0.0",
|
"sql-formatter": "^14.0.0",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"vue": "^3.4.5",
|
"vue": "^3.4.6",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"xterm": "^5.3.0",
|
"xterm": "^5.3.0",
|
||||||
"xterm-addon-fit": "^0.8.0",
|
"xterm-addon-fit": "^0.8.0",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<template #default="{ height, width }">
|
<template #default="{ height, width }">
|
||||||
<el-table-v2
|
<el-table-v2
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:header-height="30"
|
:header-height="showColumnTip && dbConfig.showColumnComment ? 45 : 30"
|
||||||
:row-height="30"
|
:row-height="30"
|
||||||
:row-class="rowClass"
|
:row-class="rowClass"
|
||||||
:row-key="null"
|
:row-key="null"
|
||||||
@@ -22,13 +22,12 @@
|
|||||||
:style="{
|
:style="{
|
||||||
width: `${column.width}px`,
|
width: `${column.width}px`,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
lineHeight: '30px',
|
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
borderRight: 'var(--el-table-border)',
|
borderRight: 'var(--el-table-border)',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<!-- 行号列 -->
|
<!-- 行号列 -->
|
||||||
<div v-if="column.key == rowNoColumn.key">
|
<div v-if="column.key == rowNoColumn.key" class="header-column-title">
|
||||||
<b class="el-text" tag="b"> {{ column.title }} </b>
|
<b class="el-text" tag="b"> {{ column.title }} </b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -43,6 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="showColumnTip">
|
<div v-if="showColumnTip">
|
||||||
|
<div class="header-column-title">
|
||||||
<b :title="column.remark" class="el-text" style="cursor: pointer">
|
<b :title="column.remark" class="el-text" style="cursor: pointer">
|
||||||
{{ column.title }}
|
{{ column.title }}
|
||||||
</b>
|
</b>
|
||||||
@@ -56,7 +56,17 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<!-- 字段备注信息 -->
|
||||||
|
<span
|
||||||
|
v-if="dbConfig.showColumnComment"
|
||||||
|
style="color: var(--el-color-info-light-3)"
|
||||||
|
class="font10 el-text el-text--small is-truncated"
|
||||||
|
>
|
||||||
|
{{ column.columnComment }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="header-column-title">
|
||||||
<b class="el-text">
|
<b class="el-text">
|
||||||
{{ column.title }}
|
{{ column.title }}
|
||||||
</b>
|
</b>
|
||||||
@@ -141,8 +151,8 @@ import { Contextmenu, ContextmenuItem } from '@/components/contextmenu';
|
|||||||
import SvgIcon from '@/components/svgIcon/index.vue';
|
import SvgIcon from '@/components/svgIcon/index.vue';
|
||||||
import { exportCsv, exportFile } from '@/common/utils/export';
|
import { exportCsv, exportFile } from '@/common/utils/export';
|
||||||
import { dateStrFormat } from '@/common/utils/date';
|
import { dateStrFormat } from '@/common/utils/date';
|
||||||
import { useIntervalFn } from '@vueuse/core';
|
import { useIntervalFn, useStorage } from '@vueuse/core';
|
||||||
import { ColumnTypeSubscript, compatibleMysql, DataType, DbDialect, DbType, getDbDialect } from '../../dialect/index';
|
import { ColumnTypeSubscript, compatibleMysql, DataType, DbDialect, getDbDialect } from '../../dialect/index';
|
||||||
import ColumnFormItem from './ColumnFormItem.vue';
|
import ColumnFormItem from './ColumnFormItem.vue';
|
||||||
|
|
||||||
const emits = defineEmits(['dataDelete', 'sortChange', 'deleteData', 'selectionChange', 'changeUpdatedField']);
|
const emits = defineEmits(['dataDelete', 'sortChange', 'deleteData', 'selectionChange', 'changeUpdatedField']);
|
||||||
@@ -333,6 +343,8 @@ const state = reactive({
|
|||||||
|
|
||||||
const { tableHeight, datas } = toRefs(state);
|
const { tableHeight, datas } = toRefs(state);
|
||||||
|
|
||||||
|
const dbConfig = useStorage('dbConfig', { showColumnComment: false });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 行号字段列
|
* 行号字段列
|
||||||
*/
|
*/
|
||||||
@@ -825,6 +837,13 @@ defineExpose({
|
|||||||
border-right: var(--el-table-border);
|
border-right: var(--el-table-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-column-title {
|
||||||
|
height: 30px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
.table-data-cell {
|
.table-data-cell {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -844,7 +863,7 @@ defineExpose({
|
|||||||
color: var(--el-color-info-light-3);
|
color: var(--el-color-info-light-3);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -12px;
|
top: -7px;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,22 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-divider direction="vertical" border-style="dashed" />
|
<el-divider direction="vertical" border-style="dashed" />
|
||||||
|
|
||||||
|
<!-- 表数据展示配置 -->
|
||||||
|
<el-popover
|
||||||
|
popper-style="max-height: 550px; overflow: auto; max-width: 450px"
|
||||||
|
placement="bottom"
|
||||||
|
width="auto"
|
||||||
|
title="展示配置"
|
||||||
|
trigger="click"
|
||||||
|
>
|
||||||
|
<el-checkbox v-model="dbConfig.showColumnComment" label="显示字段备注" :true-label="true" :false-label="false" size="small" />
|
||||||
|
<template #reference>
|
||||||
|
<el-link type="primary" icon="setting" :underline="false"></el-link>
|
||||||
|
</template>
|
||||||
|
</el-popover>
|
||||||
|
|
||||||
|
<el-divider direction="vertical" border-style="dashed" />
|
||||||
|
|
||||||
<el-tooltip :show-after="500" v-if="hasUpdatedFileds" class="box-item" effect="dark" content="提交修改" placement="top">
|
<el-tooltip :show-after="500" v-if="hasUpdatedFileds" class="box-item" effect="dark" content="提交修改" placement="top">
|
||||||
<el-link @click="submitUpdateFields()" type="success" :underline="false" class="font12">提交</el-link>
|
<el-link @click="submitUpdateFields()" type="success" :underline="false" class="font12">提交</el-link>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@@ -188,11 +204,11 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog v-model="addDataDialog.visible" :title="addDataDialog.title" :destroy-on-close="true" width="600px">
|
<el-dialog v-model="addDataDialog.visible" :title="addDataDialog.title" :destroy-on-close="true" width="600px">
|
||||||
<el-form ref="dataForm" :model="addDataDialog.data" label-width="auto" size="small">
|
<el-form ref="dataForm" :model="addDataDialog.data" :show-message="false" label-width="auto" size="small">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-for="column in columns"
|
v-for="column in columns"
|
||||||
:key="column.columnName"
|
:key="column.columnName"
|
||||||
class="w100"
|
class="w100 mb5"
|
||||||
:prop="column.columnName"
|
:prop="column.columnName"
|
||||||
:label="column.columnName"
|
:label="column.columnName"
|
||||||
:required="column.nullable != 'YES' && column.columnKey != 'PRI'"
|
:required="column.nullable != 'YES' && column.columnKey != 'PRI'"
|
||||||
@@ -224,7 +240,7 @@ import DbTableData from './DbTableData.vue';
|
|||||||
import { DbDialect, getDbDialect } from '@/views/ops/db/dialect';
|
import { DbDialect, getDbDialect } from '@/views/ops/db/dialect';
|
||||||
import SvgIcon from '@/components/svgIcon/index.vue';
|
import SvgIcon from '@/components/svgIcon/index.vue';
|
||||||
import ColumnFormItem from './ColumnFormItem.vue';
|
import ColumnFormItem from './ColumnFormItem.vue';
|
||||||
import { useEventListener } from '@vueuse/core';
|
import { useEventListener, useStorage } from '@vueuse/core';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dbId: {
|
dbId: {
|
||||||
@@ -253,6 +269,8 @@ const condDialogInputRef: Ref = ref(null);
|
|||||||
|
|
||||||
const defaultPageSize = DbInst.DefaultLimit;
|
const defaultPageSize = DbInst.DefaultLimit;
|
||||||
|
|
||||||
|
const dbConfig = useStorage('dbConfig', { showColumnComment: false });
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
datas: [],
|
datas: [],
|
||||||
sql: '', // 当前数据tab执行的sql
|
sql: '', // 当前数据tab执行的sql
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11,16 +11,6 @@ type DbBackup struct {
|
|||||||
DbInstanceId uint64 `json:"dbInstanceId"` // 数据库实例ID
|
DbInstanceId uint64 `json:"dbInstanceId"` // 数据库实例ID
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
backupResult = map[TaskStatus]string{
|
|
||||||
TaskDelay: "等待备份数据库",
|
|
||||||
TaskReady: "准备备份数据库",
|
|
||||||
TaskReserved: "数据库备份中",
|
|
||||||
TaskSuccess: "数据库备份成功",
|
|
||||||
TaskFailed: "数据库备份失败",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func (*DbBackup) MessageWithStatus(status TaskStatus) string {
|
func (*DbBackup) MessageWithStatus(status TaskStatus) string {
|
||||||
var result string
|
var result string
|
||||||
switch status {
|
switch status {
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ func (d *DbBinlogHistory) TableName() string {
|
|||||||
|
|
||||||
type BinlogInfo struct {
|
type BinlogInfo struct {
|
||||||
FileName string `json:"fileName"`
|
FileName string `json:"fileName"`
|
||||||
Sequence int64 `json:"sequence""`
|
Sequence int64 `json:"sequence"`
|
||||||
Position int64 `json:"position"`
|
Position int64 `json:"position"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gorm.io/gorm"
|
|
||||||
"mayfly-go/internal/db/domain/entity"
|
"mayfly-go/internal/db/domain/entity"
|
||||||
"mayfly-go/internal/db/domain/repository"
|
"mayfly-go/internal/db/domain/repository"
|
||||||
"mayfly-go/pkg/gormx"
|
"mayfly-go/pkg/gormx"
|
||||||
"mayfly-go/pkg/model"
|
"mayfly-go/pkg/model"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ repository.DbBackup = (*dbBackupRepoImpl)(nil)
|
var _ repository.DbBackup = (*dbBackupRepoImpl)(nil)
|
||||||
@@ -61,7 +62,7 @@ func (d *dbBackupRepoImpl) AddTask(ctx context.Context, tasks ...*entity.DbBacku
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(res) > 0 {
|
if len(res) > 0 {
|
||||||
return errors.New(fmt.Sprintf("数据库备份任务已存在: %v", res))
|
return fmt.Errorf("数据库备份任务已存在: %v", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.BatchInsertWithDb(ctx, db, tasks)
|
return d.BatchInsertWithDb(ctx, db, tasks)
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gorm.io/gorm"
|
|
||||||
"mayfly-go/internal/db/domain/entity"
|
"mayfly-go/internal/db/domain/entity"
|
||||||
"mayfly-go/internal/db/domain/repository"
|
"mayfly-go/internal/db/domain/repository"
|
||||||
"mayfly-go/pkg/gormx"
|
"mayfly-go/pkg/gormx"
|
||||||
"mayfly-go/pkg/model"
|
"mayfly-go/pkg/model"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ repository.DbRestore = (*dbRestoreRepoImpl)(nil)
|
var _ repository.DbRestore = (*dbRestoreRepoImpl)(nil)
|
||||||
@@ -60,7 +61,7 @@ func (d *dbRestoreRepoImpl) AddTask(ctx context.Context, tasks ...*entity.DbRest
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(res) > 0 {
|
if len(res) > 0 {
|
||||||
return errors.New(fmt.Sprintf("数据库备份任务已存在: %v", res))
|
return fmt.Errorf("数据库备份任务已存在: %v", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.BatchInsertWithDb(ctx, db, tasks)
|
return d.BatchInsertWithDb(ctx, db, tasks)
|
||||||
|
|||||||
Reference in New Issue
Block a user