123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- // pages/loadArrive/edit.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- showModal: false,
- defaultText: '请选择',
- isSubmitting: false,
- loadappointArray:[], //起卸预约
- loadappointIndex:null,
- fileList:[],
- minHour: 0,
- maxHour: 24,
- minDate: new Date().getTime(),
- maxDate: new Date(9999, 12, 31).getTime(),
- currentDate: new Date().getTime(),
- show: false,
- currentChoose: ''
- },
- openPicker() {
- this.setData({ show: true })
- },
- onConfirm(e) {
- this.setData({ show: false, currentChoose: this.formatDate(new Date(e.detail)) })
- },
- onClose() {
- this.setData({ show: false })
- },
- onCancel() {
- this.setData({ show: false })
- },
- formatDate(date) {
- let taskStartTime
- if (date.getMonth() < 9) {
- taskStartTime = date.getFullYear() + "-0" + (date.getMonth() + 1) + "-"
- } else {
- taskStartTime = date.getFullYear() + "-" + (date.getMonth() + 1) + "-"
- }
- if (date.getDate() < 10) {
- taskStartTime += "0" + date.getDate()
- } else {
- taskStartTime += date.getDate()
- }
- if (date.getHours() < 10) {
- taskStartTime += " " + "0" + date.getHours()
- } else {
- taskStartTime += " " + date.getHours()
- }
- if (date.getMinutes() < 10) {
- taskStartTime += ":" + "0" + date.getMinutes()
- } else {
- taskStartTime += ":" + date.getMinutes()
- }
- this.setData({
- taskStartTime: taskStartTime,
- })
- return taskStartTime;
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- //根据列表页面获取详情
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- let getInfo = prevPage.data.resData[options.index]
- //司机回签图片
- let fileList = []
- if(getInfo.sailFilePath){
- let unloadImgArr = getInfo.sailFilePath.split(',')
- unloadImgArr.forEach(element => {
- fileList.push({
- url: app.host.BASEIMG_URL+element,
- isImage:true
- })
- });
- }
- this.setData({
- info : getInfo,
- currentChoose : getInfo.arriveTime,
- fileList : fileList
- })
- //获取起卸预约信息
- this.getLoadappointData()
- },
- //选择起卸预约
- getLoadappointData:function(){
- app.request.GET({
- url: app.API.bizloadappointList,
- params: {'status' : '2,3'},
- page: this,
- successFun: true
- }).then(res => {
- let appointList = res.data.data
- appointList.forEach((element,index) => {
- // appointList[index].name = element.loadNumber + '-' + element.orderPrice
- appointList[index].name = element.loadNumber
- });
- this.setData({
- loadappointArray: appointList,
- loadappointIndex: app.util.getDicIndex(res.data.data, this.data.info.appointId, 'id')
- })
- })
- },
- //下拉选择
- bindPickerChange: function (e) { //下拉菜单
- let { pickername } = e.target.dataset
- let getIndex = pickername + 'Index'
- app.util.getPickerIndex(this, getIndex, e);
- // switch (pickername) {
- // case 'appointId': //报港预约
- // this.getSaleOrderData()
- // break;
- // }
- },
- //图片上传
- afterRead:function(event){
- const { file } = event.detail;
- const { type } = event.currentTarget.dataset
- app.request.uploadDIY({
- url: app.API.uploadImgMap,
- page: this,
- filePaths:file.url,
- setfiled:'file',
- params: {},
- //isToken: false,
- isLoading: false,
- successFun: true
- }).then(res => {
- const imgArray = this.data[type];
- imgArray.push({
- ...file,
- url: app.host.BASEIMG_URL + JSON.parse(res.data).data.imageFile,
- imgUrl: JSON.parse(res.data).data.imageFile
- });
- this.setData({
- [type]: imgArray
- });
- })
- },
- // 删除图片
- deleteImg: function (event) {
- const { type } = event.currentTarget.dataset
- let getFileList = this.data[type];
- getFileList.splice(event.detail.index, 1)
- this.setData({
- [type]: getFileList
- })
- },
- // 单选
- 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 = ""; //弹框时提示的内容
- if (value.appointId == '') {
- warn = "请选择起卸预约订单!";
- } else if(value.shipNo == ''){
- warn = "请输入船号!";
- } else if(value.arriveNumber == ''){
- warn = "请输入报港数量!";
- } else if(value.arriveTime == ''){
- warn = "请选择到港时间!";
- }
- /** 图片处理 START **/
- let getfileList = this.data.fileList
- if(getfileList.length < 1){
- warn = "请上传发航单!";
- }
- let fileNameList = []
- let filePathList = []
- getfileList.forEach((element,index) => {
- fileNameList.push('图片'+(index+1)+'.'+element.imgUrl.split('.')[1])
- filePathList.push(element.imgUrl)
- });
- value.fileNameList = fileNameList
- value.filePathList = filePathList
- /** 图片处理 END **/
- // 处理时间
- value.arriveTime = value.arriveTime + ":00"
- if (warn != '') {
- app.util.checkForm(warn);
- } else {
- app.request.POST({
- url: app.API.bizloadarriveEdit,
- 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 () {
- }
- })
|