<!DOCTYPE html>
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
<head>
|
<th:block th:include="include :: header('产品包授权')"/>
|
<th:block th:include="include :: select2-css"/>
|
<th:block th:include="include :: bootstrap-select-css"/>
|
</head>
|
<body class="white-bg">
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
<form class="form-horizontal m" id="form-demographyParam-edit">
|
<input name="userId" id="userId" type="hidden" th:value="${userId}"/>
|
<input name="prodCodes" id="prodCodes" type="hidden"/>
|
<div class="form-group">
|
<label class="col-sm-3 control-label">[[#{menu.exam.product.view}]]:</label>
|
<div class="select-list col-sm-8">
|
<ul>
|
<li>
|
<select id="prodId" name="prodId" class="select2-container" onchange="testTypeChange()" >
|
<option th:each="dict : ${userProds}" th:text="${dict.name}"
|
th:value="${dict.id} "></option>
|
</select>
|
</li>
|
</ul>
|
</div>
|
</div>
|
<div class="form-group">
|
<label class="col-sm-3 control-label">[[#{jsp.exam.productReportTemplate}]]:</label>
|
<div class="col-sm-8">
|
<select id="reportTemplateId" name="reportTemplateId" class="form-control noselect2 selectpicker"
|
multiple>
|
<option th:each="dict : ${templateList}" th:text="${dict['reportType']}"
|
th:value="${dict['id']}"></option>
|
</select>
|
<!-- <select id="reportTemplateIdAll" name="reportTemplateIdAll" class="form-control noselect2 selectpicker"-->
|
<!-- multiple>-->
|
<!-- <option th:each="dict : ${templateList}" th:text="${dict['reportType']}"-->
|
<!-- th:value="${dict['id']}"></option>-->
|
<!-- </select>-->
|
</div>
|
</div>
|
<div class="form-group">
|
<label class="col-sm-1 control-label"></label>
|
<div class="col-sm-2">
|
<a class="btn btn-success" onclick="insertRow()">
|
<i class="fa fa-plus"></i> [[#{jsp.product.package.authorization}]]
|
</a>
|
</div>
|
</div>
|
<div class="row">
|
<div class="col-sm-12 select-table table-striped">
|
<table id="bootstrap-table" data-mobile-responsive="true"></table>
|
</div>
|
</div>
|
|
</form>
|
</div>
|
<th:block th:include="include :: footer"/>
|
<th:block th:include="include :: select2-js"/>
|
<th:block th:include="include :: bootstrap-select-js"/>
|
<script type="text/javascript">
|
var prefix = ctx + "exam/paper";
|
$("#form-demographyParam-edit").validate({
|
focusCleanup: true
|
});
|
|
$(function () {
|
var options = {
|
url: prefix + "/listCodes",
|
showSearch: false,
|
showRefresh: false,
|
showToggle: false,
|
showColumns: false,
|
pagination: false,
|
uniqueId: "prodId",
|
height: 400,
|
columns: [
|
{
|
field: 'prodId',
|
title: '[[#{jsp.exam.product.productPackageNumber}]]',
|
visible: false
|
},
|
{
|
field: 'prodName',
|
title: '[[#{jsp.exam.report.productName}]]'
|
},
|
{
|
field: 'reportTemplateId',
|
title: '[[#{jsp.exam.report.013}]]',
|
visible: false
|
},
|
{
|
field: 'reportTemplateText',
|
title: '[[#{jsp.exam.userpaper.reporttype}]]'
|
},
|
{
|
title: '[[#{basis.operate}]]',
|
align: 'center',
|
formatter: function (value, row, index) {
|
var actions = [];
|
actions.push('<a class="btn btn-danger" onclick="removeRowByUniqueId(\'' + row.prodId + '\')"><i class="fa fa-remove"></i>[[#{basis.del}]]</a>');
|
return actions.join('');
|
}
|
}
|
]
|
};
|
$.table.init(options);
|
});
|
|
/*[[#{basis.add}]]表格行 */
|
function insertRow() {
|
var prodId = $("#prodId").val();
|
var prodName = $("#prodId option:selected").text();
|
var arr = $("#reportTemplateId").val();//取值是一个数组
|
var reportTemplateId = "";
|
for(var i = 0; i < arr.length; i++) {
|
if (i==arr.length-1) {
|
reportTemplateId=reportTemplateId+arr[i]
|
}else {
|
reportTemplateId=reportTemplateId+arr[i]+",";
|
}
|
}
|
|
var reportTemplateText = $("#reportTemplateId option:selected").text();
|
|
if (checkDuplicate(prodId)) {
|
$.modal.alertWarning('存在产品包权限,不允许重复添加!');
|
return;
|
}
|
|
$.btTable.bootstrapTable('insertRow', {
|
index: 0, // 你想插入到哪,0表示第一行
|
row: {
|
prodId: prodId,
|
reportTemplateId: reportTemplateId,
|
reportTemplateText: reportTemplateText,
|
prodName: prodName
|
}
|
})
|
}
|
|
function checkDuplicate(prodId) {
|
var data = $.btTable.bootstrapTable('getData');
|
var sdata = JSON.stringify(data);
|
var jsonArr = JSON.parse(sdata);
|
var check = false;
|
$.each(jsonArr, function (index, value) {
|
if (prodId == value.prodId) {
|
check = true;
|
}
|
});
|
return check;
|
}
|
|
/* 删除行ID值为1的数据 */
|
function removeRowByUniqueId(id) {
|
$.btTable.bootstrapTable('removeByUniqueId', id);
|
}
|
|
function submitHandler() {
|
if ($.validate.form()) {
|
var sdata = getData();
|
var jsonArr = JSON.parse(sdata);
|
$("#prodCodes").val(sdata);
|
$.operate.save(prefix + "/edit", $('#form-demographyParam-edit').serialize());
|
}
|
}
|
|
/* 查询表格所有数据值 */
|
function getData() {
|
var data = $.btTable.bootstrapTable('getData');
|
return JSON.stringify(data);
|
}
|
|
function doSubmit(index, layero) {
|
var body = layer.getChildFrame('body', index);
|
var prodid = body.find('#prodId').val();
|
layer.close(index);
|
$("#dicttype").val(prodid);
|
}
|
</script>
|
</body>
|
</html>
|