纸通宝SAAS仓库
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.
 

98 lines
2.9 KiB

// pages/setting/paper-detial/index.js
import Scene from '../../index/scene'
import Dialog from '../../../components/dialog/dialog'
import { getCarInfo, saveCar, editCar, deleteCar } from "../../../api/saas"
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
form: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({ title: '正在获取', mask: true })
getCarInfo(options.id).then(result => {
wx.hideLoading()
this.setData({ form: result.data, safeBottom: app.globalData.safeBottom })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
showPlate: function(e){
if(e.currentTarget.id == 'plateNumber'){
this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard')
this.keyboard.show(this.data.form.plateNumber, 0)
} else {
var that = this
var events = {}
events.onCallback = function(data){
if (data.what == 121) {
that.data.form.driverId = data.detail.enterpriseMemberId
that.setData({ ['form.driverName']: data.detail.enterpriseMemberName })
}
}
wx.navigateTo({url: `/pages/home/employee/index?type=1`, events})
}
},
onPlatenumber: function({detail}){
if(detail && detail.plateNumber){
this.setData({ ['form.plateNumber']: detail.plateNumber })
}
},
deleteForm: function(e){
Dialog.confirm({ title: '温馨提示', message: '确定删除该纸品?' }).then(() => {
wx.showLoading({ title: '正在处理', mask: true })
deleteCar(this.data.form.id).then(result => {
wx.hideLoading()
util.showBackToast('删除成功')
event.emit('OrderMessage', { what: 201 })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}).catch(err => {
})
},
submitForm: function(e){
if(util.isEmpty(this.data.form.plateNumber)){
util.showToast('请输入车牌号码')
return
}
if(util.isEmpty(this.data.form.driverId)){
util.showToast('请选择司机')
return
}
wx.showLoading({ title: '正在处理', mask: true })
if(util.isEmpty(this.data.form.id)){
saveCar(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('添加成功')
event.emit('OrderMessage', { what: 201 })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
} else {
editCar(this.data.form).then(result => {
wx.hideLoading()
util.showBackToast('修改成功')
event.emit('OrderMessage', { what: 202, detail: this.data.form })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
}
})