|
|
|
//第三方物流
|
|
|
|
var datePicker = require('../../utils/dateSetting')
|
|
|
|
var request = require('../../utils/http')
|
|
|
|
var dateUtils = require('../../utils/dateUtils')
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
selfOrderCode: '', //物流单号
|
|
|
|
list: [{
|
|
|
|
'id': 1,
|
|
|
|
'number': '2023050002',
|
|
|
|
'time': '2023-5-12 11:32',
|
|
|
|
'status': '已签收',
|
|
|
|
'name': '张三',
|
|
|
|
'num': 'M2023055568'
|
|
|
|
}],
|
|
|
|
pipenum: '',
|
|
|
|
ins: [],
|
|
|
|
insIdx: 0, //物流所选下标
|
|
|
|
date: '',
|
|
|
|
start: '2023-07-01', // 时间选择器开始时间
|
|
|
|
end: '', // 时间选择器结束时间
|
|
|
|
|
|
|
|
potoSrc: '../../images/addPoto.png', //默认图片
|
|
|
|
poto: [], //车辆&转运箱照片 最大长度 4
|
|
|
|
|
|
|
|
expectedEndTime: '', //预计到达时间
|
|
|
|
multiArray: [],
|
|
|
|
multiIndex: [0, 0, 0, 0, 0],
|
|
|
|
choose_year: "",
|
|
|
|
srcArray: [],
|
|
|
|
phone: '', //物流电话
|
|
|
|
boxNum: '', //转运箱号
|
|
|
|
cost: '', //物流费用
|
|
|
|
logisticsMen: '', //物流员
|
|
|
|
notes: '', //备注
|
|
|
|
|
|
|
|
sampleCount: '0', //样本数量
|
|
|
|
//样本列表
|
|
|
|
sampleList: [{
|
|
|
|
'id': 1,
|
|
|
|
'number': '2023050002',
|
|
|
|
'time': '2023-5-12 11:32',
|
|
|
|
'status': '已签收',
|
|
|
|
'name': '张三',
|
|
|
|
'num': 'M2023055568'
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
|
|
|
|
//物流车、转运箱拍照
|
|
|
|
photograph(e) {
|
|
|
|
var potoIdx = 0;
|
|
|
|
if (e.target.dataset.id == 'car_1') potoIdx = 0
|
|
|
|
if (e.target.dataset.id == 'car_2') potoIdx = 1
|
|
|
|
if (e.target.dataset.id == 'box_1') potoIdx = 2
|
|
|
|
if (e.target.dataset.id == 'box_2') potoIdx = 3
|
|
|
|
|
|
|
|
//回显所拍摄照片
|
|
|
|
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)
|
|
|
|
console.log('upImgFile data =' + resObj.data.url);
|
|
|
|
console.log('upImgFile res=' + JSON.stringify(res.data));
|
|
|
|
if (resObj.code > 400) {
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: resObj.message,
|
|
|
|
complete: (res) => {
|
|
|
|
if (res.cancel) {}
|
|
|
|
if (res.confirm) {}
|
|
|
|
//上传失败后移除图片
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
//保存图片路径到数组
|
|
|
|
// this.data.upImageArr.push(resObj.data.url);
|
|
|
|
_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
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
//文本输入信息
|
|
|
|
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 == 'phone') {
|
|
|
|
this.setData({
|
|
|
|
phone: value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//转运箱号
|
|
|
|
if (data_id == 'boxNum') {
|
|
|
|
this.setData({
|
|
|
|
boxNum: value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//物流费用
|
|
|
|
if (data_id == 'cost') {
|
|
|
|
this.setData({
|
|
|
|
cost: 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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
scacode() {
|
|
|
|
wx.scanCode({
|
|
|
|
success: (res) => {
|
|
|
|
console.log(res.result);
|
|
|
|
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() {
|
|
|
|
wx.chooseMedia({
|
|
|
|
count: 1,
|
|
|
|
mediaType: ['image', 'video'],
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
maxDuration: 30,
|
|
|
|
camera: 'back',
|
|
|
|
success: res => {
|
|
|
|
// this.up();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//送检机构
|
|
|
|
bindPickerChange(e) {
|
|
|
|
console.log('bindPickerChange = ' + JSON.stringify(e));
|
|
|
|
this.setData({
|
|
|
|
index: e.detail.value,
|
|
|
|
insIdx: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({
|
|
|
|
expectedEndTime: 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
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//查询底部列表数据
|
|
|
|
selSampleList() {
|
|
|
|
var reqData = {
|
|
|
|
'logisticsNo': this.data.selfOrderCode
|
|
|
|
}
|
|
|
|
request.post(`/logistics/selectTranLogistics`, reqData).then(res => {
|
|
|
|
console.log(res.data);
|
|
|
|
this.setData({
|
|
|
|
sampleList: res.data.data,
|
|
|
|
sampleCount: res.data.data.length
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
goDetail() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '../details/details',
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//保存样本信息
|
|
|
|
saveInfo() {
|
|
|
|
var temp = this.data;
|
|
|
|
//处理出发时间
|
|
|
|
// var startTime = dateUtils.customizeDateFormat(temp.time);
|
|
|
|
//处理到达时间
|
|
|
|
var endTime = dateUtils.customizeDateFormat(temp.expectedEndTime);
|
|
|
|
|
|
|
|
// 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 < 2 && array[index] != this.data.potoSrc) {
|
|
|
|
carPoto.push(array[index])
|
|
|
|
} else if (array[index] != this.data.potoSrc) {
|
|
|
|
boxPoto.push(array[index])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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.ins[temp.insIdx].orgName, //送检机构名称
|
|
|
|
"institutionNo": temp.ins[temp.insIdx].id, //送检机构编号
|
|
|
|
"logisticsMen": temp.logisticsMen, //物流员
|
|
|
|
"logisticsNo": temp.selfOrderCode, //物流编号
|
|
|
|
"logisticsWay": 2, //物流方式 1自建 2第三方 3货运
|
|
|
|
"notes": temp.notes, // 物流备注
|
|
|
|
"number": temp.number, // 数量
|
|
|
|
"numberplate": "", // 车牌号
|
|
|
|
"phone": temp.phone, //物流电话
|
|
|
|
"startTime": "", //出发时间
|
|
|
|
"tranType": "", //物流方式
|
|
|
|
"unitType": temp.insIdx, //物流单位 1.顺丰 2.京东
|
|
|
|
"updateBy": 0,
|
|
|
|
"updateTime": ""
|
|
|
|
}
|
|
|
|
|
|
|
|
request.post(`/batch/addTranLogistics`, tempData).then(res => {
|
|
|
|
console.log(JSON.stringify(res.data));
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
this.data.selfOrderCode = res.data.data
|
|
|
|
//保存成功后,查询底部列表
|
|
|
|
this.selSampleList();
|
|
|
|
} else {
|
|
|
|
wx.showModal({
|
|
|
|
title: '错误',
|
|
|
|
content: res.data.message,
|
|
|
|
showCancel: false,
|
|
|
|
complete: (res) => {
|
|
|
|
if (res.confirm) {}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//显示必选项为空提示
|
|
|
|
showErrInfo(field, errInfo) {
|
|
|
|
if (field === undefined || field.length == 0) {
|
|
|
|
wx.showToast({
|
|
|
|
icon: 'error',
|
|
|
|
title: errInfo,
|
|
|
|
})
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
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()
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//获取物流单号 1.自建物流 2.第三方物流 3.货运物流
|
|
|
|
request.get(`/batch/getBatchsNumber?logisticsWay=2`).then(res => {
|
|
|
|
console.log('getBatchsNumber=' + JSON.stringify(res.data))
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
this.setData({
|
|
|
|
selfOrderCode: res.data.data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
//获取物流机构列表 /dict/type/{dictType}
|
|
|
|
request.get(`/dict/type/unit_type`).then(res => {
|
|
|
|
var array = res.data.data
|
|
|
|
var tempArr = []
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
tempArr.push(array[index].dictLabel)
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
ins: tempArr
|
|
|
|
})
|
|
|
|
|
|
|
|
//查询物流批次列表
|
|
|
|
this.selSampleList()
|
|
|
|
})
|
|
|
|
|
|
|
|
//初始化照片按钮
|
|
|
|
var tempSrc = [this.data.potoSrc, this.data.potoSrc, this.data.potoSrc, this.data.potoSrc]
|
|
|
|
this.setData({
|
|
|
|
poto: tempSrc
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|