Files
jshERP/erp_web/pages/manage/systemConfig.html
2019-05-06 09:51:36 +08:00

445 lines
19 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html>
<head>
<title>系统配置</title>
<meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<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/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="/js/colorbox/colorboxSet.js"></script>
<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/icon.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/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/js/common/common.js"></script>
</head>
<body>
<!-- 查询 -->
<div id="searchPanel" class="easyui-panel" style="padding:10px;" title="查询窗口" iconCls="icon-search" collapsible="true"
closable="false">
<table id="searchTable">
<tr>
<td>公司名称:</td>
<td>
<input type="text" name="searchCompanyName" id="searchCompanyName" style="width:100px;"/>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="searchBtn">查询</a>&nbsp;&nbsp;
</td>
</tr>
</table>
</div>
<!-- 数据显示table -->
<div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="系统配置" iconCls="icon-list"
collapsible="true" closable="false">
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF"></table>
</div>
<div id="systemConfigDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
closed="true" buttons="#dlg-buttons" modal="true" collapsible="false" closable="true">
<form id="systemConfigFM" method="post" novalidate>
<div class="fitem" style="padding:5px">
<label id="companyNameLabel">公司名称 &nbsp;&nbsp;</label>
<input name="companyName" id="companyName" class="easyui-validatebox"
data-options="required:true,validType:'length[2,15]'" style="width: 220px;height: 20px"/>
</div>
<div class="fitem" style="padding:5px">
<label id="companyContactsLabel">联系人&nbsp;&nbsp;</label>
<input name="companyContacts" id="companyContacts" style="width: 220px;height: 20px"/>
</div>
<div class="fitem" style="padding:5px">
<label id="companyAddressLabel">公司地址&nbsp;&nbsp;</label>
<input name="companyAddress" id="companyAddress" style="width: 220px;height: 20px"/>
</div>
<div class="fitem" style="padding:5px">
<label id="companyTelLabel">公司电话&nbsp;&nbsp;</label>
<input name="companyTel" id="companyTel" style="width: 220px;height: 20px"/>
</div>
<div class="fitem" style="padding:5px">
<label id="companyFaxLabel">公司传真&nbsp;&nbsp;</label>
<input name="companyFax" id="companyFax" style="width: 220px;height: 20px"/>
</div>
<div class="fitem" style="padding:5px">
<label id="companyPostCodeLabel">公司邮编&nbsp;&nbsp;</label>
<input name="companyPostCode" id="companyPostCode" style="width: 220px;height: 20px"/>
</div>
</form>
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" id="saveSystemConfig" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
<a href="javascript:void(0)" id="cancelSystemConfig" class="easyui-linkbutton" iconCls="icon-cancel"
onclick="javascript:$('#systemConfigDlg').dialog('close')">取消</a>
</div>
<script type="text/javascript">
//初始化界面
$(function () {
initTableData();
ininPager();
});
//初始化表格数据
function initTableData() {
$('#tableData').datagrid({
height: heightInfo,
nowrap: false,
rownumbers: false,
//动画效果
animate: false,
//选中单行
singleSelect: true,
collapsible: false,
pagination: true,
//交替出现背景
striped: true,
pageSize: initPageSize,
pageList: initPageNum,
columns: [[
{field: 'id', width: 35, align: "center", checkbox:true},
{title: '公司名称', field: 'companyName', width: 150},
{title: '联系人', field: 'companyContacts', width: 80, align: "center"},
{title: '公司地址', field: 'companyAddress', width: 150, align: "center"},
{title: '公司电话', field: 'companyTel', width: 120, align: "center"},
{title: '公司传真', field: 'companyFax', width: 120, align: "center"},
{title: '公司邮编', field: 'companyPostCode', width: 80, align: "center"},
{
title: '操作', field: 'op', width: 160, formatter: function (value, rec,index) {
/**
* create by: qiankunpingtai
* create time: 2019/5/6 9:33
* websitehttps://qiankunpingtai.cn
* description:
* 修改效率低下的js实现
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.companyName + 'AaBb' + rec.companyContacts + 'AaBb' + rec.companyAddress
// + 'AaBb' + rec.companyTel + 'AaBb' + rec.companyFax + 'AaBb' + rec.companyPostCode;
str += '<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editSystemConfig(\'' + index + '\');"/>&nbsp;<a onclick="editSystemConfig(\'' + index + '\');" 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="deleteSystemConfig(' + rec.id + ');"/>&nbsp;<a onclick="deleteSystemConfig(' + rec.id + ');" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>&nbsp;&nbsp;';
return str;
}
}
]],
toolbar: [
{
id: 'addSystemConfig',
text: '增加',
iconCls: 'icon-add',
handler: function () {
addSystemConfig();
}
},
{
id: 'deleteSystemConfig',
text: '删除',
iconCls: 'icon-remove',
handler: function () {
batDeleteSystemConfig();
}
}
],
onLoadError: function () {
$.messager.alert('页面加载提示', '页面加载异常,请稍后再试!', 'error');
return;
}
});
showSystemConfigDetails(1, initPageSize);
}
//初始化键盘enter事件
$(document).keydown(function (event) {
//兼容 IE和firefox 事件
var e = window.event || event;
var k = e.keyCode || e.which || e.charCode;
//兼容 IE,firefox 兼容
var obj = e.srcElement ? e.srcElement : e.target;
//绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件
if (k == "13" && (obj.id == "companyName" || obj.id == "companyContacts" || obj.id == "companyAddress"
|| obj.id == "companyTel" || obj.id == "companyFax" || obj.id == "companyPostCode")) {
$("#saveSystemConfig").click();
}
//搜索按钮添加快捷键
if (k == "13" && (obj.id == "searchCompanyName")) {
$("#searchBtn").click();
}
});
//分页信息处理
function ininPager() {
try {
var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager');
pager.pagination({
onSelectPage: function (pageNum, pageSize) {
opts.pageNumber = pageNum;
opts.pageSize = pageSize;
pager.pagination('refresh', {
pageNumber: pageNum,
pageSize: pageSize
});
showSystemConfigDetails(pageNum, pageSize);
}
});
}
catch (e) {
$.messager.alert('异常处理提示', "分页信息异常 : " + e.name + ": " + e.message, 'error');
}
}
//删除系统配置信息
function deleteSystemConfig(systemConfigId) {
$.messager.confirm('删除确认', '确定要删除此系统配置信息吗?', function (r) {
if (r) {
$.ajax({
type: "post",
url: "/systemConfig/batchDeleteSystemConfigByIds",
dataType: "json",
data: ({
ids: systemConfigId
}),
success: function (res) {
if(res && res.code == 200) {
$("#searchBtn").click();
} else {
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
}
},
//此处添加错误处理
error: function () {
$.messager.alert('删除提示', '删除系统配置信息异常,请稍后再试!', 'error');
return;
}
});
}
});
}
//批量删除系统配置
function batDeleteSystemConfig() {
var row = $('#tableData').datagrid('getChecked');
if (row.length == 0) {
$.messager.alert('删除提示', '没有记录被选中!', 'warning');
return;
}
if (row.length > 0) {
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条系统配置信息吗?', function (r) {
if (r) {
var ids = "";
for (var i = 0; i < row.length; i++) {
if (i == row.length - 1) {
ids += row[i].id;
break;
}
ids += row[i].id + ",";
}
if(row[i].loginame == "jsh"){
$.messager.alert('提示', '管理员jsh不能删除', 'warning');
return;
} else {
$.ajax({
type: "post",
url: "/systemConfig/batchDeleteSystemConfigByIds",
dataType: "json",
async: false,
data: ({
ids: ids
}),
success: function (res) {
if(res && res.code === 200) {
$("#searchBtn").click();
$(":checkbox").attr("checked", false);
} else {
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
}
},
//此处添加错误处理
error: function () {
$.messager.alert('删除提示', '删除系统配置信息异常,请稍后再试!', 'error');
return;
}
});
}
}
});
}
}
//增加系统配置
var url;
var systemConfigId = 0;
//保存编辑前的名称
var oldCompanyName = "";
var pageTotal = 0; //数据总量
function addSystemConfig() {
if(pageTotal>=1) {
$.messager.alert('提示', '只能填写一条系统配置信息', 'warning');
} else {
$('#systemConfigDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加系统配置');
$(".window-mask").css({width: webW, height: webH});
$('#systemConfigFM').form('clear');
var row = {};
$('#systemConfigFM').form('load', row);
$("#companyName").focus();
oldCompanyName = "";
systemConfigId = 0;
url = '/systemConfig/add';
}
}
//保存系统配置信息
$("#saveSystemConfig").off("click").on("click", function () {
if (checkCompanyName()) {
return;
}
var companyName = $.trim($("#companyName").val());
if (!companyName) {
$.messager.alert('提示', '公司名称不能为空', 'warning');
$("#companyName").val("").focus();
return;
}
$.ajax({
url: url,
type: "post",
dataType: "json",
data: {
info: JSON.stringify($("#systemConfigFM").serializeObject())
},
success: function(res) {
if(res && res.code === 200) {
$('#systemConfigDlg').dialog('close');
//加载完以后重新初始化
var opts = $("#tableData").datagrid('options');
showSystemConfigDetails(opts.pageNumber, opts.pageSize);
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '网络异常,请稍后再试!', 'error');
return;
}
});
});
//编辑系统配置信息
function editSystemConfig(index) {
// var systemConfigInfo = systemConfigTotalInfo.split("AaBb");
//获取当前行
var rowsdata = $("#tableData").datagrid("getRows")[index];
var row = {
companyName: rowsdata.companyName,
companyContacts: rowsdata.companyContacts,
companyAddress: rowsdata.companyAddress,
companyTel: rowsdata.companyTel,
companyFax: rowsdata.companyFax,
companyPostCode: rowsdata.companyPostCode
};
oldCompanyName = rowsdata.companyName;
$('#systemConfigDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/>&nbsp;编辑系统配置信息');
$(".window-mask").css({width: webW, height: webH});
$('#systemConfigFM').form('load', row);
systemConfigId = rowsdata.id;
//焦点在名称输入框==定焦在输入文字后面
$("#companyName").val("").focus().val(rowsdata.companyName);
url = '/systemConfig/update?id=' + rowsdata.id;
}
//检查系统配置 名称是否存在 ++ 重名无法提示问题需要跟进
function checkCompanyName() {
var companyName = $.trim($("#companyName").val());
//表示是否存在 true == 存在 false = 不存在
var flag = false;
//开始ajax名称检验不能重名
if (companyName.length > 0 && (oldCompanyName.length == 0 || companyName != oldCompanyName)) {
$.ajax({
type: "get",
url: "/systemConfig/checkIsNameExist",
dataType: "json",
async: false,
data: ({
id: systemConfigId,
companyName: companyName
}),
success: function (res) {
if(res && res.code === 200) {
if(res.data && res.data.status) {
flag = res.data.status;
if (flag) {
$.messager.alert('提示', '系统配置名称已经存在', 'info');
return;
}
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '检查系统配置名称是否存在异常,请稍后再试!', 'error');
return;
}
});
}
return flag;
}
//搜索处理
$("#searchBtn").unbind().bind({
click: function () {
showSystemConfigDetails(1, initPageSize);
var opts = $("#tableData").datagrid('options');
var pager = $("#tableData").datagrid('getPager');
opts.pageNumber = 1;
opts.pageSize = initPageSize;
pager.pagination('refresh', {
pageNumber: 1,
pageSize: initPageSize
});
}
});
function showSystemConfigDetails(pageNo, pageSize) {
var companyName = $.trim($("#searchCompanyName").val());
$.ajax({
type: "get",
url: "/systemConfig/list",
dataType: "json",
data: ({
search: JSON.stringify({
companyName: companyName
}),
currentPage: pageNo,
pageSize: pageSize
}),
success: function (res) {
if(res && res.code === 200){
if(res.data && res.data.page) {
pageTotal = res.data.page.total;
$("#tableData").datagrid('loadData', res.data.page);
}
}
},
//此处添加错误处理
error: function () {
$.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
return;
}
});
}
//重置按钮
$("#searchResetBtn").unbind().bind({
click: function () {
$("#searchCompanyName").val("");
//加载完以后重新初始化
$("#searchBtn").click();
}
});
</script>
</body>
</html>