!26 修改几个不带样式的弹框提示

Merge pull request !26 from 乾坤平台/master
This commit is contained in:
乾坤平台
2019-02-19 21:53:44 +08:00
committed by 季圣华
4 changed files with 1935 additions and 1935 deletions

View File

@@ -1,471 +1,471 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>仓库管理</title> <title>仓库管理</title>
<meta charset="utf-8"> <meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 --> <!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/> <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/> <link type="text/css" rel="stylesheet" href="/css/common.css"/>
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script> <script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script> <script type="text/javascript" src="/js/common/common.js"></script>
</head> </head>
<body> <body>
<!-- 查询 --> <!-- 查询 -->
<div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true" <div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true"
closable="false"> closable="false">
<table id="searchTable"> <table id="searchTable">
<tr> <tr>
<td>仓库名称:</td> <td>仓库名称:</td>
<td> <td>
<input type="text" name="searchName" id="searchName" style="width:100px;"/> <input type="text" name="searchName" id="searchName" style="width:100px;"/>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td id="searchRemarkLabel">描述:</td> <td id="searchRemarkLabel">描述:</td>
<td> <td>
<input type="text" name="searchRemark" id="searchRemark" style="width:100px;"/> <input type="text" name="searchRemark" id="searchRemark" style="width:100px;"/>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<!-- 数据显示table --> <!-- 数据显示table -->
<div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="仓库列表" iconCls="icon-list" <div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="仓库列表" iconCls="icon-list"
collapsible="true" closable="false"> collapsible="true" closable="false">
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table> <table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div> </div>
<div id="depotDlg" class="easyui-dialog" style="width:380px;padding:10px 20px" <div id="depotDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true"> closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true">
<form id="depotFM" method="post" novalidate> <form id="depotFM" method="post" novalidate>
<table> <table>
<tr> <tr>
<td>仓库名称</td> <td>仓库名称</td>
<td style="padding:5px"> <td style="padding:5px">
<input name="name" id="name" class="easyui-validatebox" <input name="name" id="name" class="easyui-validatebox"
data-options="required:true,validType:'length[2,30]'" style="width: 230px;height: 20px"/> data-options="required:true,validType:'length[2,30]'" style="width: 230px;height: 20px"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>仓库地址</td> <td>仓库地址</td>
<td style="padding:5px"> <td style="padding:5px">
<input name="address" id="address" class="easyui-validatebox" <input name="address" id="address" class="easyui-validatebox"
data-options="validType:'length[2,30]'" style="width: 230px;height: 20px"/> data-options="validType:'length[2,30]'" style="width: 230px;height: 20px"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>仓储费</td> <td>仓储费</td>
<td style="padding:5px"> <td style="padding:5px">
<input name="warehousing" id="warehousing" class="easyui-numberbox" data-options="min:0,precision:2" <input name="warehousing" id="warehousing" class="easyui-numberbox" data-options="min:0,precision:2"
style="width: 175px;height: 20px"/>&nbsp;元/天/KG style="width: 175px;height: 20px"/>&nbsp;元/天/KG
</td> </td>
</tr> </tr>
<tr> <tr>
<td>搬运费</td> <td>搬运费</td>
<td style="padding:5px"> <td style="padding:5px">
<input name="truckage" id="truckage" class="easyui-numberbox" placeholder="如上下搬运20元,则填写10元" <input name="truckage" id="truckage" class="easyui-numberbox" placeholder="如上下搬运20元,则填写10元"
data-options="min:0,precision:2" style="width: 215px;height: 20px"/>&nbsp; data-options="min:0,precision:2" style="width: 215px;height: 20px"/>&nbsp;
</td> </td>
</tr> </tr>
<tr> <tr>
<td>排序</td> <td>排序</td>
<td style="padding:5px"> <td style="padding:5px">
<input name="sort" id="sort" class="easyui-textbox" style="width: 230px;height: 20px"/> <input name="sort" id="sort" class="easyui-textbox" style="width: 230px;height: 20px"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>描述</td> <td>描述</td>
<td style="padding:5px"> <td style="padding:5px">
<textarea name="remark" id="remark" rows="2" cols="2" style="width: 230px;"></textarea> <textarea name="remark" id="remark" rows="2" cols="2" style="width: 230px;"></textarea>
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>
</div> </div>
<div id="dlg-buttons"> <div id="dlg-buttons">
<a href="javascript:void(0)" id="saveDepot" class="easyui-linkbutton" iconCls="icon-ok">保存</a> <a href="javascript:void(0)" id="saveDepot" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
<a href="javascript:void(0)" id="cancelDepot" class="easyui-linkbutton" iconCls="icon-cancel" <a href="javascript:void(0)" id="cancelDepot" class="easyui-linkbutton" iconCls="icon-cancel"
onclick="javascript:$('#depotDlg').dialog('close')">取消</a> onclick="javascript:$('#depotDlg').dialog('close')">取消</a>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//初始化界面 //初始化界面
$(function () { $(function () {
initTableData(); initTableData();
ininPager(); ininPager();
initForm(); initForm();
}); });
//防止表单提交重复 //防止表单提交重复
function initForm() { function initForm() {
$('#depotFM').form({ $('#depotFM').form({
onSubmit: function () { onSubmit: function () {
return false; return false;
} }
}); });
} }
//初始化表格数据 //初始化表格数据
function initTableData() { function initTableData() {
$('#tableData').datagrid({ $('#tableData').datagrid({
//title:'仓库列表', //title:'仓库列表',
//iconCls:'icon-save', //iconCls:'icon-save',
//width:700, //width:700,
height: heightInfo, height: heightInfo,
nowrap: false, nowrap: false,
rownumbers: false, rownumbers: false,
//动画效果 //动画效果
animate: false, animate: false,
//选中单行 //选中单行
singleSelect: true, singleSelect: true,
collapsible: false, collapsible: false,
selectOnCheck: false, selectOnCheck: false,
//fitColumns:true, //fitColumns:true,
//单击行是否选中 //单击行是否选中
checkOnSelect: false, checkOnSelect: false,
pagination: true, pagination: true,
//交替出现背景 //交替出现背景
striped: true, striped: true,
//loadFilter: pagerFilter, //loadFilter: pagerFilter,
pageSize: initPageSize, pageSize: initPageSize,
pageList: initPageNum, pageList: initPageNum,
columns: [[ columns: [[
{field: 'id', width: 35, align: "center", checkbox: true}, {field: 'id', width: 35, align: "center", checkbox: true},
{ {
title: '操作', field: 'op', align: "center", width: 60, title: '操作', field: 'op', align: "center", width: 60,
formatter: function (value, rec) { formatter: function (value, rec) {
var str = ''; var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.sort + 'AaBb' + rec.remark + 'AaBb' var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.sort + 'AaBb' + rec.remark + 'AaBb'
+ rec.address + 'AaBb' + rec.warehousing + 'AaBb' + rec.truckage; + rec.address + 'AaBb' + rec.warehousing + 'AaBb' + rec.truckage;
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editDepot(\'' + rowInfo + '\');"/>&nbsp;&nbsp;&nbsp;'; str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editDepot(\'' + rowInfo + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteDepot(' + rec.id + ');"/>'; str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteDepot(' + rec.id + ');"/>';
return str; return str;
} }
}, },
{title: '仓库名称', field: 'name', width: 200}, {title: '仓库名称', field: 'name', width: 200},
{title: '仓库地址', field: 'address', width: 200}, {title: '仓库地址', field: 'address', width: 200},
{title: '仓储费', field: 'warehousing', width: 60}, {title: '仓储费', field: 'warehousing', width: 60},
{title: '搬运费', field: 'truckage', width: 60}, {title: '搬运费', field: 'truckage', width: 60},
{title: '排序', field: 'sort', width: 60}, {title: '排序', field: 'sort', width: 60},
{title: '描述', field: 'remark', width: 120} {title: '描述', field: 'remark', width: 120}
]], ]],
toolbar: [ toolbar: [
{ {
id: 'addDepot', id: 'addDepot',
text: '增加', text: '增加',
iconCls: 'icon-add', iconCls: 'icon-add',
handler: function () { handler: function () {
addDepot(); addDepot();
} }
}, '-', }, '-',
{ {
id: 'deleteDepot', id: 'deleteDepot',
text: '删除', text: '删除',
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: function () { handler: function () {
batDeleteDepot(); batDeleteDepot();
} }
} }
], ],
onLoadError: function () { onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error'); $.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
return; return;
} }
}); });
showDepotDetails(1, initPageSize); showDepotDetails(1, initPageSize);
} }
//初始化键盘enter事件 //初始化键盘enter事件
$(document).keydown(function (event) { $(document).keydown(function (event) {
//兼容 IE和firefox 事件 //兼容 IE和firefox 事件
var e = window.event || event; var e = window.event || event;
var k = e.keyCode || e.which || e.charCode; var k = e.keyCode || e.which || e.charCode;
//兼容 IE,firefox 兼容 //兼容 IE,firefox 兼容
var obj = e.srcElement ? e.srcElement : e.target; var obj = e.srcElement ? e.srcElement : e.target;
//绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题 //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) { if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) {
$("#saveDepot").click(); $("#saveDepot").click();
} }
//搜索按钮添加快捷键 //搜索按钮添加快捷键
if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) { if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) {
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//分页信息处理 //分页信息处理
function ininPager() { function ininPager() {
try { try {
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
pager.pagination({ pager.pagination({
onSelectPage: function (pageNum, pageSize) { onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum; opts.pageNumber = pageNum;
opts.pageSize = pageSize; opts.pageSize = pageSize;
pager.pagination('refresh', { pager.pagination('refresh', {
pageNumber: pageNum, pageNumber: pageNum,
pageSize: pageSize pageSize: pageSize
}); });
showDepotDetails(pageNum, pageSize); showDepotDetails(pageNum, pageSize);
} }
}); });
} }
catch (e) { catch (e) {
$.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error'); $.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error');
} }
} }
//删除仓库信息 //删除仓库信息
function deleteDepot(depotID) { function deleteDepot(depotID) {
$.messager.confirm('删除确认', '确定要删除此仓库信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除此仓库信息吗?', function (r) {
if (r) { if (r) {
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/depot/" + depotID + "/delete", url: "/depot/" + depotID + "/delete",
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
if(res && res.code == 200) { if(res && res.code == 200) {
$("#searchBtn").click(); $("#searchBtn").click();
} else { } else {
$.messager.alert('删除提示', '删除仓库信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除仓库信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除仓库信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除仓库信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
//批量删除仓库 //批量删除仓库
function batDeleteDepot() { function batDeleteDepot() {
var row = $('#tableData').datagrid('getChecked'); var row = $('#tableData').datagrid('getChecked');
if (row.length == 0) { if (row.length == 0) {
$.messager.alert('删除提示', '没有记录被选中!', 'info'); $.messager.alert('删除提示', '没有记录被选中!', 'info');
return; return;
} }
if (row.length > 0) { if (row.length > 0) {
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条仓库信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条仓库信息吗?', function (r) {
if (r) { if (r) {
var ids = ""; var ids = "";
for (var i = 0; i < row.length; i++) { for (var i = 0; i < row.length; i++) {
if (i == row.length - 1) { if (i == row.length - 1) {
ids += row[i].id; ids += row[i].id;
break; break;
} }
ids += row[i].id + ","; ids += row[i].id + ",";
} }
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/depot/batchDelete", url: "/depot/batchDelete",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
ids: ids ids: ids
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$("#searchBtn").click(); $("#searchBtn").click();
$(":checkbox").attr("checked", false); $(":checkbox").attr("checked", false);
} else { } else {
$.messager.alert('删除提示', '删除仓库信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除仓库信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除仓库信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除仓库信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
} }
//增加 //增加
var url; var url;
var depotID = 0; var depotID = 0;
//保存编辑前的名称 //保存编辑前的名称
var oldDepot = ""; var oldDepot = "";
function addDepot() { function addDepot() {
$('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加仓库信息'); $('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加仓库信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
$('#depotFM').form('clear'); $('#depotFM').form('clear');
$("#name").focus(); $("#name").focus();
oldDepot = ""; oldDepot = "";
depotID = 0; depotID = 0;
url = '/depot/add'; url = '/depot/add';
} }
//保存信息 //保存信息
$("#saveDepot").off("click").on("click", function () { $("#saveDepot").off("click").on("click", function () {
var infoObj = $("#depotFM").serializeObject(); var infoObj = $("#depotFM").serializeObject();
infoObj.type = 0; infoObj.type = 0;
if (checkDepotName()) { if (checkDepotName()) {
return; return;
} }
$.ajax({ $.ajax({
url: url, url: url,
type: "post", type: "post",
dataType: "json", dataType: "json",
data: ({ data: ({
info: JSON.stringify(infoObj) info: JSON.stringify(infoObj)
}), }),
success: function(res) { success: function(res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$('#depotDlg').dialog('close'); $('#depotDlg').dialog('close');
//加载完以后重新初始化 //加载完以后重新初始化
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
showDepotDetails(opts.pageNumber, opts.pageSize); showDepotDetails(opts.pageNumber, opts.pageSize);
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '保存仓库信息异常,请稍后再试!', 'error'); $.messager.alert('提示', '保存仓库信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
}); });
//编辑信息 //编辑信息
function editDepot(depotTotalInfo) { function editDepot(depotTotalInfo) {
var depotInfo = depotTotalInfo.split("AaBb"); var depotInfo = depotTotalInfo.split("AaBb");
$("#name").focus().val(depotInfo[1]); $("#name").focus().val(depotInfo[1]);
$("#sort").val(depotInfo[2]); $("#sort").val(depotInfo[2]);
$("#remark").val(depotInfo[3]); $("#remark").val(depotInfo[3]);
$("#address").val(depotInfo[4]); $("#address").val(depotInfo[4]);
$("#warehousing").val(depotInfo[5]); $("#warehousing").val(depotInfo[5]);
$("#truckage").val(depotInfo[6]); $("#truckage").val(depotInfo[6]);
oldDepot = depotInfo[1]; oldDepot = depotInfo[1];
$('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑仓库信息'); $('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑仓库信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
depotID = depotInfo[0]; depotID = depotInfo[0];
//焦点在名称输入框==定焦在输入文字后面 //焦点在名称输入框==定焦在输入文字后面
$("#name").val("").focus().val(depotInfo[1]); $("#name").val("").focus().val(depotInfo[1]);
url = '/depot/update?id=' + depotInfo[0]; url = '/depot/update?id=' + depotInfo[0];
} }
//检查名称是否存在 ++ 重名无法提示问题需要跟进 //检查名称是否存在 ++ 重名无法提示问题需要跟进
function checkDepotName() { function checkDepotName() {
var name = $.trim($("#name").val()); var name = $.trim($("#name").val());
//表示是否存在 true == 存在 false = 不存在 //表示是否存在 true == 存在 false = 不存在
var flag = false; var flag = false;
//开始ajax名称检验不能重名 //开始ajax名称检验不能重名
if (name.length > 0 && (oldDepot.length == 0 || name != oldDepot)) { if (name.length > 0 && (oldDepot.length == 0 || name != oldDepot)) {
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/depot/checkIsNameExist", url: "/depot/checkIsNameExist",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
id: depotID, id: depotID,
name: name name: name
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
if(res.data && res.data.status) { if(res.data && res.data.status) {
flag = res.data.status; flag = res.data.status;
if (flag) { if (flag) {
$.messager.alert('提示', '仓库名称已经存在', 'info'); $.messager.alert('提示', '仓库名称已经存在', 'info');
return; return;
} }
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '检查仓库名称是否存在异常,请稍后再试!', 'error'); $.messager.alert('提示', '检查仓库名称是否存在异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
return flag; return flag;
} }
//搜索处理 //搜索处理
$("#searchBtn").unbind().bind({ $("#searchBtn").unbind().bind({
click: function () { click: function () {
showDepotDetails(1, initPageSize); showDepotDetails(1, initPageSize);
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
opts.pageNumber = 1; opts.pageNumber = 1;
opts.pageSize = initPageSize; opts.pageSize = initPageSize;
pager.pagination('refresh', pager.pagination('refresh',
{ {
pageNumber: 1, pageNumber: 1,
pageSize: initPageSize pageSize: initPageSize
}); });
} }
}); });
function showDepotDetails(pageNo, pageSize) { function showDepotDetails(pageNo, pageSize) {
var name = $.trim($("#searchName").val()); var name = $.trim($("#searchName").val());
var type = 0; //仓库 var type = 0; //仓库
var remark = $.trim($("#searchRemark").val()); var remark = $.trim($("#searchRemark").val());
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/depot/list", url: "/depot/list",
dataType: "json", dataType: "json",
data: ({ data: ({
search: JSON.stringify({ search: JSON.stringify({
name: name, name: name,
type: type, type: type,
remark: remark remark: remark
}), }),
currentPage: pageNo, currentPage: pageNo,
pageSize: pageSize pageSize: pageSize
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200){ if(res && res.code === 200){
if(res.data && res.data.page) { if(res.data && res.data.page) {
$("#tableData").datagrid('loadData', res.data.page); $("#tableData").datagrid('loadData', res.data.page);
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error'); $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
//重置按钮 //重置按钮
$("#searchResetBtn").unbind().bind({ $("#searchResetBtn").unbind().bind({
click: function () { click: function () {
$("#searchName").val(""); $("#searchName").val("");
$("#searchRemark").val(""); $("#searchRemark").val("");
//加载完以后重新初始化 //加载完以后重新初始化
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//查看单元(设置) //查看单元(设置)
$('#setBuilding').click(function () { $('#setBuilding').click(function () {
var currentRow = $("#tableData").datagrid("getChecked"); var currentRow = $("#tableData").datagrid("getChecked");
if (currentRow.length == 0) { if (currentRow.length == 0) {
alert("请选择一条数据再操作!"); $.messager.alert('提示',"请选择一条数据再操作!",'warning');
return false; return false;
} }
parent.addTab(currentRow[0].id + "单元", "/pages/materials/building.jsp?ProjectId=" + currentRow[0].id, ""); parent.addTab(currentRow[0].id + "单元", "/pages/materials/building.jsp?ProjectId=" + currentRow[0].id, "");
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@@ -1,462 +1,462 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>礼品卡管理</title> <title>礼品卡管理</title>
<meta charset="utf-8"> <meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 --> <!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/> <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/> <link type="text/css" rel="stylesheet" href="/css/common.css"/>
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script> <script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script> <script type="text/javascript" src="/js/common/common.js"></script>
</head> </head>
<body> <body>
<!-- 查询 --> <!-- 查询 -->
<div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true" <div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true"
closable="false"> closable="false">
<table id="searchTable"> <table id="searchTable">
<tr> <tr>
<td>礼品卡名称:</td> <td>礼品卡名称:</td>
<td> <td>
<input type="text" name="searchName" id="searchName" style="width:150px;"/> <input type="text" name="searchName" id="searchName" style="width:150px;"/>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td id="searchRemarkLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</td> <td id="searchRemarkLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</td>
<td> <td>
<input type="text" name="searchRemark" id="searchRemark" style="width:150px;"/> <input type="text" name="searchRemark" id="searchRemark" style="width:150px;"/>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<!-- 数据显示table --> <!-- 数据显示table -->
<div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="礼品卡列表" iconCls="icon-list" <div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="礼品卡列表" iconCls="icon-list"
collapsible="true" closable="false"> collapsible="true" closable="false">
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table> <table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div> </div>
<div id="depotDlg" class="easyui-dialog" style="width:380px;padding:10px 20px" <div id="depotDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true"> closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true">
<form id="depotFM" method="post" novalidate> <form id="depotFM" method="post" novalidate>
<table> <table>
<tr> <tr>
<td><label id="nameLabel">礼品卡名称&nbsp;&nbsp;</label></td> <td><label id="nameLabel">礼品卡名称&nbsp;&nbsp;</label></td>
<td style="padding:5px"><input name="name" id="name" class="easyui-validatebox" <td style="padding:5px"><input name="name" id="name" class="easyui-validatebox"
data-options="required:true,validType:'length[2,30]'" data-options="required:true,validType:'length[2,30]'"
style="width: 230px;height: 20px"/></td> style="width: 230px;height: 20px"/></td>
</tr> </tr>
<tr> <tr>
<td><label id="sortLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td> <td><label id="sortLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
<td style="padding:5px"><input name="sort" id="sort" class="easyui-textbox" <td style="padding:5px"><input name="sort" id="sort" class="easyui-textbox"
style="width: 230px;height: 20px"/></td> style="width: 230px;height: 20px"/></td>
</tr> </tr>
<tr> <tr>
<td><label id="remarkLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td> <td><label id="remarkLabel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></td>
<td style="padding:5px"><textarea name="remark" id="remark" rows="2" cols="2" style="width: 230px;"></textarea></td> <td style="padding:5px"><textarea name="remark" id="remark" rows="2" cols="2" style="width: 230px;"></textarea></td>
</tr> </tr>
</table> </table>
</form> </form>
</div> </div>
<div id="dlg-buttons"> <div id="dlg-buttons">
<a href="javascript:void(0)" id="saveDepot" class="easyui-linkbutton" iconCls="icon-ok">保存</a> <a href="javascript:void(0)" id="saveDepot" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
<a href="javascript:void(0)" id="cancelDepot" class="easyui-linkbutton" iconCls="icon-cancel" <a href="javascript:void(0)" id="cancelDepot" class="easyui-linkbutton" iconCls="icon-cancel"
onclick="javascript:$('#depotDlg').dialog('close')">取消</a> onclick="javascript:$('#depotDlg').dialog('close')">取消</a>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//初始化界面 //初始化界面
$(function () { $(function () {
initTableData(); initTableData();
ininPager(); ininPager();
initForm(); initForm();
browserFit(); browserFit();
}); });
//浏览器适配 //浏览器适配
function browserFit() { function browserFit() {
if (getOs() == 'MSIE') { if (getOs() == 'MSIE') {
$("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:"); $("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:");
$("#nameLabel").empty().append("礼品卡名称&nbsp;&nbsp;"); $("#nameLabel").empty().append("礼品卡名称&nbsp;&nbsp;");
$("#sortLabel").empty().append("排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序&nbsp;&nbsp;"); $("#sortLabel").empty().append("排&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序&nbsp;&nbsp;");
$("#remarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;"); $("#remarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;");
} }
else { else {
$("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述:"); $("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述:");
$("#nameLabel").empty().append("礼品卡名称&nbsp;"); $("#nameLabel").empty().append("礼品卡名称&nbsp;");
$("#sortLabel").empty().append("排&nbsp;&nbsp;&nbsp;&nbsp;序&nbsp;"); $("#sortLabel").empty().append("排&nbsp;&nbsp;&nbsp;&nbsp;序&nbsp;");
$("#remarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;"); $("#remarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;");
} }
} }
//防止表单提交重复 //防止表单提交重复
function initForm() { function initForm() {
$('#depotFM').form({ $('#depotFM').form({
onSubmit: function () { onSubmit: function () {
return false; return false;
} }
}); });
} }
//初始化表格数据 //初始化表格数据
function initTableData() { function initTableData() {
$('#tableData').datagrid({ $('#tableData').datagrid({
//title:'仓库列表', //title:'仓库列表',
//iconCls:'icon-save', //iconCls:'icon-save',
//width:700, //width:700,
height: heightInfo, height: heightInfo,
nowrap: false, nowrap: false,
rownumbers: false, rownumbers: false,
//动画效果 //动画效果
animate: false, animate: false,
//选中单行 //选中单行
singleSelect: true, singleSelect: true,
collapsible: false, collapsible: false,
selectOnCheck: false, selectOnCheck: false,
//fitColumns:true, //fitColumns:true,
//单击行是否选中 //单击行是否选中
checkOnSelect: false, checkOnSelect: false,
pagination: true, pagination: true,
//交替出现背景 //交替出现背景
striped: true, striped: true,
//loadFilter: pagerFilter, //loadFilter: pagerFilter,
pageSize: initPageSize, pageSize: initPageSize,
pageList: initPageNum, pageList: initPageNum,
columns: [[ columns: [[
{field: 'id', width: 35, align: "center", checkbox: true}, {field: 'id', width: 35, align: "center", checkbox: true},
{title: '礼品卡名称', field: 'name', width: 200}, {title: '礼品卡名称', field: 'name', width: 200},
{title: '排序', field: 'sort', width: 200}, {title: '排序', field: 'sort', width: 200},
{title: '描述', field: 'remark', width: 200}, {title: '描述', field: 'remark', width: 200},
{ {
title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) { title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) {
var str = ''; var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.sort + 'AaBb' + rec.remark; var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.sort + 'AaBb' + rec.remark;
str += '<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editDepot(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editDepot(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;'; str += '<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editDepot(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editDepot(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;';
str += '<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteDepot(' + rec.id + ');"/>&nbsp;<a onclick="deleteDepot(' + rec.id + ');" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>&nbsp;&nbsp;'; str += '<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteDepot(' + rec.id + ');"/>&nbsp;<a onclick="deleteDepot(' + rec.id + ');" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>&nbsp;&nbsp;';
return str; return str;
} }
} }
]], ]],
toolbar: [ toolbar: [
{ {
id: 'addDepot', id: 'addDepot',
text: '增加', text: '增加',
iconCls: 'icon-add', iconCls: 'icon-add',
handler: function () { handler: function () {
addDepot(); addDepot();
} }
}, },
{ {
id: 'deleteDepot', id: 'deleteDepot',
text: '删除', text: '删除',
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: function () { handler: function () {
batDeleteDepot(); batDeleteDepot();
} }
} }
], ],
onLoadError: function () { onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error'); $.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
return; return;
} }
}); });
showDepotDetails(1, initPageSize); showDepotDetails(1, initPageSize);
} }
//初始化键盘enter事件 //初始化键盘enter事件
$(document).keydown(function (event) { $(document).keydown(function (event) {
//兼容 IE和firefox 事件 //兼容 IE和firefox 事件
var e = window.event || event; var e = window.event || event;
var k = e.keyCode || e.which || e.charCode; var k = e.keyCode || e.which || e.charCode;
//兼容 IE,firefox 兼容 //兼容 IE,firefox 兼容
var obj = e.srcElement ? e.srcElement : e.target; var obj = e.srcElement ? e.srcElement : e.target;
//绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题 //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) { if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) {
$("#saveDepot").click(); $("#saveDepot").click();
} }
//搜索按钮添加快捷键 //搜索按钮添加快捷键
if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) { if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) {
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//分页信息处理 //分页信息处理
function ininPager() { function ininPager() {
try { try {
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
pager.pagination({ pager.pagination({
onSelectPage: function (pageNum, pageSize) { onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum; opts.pageNumber = pageNum;
opts.pageSize = pageSize; opts.pageSize = pageSize;
pager.pagination('refresh', pager.pagination('refresh',
{ {
pageNumber: pageNum, pageNumber: pageNum,
pageSize: pageSize pageSize: pageSize
}); });
showDepotDetails(pageNum, pageSize); showDepotDetails(pageNum, pageSize);
} }
}); });
} }
catch (e) { catch (e) {
$.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error'); $.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error');
} }
} }
//删除礼品卡信息 //删除礼品卡信息
function deleteDepot(depotID) { function deleteDepot(depotID) {
$.messager.confirm('删除确认', '确定要删除此礼品卡信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除此礼品卡信息吗?', function (r) {
if (r) { if (r) {
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/depot/" + depotID + "/delete", url: "/depot/" + depotID + "/delete",
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
if(res && res.code == 200) { if(res && res.code == 200) {
$("#searchBtn").click(); $("#searchBtn").click();
} else { } else {
$.messager.alert('删除提示', '删除礼品卡信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除礼品卡信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除礼品卡信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除礼品卡信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
//批量删除礼品卡 //批量删除礼品卡
function batDeleteDepot() { function batDeleteDepot() {
var row = $('#tableData').datagrid('getChecked'); var row = $('#tableData').datagrid('getChecked');
if (row.length == 0) { if (row.length == 0) {
$.messager.alert('删除提示', '没有记录被选中!', 'info'); $.messager.alert('删除提示', '没有记录被选中!', 'info');
return; return;
} }
if (row.length > 0) { if (row.length > 0) {
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条礼品卡信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条礼品卡信息吗?', function (r) {
if (r) { if (r) {
var ids = ""; var ids = "";
for (var i = 0; i < row.length; i++) { for (var i = 0; i < row.length; i++) {
if (i == row.length - 1) { if (i == row.length - 1) {
ids += row[i].id; ids += row[i].id;
break; break;
} }
//alert(row[i].id); //alert(row[i].id);
ids += row[i].id + ","; ids += row[i].id + ",";
} }
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/depot/batchDelete", url: "/depot/batchDelete",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
ids: ids ids: ids
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$("#searchBtn").click(); $("#searchBtn").click();
$(":checkbox").attr("checked", false); $(":checkbox").attr("checked", false);
} else { } else {
$.messager.alert('删除提示', '删除礼品卡信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除礼品卡信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除礼品卡信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除礼品卡信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
} }
//增加 //增加
var url; var url;
var depotID = 0; var depotID = 0;
//保存编辑前的名称 //保存编辑前的名称
var oldDepot = ""; var oldDepot = "";
function addDepot() { function addDepot() {
$("#sort").val(""); $("#sort").val("");
$("#remark").val(""); $("#remark").val("");
$('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加仓库信息'); $('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加仓库信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
$("#name").val("").focus(); $("#name").val("").focus();
//$('#depotFM').form('clear'); //$('#depotFM').form('clear');
oldDepot = ""; oldDepot = "";
depotID = 0; depotID = 0;
url = '/depot/add'; url = '/depot/add';
} }
//保存信息 //保存信息
$("#saveDepot").off("click").on("click", function () { $("#saveDepot").off("click").on("click", function () {
var infoObj = $("#depotFM").serializeObject(); var infoObj = $("#depotFM").serializeObject();
infoObj.type = 1; infoObj.type = 1;
if (checkDepotName()) { if (checkDepotName()) {
return; return;
} }
$.ajax({ $.ajax({
url: url, url: url,
type: "post", type: "post",
dataType: "json", dataType: "json",
data: ({ data: ({
info: JSON.stringify(infoObj) info: JSON.stringify(infoObj)
}), }),
success: function(res) { success: function(res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$('#depotDlg').dialog('close'); $('#depotDlg').dialog('close');
//加载完以后重新初始化 //加载完以后重新初始化
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
showDepotDetails(opts.pageNumber, opts.pageSize); showDepotDetails(opts.pageNumber, opts.pageSize);
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '保存仓库信息异常,请稍后再试!', 'error'); $.messager.alert('提示', '保存仓库信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
}); });
//编辑信息 //编辑信息
function editDepot(depotTotalInfo) { function editDepot(depotTotalInfo) {
var depotInfo = depotTotalInfo.split("AaBb"); var depotInfo = depotTotalInfo.split("AaBb");
$("#name").focus().val(depotInfo[1]); $("#name").focus().val(depotInfo[1]);
$("#sort").val(depotInfo[2]); $("#sort").val(depotInfo[2]);
$("#remark").val(depotInfo[3]); $("#remark").val(depotInfo[3]);
oldDepot = depotInfo[1]; oldDepot = depotInfo[1];
$('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑仓库信息'); $('#depotDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑仓库信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
depotID = depotInfo[0]; depotID = depotInfo[0];
//焦点在名称输入框==定焦在输入文字后面 //焦点在名称输入框==定焦在输入文字后面
$("#name").val("").focus().val(depotInfo[1]); $("#name").val("").focus().val(depotInfo[1]);
url = '/depot/update?id=' + depotInfo[0]; url = '/depot/update?id=' + depotInfo[0];
} }
//检查名称是否存在 ++ 重名无法提示问题需要跟进 //检查名称是否存在 ++ 重名无法提示问题需要跟进
function checkDepotName() { function checkDepotName() {
var name = $.trim($("#name").val()); var name = $.trim($("#name").val());
//表示是否存在 true == 存在 false = 不存在 //表示是否存在 true == 存在 false = 不存在
var flag = false; var flag = false;
//开始ajax名称检验不能重名 //开始ajax名称检验不能重名
if (name.length > 0 && (oldDepot.length == 0 || name != oldDepot)) { if (name.length > 0 && (oldDepot.length == 0 || name != oldDepot)) {
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/depot/checkIsNameExist", url: "/depot/checkIsNameExist",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
id: depotID, id: depotID,
name: name name: name
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
if(res.data && res.data.status) { if(res.data && res.data.status) {
flag = res.data.status; flag = res.data.status;
if (flag) { if (flag) {
$.messager.alert('提示', '礼品卡名称已经存在', 'info'); $.messager.alert('提示', '礼品卡名称已经存在', 'info');
return; return;
} }
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '检查礼品卡名称是否存在异常,请稍后再试!', 'error'); $.messager.alert('提示', '检查礼品卡名称是否存在异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
return flag; return flag;
} }
//搜索处理 //搜索处理
$("#searchBtn").unbind().bind({ $("#searchBtn").unbind().bind({
click: function () { click: function () {
showDepotDetails(1, initPageSize); showDepotDetails(1, initPageSize);
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
opts.pageNumber = 1; opts.pageNumber = 1;
opts.pageSize = initPageSize; opts.pageSize = initPageSize;
pager.pagination('refresh', pager.pagination('refresh',
{ {
pageNumber: 1, pageNumber: 1,
pageSize: initPageSize pageSize: initPageSize
}); });
} }
}); });
function showDepotDetails(pageNo, pageSize) { function showDepotDetails(pageNo, pageSize) {
var name = $.trim($("#searchName").val()); var name = $.trim($("#searchName").val());
var type = 1; // 礼品卡 var type = 1; // 礼品卡
var remark = $.trim($("#searchRemark").val()); var remark = $.trim($("#searchRemark").val());
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/depot/list", url: "/depot/list",
dataType: "json", dataType: "json",
data: ({ data: ({
search: JSON.stringify({ search: JSON.stringify({
name: name, name: name,
type: type, type: type,
remark: remark remark: remark
}), }),
currentPage: pageNo, currentPage: pageNo,
pageSize: pageSize pageSize: pageSize
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200){ if(res && res.code === 200){
if(res.data && res.data.page) { if(res.data && res.data.page) {
$("#tableData").datagrid('loadData', res.data.page); $("#tableData").datagrid('loadData', res.data.page);
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error'); $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
//重置按钮 //重置按钮
$("#searchResetBtn").unbind().bind({ $("#searchResetBtn").unbind().bind({
click: function () { click: function () {
$("#searchName").val(""); $("#searchName").val("");
$("#searchRemark").val(""); $("#searchRemark").val("");
//加载完以后重新初始化 //加载完以后重新初始化
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//查看单元(设置) //查看单元(设置)
$('#setBuilding').click(function () { $('#setBuilding').click(function () {
var currentRow = $("#tableData").datagrid("getChecked"); var currentRow = $("#tableData").datagrid("getChecked");
if (currentRow.length == 0) { if (currentRow.length == 0) {
alert("请选择一条数据再操作!"); $.messager.alert('提示',"请选择一条数据再操作!",'warning');
return false; return false;
} }
parent.addTab(currentRow[0].id + "单元", "/pages/materials/building.jsp?ProjectId=" + currentRow[0].id, ""); parent.addTab(currentRow[0].id + "单元", "/pages/materials/building.jsp?ProjectId=" + currentRow[0].id, "");
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@@ -1,453 +1,453 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>角色管理</title> <title>角色管理</title>
<meta charset="utf-8"> <meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 --> <!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/> <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script> <script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/js/colorbox/jquery.colorbox-min.js"></script> <script type="text/javascript" src="/js/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="/js/colorbox/colorboxSet.js"></script> <script type="text/javascript" src="/js/colorbox/colorboxSet.js"></script>
<link href="/js/colorbox/colorbox.css" rel="stylesheet" type="text/css"/> <link href="/js/colorbox/colorbox.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/> <link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
<link type="text/css" rel="stylesheet" href="/css/common.css"/> <link type="text/css" rel="stylesheet" href="/css/common.css"/>
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script> <script type="text/javascript" src="/js/common/common.js"></script>
</head> </head>
<body> <body>
<!-- 查询 --> <!-- 查询 -->
<div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true" <div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true"
closable="false"> closable="false">
<table id="searchTable"> <table id="searchTable">
<tr> <tr>
<td>角色名称:</td> <td>角色名称:</td>
<td> <td>
<input type="text" name="searchName" id="searchName" style="width:150px;"/> <input type="text" name="searchName" id="searchName" style="width:150px;"/>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>&nbsp;&nbsp; <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" id="searchResetBtn">重置</a>&nbsp;&nbsp;
<a id="btnSetApp" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配应用'>分配应用</a>&nbsp;&nbsp; <a id="btnSetApp" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配应用'>分配应用</a>&nbsp;&nbsp;
<a id="btnSetFunctions" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配功能'>分配功能</a>&nbsp;&nbsp; <a id="btnSetFunctions" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配功能'>分配功能</a>&nbsp;&nbsp;
<a id="btnSetPushBtn" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配按钮'>分配按钮</a> <a id="btnSetPushBtn" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配按钮'>分配按钮</a>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<!-- 数据显示table --> <!-- 数据显示table -->
<div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="角色列表" iconCls="icon-list" <div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="角色列表" iconCls="icon-list"
collapsible="true" closable="false"> collapsible="true" closable="false">
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table> <table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div> </div>
<div id="roleDlg" class="easyui-dialog" style="width:380px;padding:10px 20px" <div id="roleDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true"> closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true">
<form id="roleFM" method="post" novalidate> <form id="roleFM" method="post" novalidate>
<table> <table>
<tr> <tr>
<td><label id="nameLabel">角色名称&nbsp;&nbsp;</label></td> <td><label id="nameLabel">角色名称&nbsp;&nbsp;</label></td>
<td style="padding:5px"><input name="name" id="name" class="easyui-validatebox" <td style="padding:5px"><input name="name" id="name" class="easyui-validatebox"
data-options="required:true,validType:'length[2,30]'" style="width: 230px;height: 20px"/></td> data-options="required:true,validType:'length[2,30]'" style="width: 230px;height: 20px"/></td>
</tr> </tr>
</table> </table>
</form> </form>
</div> </div>
<div id="dlg-buttons"> <div id="dlg-buttons">
<a href="javascript:void(0)" id="saveRole" class="easyui-linkbutton" iconCls="icon-ok">保存</a> <a href="javascript:void(0)" id="saveRole" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
<a href="javascript:void(0)" id="cancelRole" class="easyui-linkbutton" iconCls="icon-cancel" <a href="javascript:void(0)" id="cancelRole" class="easyui-linkbutton" iconCls="icon-cancel"
onclick="javascript:$('#roleDlg').dialog('close')">取消</a> onclick="javascript:$('#roleDlg').dialog('close')">取消</a>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//初始化界面 //初始化界面
$(function () { $(function () {
initTableData(); initTableData();
ininPager(); ininPager();
initForm(); initForm();
browserFit(); browserFit();
}); });
//浏览器适配 //浏览器适配
function browserFit() { function browserFit() {
if (getOs() == 'MSIE') { if (getOs() == 'MSIE') {
$("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:"); $("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:");
$("#nameLabel").empty().append("角色名称&nbsp;&nbsp;"); $("#nameLabel").empty().append("角色名称&nbsp;&nbsp;");
} }
else { else {
$("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述:"); $("#searchRemarkLabel").empty().append("描&nbsp;&nbsp;&nbsp;&nbsp;述:");
$("#nameLabel").empty().append("角色名称&nbsp;"); $("#nameLabel").empty().append("角色名称&nbsp;");
} }
} }
//防止表单提交重复 //防止表单提交重复
function initForm() { function initForm() {
$('#roleFM').form({ $('#roleFM').form({
onSubmit: function () { onSubmit: function () {
return false; return false;
} }
}); });
} }
//初始化表格数据 //初始化表格数据
function initTableData() { function initTableData() {
$('#tableData').datagrid({ $('#tableData').datagrid({
//title:'角色列表', //title:'角色列表',
//iconCls:'icon-save', //iconCls:'icon-save',
//width:700, //width:700,
height: heightInfo, height: heightInfo,
nowrap: false, nowrap: false,
rownumbers: false, rownumbers: false,
//动画效果 //动画效果
animate: false, animate: false,
//选中单行 //选中单行
singleSelect: true, singleSelect: true,
collapsible: false, collapsible: false,
//selectOnCheck:false, //selectOnCheck:false,
//fitColumns:true, //fitColumns:true,
//单击行是否选中 //单击行是否选中
//checkOnSelect : false, //checkOnSelect : false,
pagination: true, pagination: true,
//交替出现背景 //交替出现背景
striped: true, striped: true,
//loadFilter: pagerFilter, //loadFilter: pagerFilter,
pageSize: initPageSize, pageSize: initPageSize,
pageList: initPageNum, pageList: initPageNum,
columns: [[ columns: [[
{field: 'id', width: 35, align: "center", checkbox: true}, {field: 'id', width: 35, align: "center", checkbox: true},
{title: '角色名称', field: 'name', width: 200}, {title: '角色名称', field: 'name', width: 200},
{ {
title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) { title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) {
var str = ''; var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name; var rowInfo = rec.id + 'AaBb' + rec.name;
str += '<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editRole(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editRole(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;'; str += '<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editRole(\'' + rowInfo + '\');"/>&nbsp;<a onclick="editRole(\'' + rowInfo + '\');" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>&nbsp;&nbsp;';
str += '<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteRole(' + rec.id + ');"/>&nbsp;<a onclick="deleteRole(' + rec.id + ');" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>&nbsp;&nbsp;'; str += '<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteRole(' + rec.id + ');"/>&nbsp;<a onclick="deleteRole(' + rec.id + ');" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>&nbsp;&nbsp;';
return str; return str;
} }
} }
]], ]],
toolbar: [ toolbar: [
{ {
id: 'addRole', id: 'addRole',
text: '增加', text: '增加',
iconCls: 'icon-add', iconCls: 'icon-add',
handler: function () { handler: function () {
addRole(); addRole();
} }
}, },
{ {
id: 'deleteRole', id: 'deleteRole',
text: '删除', text: '删除',
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: function () { handler: function () {
batDeleteRole(); batDeleteRole();
} }
} }
], ],
onLoadError: function () { onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error'); $.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
return; return;
} }
}); });
showRoleDetails(1, initPageSize); showRoleDetails(1, initPageSize);
} }
//初始化键盘enter事件 //初始化键盘enter事件
$(document).keydown(function (event) { $(document).keydown(function (event) {
//兼容 IE和firefox 事件 //兼容 IE和firefox 事件
var e = window.event || event; var e = window.event || event;
var k = e.keyCode || e.which || e.charCode; var k = e.keyCode || e.which || e.charCode;
//兼容 IE,firefox 兼容 //兼容 IE,firefox 兼容
var obj = e.srcElement ? e.srcElement : e.target; var obj = e.srcElement ? e.srcElement : e.target;
//绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题 //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) { if (k == "13" && (obj.id == "name" || obj.id == "sort" || obj.id == "remark")) {
$("#saveRole").click(); $("#saveRole").click();
} }
//搜索按钮添加快捷键 //搜索按钮添加快捷键
if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) { if (k == "13" && (obj.id == "searchName" || obj.id == "searchRemark")) {
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//分页信息处理 //分页信息处理
function ininPager() { function ininPager() {
try { try {
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
pager.pagination({ pager.pagination({
onSelectPage: function (pageNum, pageSize) { onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum; opts.pageNumber = pageNum;
opts.pageSize = pageSize; opts.pageSize = pageSize;
pager.pagination('refresh', { pager.pagination('refresh', {
pageNumber: pageNum, pageNumber: pageNum,
pageSize: pageSize pageSize: pageSize
}); });
showRoleDetails(pageNum, pageSize); showRoleDetails(pageNum, pageSize);
} }
}); });
} }
catch (e) { catch (e) {
$.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error'); $.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error');
} }
} }
//删除角色信息 //删除角色信息
function deleteRole(roleID) { function deleteRole(roleID) {
$.messager.confirm('删除确认', '确定要删除此角色信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除此角色信息吗?', function (r) {
if (r) { if (r) {
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/role/" + roleID + "/delete", url: "/role/" + roleID + "/delete",
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
if(res && res.code == 200) { if(res && res.code == 200) {
$("#searchBtn").click(); $("#searchBtn").click();
} else { } else {
$.messager.alert('删除提示', '删除角色信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除角色信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除角色信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除角色信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
//批量删除角色 //批量删除角色
function batDeleteRole() { function batDeleteRole() {
var row = $('#tableData').datagrid('getChecked'); var row = $('#tableData').datagrid('getChecked');
if (row.length == 0) { if (row.length == 0) {
$.messager.alert('删除提示', '没有记录被选中!', 'info'); $.messager.alert('删除提示', '没有记录被选中!', 'info');
return; return;
} }
if (row.length > 0) { if (row.length > 0) {
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条角色信息吗?', function (r) { $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条角色信息吗?', function (r) {
if (r) { if (r) {
var ids = ""; var ids = "";
for (var i = 0; i < row.length; i++) { for (var i = 0; i < row.length; i++) {
if (i == row.length - 1) { if (i == row.length - 1) {
ids += row[i].id; ids += row[i].id;
break; break;
} }
ids += row[i].id + ","; ids += row[i].id + ",";
} }
$.ajax({ $.ajax({
type: "post", type: "post",
url: "/role/batchDelete", url: "/role/batchDelete",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
ids: ids, ids: ids,
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$("#searchBtn").click(); $("#searchBtn").click();
$(":checkbox").attr("checked", false); $(":checkbox").attr("checked", false);
} else { } else {
$.messager.alert('删除提示', '删除角色信息失败,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除角色信息失败,请稍后再试!', 'error');
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('删除提示', '删除角色信息异常,请稍后再试!', 'error'); $.messager.alert('删除提示', '删除角色信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
}); });
} }
} }
//增加 //增加
var url; var url;
var roleID = 0; var roleID = 0;
//保存编辑前的名称 //保存编辑前的名称
var oldName = ""; var oldName = "";
function addRole() { function addRole() {
$("#sort").val(""); $("#sort").val("");
$("#remark").val(""); $("#remark").val("");
$('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加角色信息'); $('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加角色信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
$("#name").val("").focus(); $("#name").val("").focus();
//$('#roleFM').form('clear'); //$('#roleFM').form('clear');
oldName = ""; oldName = "";
roleID = 0; roleID = 0;
url = '/role/add'; url = '/role/add';
} }
//保存信息 //保存信息
$("#saveRole").off("click").on("click", function () { $("#saveRole").off("click").on("click", function () {
if (checkRoleName()) { if (checkRoleName()) {
return; return;
} }
$.ajax({ $.ajax({
type: "post", type: "post",
url: url, url: url,
dataType: "json", dataType: "json",
data: ({ data: ({
info: JSON.stringify($("#roleFM").serializeObject()) info: JSON.stringify($("#roleFM").serializeObject())
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
$('#roleDlg').dialog('close'); $('#roleDlg').dialog('close');
//加载完以后重新初始化 //加载完以后重新初始化
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
showRoleDetails(opts.pageNumber, opts.pageSize); showRoleDetails(opts.pageNumber, opts.pageSize);
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '保存角色信息异常,请稍后再试!', 'error'); $.messager.alert('提示', '保存角色信息异常,请稍后再试!', 'error');
return; return;
} }
}); });
}); });
//编辑信息 //编辑信息
function editRole(roleTotalInfo) { function editRole(roleTotalInfo) {
var roleInfo = roleTotalInfo.split("AaBb"); var roleInfo = roleTotalInfo.split("AaBb");
$("#name").focus().val(roleInfo[1]); $("#name").focus().val(roleInfo[1]);
oldName = roleInfo[1]; oldName = roleInfo[1];
$('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑角色信息'); $('#roleDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑角色信息');
$(".window-mask").css({width: webW, height: webH}); $(".window-mask").css({width: webW, height: webH});
roleID = roleInfo[0]; roleID = roleInfo[0];
//焦点在名称输入框==定焦在输入文字后面 //焦点在名称输入框==定焦在输入文字后面
$("#name").val("").focus().val(roleInfo[1]); $("#name").val("").focus().val(roleInfo[1]);
url = '/role/update?id=' + roleInfo[0]; url = '/role/update?id=' + roleInfo[0];
} }
//检查名称是否存在 ++ 重名无法提示问题需要跟进 //检查名称是否存在 ++ 重名无法提示问题需要跟进
function checkRoleName() { function checkRoleName() {
var name = $.trim($("#name").val()); var name = $.trim($("#name").val());
//表示是否存在 true == 存在 false = 不存在 //表示是否存在 true == 存在 false = 不存在
var flag = false; var flag = false;
//开始ajax名称检验不能重名 //开始ajax名称检验不能重名
if (name.length > 0 && (oldName.length == 0 || name != oldName)) { if (name.length > 0 && (oldName.length == 0 || name != oldName)) {
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/role/checkIsNameExist", url: "/role/checkIsNameExist",
dataType: "json", dataType: "json",
async: false, async: false,
data: ({ data: ({
id: roleID, id: roleID,
name: name name: name
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200) { if(res && res.code === 200) {
if(res.data && res.data.status) { if(res.data && res.data.status) {
flag = res.data.status; flag = res.data.status;
if (flag) { if (flag) {
$.messager.alert('提示', '角色名称已经存在', 'info'); $.messager.alert('提示', '角色名称已经存在', 'info');
return; return;
} }
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('提示', '检查角色名称是否存在异常,请稍后再试!', 'error'); $.messager.alert('提示', '检查角色名称是否存在异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
return flag; return flag;
} }
//搜索处理 //搜索处理
$("#searchBtn").unbind().bind({ $("#searchBtn").unbind().bind({
click: function () { click: function () {
showRoleDetails(1, initPageSize); showRoleDetails(1, initPageSize);
var opts = $("#tableData").datagrid('options'); var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager'); var pager = $("#tableData").datagrid('getPager');
opts.pageNumber = 1; opts.pageNumber = 1;
opts.pageSize = initPageSize; opts.pageSize = initPageSize;
pager.pagination('refresh', { pager.pagination('refresh', {
pageNumber: 1, pageNumber: 1,
pageSize: initPageSize pageSize: initPageSize
}); });
} }
}); });
function showRoleDetails(pageNo, pageSize) { function showRoleDetails(pageNo, pageSize) {
var searchName = $.trim($("#searchName").val()); var searchName = $.trim($("#searchName").val());
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/role/list", url: "/role/list",
dataType: "json", dataType: "json",
data: ({ data: ({
search: JSON.stringify({ search: JSON.stringify({
name: searchName name: searchName
}), }),
currentPage: pageNo, currentPage: pageNo,
pageSize: pageSize pageSize: pageSize
}), }),
success: function (res) { success: function (res) {
if(res && res.code === 200){ if(res && res.code === 200){
if(res.data && res.data.page) { if(res.data && res.data.page) {
$("#tableData").datagrid('loadData', res.data.page); $("#tableData").datagrid('loadData', res.data.page);
} }
} }
}, },
//此处添加错误处理 //此处添加错误处理
error: function () { error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error'); $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return; return;
} }
}); });
} }
//重置按钮 //重置按钮
$("#searchResetBtn").unbind().bind({ $("#searchResetBtn").unbind().bind({
click: function () { click: function () {
$("#searchName").val(""); $("#searchName").val("");
//加载完以后重新初始化 //加载完以后重新初始化
$("#searchBtn").click(); $("#searchBtn").click();
} }
}); });
//分配应用 //分配应用
$('#btnSetApp').click(function () { $('#btnSetApp').click(function () {
var currentRow = $("#tableData").datagrid("getSelected"); var currentRow = $("#tableData").datagrid("getSelected");
if (currentRow == null) { if (currentRow == null) {
alert("请选择一条数据再操作!"); $.messager.alert('提示',"请选择一条数据再操作!",'warning');
return false; return false;
} }
this.href = "/pages/manage/roleApp.html?id=" + currentRow.id; this.href = "/pages/manage/roleApp.html?id=" + currentRow.id;
}); });
//分配功能 //分配功能
$('#btnSetFunctions').click(function () { $('#btnSetFunctions').click(function () {
var currentRow = $("#tableData").datagrid("getSelected"); var currentRow = $("#tableData").datagrid("getSelected");
if (currentRow == null) { if (currentRow == null) {
alert("请选择一条数据再操作!"); $.messager.alert('提示',"请选择一条数据再操作!",'warning');
return false; return false;
} }
this.href = "/pages/manage/roleFunctions.html?id=" + currentRow.id; this.href = "/pages/manage/roleFunctions.html?id=" + currentRow.id;
}); });
//分配按钮 //分配按钮
$('#btnSetPushBtn').click(function () { $('#btnSetPushBtn').click(function () {
var currentRow = $("#tableData").datagrid("getSelected"); var currentRow = $("#tableData").datagrid("getSelected");
if (currentRow == null) { if (currentRow == null) {
alert("请选择一条数据再操作!"); $.messager.alert('提示',"请选择一条数据再操作!",'warning');
return false; return false;
} }
this.href = "/pages/manage/rolePushBtn.html?id=" + currentRow.id; this.href = "/pages/manage/rolePushBtn.html?id=" + currentRow.id;
}); });
</script> </script>
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff