增加默认账户的功能

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

File diff suppressed because one or more lines are too long

View File

@ -220,6 +220,41 @@ public class AccountAction extends BaseAction<AccountModel>
, tipType, "更新结算账户ID为 "+ model.getAccountID() + " " + tipMsg + "", "更新结算账户" + tipMsg));
}
/**
* 更新结算账户-设置是否默认
* @return
*/
public void updateAmountIsDefault() {
Boolean flag = false;
try {
Account Account = accountService.get(model.getAccountID());
Account.setIsDefault(model.getIsDefault());
accountService.update(Account);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改结算账户ID为 " + model.getAccountID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally {
try {
toClient(flag.toString());
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>修改结算账户回写客户端结果异常", e);
}
}
//如果改为默认账户时记录日志
if(model.getIsDefault()) {
logService.create(new Logdetails(getUser(), "更新默认账户", model.getClientIp(), new Timestamp(System.currentTimeMillis()),
tipType, "更新账户ID"+ model.getAccountID() + "为默认账户" + tipMsg + "", "更新默认账户" + tipMsg));
}
}
/**
* 批量删除指定ID结算账户
* @return
@ -314,6 +349,7 @@ public class AccountAction extends BaseAction<AccountModel>
Double currentAmount = getAccountSum(account.getId(),"") + getAccountSumByHead(account.getId(), "") + getAccountSumByDetail(account.getId(), "") + getManyAccountSum(account.getId(), "") + account.getInitialAmount();
String currentAmountFmt=df.format(currentAmount);
item.put("currentAmount", currentAmountFmt); //当前余额
item.put("isDefault", account.getIsDefault()); //是否默认
item.put("remark", account.getRemark());
item.put("op", 1);
dataArray.add(item);

View File

@ -8,6 +8,7 @@ public class Account implements java.io.Serializable
private String SerialNo;
private Double InitialAmount;
private Double CurrentAmount;
private Boolean IsDefault;
private String Remark;
public Account()
@ -20,11 +21,12 @@ public class Account implements java.io.Serializable
this.Id = Id;
}
public Account(String name, String serialNo, Double initialAmount, Double currentAmount, String remark) {
public Account(String name, String serialNo, Double initialAmount, Double currentAmount, Boolean isDefault, String remark) {
Name = name;
SerialNo = serialNo;
InitialAmount = initialAmount;
CurrentAmount = currentAmount;
IsDefault = isDefault;
Remark = remark;
}
@ -78,6 +80,14 @@ public class Account implements java.io.Serializable
return CurrentAmount;
}
public Boolean getIsDefault() {
return IsDefault;
}
public void setIsDefault(Boolean isDefault) {
IsDefault = isDefault;
}
public void setRemark(String remark)
{
Remark = remark;

View File

@ -28,6 +28,11 @@ public class AccountModel implements Serializable
*/
private Double currentAmount;
/**
* 是否设为默认
*/
private Boolean isDefault;
/**
* 备注
*/
@ -108,6 +113,14 @@ public class AccountModel implements Serializable
return currentAmount;
}
public Boolean getIsDefault() {
return isDefault;
}
public void setIsDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
public void setRemark(String remark)
{
this.remark = remark;

View File

@ -27,6 +27,11 @@
<comment>当前余额</comment>
</column>
</property>
<property generated="never" lazy="false" name="IsDefault" type="boolean">
<column length="1" name="IsDefault">
<comment>是否设为默认</comment>
</column>
</property>
<property generated="never" lazy="false" name="Remark" type="java.lang.String">
<column length="100" name="Remark">
<comment>备注</comment>

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:[[