Commit 336bf677 by LJM

bug

parent b403e98d
...@@ -81,261 +81,260 @@ ...@@ -81,261 +81,260 @@
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import { titleCase } from '@/util/util.js'; import { titleCase } from '@/util/util.js';
import w_md5 from '../../js_sdk/zww-md5/w_md5.js'; import w_md5 from '../../js_sdk/zww-md5/w_md5.js';
export default { export default {
data() { data() {
return { return {
noexebshowFalg: true, //控制是否会触发生命周期 noexebshowFalg: true, //控制是否会触发生命周期
array: ['FedEx', 'DHL', 'UPS', '顺丰', 'Air'], array: ['FedEx', 'DHL', 'UPS', '顺丰', 'Air'],
textArr: ['物流', '送货', '上门取货'], textArr: ['物流', '送货', '上门取货'],
unitArr: ['件', '箱'], unitArr: ['件', '箱'],
index: -1, index: -1,
flag: false, flag: false,
text: '展开', text: '展开',
currentIndex: 0, currentIndex: 0,
unitIndex: 0, unitIndex: 0,
limitword: 0, limitword: 0,
id: '', id: '',
form: { form: {
delivery_method: 1, //来货方式1物流2送货3上门取货 delivery_method: 1, //来货方式1物流2送货3上门取货
logistics_company: '', //物流公司 logistics_company: '', //物流公司
logistics_number: '', //物流单号 logistics_number: '', //物流单号
total_num: '', //登记数量 total_num: '', //登记数量
unit: '件', //单位 unit: '件', //单位
check_in_pic: [], //收货图片 check_in_pic: [], //收货图片
check_in_remark: '', //收货备注 check_in_remark: '', //收货备注
checkIn: '', checkIn: '',
erp_order_sn: '' //入仓号 erp_order_sn: '' //入仓号
}
};
},
onLoad(options) {
this.id = options.number;
},
methods: {
getData() {
this.request(API.getCheckInList, 'POST', { number: this.id }, this.loading).then(res => {
if (res.err_code === 0) {
this.form.checkIn = res.data[0];
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
} }
}); };
}, },
scanChangeErp() { onLoad(options) {
this.form.erp_order_sn = ''; this.id = options.number;
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.erp_order_sn = res.result;
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败',
icon: 'error'
});
}
});
}, },
scanChange() { methods: {
this.form.logistics_number = ''; getData() {
uni.scanCode({ this.request(API.getCheckInList, 'POST', { number: this.id }, this.loading).then(res => {
success: res => { if (res.err_code === 0) {
console.log(res); this.form.checkIn = res.data[0];
if (res.errMsg == 'scanCode:ok') { } else {
this.form.logistics_number = res.result; uni.showToast({
title: res.err_msg,
icon: 'error'
});
} }
}, });
fail: function(res) { },
console.log(res); scanChangeErp() {
uni.showToast({ this.form.erp_order_sn = '';
title: '扫码失败', uni.scanCode({
icon: 'error' success: res => {
}); console.log(res);
} if (res.errMsg == 'scanCode:ok') {
}); this.form.erp_order_sn = res.result;
}, }
previewChange(img, index) { },
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期 fail: function(res) {
uni.previewImage({ console.log(res);
current: index,
urls: img
});
},
deletePic(index) {
this.form.check_in_pic.splice(index, 1);
},
chooseImageChange() {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
var self = this;
var time = parseInt(new Date().getTime() / 1000);
uni.chooseImage({
count: 4,
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
let maxNum = tempFilePaths.length * 1 + self.form.check_in_pic.length * 1;
if (maxNum > 4) {
uni.hideLoading();
uni.showToast({ uni.showToast({
title: '图片不超过4张' title: '扫码失败',
icon: 'error'
}); });
return false;
} }
for (let i = 0; i < tempFilePaths.length; i++) { });
console.log(tempFilePaths[i]); },
uni.uploadFile({ scanChange() {
url: API.upload, this.form.logistics_number = '';
filePath: tempFilePaths[i], uni.scanCode({
name: 'upload', success: res => {
formData: { console.log(res);
source: '1', if (res.errMsg == 'scanCode:ok') {
k1: time, this.form.logistics_number = res.result;
k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi') }
}, },
success: uploadFileRes => { fail: function(res) {
uni.hideLoading(); console.log(res);
var data = JSON.parse(uploadFileRes.data); uni.showToast({
console.log(data); title: '扫码失败',
if (data.code === 200) { icon: 'error'
self.form.check_in_pic.push(data.data[0]);
} else {
uni.showToast({
title: data.message,
icon: 'error'
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
}); });
} }
}
});
},
inputChange() {
if (this.form.check_in_remark.length <= 200) {
this.limitword = this.form.check_in_remark.length;
}
},
changeTab(index, type) {
if (type == 1) {
this.currentIndex = index;
this.form.delivery_method = index + 1;
} else if (type == 2) {
this.unitIndex = index;
if (index == 0) {
this.form.unit = '件';
} else if (index == 1) {
this.form.unit = '箱';
}
}
},
toggle() {
this.flag = !this.flag;
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.target.value);
this.index = e.target.value;
this.form.logistics_company = this.array[e.target.value];
},
submit() {
if (!this.form.erp_order_sn) {
uni.showModal({
title: '提示',
content: '请输入入仓号',
showCancel: false
}); });
return false; },
} previewChange(img, index) {
if (!this.form.total_num) { this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.showModal({ uni.previewImage({
title: '提示', current: index,
content: '请输入登记数量', urls: img
showCancel: false
}); });
return false; },
} deletePic(index) {
this.form.check_in_pic.splice(index, 1);
if (this.currentIndex == 0) { },
if (!this.form.logistics_company) { chooseImageChange() {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
var self = this;
var time = parseInt(new Date().getTime() / 1000);
uni.chooseImage({
count: 4,
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
let maxNum = tempFilePaths.length * 1 + self.form.check_in_pic.length * 1;
if (maxNum > 4) {
uni.hideLoading();
uni.showToast({
title: '图片不超过4张'
});
return false;
}
for (let i = 0; i < tempFilePaths.length; i++) {
console.log(tempFilePaths[i]);
uni.uploadFile({
url: API.upload,
filePath: tempFilePaths[i],
name: 'upload',
formData: {
source: '1',
k1: time,
k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi')
},
success: uploadFileRes => {
uni.hideLoading();
var data = JSON.parse(uploadFileRes.data);
console.log(data);
if (data.code === 200) {
self.form.check_in_pic.push(data.data[0]);
} else {
uni.showToast({
title: data.message,
icon: 'error'
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
}
});
},
inputChange() {
if (this.form.check_in_remark.length <= 200) {
this.limitword = this.form.check_in_remark.length;
}
},
changeTab(index, type) {
if (type == 1) {
this.currentIndex = index;
this.form.delivery_method = index + 1;
} else if (type == 2) {
this.unitIndex = index;
if (index == 0) {
this.form.unit = '件';
} else if (index == 1) {
this.form.unit = '箱';
}
}
},
toggle() {
this.flag = !this.flag;
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.target.value);
this.index = e.target.value;
this.form.logistics_company = this.array[e.target.value];
},
submit() {
if (!this.form.erp_order_sn) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请选择物流公司', content: '请输入入仓号',
showCancel: false showCancel: false
}); });
return false; return false;
} }
if (!this.form.total_num) {
if (!this.form.logistics_number) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '请输入物流单号', content: '请输入登记数量',
showCancel: false showCancel: false
}); });
return false; return false;
} }
}
this.form.erp_order_sn = titleCase(this.form.erp_order_sn); //自动转成大写 if (this.currentIndex == 0) {
if (!this.form.logistics_company) {
uni.showModal({
title: '提示',
content: '请选择物流公司',
showCancel: false
});
return false;
}
//如果选择的fedex就截取后12位 if (!this.form.logistics_number) {
if (this.index == 0) { uni.showModal({
let str = this.form.logistics_number; title: '提示',
this.form.logistics_number = str.substring(str.length - 12); content: '请输入物流单号',
} showCancel: false
});
return false;
}
}
this.request(API.addCheckIn, 'POST', this.form, true).then(res => { this.form.erp_order_sn = titleCase(this.form.erp_order_sn); //自动转成大写
if (res.err_code === 0) {
uni.showModal({ //如果选择的fedex就截取后12位
title: '提示', if (this.index == 0) {
content: res.err_msg, let str = this.form.logistics_number;
showCancel: false, this.form.logistics_number = str.substring(str.length - 12);
success: res => { }
if (res.confirm) {
setTimeout(() => { this.request(API.addCheckIn, 'POST', this.form, true).then(res => {
uni.navigateBack({ if (res.err_code === 0) {
delta: 1 uni.showModal({
}); title: '提示',
}, 2000); content: res.err_msg,
} else if (res.cancel) { showCancel: false,
console.log('用户点击取消'); success: res => {
if (res.confirm) {
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else if (res.cancel) {
console.log('用户点击取消');
}
} }
} });
}); } else {
} else { uni.showModal({
uni.showModal({ title: '提示',
title: '提示', content: res.err_msg,
content: res.err_msg, showCancel: false,
showCancel: false, success: res => {
success: res => { if (res.confirm) {} else if (res.cancel) {
if (res.confirm) { console.log('用户点击取消');
} else if (res.cancel) { }
console.log('用户点击取消');
} }
} });
}); }
} });
}); }
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '../../assets/css/goods/addReceiving.scss'; @import '../../assets/css/goods/addReceiving.scss';
</style> </style>
\ No newline at end of file
...@@ -94,7 +94,9 @@ ...@@ -94,7 +94,9 @@
<text class="tt-l">采购单上传(选填)</text> <text class="tt-l">采购单上传(选填)</text>
<text class="tt-r" v-if="switchFlag">{{ image_list.length }}/4</text> <text class="tt-r" v-if="switchFlag">{{ image_list.length }}/4</text>
</view> </view>
<view class="switch"><switch @change="switchChange" color="#197adb" style="transform:scale(0.7)" /></view> <view class="switch">
<switch @change="switchChange" color="#197adb" style="transform:scale(0.7)" />
</view>
</view> </view>
<view class="upload-list row verCenter" v-if="switchFlag"> <view class="upload-list row verCenter" v-if="switchFlag">
<template v-if="image_list.length > 0"> <template v-if="image_list.length > 0">
...@@ -112,445 +114,444 @@ ...@@ -112,445 +114,444 @@
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import { titleCase } from '@/util/util.js'; import { titleCase } from '@/util/util.js';
export default { export default {
data() { data() {
return { return {
isInspOrg: false, //是否商检 isInspOrg: false, //是否商检
noexebshowFalg: true, //控制是否会触发生命周期 noexebshowFalg: true, //控制是否会触发生命周期
customs_clearance_price_options: ['无', '有'], //清关费选项 customs_clearance_price_options: ['无', '有'], //清关费选项
currentIndex: -1, currentIndex: -1,
image_list: [], //图片列表 image_list: [], //图片列表
goods_check_pic_list: [], //商检图片列表 goods_check_pic_list: [], //商检图片列表
goods_check_pic_list_id: [], //商检图片列表ID标识 goods_check_pic_list_id: [], //商检图片列表ID标识
list: [], //商检型号列表 list: [], //商检型号列表
maxNum: 4, //最大上传图片数量 maxNum: 4, //最大上传图片数量
disabled: false, disabled: false,
switchFlag: false, switchFlag: false,
form: { form: {
erp_order_sn: '', //入仓号 erp_order_sn: '', //入仓号
customs_clearance_price: 0, //清关费 customs_clearance_price: 0, //清关费
box_num: '', //箱子 box_num: '', //箱子
board_num: '', //板子 board_num: '', //板子
gross_weight: '', //合计毛重 gross_weight: '', //合计毛重
pic_json: [], //商检图片 pic_json: [], //商检图片
detail_json: [], //产地拆分数据 detail_json: [], //产地拆分数据
fix_erp_order_sn: '', //手动合箱 fix_erp_order_sn: '', //手动合箱
pur_pic: '' //采购单上传 pur_pic: '' //采购单上传
}
};
},
watch: {
image_list(arr) {
if (arr.length > 0) {
this.form.pur_pic = arr.join(',');
} else {
this.form.pur_pic = '';
}
}
},
onLoad() {
uni.removeStorageSync('paramsOrigin');
},
onShow() {
//更新合箱数据
uni.$on('updateData', data => {
if (data.length > 0) {
this.form.fix_erp_order_sn = data.join(',');
} else {
this.form.fix_erp_order_sn = '';
}
});
//更新产地拆分国家的数据
uni.$on('updateOriginData', data => {
if (data) {
this.form.detail_json = data.detail_json;
uni.removeStorageSync('paramsOrigin');
uni.setStorageSync('paramsOrigin', data);
}
});
},
methods: {
/**
* 扫描二维码
*/
scanChange() {
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.erp_order_sn = res.result;
this.checkErpOrderSnIsTally();
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败,请重试',
icon: 'none'
});
} }
}); };
}, },
switchChange: function(e) { watch: {
this.switchFlag = e.detail.value; image_list(arr) {
console.log('switch1 发生 change 事件,携带值为', e.detail.value); if (arr.length > 0) {
this.form.pur_pic = arr.join(',');
} else {
this.form.pur_pic = '';
}
}
}, },
onInput() { onLoad() {
// 清除之前的定时器 uni.removeStorageSync('paramsOrigin');
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.checkErpOrderSnIsTally();
}, 800);
}, },
/** onShow() {
* 检测入仓号是否理货 //更新合箱数据
*/ uni.$on('updateData', data => {
checkErpOrderSnIsTally() { if (data.length > 0) {
this.request(API.checkErpOrderSnIsTally, 'GET', { erp_order_sn: this.form.erp_order_sn }, true).then(res => { this.form.fix_erp_order_sn = data.join(',');
if (res.err_code === 0) {
this.getTallyGoods();
this.disabled = false;
} else { } else {
this.disabled = true; this.form.fix_erp_order_sn = '';
uni.showModal({
content: res.err_msg,
showCancel: false
});
} }
}); });
},
/**
* 获取入仓号的理货数据
*/
getTallyGoods() {
this.request(API.getTallyGoods, 'GET', { erp_order_sn: this.form.erp_order_sn }, true).then(res => {
if (res.err_code === 0) {
this.disabled = false;
this.isInspOrg = Boolean(res.data.isInspOrg); //是否商检
this.list = res.data.entrys.filter(function(entry) {
return entry.isEntryInspOrg === true;
});
this.goods_check_pic_list_id = this.list.map(function(entry) {
return entry.ptEntryID;
});
const length = this.list.length;
this.goods_check_pic_list = Array.from({ length }, () => []);
this.form.pic_json = this.list.map(item => ({ //更新产地拆分国家的数据
entryID: item.entryID, uni.$on('updateOriginData', data => {
goods_check_pic: '' if (data) {
})); this.form.detail_json = data.detail_json;
} else { uni.removeStorageSync('paramsOrigin');
this.disabled = true; uni.setStorageSync('paramsOrigin', data);
this.list = [];
uni.showToast({
title: res.err_msg,
icon: 'none'
});
} }
}); });
}, },
/** methods: {
* @param {Object} index /**
* 清空对应的商检图片 * 扫描二维码
*/ */
clearFn(index) { scanChange() {
uni.showModal({ uni.scanCode({
title: '提示', success: res => {
content: '您确定清空嘛?', console.log(res);
showCancel: true, if (res.errMsg == 'scanCode:ok') {
cancelText: '取消', this.form.erp_order_sn = res.result;
confirmText: '确定', this.checkErpOrderSnIsTally();
success: res => { }
if (res.confirm) { },
// 用户点击了确定按钮,执行相关操作 fail: function(res) {
this.goods_check_pic_list[index] = []; console.log(res);
this.form.pic_json[index].goods_check_pic = ''; uni.showToast({
this.$forceUpdate(); title: '扫码失败,请重试',
} else if (res.cancel) { icon: 'none'
// 用户点击了取消按钮,取消操作 });
} }
} });
}); },
}, switchChange: function(e) {
/** this.switchFlag = e.detail.value;
*商检图片上传 console.log('switch1 发生 change 事件,携带值为', e.detail.value);
*/ },
uploadBusinessChange(index) { onInput() {
// 使用 chooseImage选择图片 // 清除之前的定时器
uni.chooseImage({ clearTimeout(this.timer);
sizeType: ['original', 'compressed'], this.timer = setTimeout(() => {
sourceType: ['album', 'camera'], this.checkErpOrderSnIsTally();
success: chooseImageRes => { }, 800);
console.log('选择图片成功:', chooseImageRes); },
/**
// 显示loading * 检测入仓号是否理货
uni.showLoading({ */
title: '上传中...' checkErpOrderSnIsTally() {
}); this.request(API.checkErpOrderSnIsTally, 'GET', { erp_order_sn: this.form.erp_order_sn }, true).then(res => {
if (res.err_code === 0) {
// 获取选择的图片路径数组 this.getTallyGoods();
const imagePaths = chooseImageRes.tempFilePaths; this.disabled = false;
} else {
this.disabled = true;
uni.showModal({
content: res.err_msg,
showCancel: false
});
}
});
},
/**
* 获取入仓号的理货数据
*/
getTallyGoods() {
this.request(API.getTallyGoods, 'GET', { erp_order_sn: this.form.erp_order_sn }, true).then(res => {
if (res.err_code === 0) {
this.disabled = false;
this.isInspOrg = Boolean(res.data.isInspOrg); //是否商检
// 遍历图片路径数组,对每张图片进行压缩 this.list = res.data.entrys.filter(function(entry) {
imagePaths.forEach(imagePath => { return entry.isEntryInspOrg === true;
// 使用compressImage 压缩图片 });
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器 this.goods_check_pic_list_id = this.list.map(function(entry) {
uni.uploadFile({ return entry.ptEntryID;
url: API.uploadImage + '?sys_type=4',
filePath: compressedImagePath,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
success: uploadFileRes => {
console.log('服务器上传图片成功:', uploadFileRes);
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (data.code === 0) {
this.goods_check_pic_list[index].push(data.data.oss_image_url);
this.form.pic_json[index].goods_check_pic = this.goods_check_pic_list[index].join(',');
this.$forceUpdate();
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
}
});
},
fail: err => {
console.log('压缩图片失败:', err);
}
}); });
});
}
});
},
/**
* 预览图片
* @param {Object} img
* @param {Object} index
*/
previewChange(img, index) {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.previewImage({
current: index,
urls: img
});
},
/**
* 删除图片
* @param {Object} index
*/
deletePic(index) {
this.image_list.splice(index, 1);
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading const length = this.list.length;
uni.showLoading({
title: '上传中...'
});
// 获取选择的图片路径数组 this.goods_check_pic_list = Array.from({ length }, () => []);
const imagePaths = chooseImageRes.tempFilePaths;
// 判断选择的图片数量是否超过最大限制数量 this.form.pic_json = this.list.map(item => ({
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的 entryID: item.entryID,
if (maxNum > this.maxNum) { goods_check_pic: ''
uni.hideLoading(); }));
} else {
this.disabled = true;
this.list = [];
uni.showToast({ uni.showToast({
title: '图片不超过' + this.maxNum + '张', title: res.err_msg,
icon: 'none' icon: 'none'
}); });
return false;
} }
});
},
/**
* @param {Object} index
* 清空对应的商检图片
*/
clearFn(index) {
uni.showModal({
title: '提示',
content: '您确定清空嘛?',
showCancel: true,
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
// 用户点击了确定按钮,执行相关操作
this.goods_check_pic_list[index] = [];
this.form.pic_json[index].goods_check_pic = '';
this.$forceUpdate();
} else if (res.cancel) {
// 用户点击了取消按钮,取消操作
}
}
});
},
/**
*商检图片上传
*/
uploadBusinessChange(index) {
// 使用 chooseImage选择图片
uni.chooseImage({
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 遍历图片路径数组,对每张图片进行压缩 // 获取选择的图片路径数组
imagePaths.forEach(imagePath => { const imagePaths = chooseImageRes.tempFilePaths;
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器 // 遍历图片路径数组,对每张图片进行压缩
uni.uploadFile({ imagePaths.forEach(imagePath => {
url: API.uploadImage + '?sys_type=4', // 使用compressImage 压缩图片
filePath: compressedImagePath, uni.compressImage({
name: 'file', src: imagePath,
header: { quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
'Content-Type': 'multipart/form-data' success: compressedRes => {
}, console.log('压缩图片成功:', compressedRes);
success: uploadFileRes => { // 获取压缩后的图片路径
console.log('服务器上传图片成功:', uploadFileRes); const compressedImagePath = compressedRes.tempFilePath;
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data); // 在这里处理压缩后的图片,上传到服务器
if (data.code === 0) { uni.uploadFile({
this.image_list.push(data.data.oss_image_url); url: API.uploadImage + '?sys_type=4',
} else { filePath: compressedImagePath,
uni.showToast({ name: 'file',
title: data.msg, header: {
icon: 'none' 'Content-Type': 'multipart/form-data'
}); },
success: uploadFileRes => {
console.log('服务器上传图片成功:', uploadFileRes);
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (data.code === 0) {
this.goods_check_pic_list[index].push(data.data.oss_image_url);
this.form.pic_json[index].goods_check_pic = this.goods_check_pic_list[index].join(',');
this.$forceUpdate();
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
} }
}, });
fail: error => { },
console.log('上传图片失败:', error); fail: err => {
uni.hideLoading(); console.log('压缩图片失败:', err);
} }
}); });
},
fail: err => {
console.log('压缩图片失败:', err);
}
}); });
}); }
}
});
},
/**
* 清关费选择
* @param {Object} index
*/
tabChnage(index) {
this.currentIndex = index;
this.form.customs_clearance_price = index;
},
/**
* 提交
*/
submit() {
if (!this.form.erp_order_sn) {
uni.showModal({
title: '提示',
content: '请输入入仓号',
showCancel: false
});
return false;
}
if (this.disabled) {
uni.showModal({
content: '请检查该入仓号是否正确',
showCancel: false
});
return false;
}
if (this.currentIndex == -1) {
uni.showModal({
content: '请选择清关费选项',
showCancel: false
});
return false;
}
if (!this.form.box_num) {
uni.showModal({
content: '请填写箱子数',
showCancel: false
});
return false;
}
if (!this.form.board_num) {
uni.showModal({
content: '请填写板子数',
showCancel: false
}); });
return false; },
} /**
if (!this.form.gross_weight) { * 预览图片
uni.showModal({ * @param {Object} img
content: '请填写箱毛重', * @param {Object} index
showCancel: false */
previewChange(img, index) {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.previewImage({
current: index,
urls: img
}); });
return false; },
} /**
* 删除图片
* @param {Object} index
*/
deletePic(index) {
this.image_list.splice(index, 1);
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
//商检图片必填 // 显示loading
if (this.isInspOrg) { uni.showLoading({
// 使用every方法检查每个子数组是否满足条件 title: '上传中...'
var isValid = this.goods_check_pic_list.every(subArray => subArray.length >= 2); });
if (!isValid) {
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
if (maxNum > this.maxNum) {
uni.hideLoading();
uni.showToast({
title: '图片不超过' + this.maxNum + '张',
icon: 'none'
});
return false;
}
// 遍历图片路径数组,对每张图片进行压缩
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器
uni.uploadFile({
url: API.uploadImage + '?sys_type=4',
filePath: compressedImagePath,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
success: uploadFileRes => {
console.log('服务器上传图片成功:', uploadFileRes);
uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (data.code === 0) {
this.image_list.push(data.data.oss_image_url);
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
}
});
},
fail: err => {
console.log('压缩图片失败:', err);
}
});
});
}
});
},
/**
* 清关费选择
* @param {Object} index
*/
tabChnage(index) {
this.currentIndex = index;
this.form.customs_clearance_price = index;
},
/**
* 提交
*/
submit() {
if (!this.form.erp_order_sn) {
uni.showModal({ uni.showModal({
content: '商检图片上传须大于2张', title: '提示',
content: '请输入入仓号',
showCancel: false showCancel: false
}); });
return false; return false;
} }
} if (this.disabled) {
this.request(API.submitTallyGoods, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
uni.showModal({ uni.showModal({
title: '提示', content: '请检查该入仓号是否正确',
content: res.err_msg, showCancel: false
showCancel: false,
success: res => {
if (res.confirm) {
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
}); });
} else { return false;
}
if (this.currentIndex == -1) {
uni.showModal({ uni.showModal({
title: '提示', content: '请选择清关费选项',
content: res.err_msg, showCancel: false
showCancel: false,
success: res => {
if (res.confirm) {
} else if (res.cancel) {
console.log('用户点击取消');
}
}
}); });
return false;
} }
}); if (!this.form.box_num) {
uni.showModal({
content: '请填写箱子数',
showCancel: false
});
return false;
}
if (!this.form.board_num) {
uni.showModal({
content: '请填写板子数',
showCancel: false
});
return false;
}
if (!this.form.gross_weight) {
uni.showModal({
content: '请填写箱毛重',
showCancel: false
});
return false;
}
//商检图片必填
if (this.isInspOrg) {
// 使用every方法检查每个子数组是否满足条件
var isValid = this.goods_check_pic_list.every(subArray => subArray.length >= 2);
if (!isValid) {
uni.showModal({
content: '商检图片上传须大于2张',
showCancel: false
});
return false;
}
}
this.request(API.submitTallyGoods, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
uni.showModal({
title: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 2000);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
uni.showModal({
title: '提示',
content: res.err_msg,
showCancel: false,
success: res => {
if (res.confirm) {} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
});
}
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '../../assets/css/tallyGoods/confirm.scss'; @import '../../assets/css/tallyGoods/confirm.scss';
</style> </style>
\ No newline at end of file
const API_BASE = 'https://api.ichunt.com'; // const API_BASE = 'https://api.ichunt.com';
const API_BASE_OSS = 'https://image.ichunt.net'; //oss系统 // const API_BASE_OSS = 'https://image.ichunt.net'; //oss系统
// const API_BASE = 'http://api.liexin.com'; const API_BASE = 'http://api.liexin.com';
// const API_BASE_OSS = 'http://image.liexindev.net'; const API_BASE_OSS = 'http://image.liexindev.net';
const API = { const API = {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment