|
|
|
@ -17,6 +17,7 @@ Page({ |
|
|
|
collectionArray: [], |
|
|
|
customerArray: [], |
|
|
|
checkBoxArray: [], |
|
|
|
storageCheckBoxArray: [], |
|
|
|
}, |
|
|
|
|
|
|
|
getCustomerBySearchString:function(event){ |
|
|
|
@ -80,18 +81,44 @@ Page({ |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 点击了收藏按钮
|
|
|
|
// 收藏夹点击添加客户 存数据进入global
|
|
|
|
storageAddCustomerArrayBack: function () { |
|
|
|
let choseCheck = [] |
|
|
|
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
|
|
|
|
for (var i = 0; i < this.data.collectionArray.length; i++) { |
|
|
|
for (var j = 0; j < this.data.storageCheckBoxArray.length; j++) { |
|
|
|
if (Number(this.data.collectionArray[i].ID) == this.data.storageCheckBoxArray[j]) { |
|
|
|
choseCheck.push(this.data.collectionArray[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
app.globalData.customerArray = choseCheck; |
|
|
|
|
|
|
|
var pages = getCurrentPages(); |
|
|
|
var currPage = pages[pages.length - 1]; //当前页面
|
|
|
|
var prevPage = pages[pages.length - 2]; //上一个页面
|
|
|
|
//直接调用上一个页面对象的setData()方法,把数据存到上一个页面中去
|
|
|
|
prevPage.setData({ |
|
|
|
backPage: "customerChoosePage", |
|
|
|
}); |
|
|
|
|
|
|
|
wx.navigateBack({ |
|
|
|
delta: 1, |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 点击了收藏按钮 (参数数组为定义)
|
|
|
|
storegeBtnClick: function () { |
|
|
|
var that = this; |
|
|
|
|
|
|
|
// 获取收藏的存货信息
|
|
|
|
var oldCollectionArr = this.data.collectionArray; |
|
|
|
var waitStorageArr = this.data.checkBoxArray; |
|
|
|
var goodsNameArrayAll = this.data.goodsArray; |
|
|
|
var customerArrayAll = this.data.customerArray; |
|
|
|
|
|
|
|
if (waitStorageArr.length <= 0) { |
|
|
|
wx.showToast({ |
|
|
|
title: '请选择存货', |
|
|
|
title: '请选择客户', |
|
|
|
}) |
|
|
|
return; |
|
|
|
} else { |
|
|
|
@ -99,7 +126,7 @@ Page({ |
|
|
|
// 对比所选存货是否已经存在于收藏中 有:不重复添加 返回未添加过的数组
|
|
|
|
for (var i = 0; i < waitStorageArr.length; i++) { |
|
|
|
for (var j = 0; j < oldCollectionArr.length; j++) { |
|
|
|
if (Number(waitStorageArr[i]) == Number(oldCollectionArr[j].SaleGoods_ID)) { |
|
|
|
if (Number(waitStorageArr[i]) == Number(oldCollectionArr[j].ID)) { |
|
|
|
waitStorageArr.splice(i, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -107,10 +134,10 @@ Page({ |
|
|
|
|
|
|
|
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
|
|
|
|
let choseCheck = []; |
|
|
|
for (var i = 0; i < that.data.goodsArray.length; i++) { |
|
|
|
for (var i = 0; i < that.data.customerArray.length; i++) { |
|
|
|
for (var j = 0; j < waitStorageArr.length; j++) { |
|
|
|
if (Number(goodsNameArrayAll[i].SaleGoods_ID) == waitStorageArr[j]) { |
|
|
|
choseCheck.push(goodsNameArrayAll[i]) |
|
|
|
if (Number(customerArrayAll[i].ID) == waitStorageArr[j]) { |
|
|
|
choseCheck.push(customerArrayAll[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -120,7 +147,7 @@ Page({ |
|
|
|
currentTab: 1, |
|
|
|
}); |
|
|
|
wx.setStorage({ |
|
|
|
key: "storageGoodsKey", |
|
|
|
key: "storageCustomerKey", |
|
|
|
data: oldCollectionArr, |
|
|
|
success: function () { |
|
|
|
wx.showToast({ |
|
|
|
@ -131,6 +158,43 @@ Page({ |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 收藏夹页面多选框值变化
|
|
|
|
storageCheckboxValueChange: function (e) { |
|
|
|
|
|
|
|
// 新建预报页面只允许选取一位客户
|
|
|
|
if (fromPage == "newForecast" && e.detail.value.length > 0) { |
|
|
|
this.setData({ |
|
|
|
checkBoxArray: e.detail.value, |
|
|
|
}) |
|
|
|
this.storageAddCustomerArrayBack(); |
|
|
|
} |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
storageCheckBoxArray: e.detail.value, |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
var that =this; |
|
|
|
fromPage = options.fromePage; |
|
|
|
this.GetCustomer(); |
|
|
|
// 获取收藏的客户信息
|
|
|
|
wx.getStorage({ |
|
|
|
key: 'storageCustomerKey', |
|
|
|
success(res) { |
|
|
|
console.log(res.data); |
|
|
|
if (res.data.length > 0) { |
|
|
|
that.setData({ |
|
|
|
collectionArray: res.data, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 滑动切换tab |
|
|
|
*/ |
|
|
|
@ -156,13 +220,4 @@ Page({ |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
fromPage = options.fromePage; |
|
|
|
this.GetCustomer(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |