去掉财务管理从后台获取最大id的逻辑

This commit is contained in:
qiankunpingtai
2019-05-22 15:55:07 +08:00
parent 9145b284b2
commit 79d4c7d24c
10 changed files with 345 additions and 516 deletions

View File

@@ -150,9 +150,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -596,7 +593,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
//收预付款单据支持刷卡功能
if(listType == "收预付款") {
@@ -632,7 +629,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -728,54 +725,7 @@ function bindEvent(){
return;
}
});
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -874,7 +824,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -940,8 +893,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -952,21 +904,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -975,29 +949,6 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}
}

View File

@@ -12,7 +12,6 @@ $(function(){
initSelectInfo_person(); //经手人信息
initSystemData_account(); //账户数据
initSelectInfo_account(); //账户信息
initSupplier(); //供应商
initTableData();
ininPager();
initForm();
@@ -51,20 +50,6 @@ function initSelectInfo_account(){
}
}
//初始化单位信息
function initSupplier(){
$('#OrganId').combobox({
url: organUrl,
valueField:'id',
textField:'supplier',
formatter: function(row){
var opts = $(this).combobox('options');
if(row[opts.textField]!=="非会员") {
return row[opts.textField];
}
}
});
}
//获取财务员
function initSystemData_person(){
@@ -150,9 +135,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -552,7 +534,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
}
@@ -565,7 +547,7 @@ function editAccountHead(index){
$("#BillTime").val(rowsdata.billtime);
$("#Remark").val(rowsdata.remark);
$("#AccountId").val(rowsdata.accountid);
$('#OrganId').combobox('setValue', rowsdata.organid);
// $('#OrganId').combobox('setValue', rowsdata.organid);
$("#HandsPersonId").val(rowsdata.handspersonid);
$("#ChangeAmount").val(rowsdata.changeamount);
var TotalPrice = rowsdata.totalprice;
@@ -577,7 +559,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -650,53 +632,7 @@ function bindEvent(){
ChangeAmount = 0 - ChangeAmount;
//支出和付款为负数
TotalPrice = 0 - TotalPrice;
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -795,7 +731,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -861,8 +800,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -873,21 +811,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -896,29 +856,5 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}

View File

@@ -150,9 +150,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -552,7 +549,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
}
@@ -577,7 +574,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -651,53 +648,7 @@ function bindEvent(){
var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
var OrganId = $('#OrganId').combobox('getValue');
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -796,7 +747,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -862,8 +816,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -874,21 +827,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -897,29 +872,5 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}

View File

@@ -151,9 +151,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -553,7 +550,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
}
@@ -578,7 +575,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -657,53 +654,7 @@ function bindEvent(){
//支出和付款为负数
TotalPrice = 0 - TotalPrice;
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -802,7 +753,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -868,8 +822,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -880,21 +833,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -903,29 +878,5 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}

View File

@@ -150,9 +150,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -552,7 +549,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
}
@@ -577,7 +574,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -647,53 +644,7 @@ function bindEvent(){
var ChangeAmount = $.trim($("#ChangeAmount").val());
var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
OrganId = $('#OrganId').combobox('getValue');
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -792,7 +743,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -858,8 +812,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -870,21 +823,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -893,29 +868,5 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}

View File

@@ -150,9 +150,6 @@ function initTableData(){
* 修改效率低下的js
*/
var str = '';
// var rowInfo = rec.id + 'AaBb' + rec.billno+ 'AaBb' + rec.billtime+ 'AaBb' + rec.remark
// + 'AaBb' + rec.accountid+ 'AaBb' + rec.accountname + 'AaBb' + rec.organid + 'AaBb' + rec.organname
// + 'AaBb' + rec.handspersonid + 'AaBb' + rec.handspersonname + 'AaBb' + rec.changeamount + 'AaBb' + rec.totalprice;
var orgId = rec.organid ? rec.organid : 0;
str += '<img title="查看" src="/js/easyui-1.3.5/themes/icons/list.png" style="cursor: pointer;" onclick="showAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editAccountHead(\'' + index + '\');"/>&nbsp;&nbsp;&nbsp;';
@@ -552,7 +549,7 @@ function addAccountHead(){
accountHeadID = 0;
initTableData_account("add"); //明细列表
reject(); //撤销下、刷新材料列表
url = '/accountHead/add';
url = '/accountHead/addAccountHeadAndDetail';
//收预付款单据支持刷卡功能
if(listType == "收预付款") {
@@ -588,7 +585,7 @@ function editAccountHead(index){
initTableData_account("edit",TotalPrice); //明细列表
reject(); //撤销下、刷新列表
url = '/accountHead/update?id=' + rowsdata.id;
url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
}
//查看信息
@@ -669,53 +666,7 @@ function bindEvent(){
TotalPrice = 0 - TotalPrice;
}
//保存单位信息
$.ajax({
type: "post",
url: url,
dataType: "json",
async: false,
data: ({
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
})
}),
success: function (tipInfo) {
if (tipInfo) {
//保存明细记录
if (accountHeadID == 0) {
getMaxId(); //查找最大的Id
accept(accountHeadMaxId, listType); //新增
}
else {
accept(accountHeadID, listType); //修改
}
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
}
else {
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
return;
}
});
saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
}
});
@@ -814,7 +765,10 @@ function endEditing() {
if (editIndex == undefined) { return true }
if ($('#accountData').datagrid('validateRow', editIndex)) {
var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
var textName = $(ed.target).combobox('getText');
var textName =null;
if($(ed.target)){
textName = $(ed.target).combobox('getText');
}
$('#accountData').datagrid('getRows')[editIndex][edName] = textName;
$('#accountData').datagrid('endEdit', editIndex);
editIndex = undefined;
@@ -880,8 +834,7 @@ function CheckData() {
}
return true;
}
//保存
function accept(accepId,listType) {
function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
append();
removeit();
if ($("#accountData").datagrid('getChanges').length) {
@@ -892,21 +845,43 @@ function accept(accepId,listType) {
var updated = $("#accountData").datagrid('getChanges', "updated");
$.ajax({
type: "post",
url: "/accountItem/saveDetials",
url: url,
dataType: "json",
data: {
inserted: JSON.stringify(inserted),
deleted: JSON.stringify(deleted),
updated: JSON.stringify(updated),
headerId: accepId,
info : JSON.stringify({
Type: listType,
BillNo: $.trim($("#BillNo").val()),
BillTime: $.trim($("#BillTime").val()),
AccountId: $.trim($("#AccountId").val()),
ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
TotalPrice: TotalPrice, //合计
OrganId: OrganId,
HandsPersonId: $.trim($("#HandsPersonId").val()),
Remark: $.trim($("#Remark").val())
}),
listType: listType
},
success: function (tipInfo)
{
if (tipInfo) {
$.messager.alert('提示','保存成功!','info');
$('#accountHeadDlg').dialog('close');
var opts = $("#tableData").datagrid('options');
showAccountHeadDetails(opts.pageNumber, opts.pageSize);
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
else{
$.messager.show({
title: '错误提示',
msg: '保存信息失败,请稍后重试!'
});
}
else
$.messager.alert('提示','保存失败!','error');
},
error: function (XmlHttpRequest, textStatus, errorThrown)
@@ -915,29 +890,5 @@ function accept(accepId,listType) {
}
});
}
if (endEditing()) {
$('#accountData').datagrid('acceptChanges');
}
}
//获取MaxId
function getMaxId(){
var accountHeadMax=null;
$.ajax({
type:"get",
url: "/accountHead/getMaxId",
//设置为同步
async:false,
dataType: "json",
success: function (res) {
if(res && res.code === 200) {
if(res.data) {
accountHeadMax = res.data.maxId;
}
}
}
});
if(accountHeadMax !=null) {
accountHeadMaxId=accountHeadMax;
}
}

View File

@@ -5,6 +5,7 @@ import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
import com.jsh.erp.exception.BusinessParamCheckingException;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.utils.BaseResponseInfo;
@@ -182,5 +183,38 @@ public class AccountHeadController {
}
return result;
}
/**
* create by: qiankunpingtai
* websitehttps://qiankunpingtai.cn
* description:
* 新增财务信息和财务明细信息
* create time: 2019/5/21 15:50
* @Param: beanJson
 * @Param: inserted
 * @Param: deleted
 * @Param: updated
 * @Param: request
* @return java.lang.Object
*/
@RequestMapping(value = "/addAccountHeadAndDetail")
public Object addAccountHeadAndDetail(@RequestParam("info") String beanJson,
@RequestParam("inserted") String inserted,
@RequestParam("deleted") String deleted,
@RequestParam("updated") String updated,
@RequestParam("listType") String listType,HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
accountHeadService.addAccountHeadAndDetail(beanJson,inserted,deleted,updated,listType);
return result;
}
@RequestMapping(value = "/updateAccountHeadAndDetail")
public Object updateAccountHeadAndDetail(@RequestParam("id") Long id,@RequestParam("info") String beanJson,@RequestParam("inserted") String inserted,
@RequestParam("deleted") String deleted,
@RequestParam("updated") String updated,@RequestParam("listType") String listType) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
accountHeadService.updateAccountHeadAndDetail(id,beanJson,inserted,deleted,updated,listType);
return result;
}
}

View File

@@ -43,4 +43,7 @@ public interface AccountHeadMapperEx {
List<AccountHead> getAccountHeadListByOrganIds(@Param("organIds") String[] organIds);
List<AccountHead> getAccountHeadListByHandsPersonIds(@Param("handsPersonIds") String[] handsPersonIds);
int addAccountHead(AccountHead accountHead);
int updateAccountHead(AccountHead accountHead);
}

View File

@@ -9,6 +9,7 @@ import com.jsh.erp.datasource.mappers.AccountHeadMapper;
import com.jsh.erp.datasource.mappers.AccountHeadMapperEx;
import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
@@ -22,6 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -41,6 +43,8 @@ public class AccountHeadService {
private LogService logService;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@Resource
private AccountItemService accountItemService;
public AccountHead getAccountHead(long id) throws Exception {
AccountHead result=null;
@@ -303,4 +307,49 @@ public class AccountHeadService {
deleteTotal= batchDeleteAccountHeadByIds(ids);
return deleteTotal;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addAccountHeadAndDetail(String beanJson, String inserted, String deleted, String updated, String listType) throws Exception {
/**处理财务信息*/
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
try{
accountHeadMapperEx.addAccountHead(accountHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
/**
* create by: qiankunpingtai
* create time: 2019/5/22 10:30
* websitehttps://qiankunpingtai.cn
* description:
* 处理财务明细信息
*
*/
accountItemService.saveDetials(inserted, deleted, updated, accountHead.getId(), listType);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateAccountHeadAndDetail(Long id, String beanJson, String inserted, String deleted, String updated, String listType)throws Exception {
/**更新财务信息*/
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
accountHead.setId(id);
try{
accountHeadMapperEx.updateAccountHead(accountHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
/**
* create by: qiankunpingtai
* create time: 2019/5/22 10:30
* websitehttps://qiankunpingtai.cn
* description:
* 更新财务明细信息
*/
accountItemService.saveDetials(inserted, deleted, updated, accountHead.getId(), listType);
}
}

View File

@@ -126,4 +126,56 @@
)
and ifnull(delete_Flag,'0') !='1'
</select>
<insert id="addAccountHead" parameterType="com.jsh.erp.datasource.entities.AccountHead"
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into jsh_accounthead (Id, Type, OrganId,
HandsPersonId, ChangeAmount, TotalPrice,
AccountId, BillNo, BillTime,
Remark, tenant_id, delete_Flag
)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{organid,jdbcType=BIGINT},
#{handspersonid,jdbcType=BIGINT}, #{changeamount,jdbcType=DECIMAL}, #{totalprice,jdbcType=DECIMAL},
#{accountid,jdbcType=BIGINT}, #{billno,jdbcType=VARCHAR}, #{billtime,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
)
</insert>
<update id="updateAccountHead" parameterType="com.jsh.erp.datasource.entities.AccountHead">
update jsh_accounthead
<set>
<if test="type != null">
Type = #{type,jdbcType=VARCHAR},
</if>
<if test="organid != null">
OrganId = #{organid,jdbcType=BIGINT},
</if>
<if test="handspersonid != null">
HandsPersonId = #{handspersonid,jdbcType=BIGINT},
</if>
<if test="changeamount != null">
ChangeAmount = #{changeamount,jdbcType=DECIMAL},
</if>
<if test="totalprice != null">
TotalPrice = #{totalprice,jdbcType=DECIMAL},
</if>
<if test="accountid != null">
AccountId = #{accountid,jdbcType=BIGINT},
</if>
<if test="billno != null">
BillNo = #{billno,jdbcType=VARCHAR},
</if>
<if test="billtime != null">
BillTime = #{billtime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
Remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
<if test="deleteFlag != null">
delete_Flag = #{deleteFlag,jdbcType=VARCHAR},
</if>
</set>
where Id = #{id,jdbcType=BIGINT}
</update>
</mapper>