表格数据
<input type="hidden" name="materialFieldModel">
<label class="layui-form-label" style=" width: 110px;padding: 9px 9px;">物质-场模型</label>
<div class="layui-input-block">
<table class="layui-table">
<colgroup>
<col width="15%">
<col width="15%">
<col width="15%">
<col width="15%">
<col width="15%">
<col width="15%">
<col width="10%">
</colgroup>
<thead>
<tr>
<th>功能主体(S2)</th>
<th>功能主体(S1)</th>
<th>作用类型</th>
<th>场</th>
<th>场类型</th>
<th>符号</th>
<th>操作</th>
<th><button type="button" class=" addcenter layui-btn" onclick="fieldModel()"
style="float:right;">
<i class="layui-icon"></i>添加
</button></th>
</tr>
</thead>
<tbody id="modelTbody">
</tbody>
</table>
提交
//提交
form.on('submit(normSolutionCreate)', function (data) {
let arrayList = new Array();
$("#modelTbody tr").each(function (index, element) {
let tdList = $(element).children();
let insertNorm = {};
insertNorm.funcMain = tdList.eq(0).find("input").val();
insertNorm.funcGuest = tdList.eq(1).find("input").val();
insertNorm.actionType = tdList.eq(2).find("input").val();
insertNorm.fieldName = tdList.eq(3).text();
insertNorm.fieldType = $("#modelTbody tr:eq(" + index + ") select:eq(0) option:selected").text();
insertNorm.symbol = tdList.eq(5).text();
if (insertNorm.funcMain == "" || insertNorm.funcGuest == "" || insertNorm.fieldName == "" || insertNorm.fieldType == "请选择") {
layer.msg("请填写(选择)参数!");
return false;
}
arrayList[index] = insertNorm;
})
// debugger;
data.field.materialFieldModel = JSON.stringify(arrayList);
$.ajax({
url: "insertNormSolution",
method: 'post',
data: data.field,
dataType: "json",
success: function (res) {
if (res.code == 0) {
layer.msg(res.tipMsg, {
icon: 1,
anim: 6,
time: 3600
});
setTimeout(function () {
window.location.href = "standSolution";
},
1800);
} else {
layer.msg("提交失败!");
}
}
});
return false; //这里很重要,一定要加这个。要不然提交后弹出层会刷新一次,从而不执行ajax的success
})