// pages/specialOrderApplication/creatNewSpecialOrder/creatNewSpecialOrder.js
|
|
|
|
var network = require("../../../utils/net.js");
|
|
const app = getApp();
|
|
var dateTimePicker = require('../../../utils/dateTimePicker.js');
|
|
var timechage = require("../../../utils/dateTimeUtil.js")
|
|
|
|
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,
|
|
unit: res.result
|
|
})
|
|
})
|
|
that.setData({
|
|
which: "会计部门"
|
|
})
|
|
}
|
|
|
|
Page({
|
|
|
|
data: {
|
|
currentTab: 0,
|
|
winHeight: app.globalData.winHeight,
|
|
|
|
starTime: timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D'),
|
|
endTime: timechage.formatTimeTwo(Date.parse(new Date()), 'Y-M-D'),
|
|
|
|
dateTimeArray: null,
|
|
dateTime: null,
|
|
startYear: 2018,
|
|
endYear: 2030,
|
|
|
|
// 用户数组
|
|
customerArr:[],
|
|
// 存货数组
|
|
goodsNameArr:[],
|
|
|
|
which: "",
|
|
idx: 0,
|
|
currency: [],
|
|
saletypeIndex: 0,
|
|
saletype: [{
|
|
ID: 0,
|
|
Name: "请选择销售类型"
|
|
}],
|
|
|
|
customerIndex: 0,
|
|
customer: [{
|
|
ID: 0,
|
|
Name: "请选择客户"
|
|
}],
|
|
isUnit: 0,
|
|
unit: [],//会计单位
|
|
departmentIndex: 0,
|
|
department: [],//销售部门
|
|
addrs: "",
|
|
},
|
|
|
|
// 存货特价开始时间
|
|
bindStartTimeChange: function (e) {
|
|
var itemIndex = e.currentTarget.dataset.index;
|
|
var array = this.data.goodsNameArr;
|
|
array[itemIndex]["applicationStartTime"]= e.detail.value,
|
|
this.setData({
|
|
goodsNameArr: array,
|
|
})
|
|
},
|
|
|
|
// 存货特价结束时间
|
|
bindEndTimeChange: function (e) {
|
|
var itemIndex = e.currentTarget.dataset.index;
|
|
var array = this.data.goodsNameArr;
|
|
array[itemIndex]["applicationEndTime"] = e.detail.value,
|
|
this.setData({
|
|
goodsNameArr: array,
|
|
})
|
|
},
|
|
|
|
// 基本信息日期
|
|
changeDateTime(e) {
|
|
this.setData({
|
|
dateTime: e.detail.value
|
|
});
|
|
|
|
},
|
|
|
|
// 添加客户
|
|
addCustomer: function(){
|
|
wx.navigateTo({
|
|
url: '../../customerChooseTemplate/customerChooseTemplate',
|
|
})
|
|
},
|
|
|
|
// 添加存货
|
|
addGoodsName: function(){
|
|
wx.navigateTo({
|
|
url: '../../goodaNameChooseTemplate/goodaNameChooseTemplate',
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 滑动切换tab
|
|
*/
|
|
bindChange: function (e) {
|
|
var that = this;
|
|
that.setData({
|
|
currentTab: e.detail.current
|
|
});
|
|
},
|
|
/**
|
|
* 点击tab切换
|
|
*/
|
|
swichNav: function (e) {
|
|
var that = this;
|
|
if (this.data.currentTab === e.target.dataset.current) {
|
|
return false;
|
|
} else {
|
|
that.setData({
|
|
currentTab: e.target.dataset.current
|
|
})
|
|
}
|
|
},
|
|
|
|
// 遮罩的搜索框事件
|
|
select: function (e) {
|
|
var that = this;
|
|
// 自定义的类型
|
|
var which = e.currentTarget.dataset.item;
|
|
// 输入的值
|
|
var value = e.detail.value;
|
|
if (which == "会计部门") {
|
|
GetAccountingUnit(that, value)
|
|
} else if (which == "购货客户") {
|
|
GetCustomer(that, value)
|
|
} else if (which == "部门") {
|
|
GetDepartment(that, value)
|
|
} else if (which == "销售类型") {
|
|
GetSaleKind(that, value)
|
|
}
|
|
},
|
|
|
|
// 判断条件进行遮罩内容选取
|
|
powerDrawer: function (e) {
|
|
let that = this;
|
|
let x = e.currentTarget.dataset.x;
|
|
if (x == "会计部门") {
|
|
GetAccountingUnit(that, "")
|
|
} else if (x == "购货客户") {
|
|
GetCustomer(that, "")
|
|
} else if (x == "部门") {
|
|
GetDepartment(that, "")
|
|
} else if (x == "销售类型") {
|
|
GetSaleKind(that, "")
|
|
}
|
|
let currentStatu = e.currentTarget.dataset.statu;
|
|
// 添加动画打开遮罩
|
|
this.util(currentStatu)
|
|
},
|
|
|
|
// 遮罩层点击选中具体条目
|
|
itemclick: function (e) {
|
|
var that = this;
|
|
var which = e.currentTarget.dataset.item;
|
|
var idx = e.currentTarget.dataset.idx;
|
|
|
|
if (which == "会计部门") {
|
|
that.setData({
|
|
isUnit: idx
|
|
})
|
|
} else if (which == "购货客户") {
|
|
that.setData({
|
|
customerIndex: idx
|
|
})
|
|
GetSpecifiedCustomer(that, idx)
|
|
} else if (which == "部门") {
|
|
that.setData({
|
|
departmentIndex: idx
|
|
})
|
|
} else if (which == "销售类型") {
|
|
that.setData({
|
|
saletypeIndex: idx
|
|
})
|
|
}
|
|
this.setData({
|
|
showModalStatus: false,
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 存货明细保存按钮 点击新建单据 内部做逻辑判断 存储值是否都已经加载
|
|
*/
|
|
creatNewSpecialOrder:function (){
|
|
var that =this;
|
|
// 会计单位
|
|
let unitID = this.data.unit[this.data.isUnit].ID;
|
|
|
|
let year = this.data.dateTimeArray[0][this.data.dateTime[0]]
|
|
let month = this.data.dateTimeArray[1][this.data.dateTime[1]]
|
|
let date = this.data.dateTimeArray[2][this.data.dateTime[2]]
|
|
let hour = this.data.dateTimeArray[3][this.data.dateTime[3]]
|
|
let minu = this.data.dateTimeArray[4][this.data.dateTime[4]]
|
|
|
|
let stringTime = year + "/" + month + "/" + date + " " + hour + ":" + minu + ":00"
|
|
let timestamp2 = Date.parse(new Date(stringTime));
|
|
// 基本信息时间转换
|
|
let update = "/Date(" + timestamp2 + "+0800)/";
|
|
|
|
//应该是从存货数组中获取对应的时间
|
|
|
|
// 存货明细起止时间转换
|
|
let guaranteeDate = timechage.formatymdERTDate(this.data.starTime);
|
|
let payDate = timechage.formatymdERTDate(this.data.endTime);
|
|
|
|
},
|
|
|
|
// 删除客户明细
|
|
deleteCustomerItem: function (event) {
|
|
var id = event.target.dataset.idx;
|
|
var array = this.data.customerArr;
|
|
array.splice(id, 1);
|
|
this.setData({
|
|
customerArr: array,
|
|
})
|
|
},
|
|
|
|
// 删除存货明细
|
|
deleteGoodsItem:function(event){
|
|
var id = event.target.dataset.id;
|
|
var array = this.data.goodsNameArr;
|
|
array.splice(id, 1);
|
|
this.setData({
|
|
goodsNameArr:array,
|
|
})
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
// 获取完整的年月日 时分秒,以及默认显示的数组
|
|
var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|
// 精确到分的处理,将数组的秒去掉
|
|
var lastArray = obj1.dateTimeArray.pop();
|
|
var lastTime = obj1.dateTime.pop();
|
|
|
|
this.setData({
|
|
dateTimeArray: obj1.dateTimeArray,
|
|
dateTime: obj1.dateTime,
|
|
unit: [{
|
|
ID: app.globalData.accountingUnit_ID,
|
|
Name: app.globalData.accountingUnit_Name
|
|
}],
|
|
department: [{
|
|
ID: app.globalData.department_ID,
|
|
Name: app.globalData.department_Name
|
|
}],
|
|
});
|
|
},
|
|
|
|
onShow: function () {
|
|
var that = this;
|
|
|
|
// 返回的用户只能是一条,所以index只能为0
|
|
var currentCustomerArr = app.globalData.customerArray;
|
|
if (currentCustomerArr.length > 0) {
|
|
this.setData({
|
|
customerArr: currentCustomerArr,
|
|
})
|
|
}
|
|
|
|
// 获取存货 加载完成后计算价格政策
|
|
var goodsArr = 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 infoprice = goodsArr[i].Price;
|
|
if (infoprice == null){
|
|
infoprice ="请输入原单价";
|
|
}
|
|
// 特价
|
|
var policyPrice ="请输入特价价格";
|
|
// 开始时间
|
|
var infoStartTime ="请选择开始时间";
|
|
// 结束时间
|
|
var infoEndTime = "请选择结束时间";
|
|
// 申请数量
|
|
var infoNum = "请输入申请数量";
|
|
|
|
let goodsNameObj = {
|
|
Goods_Name: name,
|
|
SaleGoods_ID: Number(id),
|
|
Price: infoprice,
|
|
applicationPrice: policyPrice,
|
|
applicationStartTime: infoStartTime,
|
|
applicationEndTime: infoEndTime,
|
|
applicationNum: infoNum,
|
|
}
|
|
backGoodsArr.push(goodsNameObj)
|
|
console.log(backGoodsArr);
|
|
|
|
}
|
|
|
|
this.setData({
|
|
goodsNameArr: backGoodsArr,
|
|
})
|
|
}
|
|
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
app.globalData.goodsNameArray = [];
|
|
app.globalData.customerArray = [];
|
|
},
|
|
|
|
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()参数,返回值是日期和时间
|
|
// var timet = utilll.formatTime(new Date());
|
|
// 再通过setData更改Page()里面的data,动态更新页面的数据
|
|
this.setData({
|
|
// time: timet,
|
|
showModalStatus: true,
|
|
});
|
|
}
|
|
},
|
|
util1: 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({
|
|
showModalStatus1: false
|
|
});
|
|
}
|
|
}.bind(this), 200)
|
|
|
|
// 显示
|
|
if (currentStatu == "open") {
|
|
// 调用函数时,传入new Date()参数,返回值是日期和时间
|
|
// var timet = utilll.formatTime(new Date());
|
|
// 再通过setData更改Page()里面的data,动态更新页面的数据
|
|
this.setData({
|
|
// time: timet,
|
|
showModalStatus1: true
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
})
|