123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- // pages/reservationLoadAppoint/edit.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- showModal: false,
- defaultText: '请选择',
- isSubmitting: false,
- loadPointArray:[], //装货点位
- loadPointIndex:null,
- loadTimeArray:[], //装卸时间
- loadTimeIndex:null,
- excessConfigArray:[], //装卸时间
- excessConfigIndex:null,
- isKeyboard: false, //是否显示车牌输入键盘
- inputOnFocusIndex: '', //当前锁定的车号位置
- licensePlate: '', //用于提交
- inputPlates: '', //用于显示
- },
- //输入框焦点聚焦时隐藏车牌号输入框
- hideKeybord: function () {
- this.setData({
- isKeyboard: false,
- inputOnFocusIndex: ''
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- //获取详情
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- let getInfo = prevPage.data.resData[options.index]
- let getCarNumArr = getInfo.licenseNumber ? getInfo.licenseNumber.split('') : ''
- let inputPlates = {};
- for (let i = 0; i < getCarNumArr.length; i++) {
- inputPlates['index' + i] = getCarNumArr[i]
- }
- this.setData({
- info: getInfo,
- orderId: getInfo.orderId,
- inputPlates: inputPlates,
- isNewEnergy: getCarNumArr.length > 7 ? true : false,
- licensePlate: getInfo.licenseNumber,
- })
- //获取装卸点位下拉列表
- this.loadPointData()
-
- //获取车辆轴数下拉列表
- this.getCarzheData()
- app.request.GET({
- url: app.API.bizloadappointDetail,
- params: {'id' : getInfo.orderId},
- page: this,
- successFun: true
- }).then(res => {
- let getInfo = res.data.data;
- this.setData({
- loadNumber : getInfo.loadNumber,
- customerName : getInfo.customerName,
- goodsName : getInfo.goodsName,
- goodsModel : getInfo.goodsModel,
- })
- })
- },
- //获取装卸点位下拉列表
- loadPointData:function(){
- app.request.GET({
- url: app.API.bizloaddispatchList,
- params: {
- 'appointId': this.data.orderId,
- 'loadType': '2'
- },
- page: this,
- successFun: true
- }).then(res => {
- this.setData({
- loadPointArray : res.data.data,
- loadPointIndex : this.data.info.loadPointId?app.util.getDicIndex(res.data.data, this.data.info.loadPointId, 'loadPointId'):null
- })
- console.info("this.data.info.loadPointIndex---" + this.data.loadPointIndex)
- if(this.data.info.loadPointId){
- this.loadTimeData()
- }
- })
- },
- //装卸时间
- loadTimeData:function(){
- app.request.GET({
- url: app.API.bizloaddispatchTimeList,
- params: {
- orderId : this.data.orderId,
- loadPointId : this.data.loadPointArray[this.data.loadPointIndex].loadPointId,
- loadType : '2'
- },
- page: this,
- successFun: true
- }).then(res => {
- let loadTimeList = res.data.data
- loadTimeList.forEach((element,index) => {
- loadTimeList[index].time = element.beginTime + '~' + element.endTime
- });
- this.setData({
- loadTimeArray : loadTimeList,
- loadTimeIndex : this.data.info.loadTimeId?app.util.getDicIndex(loadTimeList, this.data.info.loadTimeId, 'loadTimeId'):null
- })
- console.info("this.data.info.loadTimeIndex---" + this.data.loadTimeIndex)
- })
- },
- //获取车辆轴数下拉列表
- getCarzheData:function(){
- app.request.GET({
- url: app.API.bizexcessconfigList,
- params: {},
- page: this,
- successFun: true
- }).then(res => {
- let excessConfigList = res.data.data
- excessConfigList.forEach((element,index) => {
- excessConfigList[index].name = element.vehicleAxleNumber+'轴'
- });
- this.setData({
- excessConfigArray : excessConfigList,
- excessConfigIndex : this.data.info.overId?app.util.getDicIndex(excessConfigList, this.data.info.overId, 'id'):null
- })
- console.info("this.data.info.excessConfigIndex---" + this.data.excessConfigIndex)
- })
- },
- //获取车牌号
- licensePlate: function (e) {
- this.setData({
- licensePlate: e.detail.carNum
- })
- },
- //下拉选择
- bindPickerChange: function (e) {
- let { pickername } = e.target.dataset
- let getIndex = pickername + 'Index'
- app.util.getPickerIndex(this, getIndex, e);
- switch (pickername) {
- case 'loadPoint': //装货点位
- this.loadTimeData() //获取装货时间
- break;
- }
- },
- // 单选
- dangerStatusChange: function (e) {
- this.setData({
- [e.currentTarget.dataset.radiotype]: e.detail.value
- })
- },
- //多选
- checkboxChange: function (e) {
- this.setData({
- [e.currentTarget.dataset.checkboxtype]: e.detail
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- bindscrolltolowerFun() {
-
- },
- //表单提交 carTaskAdd
- formSubmit: function ({detail:{value}}) {
- var warn = ""; //弹框时提示的内容
- let reg = /^1[3-9]\d{9}$/;
- var xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
- var creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
- //value.certificateNoImage = this.data.originalInvoicePhoto
- if (value.orderId == '') {
- warn = "请选择起卸预约订单!";
- } else if (value.licenseNumber == '') {
- warn = "车牌不能为空!";
- } else if (value.licenseNumber.length < 7) {
- warn = "请选择完整车牌号!";
- } else if (value.licenseNumber.length == 7 && !creg.test(value.licenseNumber)) {
- warn = "车牌号格式错误!";
- } else if (value.licenseNumber.length == 8 && !xreg.test(value.licenseNumber)) {
- warn = "车牌号格式错误!";
- } else if (value.overId == '') {
- warn = "请选择车辆轴数!";
- } else if(value.driverName == ''){
- warn = "请输入司机姓名!";
- } else if(value.driverMobile == ''){
- warn = "请输入司机电话!";
- }
- if (warn != '') {
- app.util.checkForm(warn);
- } else {
- app.request.POST({
- url: app.API.loadEdit,
- params: value,
- page: this,
- isLoadingTxt: '提交中...',
- isSubmitting: true,
- successFun: true
- }).then(res => {
- wx.showToast({
- title: '修改成功',
- icon: 'success',
- duration: 2000,
- mask:true,
- complete: function () {
- setTimeout(() => {
- wx.navigateBack()
- }, 1500) //延迟时间
- }
- })
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|