主子表示例增加初始化数据

pull/262/head
Ricky 2021-02-01 11:01:51 +08:00
parent e69f043cad
commit 701411132d
1 changed files with 22 additions and 1 deletions

View File

@ -84,7 +84,26 @@
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
$(function() {
// 初始化数据, 可以由后台传过来
var data = [
{
id: "100",
name: "商品名称",
weight: "100",
price: "12.5",
date: "2021-02-01",
type: "1",
},
{
id: "101",
name: "商品名称2",
weight: "50",
price: "10.8",
date: "2021-02-01",
type: "0",
}];
var options = {
data: data,
pagination: false,
showSearch: false,
showRefresh: false,
@ -100,7 +119,8 @@
title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
var columnId = $.common.sprintf("<input type='hidden' name='goods[%s].id' value='%s'>", index, row.id);
return columnIndex + $.table.serialNumber(index) + columnId;
}
},
{
@ -155,6 +175,7 @@
/* 主子表-提交 */
function submitHandler(index, layero){
var data = $("#form-add").serializeArray();
alert(JSON.stringify(data))
$.operate.saveModal("/demo/operate/customer/add", data);
}