Browse Source

1、存货页面货物收藏逻辑

2、存货,客户,搜索条件
master
chenxuhui 7 years ago
parent
commit
97c436d8f5
6 changed files with 147 additions and 69 deletions
  1. +6
    -1
      pages/customerChooseTemplate/customerChooseTemplate.js
  2. +2
    -20
      pages/customerChooseTemplate/customerChooseTemplate.wxml
  3. +1
    -1
      pages/customerChooseTemplate/customerChooseTemplate.wxss
  4. +117
    -35
      pages/goodaNameChooseTemplate/goodaNameChooseTemplate.js
  5. +13
    -12
      pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxml
  6. +8
    -0
      pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxss

+ 6
- 1
pages/customerChooseTemplate/customerChooseTemplate.js View File

@ -18,7 +18,12 @@ Page({
checkBoxArray: [],
},
GetCustomer: function(inputValue) {
getCustomerBySearchString:function(event){
var searchStr =event.detail.value;
this.GetCustomer(searchStr);
},
GetCustomer: function (inputValue) {
var that =this;
let method = getCustomer;
let params = [{


+ 2
- 20
pages/customerChooseTemplate/customerChooseTemplate.wxml View File

@ -1,16 +1,8 @@
<!--pages/customerChooseTemplate/customerChooseTemplate.wxml-->
<view class="swiper-tab">
<view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">全部</view>
<view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">收藏夹</view>
</view>
<swiper current="{{currentTab}}" class="swiper-box" style='height:{{winHeight - 50}}px' duration="300" bindchange="bindChange">
<!-- 全部 -->
<swiper current="{{currentTab}}" class="swiper-box" style='height:{{winHeight}}px' duration="300" bindchange="bindChange">
<swiper-item class="swiper-items1">
<view class='searchView'>
<input class='imput_goodsName' bindinput='getGoodsName' type='text' placeholder='请输入存货名称' placeholder-style='color:rgb(202, 202, 202)'></input>
<view class='storageView'>收藏</view>
<input class='imput_goodsName' bindinput='getCustomerBySearchString' type='text' placeholder='请输入搜索条件' placeholder-style='color:rgb(202, 202, 202)'></input>
</view>
<scroll-view scroll-x="false" scroll-y="true" class='scroll-views' bindscrolltoupper="unCheckedScrollUpper" bindscrolltolower="unCheckedScrollLower">
<view class='listBackGroundView'>
@ -25,16 +17,6 @@
<view class='addGoodsName' catchtap='addCustomerName'>添加存货明细</view>
</swiper-item>
<!-- 收藏夹 -->
<swiper-item class="swiper-items2">
<scroll-view scroll-x="false" scroll-y="true" class='scroll-views' bindscrolltoupper="checkedScrollUpper" bindscrolltolower="CheckedScrollLower">
<checkbox-group bindchange="checkboxValueChange">
<block wx:for="{{CollectionArray}}" wx:key="item" wx:for-index="idx">
<template is="customerChoiceTemplate" data="{{item}}" />
</block>
</checkbox-group>
</scroll-view>
</swiper-item>
</swiper>


+ 1
- 1
pages/customerChooseTemplate/customerChooseTemplate.wxss View File

@ -57,7 +57,7 @@ page{
.imput_goodsName{
border: 1rpx solid rgb(236, 231, 231);
height: 100%;
width: 85%;
width: 100%;
border-radius: 10rpx;
background-color: #fff;
text-align: center;


+ 117
- 35
pages/goodaNameChooseTemplate/goodaNameChooseTemplate.js View File

@ -4,7 +4,9 @@ var network = require("../../utils/net.js")
var dateTimePicker = require('../../utils/dateTimePicker.js');
var utilll = require('../../utils/util.js');
var getAccountingUnit = "/MainSystem/B3MiniProgramRpc/Rpcs/BaseInfoRpc/GetAccountingUnit";
var unitID = null;
var customerID = null;
var getGoods = "/MainSystem/B3MiniProgramRpc/Rpcs/BaseInfoRpc/GetGoodsWithUnitPrice";
Page({
@ -12,55 +14,145 @@ Page({
data: {
winHeight: app.globalData.winHeight,
currentTab: 0,
collectionArray:[],
goodsArray:[],
checkBoxArray:[],
collectionArray: [],
goodsArray: [],
checkBoxArray: [],
storageCheckBoxArray: [],
},
getGoodsNameBySearchString: function (event){
var searchString = event.detail.value;
this.GetGoodsWithUnitPrice(unitID, customerID, searchString);
},
GetGoodsWithUnitPrice: function (unitID, customerID) {
var that =this;
GetGoodsWithUnitPrice: function(unitID, customerID, searchString) {
var that = this;
let timestamp = Date.parse(new Date());
let date = "/Date(" + timestamp + "+0800)/";
let method = getGoods;
let params = [{
"Input": "",
"Input": searchString,
"PageIndex": 0,
"PageSize": 100,
"Customer_ID": parseInt(customerID),
"AccountingUnit_ID": parseInt(unitID),
"Date": date
}];
network.transfer_request(method, params, function (res) {
network.transfer_request(method, params, function(res) {
that.setData({
goodsArray: res.result,
})
})
},
// GetCustomer: function(inputValue) {
// var that =this;
// let method = getCustomer;
// let params = [{
// "InputValue": inputValue,
// "PageIndex": 0,
// "PageSize": 100
// }];
// network.transfer_request(method, params, function(res) {
// that.setData({
// customerArray: res.result
// })
// })
// },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
// 根据客户id和会计单位获取存货及价格
var that = this;
unitID = options.unitID;
customerID = options.customerID;
this.GetGoodsWithUnitPrice(unitID, customerID, "");
// 获取收藏的存货信息
wx.getStorage({
key: 'storageGoodsKey',
success(res) {
console.log(res.data);
if (res.data.length > 0) {
that.setData({
collectionArray: res.data,
})
}
}
})
},
storegeBtnClick: function() {
var that = this;
// 获取收藏的存货信息
var oldCollectionArr = this.data.collectionArray;
var waitStorageArr = this.data.checkBoxArray;
var goodsNameArrayAll = this.data.goodsArray;
if (waitStorageArr.length <= 0) {
wx.showToast({
title: '请选择存货',
})
return;
} else {
// 对比所选存货是否已经存在于收藏中 有:不重复添加 返回未添加过的数组
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)) {
waitStorageArr.splice(i, 1);
}
}
}
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
let choseCheck = [];
for (var i = 0; i < that.data.goodsArray.length; i++) {
for (var j = 0; j < waitStorageArr.length; j++) {
if (Number(goodsNameArrayAll[i].SaleGoods_ID) == waitStorageArr[j]) {
choseCheck.push(goodsNameArrayAll[i])
}
}
}
oldCollectionArr = oldCollectionArr.concat(choseCheck);
that.setData({
collectionArray: oldCollectionArr,
currentTab: 1,
});
wx.setStorage({
key: "storageGoodsKey",
data: oldCollectionArr,
success: function() {
wx.showToast({
title: '收藏成功',
});
},
})
}
},
// 多选框数值变化
checkboxValueChange: function (e) {
checkboxValueChange: function(e) {
this.setData({
checkBoxArray: e.detail.value,
})
},
// 点击添加存货明细按钮 存数据进入global
addGoodsName:function(){
// 收藏夹页面多选框值变化
storageCheckboxValueChange:function (e){
this.setData({
storageCheckBoxArray: e.detail.value,
})
},
// 收藏夹点击添加存货明细按钮 存数据进入global
storageAddGoodsNameArrayBack: 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].SaleGoods_ID) == this.data.storageCheckBoxArray[j]) {
choseCheck.push(this.data.collectionArray[i])
}
}
}
app.globalData.goodsNameArray = choseCheck;
wx.navigateBack({
delta: 1,
})
},
// 全部页面点击添加存货明细按钮 存数据进入global
addGoodsName: function() {
let choseCheck = []
// 对比原有数组和选中的数组 存在,将数组包含的其他值也取出加载
for (var i = 0; i < this.data.goodsArray.length; i++) {
@ -101,14 +193,4 @@ Page({
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let unitID = options.unitID;
let customerID = options.customerID;
this.GetGoodsWithUnitPrice(unitID, customerID);
},
})

+ 13
- 12
pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxml View File

@ -9,8 +9,8 @@
<!-- 全部 -->
<swiper-item class="swiper-items1">
<view class='searchView'>
<input class='imput_goodsName' bindinput='getGoodsName' type='text' placeholder='请输入存货名称' placeholder-style='color:rgb(202, 202, 202)'></input>
<view class='storageView'>收藏</view>
<input class='imput_goodsName' bindinput='getGoodsNameBySearchString' type='text' placeholder='请输入存货名称' placeholder-style='color:rgb(202, 202, 202)'></input>
<view class='storageView' catchtap='storegeBtnClick'>收藏</view>
</view>
<scroll-view scroll-x="false" scroll-y="true" class='scroll-views' bindscrolltoupper="unCheckedScrollUpper" bindscrolltolower="unCheckedScrollLower">
<view class='listBackGroundView'>
@ -20,28 +20,29 @@
</block>
</checkbox-group>
</view>
</scroll-view>
<view class='addGoodsName' catchtap='addGoodsName'>添加存货明细</view>
</swiper-item>
<!-- 收藏夹 -->
<swiper-item class="swiper-items2">
<scroll-view scroll-x="false" scroll-y="true" class='scroll-views' bindscrolltoupper="checkedScrollUpper" bindscrolltolower="CheckedScrollLower">
<checkbox-group bindchange="checkboxValueChange">
<block wx:for="{{CollectionArray}}" wx:key="item" wx:for-index="idx">
<template is="customerChoiceTemplate" data="{{item}}" />
</block>
</checkbox-group>
<scroll-view scroll-x="false" scroll-y="true" class='storage-scroll-views' bindscrolltoupper="checkedScrollUpper" bindscrolltolower="CheckedScrollLower">
<view class='listBackGroundView'>
<checkbox-group bindchange="storageCheckboxValueChange">
<block wx:for="{{collectionArray}}" wx:key="item" wx:for-index="idx">
<template is="customerChoiceTemplate" data="{{item}}" />
</block>
</checkbox-group>
</view>
</scroll-view>
<view class='addGoodsName' catchtap='storageAddGoodsNameArrayBack'>添加存货明细</view>
</swiper-item>
</swiper>
<template name="customerChoiceTemplate">
<view class='listItem'>
<view class='itemClass'>{{item.Goods_Name}}</view>
<checkbox value="{{item.SaleGoods_ID}}"/>
<checkbox value="{{item.SaleGoods_ID}}" />
</view>
<view class='horizontallineView'></view>
</template>

+ 8
- 0
pages/goodaNameChooseTemplate/goodaNameChooseTemplate.wxss View File

@ -80,6 +80,14 @@ page{
flex-direction: column;
}
.storage-scroll-views {
margin-top: 25rpx;
height: calc(100% - 45px);
width: 100%;
display: flex;
flex-direction: column;
}
.listBackGroundView{
background-color: #fff;
}


Loading…
Cancel
Save