mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-14 09:20:49 +08:00
commit
65697cfe9e
@ -23,6 +23,7 @@ import io.edurt.datacap.spi.Plugin;
|
||||
import io.edurt.datacap.spi.model.Configure;
|
||||
import io.edurt.datacap.spi.model.Pagination;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -208,12 +209,31 @@ public class TableServiceImpl
|
||||
updateConfigure.setFormat(FormatType.NONE);
|
||||
plugin.connect(updateConfigure);
|
||||
List<String> allSql = Lists.newArrayList();
|
||||
// Gets the auto-increment column for the current row
|
||||
List<String> autoIncrementColumns = table.getColumns()
|
||||
.stream()
|
||||
.filter(v -> v.getExtra().toLowerCase().contains("auto_increment"))
|
||||
.map(v -> v.getName())
|
||||
.collect(Collectors.toList());
|
||||
configure.getNewColumns().forEach(v -> {
|
||||
List<SqlColumn> columns = Lists.newArrayList();
|
||||
v.entrySet().forEach(entry -> columns.add(SqlColumn.builder()
|
||||
.column(String.format("`%s`", entry.getKey()))
|
||||
.value(entry.getValue())
|
||||
.build()));
|
||||
v.entrySet().forEach(entry -> {
|
||||
SqlColumn column = SqlColumn.builder()
|
||||
.column(String.format("`%s`", entry.getKey()))
|
||||
.build();
|
||||
if (entry.getValue() == null) {
|
||||
column.setValue(null);
|
||||
}
|
||||
else {
|
||||
if (autoIncrementColumns.contains(entry.getKey())) {
|
||||
column.setValue(null);
|
||||
}
|
||||
else {
|
||||
column.setValue(String.format("'%s'", StringEscapeUtils.escapeSql(entry.getValue())));
|
||||
}
|
||||
}
|
||||
columns.add(column);
|
||||
});
|
||||
SqlBody body = SqlBody.builder()
|
||||
.type(SqlType.INSERT)
|
||||
.database(table.getDatabase().getName())
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
faCircle,
|
||||
faCircleInfo,
|
||||
faClock,
|
||||
faClone,
|
||||
faColumns,
|
||||
faDatabase,
|
||||
faDroplet,
|
||||
@ -40,6 +41,7 @@ import {
|
||||
*/
|
||||
const createIcons = (app: any) => {
|
||||
library.add(faArrowRight,
|
||||
faClone,
|
||||
faPlus,
|
||||
faTablet,
|
||||
faMinus,
|
||||
|
@ -67,7 +67,7 @@
|
||||
<Button :disabled="currentUserId !== row.user.id" shape="circle" type="error" size="small" icon="md-trash"/>
|
||||
</Poptip>
|
||||
</Tooltip>
|
||||
<Tooltip :content="$t('common.admin') + $t('common.beta')"
|
||||
<Tooltip :content="$t('common.admin')"
|
||||
transfer>
|
||||
<Button :disabled="currentUserId !== row.user.id || !row.available"
|
||||
shape="circle"
|
||||
|
@ -81,10 +81,20 @@
|
||||
<Button size="small"
|
||||
shape="circle"
|
||||
type="text"
|
||||
@click="handlerAddRow">
|
||||
@click="handlerAddOrCloneRow(false)">
|
||||
<FontAwesomeIcon icon="plus"/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip :content="$t('source.manager.addRows')"
|
||||
transfer>
|
||||
<Button size="small"
|
||||
shape="circle"
|
||||
type="text"
|
||||
:disabled="dataSelectedChanged.columns.length === 0"
|
||||
@click="handlerAddOrCloneRow(true)">
|
||||
<FontAwesomeIcon icon="clone"/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip :content="$t('source.manager.deleteRows')"
|
||||
transfer>
|
||||
<Button size="small"
|
||||
@ -450,14 +460,22 @@ export default defineComponent({
|
||||
{
|
||||
this.filterConfigure.configure = value;
|
||||
},
|
||||
handlerAddRow()
|
||||
handlerAddOrCloneRow(clone: boolean)
|
||||
{
|
||||
const newData = {};
|
||||
this.originalColumns.forEach((column: { field: string; }) => {
|
||||
newData[column.field] = null;
|
||||
});
|
||||
this.configure.datasets.push(newData);
|
||||
this.newRows.push(newData);
|
||||
if (!clone) {
|
||||
this.originalColumns.forEach((column: { field: string; }) => {
|
||||
newData[column.field] = null;
|
||||
});
|
||||
this.configure.datasets.push(newData);
|
||||
this.newRows.push(newData);
|
||||
}
|
||||
else {
|
||||
this.dataSelectedChanged.columns.forEach(column => {
|
||||
this.configure.datasets.push(column);
|
||||
this.newRows.push(column);
|
||||
});
|
||||
}
|
||||
this.dataCellChanged.type = SqlType.INSERT;
|
||||
this.dataCellChanged.changed = true;
|
||||
this.dataCellChanged.columns = this.newRows;
|
||||
|
Loading…
Reference in New Issue
Block a user