// pages/waitForApproval/approvalDetail/approvalDetail.js
|
|
var app = getApp();
|
|
var network = require("../../../utils/net.js");
|
|
var timechage = require("../../../utils/dateTimeUtil.js");
|
|
|
|
// 销售 - 销售订单
|
|
var saleOrderMethod = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/OrderRpc/Load';
|
|
// 销售 - 业务担保
|
|
var businessGuaranteeMethod = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Load';
|
|
// 销售 - 特价申请
|
|
var specialOrderApplyMethod = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/MarketingActivityRpc/Load';
|
|
|
|
/**
|
|
* 确定按钮点击进行审核的方法
|
|
*/
|
|
// 销售 - 销售订单
|
|
var saleOrderForward = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/OrderRpc/Forward';
|
|
var saleOrderBackward = "/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/OrderRpc/Backward"
|
|
// 销售 - 业务担保
|
|
var businessGuaranteeForward = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Forward';
|
|
var businessGuaranteeBackward = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/BusinessGuaranteeRpc/Backward';
|
|
// 销售 - 特价申请
|
|
var specialOrderApplyForward = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/MarketingActivityRpc/Forward';
|
|
var specialOrderApplyBackward = '/MainSystem/B3MiniProgramRpc/XuRpcs/Employee/MarketingActivityRpc/Backward';
|
|
|
|
//将要获取的表头模版名称
|
|
var formTitleTemplate = "";
|
|
//将要获取的详情模版名称
|
|
var detailInfoTemplate = "";
|
|
|
|
var detailItemType = "";
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
dataArr: [],
|
|
// 特价申请客户明细的数组
|
|
customer_arr: [],
|
|
titleObj: {},
|
|
templateName: "",
|
|
titleTemplateName: "",
|
|
showBottomView: false,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
//正常登录流程进入值为0,分享页面直接进入值为1
|
|
if (app.globalData.shareInState == 1) {
|
|
return;
|
|
}
|
|
var that = this;
|
|
|
|
if (app.globalData.shareInParameter.id) {
|
|
var detailItemID = parseInt(app.globalData.shareInParameter.id);
|
|
detailItemType = app.globalData.shareInParameter.detailItemType;
|
|
that.setData({
|
|
showBottomView: true,
|
|
});
|
|
} else {
|
|
var detailItemID = parseInt(options.id);
|
|
detailItemType = options.detailItemType;
|
|
var detailItemState = options.detailItemState;
|
|
if (detailItemState == "true") {
|
|
that.setData({
|
|
showBottomView: true,
|
|
});
|
|
} else {
|
|
that.setData({
|
|
showBottomView: false,
|
|
});
|
|
}
|
|
}
|
|
|
|
if (!detailItemID || !detailItemType) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '单据信息不明确,无法获取详情数据',
|
|
success:function(res){
|
|
app.globalData.shareInParameter = {};
|
|
app.globalData.shareInPath = '';
|
|
if (res.confirm) {
|
|
wx.navigateBack({
|
|
delta:1,
|
|
})
|
|
}
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
console.log("获取到的详情ID = " + detailItemID);
|
|
console.log("获取到的详情类型 = " + detailItemType);
|
|
|
|
let method = '';
|
|
switch (detailItemType) {
|
|
case "销售-销售订单":
|
|
method = saleOrderMethod;
|
|
break;
|
|
case "销售-业务担保":
|
|
method = businessGuaranteeMethod;
|
|
break;
|
|
case "销售-市场活动":
|
|
method = specialOrderApplyMethod;
|
|
break;
|
|
}
|
|
let params = [detailItemID];
|
|
network.transfer_request(method, params, function(res) {
|
|
|
|
// let DepartmentWorkFlow_Detail_Name = res.result.DepartmentWorkFlow_Detail_Name
|
|
// if (DepartmentWorkFlow_Detail_Name == "初始") {
|
|
// that.setData({
|
|
// showBottomView: true,
|
|
// });
|
|
// } else {
|
|
// that.setData({
|
|
// showBottomView: true,
|
|
// });
|
|
// }
|
|
// 置空公众号跳转信息json 防止下次进入
|
|
app.globalData.shareInParameter = {};
|
|
app.globalData.shareInPath = '';
|
|
|
|
var array = res.result;
|
|
if (array.length <= 0) {
|
|
wx.showToast({
|
|
title: '无数据更新',
|
|
})
|
|
return;
|
|
}
|
|
switch (detailItemType) {
|
|
case "销售-销售订单":
|
|
formTitleTemplate = "commonFormTitleTemplate";
|
|
detailInfoTemplate = "saleOrderTemplate";
|
|
that.saleOrder(array, detailInfoTemplate, formTitleTemplate);
|
|
break;
|
|
|
|
case "销售-业务担保":
|
|
formTitleTemplate = "guaranteeFormTitleTemplate";
|
|
detailInfoTemplate = "businessGuaranteeTemplate";
|
|
that.businessGuarantee(array, detailInfoTemplate, formTitleTemplate);
|
|
break;
|
|
|
|
case "销售-市场活动":
|
|
formTitleTemplate = "specialOrderApplyTitleTemplate";
|
|
detailInfoTemplate = "specialOrderApplyTemplate";
|
|
that.specialOrderApply(array, detailInfoTemplate, formTitleTemplate);
|
|
break;
|
|
}
|
|
})
|
|
},
|
|
|
|
// 销售订单 销售预报 数据解析
|
|
saleOrder: function(result, infoTemplate, titleTemplate) {
|
|
var formTitle = {
|
|
//返回的订单ID
|
|
orderID: result.ID,
|
|
// 购货客户
|
|
Customer_Name: result.Customer_Name,
|
|
// 会计单位
|
|
AccountingUnit_Name: result.AccountingUnit_Name,
|
|
// 部门
|
|
Department_Name: result.Department_Name,
|
|
// 日期
|
|
CreateTime: timechage.formatTimeTwo(result.CreateTime.substring(6, 19), 'Y/M/D h:m')
|
|
}
|
|
let arrayLast = [];
|
|
var detailArr = result.Details;
|
|
for (var i = 0; i < detailArr.length; i++) {
|
|
var policyPrice = detailArr[i].PolicyPrice;
|
|
if (!policyPrice) {
|
|
policyPrice = 0;
|
|
}
|
|
var dmo = {
|
|
listNumber: i + 1,
|
|
// 存活名称
|
|
Goods_Name: detailArr[i].Goods_Name,
|
|
// 主数量
|
|
Number: detailArr[i].Number,
|
|
// 单价
|
|
Price: detailArr[i].Price,
|
|
// 辅数量
|
|
SecondNumber: detailArr[i].SecondNumber,
|
|
// 政策单价
|
|
PolicyPrice: policyPrice,
|
|
|
|
}
|
|
arrayLast.push(dmo);
|
|
}
|
|
this.setData({
|
|
// 表头模版
|
|
titleTemplateName: titleTemplate,
|
|
// 详情模版名称
|
|
templateName: infoTemplate,
|
|
// 详情数组
|
|
dataArr: arrayLast,
|
|
// 置空客户数组
|
|
customer_arr: [],
|
|
// 表头明细
|
|
titleObj: formTitle,
|
|
})
|
|
},
|
|
|
|
// 业务担保数据解析
|
|
businessGuarantee: function(result, infoTemplate, titleTemplate) {
|
|
var backDate ='';
|
|
if (result.CashBackDate) {
|
|
backDate =timechage.formatTimeTwo(result.CashBackDate.substring(6, 19), 'Y/M/D h:m')
|
|
}
|
|
var formTitle = {
|
|
//返回的订单ID
|
|
orderID: result.ID,
|
|
// 购货客户
|
|
Customer_Name: result.Customer_Name,
|
|
// 会计单位
|
|
AccountingUnit_Name: result.AccountingUnit_Name,
|
|
// 部门
|
|
Department_Name: result.Department_Name,
|
|
// 担保日期
|
|
GuaranteeDate: timechage.formatTimeTwo(result.GuaranteeDate.substring(6, 19), 'Y/M/D h:m'),
|
|
// 承诺回款日期
|
|
CashBackDate: backDate,
|
|
// 担保金额
|
|
GuaranteeMoney: result.GuaranteeMoney,
|
|
}
|
|
let arrayLast = [];
|
|
var detailArr = result.Details;
|
|
for (var i = 0; i < detailArr.length; i++) {
|
|
var money = detailArr[i].Value;
|
|
if (!money) {
|
|
money = 0;
|
|
}
|
|
var dmo = {
|
|
listNumber: i + 1,
|
|
// 客户名称
|
|
Customer_Name: detailArr[i].Customer_Name,
|
|
// 单据类型
|
|
DmoTypeIDName: detailArr[i].DmoTypeIDName,
|
|
// 单号
|
|
ID: detailArr[i].ID,
|
|
// 单据日期
|
|
Date: timechage.formatTimeTwo(detailArr[i].Date.substring(6, 19), 'Y/M/D h:m'),
|
|
// 单据金额
|
|
Value: money,
|
|
}
|
|
arrayLast.push(dmo);
|
|
}
|
|
this.setData({
|
|
// 表头模版
|
|
titleTemplateName: titleTemplate,
|
|
// 详情模版名称
|
|
templateName: infoTemplate,
|
|
// 详情数组
|
|
dataArr: arrayLast,
|
|
// 置空客户数组
|
|
customer_arr:[],
|
|
// 表头明细
|
|
titleObj: formTitle,
|
|
})
|
|
},
|
|
|
|
|
|
// 特价申请数据解析
|
|
specialOrderApply: function(result, infoTemplate, titleTemplate) {
|
|
|
|
var formTitle = {
|
|
|
|
//返回的订单ID
|
|
orderID: result.ID,
|
|
// 名称
|
|
name: result.Name,
|
|
// 摘要
|
|
remark: result.Remark,
|
|
// 会计单位
|
|
AccountingUnit_Name: result.AccountingUnit_Name,
|
|
// 部门
|
|
Department_Name: result.Department_Name,
|
|
// 日期
|
|
CreateTime: timechage.formatTimeTwo(result.MarketingActivityDate.substring(6, 19), 'Y/M/D'),
|
|
}
|
|
|
|
let goodsDetailInfoArr = [];
|
|
var goodsNameArray = result.GoodsDetails;
|
|
for (var i = 0; i < goodsNameArray.length; i++) {
|
|
let beginTime = timechage.formatTimeTwo(goodsNameArray[i].BeginTime.substring(6, 19), 'Y-M-D')
|
|
let endTime = timechage.formatTimeTwo(goodsNameArray[i].EndTime.substring(6, 19), 'Y-M-D')
|
|
var dmo = {
|
|
// 存货明细单号
|
|
listNumber: i + 1,
|
|
SaleGoods_ID: goodsNameArray[i].SaleGoods_ID,
|
|
// 存货名称
|
|
Goods_Name: goodsNameArray[i].Goods_Name,
|
|
// 原单价
|
|
Price: goodsNameArray[i].LastPrice,
|
|
// 特价
|
|
applicationPrice: goodsNameArray[i].Price,
|
|
// 开始时间
|
|
applicationStartTime: beginTime,
|
|
// 结束时间
|
|
applicationEndTime: endTime,
|
|
// 申请数量
|
|
applicationNum: goodsNameArray[i].Number,
|
|
// 单位(没用到)
|
|
applicationUnit: goodsNameArray[i].Unit,
|
|
}
|
|
goodsDetailInfoArr.push(dmo);
|
|
}
|
|
|
|
let customerDetailsArray = [];
|
|
var customerArray = result.CustomerDetails;
|
|
for (var i = 0; i < customerArray.length; i++) {
|
|
var dmo = {
|
|
// 存货明细单号
|
|
listNumber: i + 1,
|
|
ID: customerArray[i].Customer_ID,
|
|
CustomerCatalog_Name: customerArray[i].CustomerCatalog_Name,
|
|
Name: customerArray[i].Customer_Name,
|
|
}
|
|
customerDetailsArray.push(dmo)
|
|
}
|
|
|
|
this.setData({
|
|
// 表头模版
|
|
titleTemplateName: titleTemplate,
|
|
// 详情模版名称
|
|
templateName: infoTemplate,
|
|
// 存货详情数组
|
|
dataArr: goodsDetailInfoArr,
|
|
// 客户详情数组
|
|
customer_arr: customerDetailsArray,
|
|
// 表头明细
|
|
titleObj: formTitle,
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 确定按钮点击事件
|
|
*/
|
|
sureBtnClicked: function(event) {
|
|
var id = event.currentTarget.dataset.orderid;
|
|
console.log("点击的按钮ID == " + id);
|
|
let method = '';
|
|
switch (detailItemType) {
|
|
case "销售-销售订单":
|
|
method = saleOrderForward;
|
|
break;
|
|
case "销售-业务担保":
|
|
method = businessGuaranteeForward;
|
|
break;
|
|
case "销售-市场活动":
|
|
method = specialOrderApplyForward;
|
|
break;
|
|
}
|
|
let params = [id];
|
|
network.transfer_request(method, params, function(res) {
|
|
wx.showToast({
|
|
title: '审批成功',
|
|
success: function() {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
}
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 退回按钮点击事件
|
|
*/
|
|
cancleBtnClicked: function(event) {
|
|
var id = event.currentTarget.dataset.orderid;
|
|
console.log("点击的按钮ID == " + id);
|
|
let method = '';
|
|
switch (detailItemType) {
|
|
case "销售-销售订单":
|
|
method = saleOrderBackward;
|
|
break;
|
|
case "销售-业务担保":
|
|
method = businessGuaranteeBackward;
|
|
break;
|
|
case "销售-市场活动":
|
|
method = specialOrderApplyBackward;
|
|
break;
|
|
}
|
|
let params = [id];
|
|
network.transfer_request(method, params, function(res) {
|
|
wx.showToast({
|
|
title: '退回成功',
|
|
success: function() {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
}
|
|
})
|
|
})
|
|
},
|
|
|
|
|
|
|
|
})
|