客户对账单优化

This commit is contained in:
季圣华
2017-10-28 00:12:27 +08:00
parent a348bc29f1
commit dfdfce09a0
7 changed files with 274 additions and 34 deletions

View File

@@ -631,13 +631,23 @@
url = path + '/supplier/update.action?supplierID=' + supplierInfo[0];
//显示累计应收和累计应付
var thisDateTime = getNowFormatDateTime(); //当前时间
var supType = "customer";
if(listType === "客户"){
supType = "customer"
}
else if(listType === "供应商"){
supType = "vendor"
}
$.ajax({
type:"post",
url: path + "/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierInfo[0]
supplierId: supplierInfo[0],
EndTime:thisDateTime,
supType: supType
}),
success: function(res){
if(res) {
@@ -648,7 +658,9 @@
dataType: "json",
async: false,
data: ({
supplierId: supplierInfo[0]
supplierId: supplierInfo[0],
EndTime:thisDateTime,
supType: supType
}),
success: function(res){
if(res) {
@@ -656,14 +668,13 @@
var money = moneyA+moneyB;
var moneyBeginNeedGet = $("#BeginNeedGet").val()-0; //期初应收
var moneyBeginNeedPay = $("#BeginNeedPay").val()-0; //期初应付
money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
if(money>0) {
$("#AllNeedGet").val(""); //累计应收-置空
$("#AllNeedPay").val(money); //累计应付
if(listType === "客户"){
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$("#AllNeedGet").val(money); //累计应收
}
else {
$("#AllNeedGet").val(-money); //累计应收
$("#AllNeedPay").val(""); //累计应付-置空
else if(listType === "供应商"){
money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
$("#AllNeedPay").val(money); //累计应付
}
}
},

View File

@@ -7,7 +7,7 @@
<!DOCTYPE html>
<html>
<head>
<title>对账</title>
<title>客户对账</title>
<meta charset="utf-8">
<!-- 指定以IE8的方式来渲染 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
@@ -49,12 +49,17 @@
&nbsp;&nbsp;
<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-print" id="printBtn">打印</a>
</td>
<td>&nbsp;</td>
<td>
期初应收:<span class="first-total">0</span>&nbsp;&nbsp;
期末应收:<span class="last-total">0</span>
</td>
</tr>
</table>
</div>
<!-- 数据显示table -->
<div id = "tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="对账列表" iconCls="icon-list" collapsible="true" closable="false">
<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>
@@ -76,7 +81,7 @@
});
//初始化供应商、客户
//初始化客户
function initSupplier(){
$('#OrganId').combobox({
url: cusUrl,
@@ -107,10 +112,11 @@
pageList: [10,50,100],
columns:[[
{ title: '单据编号',field: 'number',width:140},
{ title: '类型',field: 'type',width:100},
{ title: '单位名称',field: 'supplierName',width:200},
{ title: '金额',field: 'allPrice',width:60,formatter: function(value,rec){
return (rec.changeAmount-rec.totalPrice).toFixed(2);
}},
{ title: '单据金额',field: 'totalPrice',width:80},
{ title: '实际支付',field: 'changeAmount',width:80},
{ title: '本期变化',field: 'allPrice',width:80},
{ title: '单据日期',field: 'operTime',width:140}
]],
onLoadError:function()
@@ -209,6 +215,131 @@
success: function (res) {
if(res){
$("#tableData").datagrid('loadData',res);
//如果选择了单位信息,就进行计算期初和期末
var supplierId = $('#OrganId').combobox('getValue');
if(supplierId) {
//先查找期初信息
var beginNeedGet = 0;
var beginNeedPay = 0;
$.ajax({
type:"post",
url: "<%=path %>/supplier/findById.action",
dataType: "json",
async: false,
data: ({
supplierID: supplierId
}),
success: function(res){
if(res && res.rows && res.rows[0]) {
if(res.rows[0].BeginNeedGet) {
beginNeedGet = res.rows[0].BeginNeedGet;
}
if(res.rows[0].BeginNeedPay) {
beginNeedPay = res.rows[0].BeginNeedPay;
}
//显示期初结存
var searchBeginTime = $("#searchBeginTime").val(); //开始时间
$.ajax({
type:"post",
url: "<%=path %>/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchBeginTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyA = res.getAllMoney.toFixed(2)-0;
$.ajax({
type:"post",
url: "<%=path %>/accountHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchBeginTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyB = res.getAllMoney.toFixed(2)-0;
var money = moneyA+moneyB;
var moneyBeginNeedGet = beginNeedGet-0; //期初应收
var moneyBeginNeedPay = beginNeedPay-0; //期初应付
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$(".first-total").text(money); //期初结存
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
})
//显示期末合计
var searchEndTime = $("#searchEndTime").val(); //结束时间
$.ajax({
type:"post",
url: "<%=path %>/depotHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchEndTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyA = res.getAllMoney.toFixed(2)-0;
$.ajax({
type:"post",
url: "<%=path %>/accountHead/findTotalPay.action",
dataType: "json",
async: false,
data: ({
supplierId: supplierId,
EndTime:searchEndTime,
supType: "customer"
}),
success: function(res){
if(res) {
var moneyB = res.getAllMoney.toFixed(2)-0;
var money = moneyA+moneyB;
var moneyBeginNeedGet = beginNeedGet-0; //期初应收
var moneyBeginNeedPay = beginNeedPay-0; //期初应付
money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
$(".last-total").text(money); //期末合计
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
})
}
},
error: function(){
$.messager.alert('提示','网络异常请稍后再试!','error');
return;
}
});
}
}
},
//此处添加错误处理