mirror of https://gitee.com/y_project/RuoYi.git
主子表操作列新增单个删除
parent
94e23ec0f8
commit
0264da8d7c
|
@ -417,7 +417,7 @@ var storage = {
|
|||
|
||||
// 主子表操作封装处理
|
||||
var sub = {
|
||||
editColumn: function() {
|
||||
editRow: function() {
|
||||
var dataColumns = [];
|
||||
for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
|
||||
if (table.options.columns[columnIndex].visible != false) {
|
||||
|
@ -441,18 +441,22 @@ var sub = {
|
|||
obj[key] = selectValue.val();
|
||||
} else if ($.common.isNotEmpty(textareaValue.val())) {
|
||||
obj[key] = textareaValue.val();
|
||||
} else {
|
||||
if (key == "index" && $.common.isNotEmpty(data[dataIndex].index)) {
|
||||
obj[key] = data[dataIndex].index;
|
||||
} else {
|
||||
obj[key] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
var item = data[dataIndex];
|
||||
var extendObj = $.extend({}, item, obj);
|
||||
params.push({ index: dataIndex, row: extendObj });
|
||||
}
|
||||
$("#" + table.options.id).bootstrapTable("updateRow", params);
|
||||
},
|
||||
delColumn: function(column) {
|
||||
sub.editColumn();
|
||||
delRow: function(column) {
|
||||
sub.editRow();
|
||||
var subColumn = $.common.isEmpty(column) ? "index" : column;
|
||||
var ids = $.table.selectColumns(subColumn);
|
||||
if (ids.length == 0) {
|
||||
|
@ -461,15 +465,18 @@ var sub = {
|
|||
}
|
||||
$("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
|
||||
},
|
||||
addColumn: function(row, tableId) {
|
||||
delRowByIndex: function(defindex, index) {
|
||||
sub.editRow();
|
||||
var value = $.common.isNotEmpty(index) ? index : defindex;
|
||||
$("#" + table.options.id).bootstrapTable('remove', { field: "index", values: [value] });
|
||||
sub.editRow();
|
||||
},
|
||||
addRow: function(row, tableId) {
|
||||
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
|
||||
table.set(currentId);
|
||||
var count = $("#" + currentId).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
$("#" + currentId).bootstrapTable('insertRow', {
|
||||
index: count + 1,
|
||||
row: row
|
||||
});
|
||||
sub.editRow();
|
||||
$("#" + currentId).bootstrapTable('insertRow', { index: count + 1, row: row });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1537,7 +1537,7 @@ var table = {
|
|||
common: {
|
||||
// 判断字符串是否为空
|
||||
isEmpty: function (value) {
|
||||
if (value == null || this.trim(value) == "") {
|
||||
if (value == null || this.trim(value) == "" || value == undefined || value == "undefined") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
<h4 class="form-header h4">商品数据</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
|
@ -166,6 +166,13 @@
|
|||
var data = [{ index: index, type: value }];
|
||||
return $("#goodsTypeTpl").tmpl(data).html();
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
|
@ -184,15 +191,17 @@
|
|||
autoclose: true
|
||||
});
|
||||
|
||||
function addColumn() {
|
||||
function addRow() {
|
||||
var count = $("#" + table.options.id).bootstrapTable('getData').length;
|
||||
var row = {
|
||||
index: $.table.serialNumber(count),
|
||||
name: "",
|
||||
weight: "",
|
||||
price: "",
|
||||
date: "",
|
||||
type: "",
|
||||
}
|
||||
sub.addColumn(row);
|
||||
sub.addRow(row);
|
||||
}
|
||||
|
||||
$("#bootstrap-table").on("post-body.bs.table", function (e, args) {
|
||||
|
|
|
@ -160,8 +160,8 @@
|
|||
<h4 class="form-header h4">${subTable.functionName}信息</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
|
@ -334,9 +334,7 @@
|
|||
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
|
||||
return $.common.dictToSelect(${javaField}Datas, value, name);
|
||||
}
|
||||
#if($foreach.count != $subTable.columns.size())
|
||||
},
|
||||
#end
|
||||
#else
|
||||
{
|
||||
field: '${javaField}',
|
||||
|
@ -346,34 +344,33 @@
|
|||
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
#if($foreach.count != $subTable.columns.size())
|
||||
},
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function addColumn() {
|
||||
function addRow() {
|
||||
var count = $("#" + table.options.id).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
|
||||
$("#" + table.options.id).bootstrapTable('insertRow', {
|
||||
index: count,
|
||||
row: {
|
||||
var row = {
|
||||
index: $.table.serialNumber(count),
|
||||
#foreach($column in $subTable.columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||
#else
|
||||
${javaField}: ""#if($foreach.count != $subTable.columns.size()),#end
|
||||
|
||||
${javaField}: "",
|
||||
#end
|
||||
#end
|
||||
}
|
||||
});
|
||||
sub.addRow(row);
|
||||
}
|
||||
#end
|
||||
</script>
|
||||
|
|
|
@ -160,8 +160,8 @@
|
|||
<h4 class="form-header h4">${subTable.functionName}信息</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
|
@ -345,9 +345,7 @@
|
|||
var name = $.common.sprintf("${subclassName}List[%s].${javaField}", index);
|
||||
return $.common.dictToSelect(${javaField}Datas, value, name);
|
||||
}
|
||||
#if($foreach.count != $subTable.columns.size())
|
||||
},
|
||||
#end
|
||||
#else
|
||||
{
|
||||
field: '${javaField}',
|
||||
|
@ -357,34 +355,34 @@
|
|||
var html = $.common.sprintf("<input class='form-control' type='text' name='${subclassName}List[%s].${javaField}' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
#if($foreach.count != $subTable.columns.size())
|
||||
},
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + $.table.serialNumber(index) + '\', \'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a>';
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function addColumn() {
|
||||
function addRow() {
|
||||
var count = $("#" + table.options.id).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
|
||||
$("#" + table.options.id).bootstrapTable('insertRow', {
|
||||
index: count,
|
||||
row: {
|
||||
var row = {
|
||||
index: $.table.serialNumber(count),
|
||||
#foreach($column in $subTable.columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||
#else
|
||||
${javaField}: ""#if($foreach.count != $subTable.columns.size()),#end
|
||||
|
||||
${javaField}: "",
|
||||
#end
|
||||
#end
|
||||
}
|
||||
});
|
||||
sub.addRow(row);
|
||||
}
|
||||
#end
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue