123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- const util = require('../../utils/util')
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- currentTab: 0,
- bgColor: "linear-gradient(90deg, rgb(255, 118, 38), rgb(252, 30, 82))",
- navbar: [{
- name: "进库"
- }, {
- name: "出库"
- }],
- searchParams: {
- storeId: '',
- pageNo: 1,
- pageSize: 20,
- storeName: ''
- },
- params: {
- storeId: '',
- pageNo: 1,
- pageSize: 20,
- },
- storeList: [],
- orderList: [],
- loadding: false,
- pullUpOn: true,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.bindStoreList()
- this.bindOrderist()
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.setData({
- ["searchParams.pageNo"]: 1,
- pullUpOn: true,
- loadding: false,
- orderList: []
- })
- this.bindOrderist()
- setTimeout(() => {
- wx.stopPullDownRefresh()
- }, 300);
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- //只是测试效果,逻辑以实际数据为准
- this.setData({
- loadding: true,
- pullUpOn: true
- })
- var that = this
- this.setData({
- ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1
- })
- this.bindOrderist()
- },
- bindStorePickerChange: function (e) {
- var item = this.data.storeList[e.detail.value]
- console.log(item)
- this.setData({
- ['searchParams.storeId']: item.id,
- ['searchParams.storeName']: item.storeName,
- ["searchParams.pageNo"]: 1,
- orderList: []
- })
- this.bindOrderist()
- },
- changeTab(e) {
- console.log(e)
- this.setData({
- currentTab: e.detail.index,
- ["searchParams.pageNo"]: 1,
- pullUpOn: true,
- loadding: false,
- orderList: []
- })
- this.bindOrderist()
- },
- bindOrderist() {
- var that = this
-
- if (that.data.currentTab == 0) {
- // that.data.params.storeId = that.data.searchParams.storeId;
- that.data.params.pageNo = that.data.searchParams.pageNo;
- that.data.params.pageSize = that.data.searchParams.pageSize;
- that.data.params.productName = that.data.searchParams.productName;
- that.data.params.orderSn = that.data.searchParams.orderSn ? that.data.searchParams.orderSn : "";
- // that.data.params = Object.assign( that.data.params, that.data.searchParams)
- console.log(that.data.params)
- util.request(util.api.productOrderDetailPage, that.data.params, "GET", false, false, app.globalData.token).then((res) => {
- if (res.code == 200) {
- console.log(res)
- if (res.result.records.length > 0) {
- if (this.data.searchParams.pageNo > 1) {
- let list = that.data.orderList
- res.result.records.forEach(element => {
- var item = {}
- item.orderSn = element.orderSn
- item.productName = element.productName
- item.productNum = element.productQuantity
- list.push(item)
- });
- that.setData({
- orderList: list
- })
- } else {
- let list = []
- res.result.records.forEach(element => {
- var item = {}
- item.orderSn = element.orderSn
- item.productName = element.productName
- item.productNum = element.productQuantity
- list.push(item)
- });
- that.setData({
- orderList: list
- })
- }
- } else {
- if(this.data.searchParams.pageNo<=1){
- that.setData({
- loadding: false,
- pullUpOn: false,
- ["searchParams.pageNo"]: that.data.searchParams.pageNo - 1,
- orderList: []
- })
- }else{
- that.setData({
- loadding: false,
- pullUpOn: false,
- })
- }
-
- }
- }
- }).catch((res) => {})
- } else {
- if (!that.data.searchParams.storeId) {
- this.setData({
- orderList: []
- })
- return;
- }
- util.request(util.api.orderListPage, that.data.searchParams, "GET", false, false, app.globalData.token).then((res) => {
- if (res.code == 200) {
- if (res.result.records.length > 0) {
- if (this.data.searchParams.pageNo > 1) {
- let list = that.data.orderList
- res.result.records.forEach(element => {
- var item = {}
- item.orderSn = element.orderSn
- item.productName = element.productName
- item.productNum = 1
- list.push(item)
- });
- that.setData({
- orderList: list
- })
- } else {
- let list = []
- res.result.records.forEach(element => {
- var item = {}
- item.orderSn = element.orderSn
- item.productName = element.productName
- item.productNum = 1
- list.push(item)
- });
- that.setData({
- orderList: list
- })
- }
- } else {
- that.setData({
- loadding: false,
- pullUpOn: false,
- ["searchParams.pageNo"]: that.data.searchParams.pageNo - 1,
- orderList: []
- })
- }
- }
- }).catch((res) => {})
- }
- },
- bindStoreList() {
- var that = this
- util.request(util.api.storeList, {}, "GET", false, true, app.globalData.token).then((res) => {
- if (res.code == 200) {
- that.setData({
- storeList: res.result
- })
- }
- }).catch((res) => {})
- },
- serchOrderNo(e) {
- let _this = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- _this.data[name] = value;
- _this.setData({
- [name]: _this.data[name]
- });
- this.bindOrderist()
- }
- })
|