feat: dbms表数据新增表单视图

This commit is contained in:
meilin.huang
2024-07-19 17:06:11 +08:00
parent a80221a950
commit 2deb3109c2
8 changed files with 32 additions and 32 deletions

View File

@@ -17,7 +17,7 @@
"cropperjs": "^1.6.1",
"dayjs": "^1.11.11",
"echarts": "^5.5.1",
"element-plus": "^2.7.6",
"element-plus": "^2.7.7",
"js-base64": "^3.7.7",
"jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
@@ -34,7 +34,7 @@
"sql-formatter": "^15.0.2",
"trzsz": "^1.1.5",
"uuid": "^9.0.1",
"vue": "^3.4.31",
"vue": "^3.4.32",
"vue-router": "^4.4.0",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0",
@@ -49,15 +49,15 @@
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/compiler-sfc": "^3.4.31",
"@vue/compiler-sfc": "^3.4.32",
"code-inspector-plugin": "^0.4.5",
"dotenv": "^16.3.1",
"eslint": "^8.35.0",
"eslint-plugin-vue": "^9.25.0",
"prettier": "^3.2.5",
"sass": "^1.77.6",
"sass": "^1.77.8",
"typescript": "^5.5.3",
"vite": "^5.3.3",
"vite": "^5.3.4",
"vue-eslint-parser": "^9.4.2"
},
"browserslist": [

View File

@@ -25,7 +25,7 @@
:clearable="false"
type="Date"
value-format="YYYY-MM-DD"
placeholder="选择日期"
:placeholder="`选择日期-${placeholder}`"
/>
<el-date-picker
@@ -41,7 +41,7 @@
:clearable="false"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="选择日期时间"
:placeholder="`选择日期时间-${placeholder}`"
/>
<el-time-picker
@@ -56,7 +56,7 @@
v-model="itemValue"
:clearable="false"
value-format="HH:mm:ss"
placeholder="选择时间"
:placeholder="`选择时间-${placeholder}`"
/>
</template>

View File

@@ -258,12 +258,10 @@ const cmDataDel = new ContextmenuItem('deleteData', '删除')
return state.table == '';
});
const cmDataEdit = new ContextmenuItem('editData', '编辑行')
.withIcon('edit')
.withOnClick(() => onEditRowData())
.withHideFunc(() => {
return state.table == '';
});
const cmFormView = new ContextmenuItem('formView', '表单视图').withIcon('Document').withOnClick(() => onEditRowData());
// .withHideFunc(() => {
// return state.table == '';
// });
const cmDataGenInsertSql = new ContextmenuItem('genInsertSql', 'Insert SQL')
.withIcon('tickets')
@@ -595,7 +593,7 @@ const dataContextmenuClick = (event: any, rowIndex: number, column: any, data: a
const { clientX, clientY } = event;
state.contextmenu.dropdown.x = clientX;
state.contextmenu.dropdown.y = clientY;
state.contextmenu.items = [cmDataCopyCell, cmDataDel, cmDataEdit, cmDataGenInsertSql, cmDataGenJson, cmDataExportCsv, cmDataExportSql];
state.contextmenu.items = [cmDataCopyCell, cmDataDel, cmFormView, cmDataGenInsertSql, cmDataGenJson, cmDataExportCsv, cmDataExportSql];
contextmenuRef.value.openContextmenu({ column, rowData: data });
};
@@ -627,12 +625,12 @@ const onDeleteData = async () => {
const onEditRowData = () => {
const selectionDatas = Array.from(selectionRowsMap.values());
if (selectionDatas.length > 1) {
ElMessage.warning('只能编辑一行数据');
ElMessage.warning('只能选择一行数据');
return;
}
const data = selectionDatas[0];
state.tableDataFormDialog.data = { ...data };
state.tableDataFormDialog.title = `编辑表'${props.table}'数据`;
state.tableDataFormDialog.title = state.table ? `'${props.table}'表单数据` : '表单视图';
state.tableDataFormDialog.visible = true;
};
@@ -648,7 +646,7 @@ const onGenerateJson = async () => {
// 按列字段重新排序对象key
const jsonObj = [];
for (let selectionData of selectionDatas) {
let obj = {};
let obj: any = {};
for (let column of state.columns) {
if (column.show) {
obj[column.title] = selectionData[column.dataKey];
@@ -752,7 +750,7 @@ const submitUpdateFields = async () => {
for (let updateRow of cellUpdateMap.values()) {
const rowData = { ...updateRow.rowData };
let updateColumnValue = {};
let updateColumnValue: any = {};
for (let k of updateRow.columnsMap.keys()) {
const v = updateRow.columnsMap.get(k);

View File

@@ -6,10 +6,10 @@
:key="column.columnName"
class="w100 mb5"
:prop="column.columnName"
:required="!column.nullable && !column.isPrimaryKey && !column.isIdentity"
:required="props.tableName != '' && !column.nullable && !column.isPrimaryKey && !column.isIdentity"
>
<template #label>
<span class="pointer" :title="`${column.columnType} | ${column.columnComment}`">
<span class="pointer" :title="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType">
{{ column.columnName }}
</span>
</template>
@@ -17,13 +17,13 @@
<ColumnFormItem
v-model="modelValue[`${column.columnName}`]"
:data-type="dbInst.getDialect().getDataType(column.dataType)"
:placeholder="`${column.columnType} ${column.columnComment}`"
:placeholder="column?.columnComment ? `${column.columnType} | ${column.columnComment}` : column.columnType"
:column-name="column.columnName"
:disabled="column.isIdentity"
/>
</el-form-item>
</el-form>
<template #footer>
<template #footer v-if="props.tableName">
<span class="dialog-footer">
<el-button @click="closeDialog">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
@@ -99,7 +99,7 @@ const confirm = async () => {
let sql = '';
if (oldValue) {
const updateColumnValue = {};
const updateColumnValue: any = {};
Object.keys(oldValue).forEach((key) => {
// 如果新旧值不相等,则为需要更新的字段
if (oldValue[key] !== modelValue.value[key]) {

View File

@@ -69,7 +69,7 @@ export enum DataType {
}
/** 列数据类型角标 */
export const ColumnTypeSubscript = {
export const ColumnTypeSubscript: any = {
/** 字符串 */
string: 'ab',
/** 数字 */

View File

@@ -32,14 +32,14 @@ require (
github.com/tidwall/gjson v1.17.1
github.com/veops/go-ansiterm v0.0.5
go.mongodb.org/mongo-driver v1.16.0 // mongo
golang.org/x/crypto v0.24.0 // ssh
golang.org/x/crypto v0.25.0 // ssh
golang.org/x/oauth2 v0.21.0
golang.org/x/sync v0.7.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
// gorm
gorm.io/driver/mysql v1.5.6
gorm.io/gorm v1.25.10
gorm.io/driver/mysql v1.5.7
gorm.io/gorm v1.25.11
)
require (
@@ -96,7 +96,7 @@ require (
golang.org/x/exp v0.0.0-20230519143937-03e91628a987 // indirect
golang.org/x/image v0.13.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto v0.0.0-20230131230820-1c016267d619 // indirect
google.golang.org/grpc v1.52.3 // indirect

View File

@@ -98,18 +98,19 @@ func NewParserByteStream(width, height int) *ansiterm.ByteStream {
var (
enterMarks = [][]byte{
[]byte("\x1b[?1049h"),
[]byte("\x1b[?1049h"), // 从备用屏幕缓冲区恢复屏幕内容
[]byte("\x1b[?1048h"),
[]byte("\x1b[?1047h"),
[]byte("\x1b[?47h"),
[]byte("\x1b[?25l"),
[]byte("\x1b[?25l"), // 隐藏光标
}
exitMarks = [][]byte{
[]byte("\x1b[?1049l"),
[]byte("\x1b[?1049l"), // 从备用屏幕缓冲区恢复屏幕内容
[]byte("\x1b[?1048l"),
[]byte("\x1b[?1047l"),
[]byte("\x1b[?47l"),
[]byte("\x1b[?25h"), // 显示光标
}
screenMarks = [][]byte{

View File

@@ -112,6 +112,7 @@ func (re *RedisInfo) connSentinel() (*RedisConn, error) {
SentinelAddrs: strings.Split(masterNameAndHosts[1], ","),
Username: re.Username,
Password: re.Password, // no password set
SentinelUsername: re.Username,
SentinelPassword: re.Password, // 哨兵节点密码需与redis节点密码一致
DB: re.Db, // use default DB
DialTimeout: 8 * time.Second,