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.
589 lines
16 KiB
589 lines
16 KiB
// pages/meLogistics/meLogistics.js
|
|
//自建物流
|
|
var datePicker = require('../../utils/dateSetting')
|
|
var request = require('../../utils/http')
|
|
var dateUtils = require('../../utils/dateUtils')
|
|
|
|
//设定当前的时间,将其设定为常量
|
|
Page({
|
|
data: {
|
|
pipenum: '',
|
|
selfOrderCode: '', //物流单号
|
|
ins: [], //送检机构 服务端获取
|
|
insName: '', //机构列表名称
|
|
insIdx: 0, //当前所选机构下标
|
|
bushList: ['自建物流'], //运输方式 服务端获取
|
|
bush: '0', //运输方式下标
|
|
date: '', //当天日期
|
|
start: '2020-01-01',
|
|
end: '',
|
|
|
|
boxNum: '', //转运箱号
|
|
boxList: [], //查询回来的转运箱列表
|
|
boxIdx: '', //选择的下标
|
|
|
|
time: '', //出发时间
|
|
multiArray: [],
|
|
multiIndex: [0, 0, 0, 0, 0],
|
|
choose_year: "",
|
|
|
|
time1: '', //到达时间
|
|
multiArray1: [],
|
|
multiIndex1: [0, 0, 0, 0, 0],
|
|
choose_year1: "",
|
|
|
|
numberplate: '', //车牌号
|
|
numberplateIdx:'', //牌照角标
|
|
numberplateArr:[], //牌照号组
|
|
numberplateList:[], //车辆集合
|
|
|
|
logisticsMen: '', //物流员
|
|
number: '', //数量
|
|
notes: '', //备注
|
|
driverMen: '', //驾驶员
|
|
// srcArray: [], //样本组?
|
|
potoSrc: '../../images/addPoto.png', //默认图片
|
|
poto: [], //车辆&转运箱照片&样本 最大长度 12
|
|
tableArr: [], //扫码表数据
|
|
sampleCount: '0', //样本数量
|
|
//样本列表
|
|
sampleList: [],
|
|
},
|
|
|
|
//调用摄像头扫描样本码
|
|
scacode() {
|
|
wx.scanCode({
|
|
success: (res) => {
|
|
this.setData({
|
|
pipenum: res.result
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
//样本拍照
|
|
phot() {
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image', 'video'],
|
|
sourceType: ['album', 'camera'],
|
|
maxDuration: 30,
|
|
camera: 'back',
|
|
success: res => {
|
|
console.log(this.data.srcI)
|
|
console.log(res.tempFiles[0].tempFilePath)
|
|
// this.up();
|
|
}
|
|
})
|
|
},
|
|
|
|
//物流车拍照
|
|
bushPhot() {
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image', 'video'],
|
|
sourceType: ['album', 'camera'],
|
|
maxDuration: 30,
|
|
camera: 'back',
|
|
success: res => {
|
|
// this.up();
|
|
}
|
|
})
|
|
},
|
|
|
|
//转运箱拍照
|
|
boxPhot(e) {
|
|
console.log(e.target.dataset.id);
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image', 'video'],
|
|
sourceType: ['album', 'camera'],
|
|
maxDuration: 30,
|
|
camera: 'back',
|
|
success: res => {
|
|
// this.up();
|
|
}
|
|
})
|
|
},
|
|
|
|
//物流车、转运箱拍照
|
|
photograph(e) {
|
|
var potoIdx = 0;
|
|
if (e.target.dataset.id == 'car_0') potoIdx = 0
|
|
if (e.target.dataset.id == 'car_1') potoIdx = 1
|
|
if (e.target.dataset.id == 'car_2') potoIdx = 2
|
|
if (e.target.dataset.id == 'car_3') potoIdx = 3
|
|
if (e.target.dataset.id == 'box_0') potoIdx = 4
|
|
if (e.target.dataset.id == 'box_1') potoIdx = 5
|
|
if (e.target.dataset.id == 'box_2') potoIdx = 6
|
|
if (e.target.dataset.id == 'box_3') potoIdx = 7
|
|
if (e.target.dataset.id == 'sam_0') potoIdx = 8
|
|
if (e.target.dataset.id == 'sam_1') potoIdx = 9
|
|
if (e.target.dataset.id == 'sam_2') potoIdx = 10
|
|
if (e.target.dataset.id == 'sam_3') potoIdx = 11
|
|
|
|
//回显所拍摄照片
|
|
var _this = this;
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image', 'video'],
|
|
sourceType: ['camera'],
|
|
sizeType: ['compressed'],
|
|
camera: 'back',
|
|
success: res => {
|
|
_this.upImg(res.tempFiles[0].tempFilePath, potoIdx) //上传照片
|
|
}
|
|
})
|
|
},
|
|
|
|
//上传照片 imageSrc照片临时路径 potoIdx 点击的哪一个图片框
|
|
upImg(imageSrc, potoIdx) {
|
|
var _this = this;
|
|
request.upImgFile(`/feedBack/upload`, imageSrc).then(res => {
|
|
var resObj = JSON.parse(res.data)
|
|
if (resObj.code > 400) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: resObj.message,
|
|
complete: (res) => {
|
|
if (res.cancel) {}
|
|
if (res.confirm) {}
|
|
//上传失败后移除图片
|
|
}
|
|
})
|
|
} else {
|
|
//保存图片路径到数组
|
|
_this.data.poto[potoIdx] = resObj.data.url
|
|
_this.setData({
|
|
poto: _this.data.poto
|
|
})
|
|
}
|
|
});
|
|
},
|
|
|
|
//显示回调图片
|
|
addCallBackImage(imageSrc) {
|
|
var temp = {
|
|
isBtn: false,
|
|
imgUrl: imageSrc,
|
|
text: imageSrc,
|
|
func: "delImage"
|
|
};
|
|
this.data.imageArr.unshift(temp);
|
|
this.setData({
|
|
imageArr: this.data.imageArr
|
|
});
|
|
},
|
|
|
|
//送检机构
|
|
bindPickerChange(e) {
|
|
this.setData({
|
|
insIdx: e.detail.value,
|
|
insName: this.data.ins[e.detail.value]
|
|
})
|
|
},
|
|
|
|
//运输方式
|
|
bindbushChange(e) {
|
|
this.setData({
|
|
bush: e.detail.value
|
|
})
|
|
},
|
|
|
|
//日期
|
|
bindDateChange(e) {
|
|
// console.log(e.detail.value)
|
|
this.setData({
|
|
date: e.detail.value
|
|
})
|
|
},
|
|
|
|
//出发时间
|
|
//最后呈现时间的函数。
|
|
bindMultiPickerChange: function (e) {
|
|
var dateStr = this.data.multiArray[0][this.data.multiIndex[0]] +
|
|
this.data.multiArray[1][this.data.multiIndex[1]] +
|
|
this.data.multiArray[2][this.data.multiIndex[2]] +
|
|
this.data.multiArray[3][this.data.multiIndex[3]] +
|
|
this.data.multiArray[4][this.data.multiIndex[4]];
|
|
|
|
this.setData({
|
|
time: dateStr
|
|
})
|
|
},
|
|
|
|
bindMultiPickerChange1: function (e) {
|
|
var dateStr = this.data.multiArray1[0][this.data.multiIndex1[0]] +
|
|
this.data.multiArray1[1][this.data.multiIndex1[1]] +
|
|
this.data.multiArray1[2][this.data.multiIndex1[2]] +
|
|
this.data.multiArray1[3][this.data.multiIndex1[3]] +
|
|
this.data.multiArray1[4][this.data.multiIndex1[4]];
|
|
this.setData({
|
|
time1: dateStr
|
|
})
|
|
},
|
|
|
|
//当时间选择器呈现并进行滚动选择时间时调用该函数。开始
|
|
bindMultiPickerColumnChange: function (e) {
|
|
//e.detail.column记录哪一行发生改变,e.detail.value记录改变的值(相当于multiIndex)
|
|
switch (e.detail.column) {
|
|
//这里case的值有0/1/2/3/4,但除了需要记录年和月来确定具体的天数外,其他的都可以暂不在switch中处理。
|
|
case 0:
|
|
//记录改变的年的值
|
|
let year = this.data.multiArray[0][e.detail.value];
|
|
this.setData({
|
|
choose_year: year.substring(0, year.length - 1)
|
|
})
|
|
break;
|
|
case 1:
|
|
//根据选择的年与月,确定天数,并改变multiArray中天的具体值
|
|
let month = this.data.multiArray[1][e.detail.value];
|
|
let dayDates = datePicker.determineDay(this.data.choose_year, month.substring(0, month.length - 1));
|
|
//这里需要额外注意,改变page中设定的data,且只要改变data中某一个值,可以采用下面这种方法
|
|
this.setData({
|
|
['multiArray[2]']: dayDates
|
|
})
|
|
break;
|
|
}
|
|
//改变一个一维数组中某一个值,可供参考。
|
|
this.setData({
|
|
["multiIndex[" + e.detail.column + "]"]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//当时间选择器呈现并进行滚动选择时间时调用该函数。结束
|
|
bindMultiPickerColumnChange1: function (e) {
|
|
//e.detail.column记录哪一行发生改变,e.detail.value记录改变的值(相当于multiIndex)
|
|
switch (e.detail.column) {
|
|
//这里case的值有0/1/2/3/4,但除了需要记录年和月来确定具体的天数外,其他的都可以暂不在switch中处理。
|
|
case 0:
|
|
//记录改变的年的值
|
|
let year = this.data.multiArray1[0][e.detail.value];
|
|
this.setData({
|
|
choose_year1: year.substring(0, year.length - 1)
|
|
})
|
|
break;
|
|
case 1:
|
|
//根据选择的年与月,确定天数,并改变multiArray中天的具体值
|
|
let month = this.data.multiArray1[1][e.detail.value];
|
|
let dayDates = datePicker.determineDay(this.data.choose_year, month.substring(0, month.length - 1));
|
|
//这里需要额外注意,改变page中设定的data,且只要改变data中某一个值,可以采用下面这种方法
|
|
this.setData({
|
|
['multiArray1[2]']: dayDates
|
|
})
|
|
break;
|
|
}
|
|
//改变一个一维数组中某一个值
|
|
this.setData({
|
|
["multiIndex1[" + e.detail.column + "]"]: e.detail.value
|
|
})
|
|
},
|
|
|
|
//样本详细信息
|
|
goDetail(e) {
|
|
console.log('goDetail=' + e.currentTarget.dataset.id);
|
|
var sample = this.data.sampleList[e.currentTarget.dataset.id]
|
|
wx.navigateTo({
|
|
url: '../details/details?sample=' + JSON.stringify(sample),
|
|
})
|
|
},
|
|
|
|
//文本输入信息
|
|
inputTextInfo(e) {
|
|
var data_id = e.target.dataset.id; //组件tag
|
|
var value = e.detail.value; //输入的文本
|
|
//样本编号
|
|
if (data_id == 'barCode') {
|
|
this.setData({
|
|
pipenum: value
|
|
})
|
|
}
|
|
|
|
//数量
|
|
if (data_id == 'number') {
|
|
this.setData({
|
|
number: value
|
|
})
|
|
}
|
|
|
|
//转运箱号
|
|
if (data_id == 'boxNum') {
|
|
this.setData({
|
|
boxNum: value
|
|
})
|
|
}
|
|
|
|
//物流员
|
|
if (data_id == 'logisticsMen') {
|
|
this.setData({
|
|
logisticsMen: value
|
|
})
|
|
}
|
|
|
|
//驾驶员
|
|
if (data_id == 'driverMen') {
|
|
this.setData({
|
|
driverMen: value
|
|
})
|
|
}
|
|
|
|
//备注
|
|
if (data_id == 'notes') {
|
|
this.setData({
|
|
notes: value
|
|
})
|
|
}
|
|
},
|
|
|
|
//转运箱号下拉选择
|
|
bindBoxNumber(e) {
|
|
// console.log(JSON.stringify(e.detail.value))
|
|
this.setData({
|
|
boxIdx: e.detail.value,
|
|
boxNum: this.data.boxList[e.detail.value]
|
|
})
|
|
},
|
|
|
|
//车辆下拉选择
|
|
bindNumberplate(e) {
|
|
// console.log(JSON.stringify(e.detail.value))
|
|
this.setData({
|
|
numberplateIdx: e.detail.value,
|
|
numberplate: this.data.boxList[e.detail.value]
|
|
})
|
|
},
|
|
|
|
//显示必选项为空提示
|
|
showErrInfo(field, errInfo) {
|
|
if (field === undefined || field.length == 0) {
|
|
wx.showToast({
|
|
icon: 'error',
|
|
title: errInfo,
|
|
})
|
|
return true;
|
|
}
|
|
},
|
|
|
|
//保存样本信息
|
|
saveInfo() {
|
|
var temp = this.data;
|
|
//处理出发时间
|
|
var startTime = dateUtils.customizeDateFormat(temp.time);
|
|
//处理到达时间
|
|
var endTime = dateUtils.customizeDateFormat(temp.time1);
|
|
|
|
if (this.showErrInfo(startTime, '出发时间不可为空')) return
|
|
if (this.showErrInfo(endTime, '到过时间不可为空')) return
|
|
|
|
//处理物流车拍照
|
|
var carPoto = []
|
|
var boxPoto = []
|
|
var array = this.data.poto;
|
|
for (let index = 0; index < array.length; index++) {
|
|
//物流车照片
|
|
if (index < 4 && array[index] != this.data.potoSrc) {
|
|
carPoto.push(array[index])
|
|
|
|
//转运箱照片
|
|
} else if (array[index] != this.data.potoSrc) {
|
|
boxPoto.push(array[index])
|
|
}
|
|
//TODO 样本照片
|
|
|
|
}
|
|
|
|
var tempData = {
|
|
"barCode": temp.pipenum, //样本条码
|
|
"barCodeImg": "", //物流拍照图
|
|
"boxNum": temp.boxNum, //转运箱号
|
|
"carPics": carPoto.toString(), //物流车图片 逗号分隔
|
|
"boxPics": boxPoto.toString(), // 转运箱图片 逗号分隔
|
|
"cost": 0, // 物流费用 自建没有
|
|
"driverMen": temp.driverMen, //驾驶员
|
|
"entryDate": temp.date, // 录入日期
|
|
"endDate": '2023-07-06 14:52:53', //startTime
|
|
"expectedEndTime": endTime, //预计到达时间 endTime
|
|
"institutionName": temp.insName, //送检机构名称
|
|
"institutionNo": temp.ins[temp.insIdx].id, //送检机构编号
|
|
"logisticsMen": temp.logisticsMen, //物流员
|
|
"logisticsNo": temp.selfOrderCode, //物流编号
|
|
"logisticsWay": 1, //物流方式 1自建 2第三方 3货运
|
|
"notes": temp.notes, // 物流备注
|
|
"number": temp.number, // 数量
|
|
"numberplate": temp.numberplate, // 车牌号
|
|
"phone": "", //物流电话
|
|
"startTime": startTime, //出发时间
|
|
"tranType": "1", //物流方式
|
|
"unitType": "", //物流单位 1.顺丰 2.京东(自建物流没有该字段)
|
|
"updateBy": 0,
|
|
"updateTime": ""
|
|
}
|
|
|
|
request.post(`/batch/addTranLogistics`, tempData).then(res => {
|
|
console.log(JSON.stringify(res.data));
|
|
if (res.data.code == 200) {
|
|
//保存成功后,查询底部列表
|
|
this.selSampleList();
|
|
} else {
|
|
wx.showModal({
|
|
title: '错误',
|
|
content: res.data.message,
|
|
showCancel: false,
|
|
complete: (res) => {
|
|
if (res.confirm) {}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
//查询样本列表数据
|
|
selSampleList() {
|
|
var reqData = {
|
|
'logisticsNo': this.data.selfOrderCode
|
|
}
|
|
request.post(`/logistics/selectTranLogistics`, reqData).then(res => {
|
|
this.setData({
|
|
sampleList: res.data.data,
|
|
sampleCount: res.data.data.length
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
let now = new Date(); //获取时间
|
|
let year = now.getFullYear(); //获取当前年
|
|
let month = now.getMonth() + 1; //获取当前月份
|
|
this.setData({
|
|
end: '' + year + '-' + (Array(2).join(0) + month).slice(-2) + '-' + (Array(2).join(0) + now.getDate()).slice(-2), //当前的时间
|
|
//开始
|
|
multiArray: [
|
|
[year + "年", year + 1 + "年", year + 2 + "年"],
|
|
datePicker.determineMonth(),
|
|
datePicker.determineDay(year, month),
|
|
datePicker.determineHour(),
|
|
datePicker.determineMinute()
|
|
],
|
|
//结束
|
|
multiArray1: [
|
|
[year + "年", year + 1 + "年", year + 2 + "年"],
|
|
datePicker.determineMonth(),
|
|
datePicker.determineDay(year, month),
|
|
datePicker.determineHour(),
|
|
datePicker.determineMinute()
|
|
],
|
|
}),
|
|
|
|
//获取物流单号 1.自建物流 2.第三方物流 3.货运物流
|
|
request.get(`/batch/getBatchsNumber?logisticsWay=1`).then(res => {
|
|
if (res.data.code == 200) {
|
|
this.data.selfOrderCode = res.data.data
|
|
this.setData({
|
|
selfOrderCode: res.data.data
|
|
})
|
|
|
|
this.selSampleList(); //查询物流批次列表
|
|
}
|
|
})
|
|
|
|
|
|
//获取送检机构列表
|
|
request.post(`/institution/selectInstitution`).then(res => {
|
|
var array = res.data.data
|
|
var tempArr = []
|
|
for (let index = 0; index < array.length; index++) {
|
|
tempArr.push(array[index].orgName)
|
|
}
|
|
this.setData({
|
|
ins: tempArr
|
|
})
|
|
})
|
|
|
|
//初始化照片按钮
|
|
var tempSrc = []
|
|
for (let index = 0; index < 12; index++) {
|
|
tempSrc.push(this.data.potoSrc)
|
|
}
|
|
|
|
this.setData({
|
|
poto: tempSrc
|
|
})
|
|
|
|
//获取转运箱信息
|
|
request.post(`/box/selectTranBox`).then(res => {
|
|
var array = res.data.data
|
|
var tempBoxList = []
|
|
for (let index = 0; index < array.length; index++) {
|
|
tempBoxList.push(array[index].boxNum)
|
|
}
|
|
this.setData({
|
|
boxList: tempBoxList
|
|
})
|
|
|
|
})
|
|
|
|
//获取车辆信息
|
|
request.post(`/vehicle/selectTranVehicle`).then(res => {
|
|
var array = res.data.data
|
|
var tempNumberplatArr = []
|
|
for (let index = 0; index < array.length; index++) {
|
|
tempNumberplatArr.push(array[index].numberplate)
|
|
}
|
|
this.setData({
|
|
numberplateArr :tempNumberplatArr
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |