增加默认账户的功能

This commit is contained in:
季圣华
2017-12-10 23:13:37 +08:00
parent ad74d8057b
commit 9f18f0bc75
8 changed files with 152 additions and 28 deletions

View File

@@ -32,6 +32,7 @@
var otherColumns = true; //明细中的‘别名’列是否显示
var btnEnableList = getBtnStr(); //获取按钮的权限
var mPropertyList = ""; //商品属性列表
var defaultAccountId = 0; //默认账户id
$(function(){
//初始化系统基础信息
getType();
@@ -457,6 +458,9 @@
for(var i = 0 ;i < accountList.length;i++) {
var account = accountList[i];
options += '<option value="' + account.id + '" data-currentAmount="' + account.currentAmount + '">' + account.name + '</option>';
if(account.isDefault) {
defaultAccountId = account.id; //给账户赋值默认id
}
}
$("#AccountId").empty().append(options);
}
@@ -1559,6 +1563,7 @@
$("#DiscountLastMoney").val(0);
$("#ChangeAmount").val(0);
$("#Debt").val(0);
$("#AccountId").val(defaultAccountId); //初始化默认的账户Id
var addTitle = listTitle.replace("列表","信息");
$('#depotHeadDlg').dialog('open').dialog('setTitle','<img src="' + path + '/js/easyui-1.3.5/themes/icons/edit_add.png"/>&nbsp;增加' + addTitle);
$(".window-mask").css({ width: webW ,height: webH});

View File

@@ -2,7 +2,6 @@
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String clientIp = Tools.getLocalIp(request);
%>
<!DOCTYPE html>
@@ -101,9 +100,6 @@
//初始化表格数据
function initTableData(){
$('#tableData').datagrid({
//title:'结算账户',
//iconCls:'icon-save',
//width:700,
height:heightInfo,
nowrap: false,
rownumbers: false,
@@ -112,17 +108,10 @@
//选中单行
singleSelect : true,
collapsible:false,
selectOnCheck:false,
//fitColumns:true,
//单击行是否选中
checkOnSelect : false,
//交替出现背景
striped : true,
url:'<%=path %>/account/findBy.action?pageSize=' + initPageSize,
pagination: true,
//自动截取数据
//nowrap : true,
//loadFilter: pagerFilter,
pageSize: initPageSize,
pageList: initPageNum,
columns:[[
@@ -131,6 +120,16 @@
{ title: '编号', field: 'serialNo',width:150,align:"center"},
{ title: '期初金额', field: 'initialAmount',width:100,align:"center"},
{ title: '当前余额', field: 'currentAmount',width:100,align:"center"},
{ title: '是否默认', field: 'isDefault',width:100,align:"center",
formatter:function(value,rec){
if(rec.isDefault) {
return "<b style='color:green'>是</b>";
}
else {
return "否";
}
}
},
{ title: '备注',field: 'remark',width:100},
{ title: '操作',field: 'op',align:"center",width:180,formatter:function(value,rec)
{
@@ -164,6 +163,15 @@
{
batDeleteAccount();
}
},
{
id:'setAccountIsDefault',
text:'设为默认',
iconCls:'icon-ok',
handler:function()
{
setAccountIsDefault();
}
}
],
onLoadError:function()
@@ -333,6 +341,60 @@
accountID = 0;
url = '<%=path %>/account/create.action';
}
//设为默认操作事件
function setAccountIsDefault(){
var allRow = $('#tableData').datagrid('getRows');
var row = $('#tableData').datagrid('getChecked');
if(row.length == 0)
{
$.messager.alert('设置提示','没有记录被选中!','info');
return;
}
if(row.length > 0)
{
function setDefault(accountID, isDefault) {
$.ajax({
type:"post",
url: "<%=path %>/account/updateAmountIsDefault.action",
dataType: "json",
async : false,
data: ({
AccountID : accountID,
IsDefault : isDefault,
clientIp:'<%=clientIp %>'
}),
success: function (res) {
if(res == "true" && isDefault) {
}
else {
}
},
//此处添加错误处理
error:function()
{
$.messager.alert('删除提示','删除结算账户异常,请稍后再试!','error');
return;
}
});
}
if(row.length == 1) {
setDefault(row[0].id, true); //设置默认
for(var i = 0;i < allRow.length; i++) {
if(allRow[i].id != row[0].id) {
setDefault(allRow[i].id, false);
}
}
setTimeout(function(){
$("#searchBtn").click();
},1000);
}
return;
}
}
//保存结算账户
$("#saveAccount").unbind().bind({

View File

@@ -142,9 +142,6 @@
function initTableData()
{
$('#tableData').datagrid({
//title:'用户列表',
//iconCls:'icon-save',
//width:widthInfo,
height:heightInfo,
nowrap: false,
rownumbers: false,
@@ -153,15 +150,10 @@
//选中单行
singleSelect : true,
collapsible:false,
//selectOnCheck:false,
//fitColumns:true,
//单击行是否选中
//checkOnSelect : false,
url:'<%=path %>/user/findBy.action?pageSize=' + initPageSize,
pagination: true,
//交替出现背景
striped : true,
//loadFilter: pagerFilter,
pageSize: initPageSize,
pageList: initPageNum,
columns:[[