You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.6 KiB
118 lines
3.6 KiB
// pages/storage/index/index.js
|
|
import Scene from '../../index/scene'
|
|
import { getPoundInfo, getPaperList, createOutOrder } from "../../../api/saas"
|
|
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Scene({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
safeBottom: app.globalData.safeBottom,
|
|
form: null,
|
|
activeNames: [],
|
|
columns: [],
|
|
visible: false,
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(options.id){
|
|
wx.showLoading({ title: '正在获取', mask: true })
|
|
getPaperList({pageNum: 1, pageSize: 100}).then(result => {
|
|
this.data.paperList = result.data.records
|
|
this.data.columns = []
|
|
for (let index = 0; index < this.data.paperList.length; index++) {
|
|
this.data.columns.push(this.data.paperList[index].name)
|
|
}
|
|
this.setData({ safeBottom: app.globalData.safeBottom, columns: this.data.columns })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
this.setData({ safeBottom: app.globalData.safeBottom })
|
|
util.showToast(err)
|
|
})
|
|
getPoundInfo(options.id).then(result => {
|
|
wx.hideLoading()
|
|
result.data.sign = 1
|
|
this.setData({ form: result.data })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
},
|
|
chooseFactory: function(){
|
|
var that = this
|
|
wx.navigateTo({
|
|
url: `/pages/home/factory-list/index?type=1`,
|
|
events: {
|
|
onCallback: (data) => {
|
|
if (data.what == 140) {
|
|
that.data.form.facttoryId = data.detail.id
|
|
that.setData({ ['form.factoryName']: data.detail.name })
|
|
}
|
|
}
|
|
}
|
|
})
|
|
},
|
|
showPlate: function (e) {
|
|
this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard')
|
|
this.keyboard.show(this.data.form.plateNumber, 0)
|
|
},
|
|
onPlatenumber: function({detail}){
|
|
if(detail && detail.plateNumber){
|
|
this.setData({ ['form.plateNumber']: detail.plateNumber })
|
|
}
|
|
},
|
|
showCategory: function(){
|
|
if(this.data.columns.length <= 0){
|
|
wx.showLoading({ title: '正在获取', mask: true })
|
|
getPaperList({pageNum: 1, pageSize: 100}).then(result => {
|
|
this.data.paperList = result.data.records
|
|
this.data.columns = []
|
|
for (let index = 0; index < this.data.paperList.length; index++) {
|
|
this.data.columns.push(this.data.paperList[index].name)
|
|
}
|
|
this.setData({ visible: true, columns: this.data.columns })
|
|
}).catch(err => {
|
|
util.showToast(err)
|
|
})
|
|
} else {
|
|
this.setData({ visible: true })
|
|
}
|
|
},
|
|
onConfirm: function({detail}){
|
|
this.data.nowItem = this.data.paperList[detail.index]
|
|
this.data.form.productId = this.data.nowItem.id
|
|
this.setData({ visible: false, ['form.productName']: detail.value })
|
|
},
|
|
onChange: function({detail}) {
|
|
this.setData({ activeNames: detail });
|
|
},
|
|
submitForm: function(){
|
|
if(util.isEmpty(this.data.form.factoryName)){
|
|
util.showToast('请选择出货方名称')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.productId) || Number(this.data.form.productId) <= 0){
|
|
util.showToast('请选择废纸品类')
|
|
return
|
|
}
|
|
if(util.isEmpty(this.data.form.plateNumber)){
|
|
util.showToast('请输入车牌号码')
|
|
return
|
|
}
|
|
wx.showLoading({ title: '正在处理', mask: true })
|
|
createOutOrder(this.data.form).then(result => {
|
|
wx.hideLoading()
|
|
util.showBackToast('处理成功')
|
|
event.emit('OrderMessage', { what: 20, desc: 'cancelOrder' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
})
|
|
}
|
|
})
|