var network = require("../../../utils/net.js")
|
|
var timechage = require("../../../utils/dateTimeUtil.js")
|
|
var app = getApp()
|
|
var orderID=0;
|
|
|
|
function load(that, ID) {
|
|
let method = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Load';
|
|
let params = [ID];
|
|
network.transfer_request(method, params, function (res) {
|
|
let DepartmentWorkFlow_Detail_Name = res.result.DepartmentWorkFlow_Detail_Name
|
|
let istrue = false;
|
|
if (DepartmentWorkFlow_Detail_Name == "初始") {
|
|
istrue = true;
|
|
}
|
|
|
|
if (res.result.Customer_Name!=null){
|
|
var accountcustomerNew = [{
|
|
ID: res.result.Customer_ID,
|
|
Name: res.result.Customer_Name
|
|
}]
|
|
}
|
|
let accountUnitNew=[{
|
|
ID: res.result.AccountingUnit_ID,
|
|
Name: res.result.AccountingUnit_Name
|
|
}]
|
|
|
|
let departmentNew =[{
|
|
ID: res.result.Department_ID,
|
|
Name: res.result.Department_Name
|
|
}]
|
|
if (res.result.GuaranteeDate != null) {
|
|
that.setData({
|
|
guaranteedate: timechage.formatTimeTwo(res.result.GuaranteeDate.substring(6, 19), 'Y-M-D'),
|
|
})
|
|
}
|
|
if (res.result.CashBackDate != null) {
|
|
that.setData({
|
|
paydate: timechage.formatTimeTwo(res.result.CashBackDate.substring(6, 19), 'Y-M-D')
|
|
})
|
|
}
|
|
if (res.result.GuaranteeMoney != null) {
|
|
that.setData({
|
|
guaranteeMoney: res.result.GuaranteeMoney,
|
|
})
|
|
}
|
|
that.setData({
|
|
accountcustomer: accountcustomerNew,
|
|
accountUnit: accountUnitNew,
|
|
department: departmentNew,
|
|
showView: istrue
|
|
})
|
|
setDetails(that, res.result.Details)
|
|
GetCustomerAccountingUnitBalance(that, that.data.accountUnit[that.data.accountUnitIndex].ID, that.data.accountcustomer[that.data.accountcustomerIndex].ID)
|
|
})
|
|
}
|
|
|
|
function setDetails(that, ary) {
|
|
let array = []
|
|
let billMoney=0;
|
|
for (var i = 0; i < ary.length; i++) {
|
|
billMoney = billMoney + ary[i].Value
|
|
let data = "";
|
|
if (ary[i].Date != null) {
|
|
data = timechage.formatTimeTwo(ary[i].Date.substring(6, 19), 'Y-M-D')
|
|
}
|
|
var dmo = {
|
|
DmoTypeIDName: ary[i].DmoTypeIDName,
|
|
BillID: ary[i].BillID,
|
|
Value: ary[i].Value,
|
|
Customer_Name: ary[i].Customer_Name,
|
|
Date: data,
|
|
ID:ary[i].ID,
|
|
DmoTypeID: ary[i].DmoTypeID
|
|
}
|
|
array.push(dmo)
|
|
}
|
|
app.globalData.billInfoUp = array;
|
|
that.setData({
|
|
array: array,
|
|
allBillMoney: billMoney
|
|
})
|
|
|
|
}
|
|
|
|
|
|
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: [{
|
|
ID: 0,
|
|
Name: "请选择会计单位"
|
|
}],
|
|
departmentIndex: 0,
|
|
department: [{
|
|
ID: 0,
|
|
Name: "请选择部门"
|
|
}],
|
|
|
|
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: [],
|
|
showView: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
var that = this;
|
|
let ID = Number(options.ID);
|
|
orderID =ID;
|
|
wx.setNavigationBarTitle({
|
|
title: '业务担保单No.'+ID,
|
|
})
|
|
load(that, ID)
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
this.setData({
|
|
array: app.globalData.billInfoUp
|
|
})
|
|
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].Value
|
|
}
|
|
}
|
|
this.setData({
|
|
allBillMoney: billMoney,
|
|
guaranteeMoney: billMoney + this.data.requestMoney
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
app.globalData.billInfoUp = [];
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
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: '/pages/guaranteebillUp/guaranteebill?customerid=' + accountCustomerId,
|
|
})
|
|
},
|
|
deleteItem: function (e) {
|
|
let idx = e.currentTarget.dataset.idx;
|
|
app.globalData.billInfoUp.splice(idx, 1)
|
|
this.setData({
|
|
array: app.globalData.billInfoUp
|
|
})
|
|
|
|
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].Value
|
|
}
|
|
}
|
|
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
|
|
}
|
|
|
|
let detailsArray = [];
|
|
for (var i = 0; i < this.data.array.length; i++) {
|
|
let id =0;
|
|
if(this.data.array[i].ID!=null){
|
|
id = this.data.array[i].ID
|
|
}
|
|
var dmo = {
|
|
BillID: this.data.array[i].BillID,
|
|
DmoTypeID: this.data.array[i].DmoTypeID,
|
|
ID:id
|
|
}
|
|
detailsArray.push(dmo)
|
|
}
|
|
|
|
let method = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Update';
|
|
let params = [{
|
|
"ID": orderID,
|
|
"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: '提示',
|
|
content: '修改成功,是否返回上级列表',
|
|
success: function (res) {
|
|
if (res.cancel) {
|
|
} else {
|
|
app.globalData.billInfoUp = [];
|
|
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
|
|
})
|
|
}
|
|
|
|
|
|
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,
|
|
});
|
|
}
|
|
}
|
|
})
|