<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%
|
String path = request.getContextPath();
|
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
|
+ path + "/";
|
%>
|
<html>
|
<head>
|
<base href="<%=basePath%>">
|
<meta name="viewport" charset="width=device-width, initial-scale=1.0">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<title>验收问题选择</title>
|
<link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
|
<link href="static/plugins/jquery-easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css">
|
<link rel="stylesheet" href="static/styles/initialize.css" type="text/css">
|
<link rel="stylesheet" href="static/styles/common.css" type="text/css">
|
<link rel="stylesheet" href="static/plugins/layer/skin/default/layer.css" type="text/css">
|
|
<script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/jquery.easyui.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
|
<script type="text/javascript" src="static/scripts/easyuiExtend.js"></script>
|
<script type="text/javascript" src="static/scripts/jquery-extend.js"></script>
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery-easyui-datagrid-dnd/datagrid-dnd.js"></script>
|
<script src="static/plugins/ace/src-noconflict/ace.js" type="text/javascript"></script>
|
<script src="static/plugins/jquery.redirect.js" type="text/javascript"></script>
|
<!-- 弹窗加载组件 -->
|
<script type="text/javascript" src="static/plugins/layer/layer.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/spin.js"></script>
|
<script type="text/javascript" src="static/plugins/spinjs/jquery.spin.js"></script>
|
<script type="text/javascript" src="static/plugins/jquery.blockUI.js"></script>
|
<!-- wcp组件 -->
|
<script type="text/javascript" src="static/wcp/scripts/wcp.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.layer.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.blockUI.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.spin.js"></script>
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.jquery.js"></script>
|
|
<!--[if lt IE 9]>
|
<script type="text/javascript" src="static/plugins/json2.js"></script>
|
<![endif]-->
|
<script type="text/javascript" src="static/wcp/scripts/libs/wcp.infoPicker.js"></script>
|
<style>
|
html, body {
|
height: 100%;
|
}
|
|
.left {
|
width: 48%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.search {
|
clear: both;
|
}
|
|
.right {
|
width: 48%;
|
float: left;
|
text-align: center;
|
padding-top: 10px;
|
}
|
|
.s-choose-frame {
|
height: 30px;
|
line-height: 30px;
|
margin-bottom: 10px;
|
}
|
|
.s-choose {
|
display: inline-block;
|
border: 1px solid #D4D4D4;
|
border-radius: 2px;
|
}
|
|
.s-choose a {
|
float: left;
|
padding: 0 16px;
|
border-right: 1px solid #d4d4d4;
|
height: 30px;
|
line-height: 30px;
|
}
|
|
.s-choose a:last-child {
|
border-right: 0 none;
|
}
|
|
.s-choose a:hover, .s-choose a.s-choose-selected {
|
background: #00c0ef;
|
color: #fff;
|
}
|
</style>
|
</head>
|
<body>
|
<div>
|
<div class="left">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 400px">
|
<ul id="ul_type"></ul>
|
</div>
|
</div>
|
<div class="right">
|
<div class="easyui-panel pt-tree" style="border-right: none;height: 400px">
|
<ul id="dg_hasSelect"></ul>
|
</div>
|
</div>
|
<div class="search">
|
<div class="easyui-panel" style="padding:20px 300px; border-top:none;">
|
<input class="easyui-searchbox" data-options="prompt:'请输入问题名称进行查询',searcher:doSearch"
|
style="width:100%">
|
</div>
|
</div>
|
<div class="pt-form-btn" style="bottom:0px;">
|
<div class="form-group">
|
<button type="button" class="pt-btn pt-btn-primary" onclick="doSave();">确定</button>
|
<button type="button" class="pt-btn pt-btn-default" onclick="doClose();">关闭</button>
|
<button type="button" class="pt-btn pt-btn-danger" onclick="delAll();">删除全部</button>
|
</div>
|
</div>
|
</div>
|
|
</body>
|
<script>
|
var param = {
|
callBack: null,
|
backOne: null,
|
haveSelected: ""
|
};
|
$(function () {
|
//绑定已选择项,前端js传参数,必须加延迟,否则传参易丢失
|
setTimeout(function () {
|
bindHasSelect();
|
}, 500);
|
// 延迟初始化待选列表,确保依赖项已准备就绪
|
setTimeout(function () {
|
initWaitSelectUser("");
|
}, 1000);
|
// bindHasSelect();
|
|
});
|
|
function bindHasSelect() {
|
//已选
|
$('#dg_hasSelect').datagrid({
|
fitColumns: true,
|
nowrap: true,
|
rownumbers: true,
|
height: 385,
|
idField: "id",
|
emptyMsg: "没有找到匹配的记录",
|
toolbar: "#hasToolbar",
|
// frozenColumns:[[{field:'ck',checkbox:true}]],
|
columns: [[
|
{
|
field: 'question',
|
title: '名称',
|
width: 400
|
},
|
{
|
field: 'id',
|
title: '操作',
|
width: 100,
|
align: 'center',
|
formatter: function (value, row, index) {
|
return '<a onclick="delTableRow(\'' + row.type + '\',\'' + value + '\',' + index + ');" class="pt-color-danger">删除</a>';
|
}
|
}
|
|
]],
|
onLoadSuccess: function () {
|
// new ResizeScroll({
|
// "id": "#dg_hasSelect",
|
// "height": "341"
|
// });
|
}
|
});
|
|
if (param.haveSelected != null && param.haveSelected != "") {
|
|
var haveSelectedMinerals = param.haveSelected.split(',');
|
$.each(haveSelectedMinerals, function (index, haveSelectedMineral) {
|
var id = haveSelectedMineral.split('-')[0];
|
var question = haveSelectedMineral.split('-')[1];
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: id,
|
question: question
|
});
|
});
|
}
|
}
|
|
function initWaitSelectUser(question) {
|
debugger;
|
$('#ul_type').datagrid({
|
url: "gdMisManage/getCheckQuestion?question=" + question,
|
fitColumns: true,
|
nowrap: true,
|
rownumbers: true,
|
height: 385,
|
idField: "id",
|
emptyMsg: "没有找到匹配的记录",
|
toolbar: "#midToolbar",
|
sortOrder: "asc",
|
frozenColumns: [[{
|
field: 'ck',
|
checkbox: true
|
}]],
|
columns: [[
|
{
|
field: 'id',
|
title: '主键',
|
width: 1,
|
hidden: true
|
},
|
{
|
field: 'question',
|
title: '问题',
|
width: 400
|
}
|
]],
|
onCheck: function (index, row) {
|
debugger;
|
var state = false;
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
if (hasRows != null) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (row.id == hasRows[i].id) {
|
state = true;
|
break;
|
}
|
}
|
}
|
|
if (!state) {
|
// if (!multiSelect) {
|
// $('#dg_hasSelect').datagrid("loadData", []);
|
// }
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: row.id,
|
question: row.question
|
});
|
}
|
},
|
onUncheck: function (index, row) {
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
if (hasRows != null) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (hasRows[i].id == row.id) {
|
$('#dg_hasSelect').datagrid("deleteRow", i);
|
break;
|
}
|
}
|
}
|
},
|
onCheckAll: function (rows) {
|
debugger;
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
debugger;
|
for (var j = 0; j < rows.length; j++) {
|
var state = false;
|
if (hasRows != null) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (hasRows[i].id == rows[j].id) {
|
state = true;
|
break;
|
}
|
}
|
}
|
|
if (state != true) {
|
$('#dg_hasSelect').datagrid("appendRow", {
|
id: rows[j].id,
|
question: rows[j].question,
|
});
|
}
|
}
|
},
|
onUncheckAll: function (rows) {
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
if (hasRows != null && hasRows.length > 0) {
|
for (var j = 0; j < rows.length; j++) {
|
for (var i = 0; i < hasRows.length; i++) {
|
if (hasRows[i].id == rows[j].id) {
|
$('#dg_hasSelect').datagrid("deleteRow", i);
|
break;
|
}
|
}
|
}
|
}
|
},
|
loadFilter: function (data) {
|
// console.info("userload"+data);
|
return data;
|
},
|
onLoadSuccess: function () {
|
// new ResizeScroll({
|
// "id": "#ul_type",
|
// "height": "341"
|
// });
|
}
|
});
|
}
|
|
//查询数据
|
function doSearch(value) {
|
debugger;
|
if (value != '') {
|
// $('#ul_type').datagrid("clearChecked");
|
initWaitSelectUser(value)
|
}
|
}
|
|
//保存选中项
|
function doSave() {
|
|
var selectMineral = "";
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
var exist = false;
|
$.each(hasRows, function (index, row) {
|
var id = row.id;
|
var question = row.question;
|
var select = id + "-" + question;
|
selectMineral = selectMineral + select + ",";
|
});
|
if (selectMineral != "") {
|
selectMineral = selectMineral.substring(0, selectMineral.length - 1).trim();
|
}
|
if (param.backOne) {
|
param.backOne(selectMineral);
|
}
|
doClose();
|
}
|
|
//删除已选中的行
|
function delTableRow(type, id, index) {
|
$("#dg_hasSelect").datagrid('deleteRow', index);
|
|
//刷新已选区,重新生成行号,不然会出错
|
var hasRows = $('#dg_hasSelect').datagrid("getRows");
|
for (var i = 0; i < hasRows.length; i++) {
|
$("#dg_hasSelect").datagrid('refreshRow', i);
|
}
|
|
//刷新待选区,去掉待选区中的对应的选择项
|
var waitRows = $('#ul_type').datagrid("getRows");
|
if (waitRows != null) {
|
for (var i = 0; i < waitRows.length; i++) {
|
if (waitRows[i].id == id) {
|
$('#ul_type').datagrid("uncheckRow", i);
|
break;
|
}
|
|
}
|
}
|
}
|
|
//已选取的全部删除
|
function delAll() {
|
$('#dg_hasSelect').datagrid("loadData", []);
|
$('#ul_type').datagrid("clearChecked");
|
}
|
|
function doClose() { //关闭按钮事件
|
var index = top.layer.getFrameIndex(window.name); //获取窗口索引
|
top.layer.close(index);
|
}
|
</script>
|
<script type="text/javascript" src="static/scripts/ResizeScroll.js"></script>
|
</html>
|