Browse Source

预报新建存货选取的请求逻辑

master
chenxuhui 7 years ago
parent
commit
5fd65d29f6
1 changed files with 64 additions and 95 deletions
  1. +64
    -95
      pages/saleForecastList/newBill/newBill.js

+ 64
- 95
pages/saleForecastList/newBill/newBill.js View File

@ -29,7 +29,7 @@ function setTime(that) {
}
function GetBaseInfoList(that, method, params) {
network.transfer_request(method, params, function (res) {
network.transfer_request(method, params, function(res) {
that.setData({
currency: res.result
});
@ -43,7 +43,7 @@ function GetGoodsInfo(that, dmo, detail) {
"AccountingUnit_ID": dmo.AccountingUnit_ID,
"Date": dmo.Date,
}]
network.transfer_request(getGoodsDetail, params, function (res) {
network.transfer_request(getGoodsDetail, params, function(res) {
detail.Goods_SecondUnit = res.result.Goods_SecondUnit;
detail.Goods_UnitConvertDirection = res.result.Goods_UnitConvertDirection;
detail.Goods_MainUnitRatio = res.result.Goods_MainUnitRatio;
@ -67,7 +67,7 @@ function GetGoodsInfo(that, dmo, detail) {
function GetCustomerInfo(that, dmo) {
var params = [dmo.Customer_ID, ["Department_ID", "Department_Name", "Employee_ID", "Employee_Name", "TakeGoods_Type", "Address"]]
network.transfer_request(getCustomerInfo, params, function (res) {
network.transfer_request(getCustomerInfo, params, function(res) {
var obj = JSON.parse(res.result);
dmo.Department_ID = obj.Department_ID;
dmo.Department_Name = obj.Department_Name;
@ -92,90 +92,39 @@ Page({
},
dateTimeArray1: null,
dateTime1: null,
backPage:'',
backPage: '',
},
onLoad: function (options) {
onLoad: function(options) {
var that = this;
setTime(that);
},
onShow:function (){
onShow: function() {
var that = this;
// 客户收藏列表选取客户调用此方法
/*
if (this.data.backPage == "customerChoosePage") {
// 返回的用户只能是一条,所以index只能为0
var currentCustomerArr = app.globalData.customerArray;
if (currentCustomerArr.length > 0) {
this.data.dmo.Customer_ID = currentCustomerArr[0].ID;
this.data.dmo.Customer_Name = currentCustomerArr[0].Name;
this.setData({
//customerArr: currentCustomerArr,
dmo:this.data.dmo,
})
// 获取客户详情
GetCustomerInfo(that, this.data.dmo);
}
}
*/
if (this.data.backPage == "goodsNameChoosePage") {
// 获取存货 加载完成后计算价格政策
var goodsArr = app.globalData.goodsNameArray;
app.globalData.goodsNameArray = [];
if (goodsArr.length > 0) {
// 在此添加货品价格的请求
let backGoodsArr = [];
for (var i = 0; i < goodsArr.length; i++) {
// 存货名称
var name = goodsArr[i].Goods_Name;
// 存货ID
var id = goodsArr[i].SaleGoods_ID;
// 获取价格
var unit = goodsArr[i].Unit;
// 原单价
var infoprice = goodsArr[i].Price;
if (infoprice == null) {
infoprice = "";
}
// 特价
var policyPrice = "";
// 开始时间
var infoStartTime = timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D');
// 结束时间
var infoEndTime = timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D');
// 申请数量
var infoNum = "";
let goodsNameObj = {
Goods_Name: name,
SaleGoods_ID: Number(id),
Price: infoprice,
applicationPrice: policyPrice,
applicationStartTime: infoStartTime,
applicationEndTime: infoEndTime,
applicationNum: infoNum,
applicationUnit: unit,
}
backGoodsArr.push(goodsNameObj)
// 获取原单价
that.GetGoodsPrice(id, unit, i);
let newobj = {};
this.data.dmo.Details.push(newobj);
var itemIndex = this.data.dmo.Details.length - 1;
var detail = this.data.dmo.Details[itemIndex];
detail.SaleGoods_ID = goodsArr[i].SaleGoods_ID;
detail.Goods_Name = goodsArr[i].Goods_Name;
GetGoodsInfo(this, this.data.dmo, detail);
}
this.setData({
goodsNameArr: backGoodsArr,
})
}
}
},
/**
* 滑动切换tab
*/
bindChange: function (e) {
bindChange: function(e) {
this.setData({
currentTab: e.detail.current
});
@ -183,7 +132,7 @@ Page({
/**
* 点击tab切换
*/
swichNav: function (e) {
swichNav: function(e) {
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
@ -193,7 +142,7 @@ Page({
}
},
changeDateTime1: function (e) {
changeDateTime1: function(e) {
this.setData({
dateTime1: e.detail.value,
});
@ -201,7 +150,7 @@ Page({
},
// 添加一个时间转换
timeConversion: function () {
timeConversion: function() {
let year = this.data.dateTimeArray1[0][this.data.dateTime1[0]]
let month = this.data.dateTimeArray1[1][this.data.dateTime1[1]]
let date = this.data.dateTimeArray1[2][this.data.dateTime1[2]]
@ -216,14 +165,14 @@ Page({
})
},
getAddrs: function (e) {
getAddrs: function(e) {
this.data.dmo.DeliverAddress = e.detail.value;
this.setData({
dmo: this.data.dmo
});
},
powerDrawer: function (e) {
powerDrawer: function(e) {
let x = e.currentTarget.dataset.x;
if (x == "存货") {
var dmo = this.data.dmo;
@ -246,13 +195,13 @@ Page({
this.util();
},
select: function (e) {
select: function(e) {
var value = e.detail.value;
var x = this.data.which;
this.showDialog(x, value);
},
showDialog: function (x, value) {
showDialog: function(x, value) {
var method = null;
let params = [{
"InputValue": value,
@ -279,11 +228,11 @@ Page({
GetBaseInfoList(this, method, params);
},
dialogClose: function (e) {
dialogClose: function(e) {
this.util();
},
util: function () {
util: function() {
/* 动画部分 */
// 第1步:创建动画实例
var animation = wx.createAnimation({
@ -300,7 +249,7 @@ Page({
animationData: animation.export()
})
// 第5步:设置定时器到指定时候后,执行第二组动画
setTimeout(function () {
setTimeout(function() {
// 执行第二组动画
animation.opacity(1).rotateX(0).step();
// 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
@ -316,7 +265,7 @@ Page({
},
itemclick: function (e) {
itemclick: function(e) {
var flag = true;
var x = this.data.which;
var item = e.currentTarget.dataset.item;
@ -358,7 +307,7 @@ Page({
this.util();
},
getGoodsNum: function (e) {
getGoodsNum: function(e) {
let idx = e.target.dataset.idx;
var detail = this.data.dmo.Details[idx];
let value = Number(e.detail.value);
@ -380,7 +329,7 @@ Page({
})
},
getSecondNum: function (e) {
getSecondNum: function(e) {
let idx = e.target.dataset.idx;
var detail = this.data.dmo.Details[idx];
let value = Number(e.detail.value);
@ -402,7 +351,7 @@ Page({
})
},
getPrice: function (e) {
getPrice: function(e) {
let idx = e.target.dataset.idx;
let value = Number(e.detail.value);
if (isNaN(value)) {
@ -417,7 +366,7 @@ Page({
})
},
deleteItem: function (e) {
deleteItem: function(e) {
let idx = e.target.dataset.idx;
this.data.dmo.Details.splice(idx, 1)
this.setData({
@ -426,14 +375,14 @@ Page({
},
// 添加客户
addCustomer: function () {
addCustomer: function() {
wx.navigateTo({
url: '../../customerChooseTemplate/customerChooseTemplate?fromePage=newForecast',
})
},
// 添加存货
addGoodsName: function () {
addGoodsName: function() {
var that = this;
let unitID = that.data.unit[that.data.isUnit].ID;
var customerArr = that.data.customerArr;
@ -451,16 +400,36 @@ Page({
},
// 添加存货按钮
add: function (e) {
let newobj = {};
this.data.dmo.Details.push(newobj);
this.setData({
dmo: this.data.dmo
add: function(e) {
// 原有增加存货
// let newobj = {};
// this.data.dmo.Details.push(newobj);
// this.setData({
// dmo: this.data.dmo
// })
// 新增获取存货
var dmo = this.data.dmo;
if (dmo.Customer_ID == null) {
wx.showToast({
title: '请选择购货客户'
})
return;
}
if (dmo.AccountingUnit_ID == null) {
wx.showToast({
title: '请选择会计单位'
})
return;
}
wx.navigateTo({
url: '../../goodaNameChooseTemplate/goodaNameChooseTemplate?unitID=' + dmo.AccountingUnit_ID + '&customerID' + dmo.Customer_ID,
})
},
// 存货明细页面更多按钮
moreBtnClick: function (e) {
moreBtnClick: function(e) {
var that = this;
var itemList = [
"审核",
@ -469,7 +438,7 @@ Page({
wx.showActionSheet({
itemList: itemList,
itemColor: "#2689f8",
success: function (res) {
success: function(res) {
// res.cancel 用户是不是点击了取消按钮
// res.tapIndex 数组元素的序号,从0开始
that.moreBtnClickedDetailInfo(itemList[res.tapIndex]);
@ -478,7 +447,7 @@ Page({
},
// 更多 -> 撤销 -> 审核
moreBtnClickedDetailInfo: function (item) {
moreBtnClickedDetailInfo: function(item) {
if (item == "审核") {
wx.showModal({
title: "提示",
@ -493,7 +462,7 @@ Page({
},
// 保存按钮
submitForm: function () {
submitForm: function() {
var dmo = this.data.dmo;
if (dmo.Customer_ID == null) {
@ -563,19 +532,19 @@ Page({
"ID": dmo.ID
}];
network.transfer_request(method, params, function (res) {
network.transfer_request(method, params, function(res) {
if (res.result != null) {
wx.showModal({
title: '新建预报No.' + res.result,
content: '新建成功,是否返回首页',
success: function (res) {
success: function(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
})
}
},
fail: function (res) { }
fail: function(res) {}
})
}
})


Loading…
Cancel
Save