db模块-表数据页面支持直接修改数据(暂只支持达梦数据库)

This commit is contained in:
diant
2023-06-16 18:42:21 +08:00
parent 87e41e91c1
commit b7595dc766
7 changed files with 55 additions and 17 deletions

View File

@@ -48,7 +48,7 @@ public class DmServiceImpl extends DbBaseService {
queryColumns = Arrays.stream(queryColumns.split(",")).map(word -> "\"" + word + "\"").collect(Collectors.joining(","));
}
StringBuilder sqlSb = new StringBuilder();
sqlSb.append(String.format("select %s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName()));
sqlSb.append(String.format("select ROWID as zyplayDbRowId,%s from %s.%s", queryColumns, dataViewParam.getDbName(), dataViewParam.getTableName()));
if (StringUtils.isNotBlank(dataViewParam.getCondition())) {
sqlSb.append(String.format(" where %s", dataViewParam.getCondition()));
}

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.be60d3b3.css" rel="preload" as="style"><link href="css/index.2f89c9fb.css" rel="preload" as="style"><link href="js/chunk-vendors.7871ff07.js" rel="preload" as="script"><link href="js/index.e843feca.js" rel="preload" as="script"><link href="css/chunk-vendors.be60d3b3.css" rel="stylesheet"><link href="css/index.2f89c9fb.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.7871ff07.js"></script><script src="js/index.e843feca.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon-db.png"><title>数据库文档管理</title><link href="css/chunk-vendors.be60d3b3.css" rel="preload" as="style"><link href="css/index.9cce5501.css" rel="preload" as="style"><link href="js/chunk-vendors.7871ff07.js" rel="preload" as="script"><link href="js/index.4d0dba47.js" rel="preload" as="script"><link href="css/chunk-vendors.be60d3b3.css" rel="stylesheet"><link href="css/index.9cce5501.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.7871ff07.js"></script><script src="js/index.4d0dba47.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -76,7 +76,6 @@
<template v-else>
<ux-grid
v-clickoutside="handleClickOutside"
:data="resultItem.dataList"
stripe
border
:height="height"
@@ -84,25 +83,32 @@
:max-height="tableMaxHeight"
@selection-change="handleSelectionChange"
@cell-click="mouseOnFocus"
@cell-mouse-leave="mouseLeave"
@sort-change="tableSortChange"
keep-source
ref="plxTable"
:edit-config="{trigger:'click',mode:'cell',activeMethod:activeMethod}"
@edit-closed="editClosed"
:checkboxConfig="{checkMethod: selectable, highlight: true}"
:default-sort="tableSort">
<ux-table-column type="checkbox" width="50"></ux-table-column>
<ux-table-column type="index" width="50" title=" "></ux-table-column>
<ux-table-column v-for="(item,index) in resultItem.dataCols" :key="index"
:prop="item.prop" :title="item.prop"
:resizable="true"
:prop="item.prop" :title="item.prop" :field="item.prop"
:resizable="true" edit-render
:width="item.width" sortable>
<template slot="header" slot-scope="scope">
<template v-slot:header="scope">
<el-tooltip effect="dark" :content="item.desc" placement="top">
<span>{{ item.prop }}</span>
</el-tooltip>
</template>
<template slot-scope="scope">
<input title="" :value="scope.row[item.prop]" class="el-textarea__inner"
<template v-slot="scope">
<input title="" v-model="scope.row[item.prop]" class="el-textarea__inner"
></input>
</template>
<template v-slot:edit="scope">
<input title="" v-model="scope.row[item.prop]" class="el-textarea__inner"
></input>
</template>
</ux-table-column>
</ux-grid>
<el-pagination
@@ -425,6 +431,12 @@ export default {
this.executeShowTable = (itemIndex === 1) ? "table0" : "table1";
this.executeResultInfo = executeResultInfo;
this.executeResultList = executeResultList;
setTimeout (() => {
for (let i = 0; i < executeResultList.length; i++) {
this.datas = executeResultList[i].dataList;
this.$refs.plxTable[i].reloadData(this.datas);
}
})
}).catch(e => {
this.sqlExecuting = false;
@@ -455,6 +467,9 @@ export default {
width = (width < 50) ? 50 : width;
width = (width > 200) ? 200 : width;
let column = this.columnMap[key] || {};
if(key==='zyplayDbRowId'){
continue;
}
executeResultCols.push({prop: key, width: width + 50, desc: (column.description || key)});
}
}
@@ -474,21 +489,41 @@ export default {
if (this.uxGridCell) {
this.uxGridCell.style.border = 'none'
}
if(column.type==='index'||column.type==='checkbox'){
return;
}
cell.style.border = '2px solid #0078d7'
this.uxGridCell = cell;
},
//表格单元格 hover 退出
mouseLeave(row, column, cell, event) {
// if(this.uxGridCell){
// this.uxGridCell.style.border = 'none'
// }
},
// 点击区域外
handleClickOutside() {
if (this.uxGridCell) {
this.uxGridCell.style.border = 'none'
}
},
//根据返回值用来决定该单元格是否允许编辑
activeMethod(row){
return true
},
//单元格编辑状态下被关闭时
editClosed(row){
//判断是否发生改变
if(this.$refs.plxTable[0].isUpdateByRow(row.row)&&row.row.zyplayDbRowId){
this.$refs.plxTable[0].reloadRow(row, null, null)
let col = row.column.title;
let sql = "update \""+this.pageParam.dbName+"\".\""+this.pageParam.tableName+"\" set \""+col+"\" = \""+row.row[col] +"\" where ROWID = "+row.row.zyplayDbRowId;
datasourceApi.queryExecuteSql({
sourceId: this.pageParam.sourceId,
dbName: this.pageParam.dbName,
executeId: this.nowExecutorId,
sql: sql,
}).then(response => {
if(response.data[0].errCode!==0){
this.$message.error(response.data[0].errMsg)
}
})
}
},
doCopyCheckLineUpdate() {
let choiceData = this.choiceResultObj[this.executeShowTable] || [];
if (choiceData.length > 0) {

View File

@@ -703,6 +703,9 @@ export default {
if (this.uxGridCell) {
this.uxGridCell.style.border = 'none'
}
if(column.type==='index'||column.type==='checkbox'){
return;
}
cell.style.border = '2px solid #0078d7'
this.uxGridCell = cell;
},