You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

403 lines
10 KiB

// pages/createguarantee/createguarantee.js
var network = require("../../../utils/net.js")
var timechage = require("../../../utils/dateTimeUtil.js")
var app = getApp()
function GetAccountCustomer(that, inputValue) {
let method = "/MainSystem/B3MiniProgramRpc/Rpcs/BaseInfoRpc/GetAccountCustomer";
let params = [{
"InputValue": inputValue,
"PageIndex": 0,
"PageSize": 100
}];
network.transfer_request(method, params, function(res) {
that.setData({
currency: res.result,
accountcustomer: res.result
})
})
that.setData({
which: "结账客户"
})
}
function GetAccountingUnit(that, inputValue) {
let method = "/MainSystem/B3MiniProgramRpc/Rpcs/BaseInfoRpc/GetAccountingUnit";
let params = [{
"InputValue": inputValue,
"PageIndex": 0,
"PageSize": 100
}];
network.transfer_request(method, params, function(res) {
that.setData({
currency: res.result,
accountUnit: res.result
})
})
that.setData({
which: "会计单位"
})
}
function GetDepartment(that, inputValue) {
let method = "/MainSystem/B3MiniProgramRpc/Rpcs/BaseInfoRpc/GetDepartment";
let params = [{
"InputValue": inputValue,
"PageIndex": 0,
"PageSize": 100
}];
network.transfer_request(method, params, function(res) {
that.setData({
currency: res.result,
department: res.result
})
})
that.setData({
which: "部门"
})
}
function GetCustomerAccountingUnitBalance(that, accoutUnitId, customerId) {
let method = "/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/GetCustomerAccountingUnitBalance";
let params = [accoutUnitId, customerId];
network.transfer_request(method, params, function(res) {
that.setData({
requestMoney: res.result,
guaranteeMoney: res.result + that.data.allBillMoney
})
})
}
Page({
/**
* 页面的初始数据
*/
data: {
currency: [],
accountcustomerIndex: 0,
accountcustomer: [{
ID: 0,
Name: "请选择结账客户"
}],
accountUnitIndex: 0,
accountUnit: [],
departmentIndex: 0,
department: [],
guaranteedate: timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D'),
paydate: timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D'),
guaranteeMoney: '',
requestMoney: 0,
allBillMoney: 0,
array: [],
winHeight: app.globalData.winHeight,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
accountUnit: [{
ID: app.globalData.accountingUnit_ID,
Name: app.globalData.accountingUnit_Name
}],
department: [{
ID: app.globalData.department_ID,
Name: app.globalData.department_Name
}],
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
var tmpData = app.globalData.billInfo
var oldData = this.data.array
if (oldData.length > 0) {
tmpData.forEach(function(item, index, arrSelf) {
var has = false
for (var j = 0; j < oldData.length; j++) {
if (oldData[j].DmoTypeID == item.DmoTypeID && oldData[j].BillID == item.BillID) {
has = true;
break;
}
}
if (!has) {
oldData.push(item)
}
});
} else {
oldData = tmpData
}
this.setData({
array: oldData
})
app.globalData.billInfo = []
let billMoney = 0;
if (this.data.array != null || this.data.array != "") {
this.data.array.forEach(function(item, index, arrSelf) {
billMoney = billMoney + item.Value
});
// for (var i = 0; i < this.data.array.length; i++) {
// billMoney = billMoney + this.data.array[i].Value
// }
}
this.setData({
allBillMoney: billMoney,
guaranteeMoney: billMoney + this.data.requestMoney
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
app.globalData.billInfo = [];
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
bindguaranteeDateChange: function(e) {
this.setData({
guaranteedate: e.detail.value
})
},
bindpayDateChange: function(e) {
this.setData({
paydate: e.detail.value
})
},
addBills: function(e) {
let accountCustomerId = this.data.accountcustomer[this.data.accountcustomerIndex].ID;
if (accountCustomerId == 0) {
wx.showToast({
title: '请选择结账客户',
})
return;
}
wx.navigateTo({
url: '../selectbill/selectbill?customerid=' + accountCustomerId,
})
},
deleteItem: function(e) {
let idx = e.currentTarget.dataset.idx;
app.globalData.billInfo.splice(idx, 1)
this.setData({
array: app.globalData.billInfo
})
let billMoney = 0;
if (this.data.array != null || this.data.array != "") {
for (var i = 0; i < this.data.array.length; i++) {
billMoney = billMoney + this.data.array[i].Money
}
}
this.setData({
allBillMoney: billMoney,
guaranteeMoney: billMoney + this.data.requestMoney
})
},
submitForm: function(e) {
let accountCustomerId = this.data.accountcustomer[this.data.accountcustomerIndex].ID;
let accountUnitId = this.data.accountUnit[this.data.accountUnitIndex].ID;
let departmentId = this.data.department[this.data.departmentIndex].ID;
let guaranteeDate = timechage.formatymdERTDate(this.data.guaranteedate);
let payDate = timechage.formatymdERTDate(this.data.paydate);
if (accountUnitId == 0) {
wx.showToast({
title: '请选择会计单位',
})
return;
}
if (departmentId == 0) {
wx.showToast({
title: '请选择部门',
})
return
}
// if (this.data.guaranteeMoney==''){
// wx.showToast({
// title: '请添加担保单',
// })
// return
// }
let detailsArray = [];
for (var i = 0; i < this.data.array.length; i++) {
var dmo = {
BillID: this.data.array[i].BillID,
DmoTypeID: this.data.array[i].DmoTypeID
}
detailsArray.push(dmo)
}
let method = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Insert';
let params = [{
"Customer_ID": accountCustomerId,
"AccountingUnit_ID": accountUnitId,
"Department_ID": departmentId,
"GuaranteeDate": guaranteeDate,
"CashBackDate": payDate,
"GuaranteeMoney": this.data.guaranteeMoney,
"Details": detailsArray
}];
network.transfer_request(method, params, function(res) {
if (res.result != null) {
wx.showModal({
title: '新建业务担保单No.' + res.result,
content: '新建成功,是否返回首页',
success: function(res) {
if (res.cancel) {} else {
app.globalData.billInfo = [];
wx.navigateBack({
delta: 1
})
}
},
fail: function(res) {}
})
}
})
},
powerDrawer: function(e) {
let that = this;
let x = e.currentTarget.dataset.x;
if (x == "结账客户") {
GetAccountCustomer(that, "")
} else if (x == "会计单位") {
GetAccountingUnit(that, "")
} else if (x == "部门") {
GetDepartment(that, "")
}
let currentStatu = e.currentTarget.dataset.statu;
this.util(currentStatu)
},
itemclick: function(e) {
var that = this;
var name = e.currentTarget.dataset.name;
var id = e.currentTarget.dataset.id;
var which = e.currentTarget.dataset.item;
var idx = e.currentTarget.dataset.idx;
if (which == "结账客户") {
that.setData({
accountcustomerIndex: idx
})
}
if (which == "会计单位") {
that.setData({
accountUnitIndex: idx
})
}
if (which == "部门") {
that.setData({
departmentIndex: idx
})
}
GetCustomerAccountingUnitBalance(that, that.data.accountUnit[that.data.accountUnitIndex].ID, that.data.accountcustomer[that.data.accountcustomerIndex].ID)
this.setData({
showModalStatus: false,
})
},
select: function(e) {
var that = this;
var which = e.currentTarget.dataset.item;
var value = e.detail.value;
if (which == "结账客户") {
GetAccountCustomer(that, value)
}
if (which == "会计单位") {
GetAccountingUnit(that, value)
}
if (which == "部门") {
GetDepartment(that, value)
}
},
util: function(currentStatu) {
/* 动画部分 */
// 第1步:创建动画实例
var animation = wx.createAnimation({
duration: 200, //动画时长
timingFunction: "linear", //线性
delay: 0 //0则不延迟
});
// 第2步:这个动画实例赋给当前的动画实例
this.animation = animation;
// 第3步:执行第一组动画
animation.opacity(0).rotateX(-100).step();
// 第4步:导出动画对象赋给数据对象储存
this.setData({
animationData: animation.export()
})
// 第5步:设置定时器到指定时候后,执行第二组动画
setTimeout(function() {
// 执行第二组动画
animation.opacity(1).rotateX(0).step();
// 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
this.setData({
animationData: animation
})
//关闭
if (currentStatu == "close") {
this.setData({
showModalStatus: false,
});
}
}.bind(this), 200)
// 显示
if (currentStatu == "open") {
// 调用函数时,传入new Date()参数,返回值是日期和时间
// 再通过setData更改Page()里面的data,动态更新页面的数据
this.setData({
showModalStatus: true,
});
}
}
})