Commit 6cc13f41 by LJM

修复api

parent cf08ab1b
......@@ -90,231 +90,232 @@
</template>
<script>
import { API } from '@/util/api.js';
import { titleCase } from '@/util/util.js';
import w_md5 from '../../js_sdk/zww-md5/w_md5.js';
import { API } from '@/util/api.js';
import { titleCase } from '@/util/util.js';
import w_md5 from '../../js_sdk/zww-md5/w_md5.js';
export default {
data() {
return {
logistics_company_arr: ['FedEx', 'DHL', 'UPS', '顺丰', 'Air'], //物流公司
logistics_company_index: -1, //物流索引,
unusual_reason_arr: ['无入仓号信息', '来货外观破损', '其他'], //异常原因
unusual_reason_index: -1,
delivery_method_arr: ['物流', '送货', '上门取货'], //来货方式
delivery_method_index: 0, //来货方式索引
unit_arr: ['箱', '卡板'], //单位
unit_index: 0, //单位索引
limitword: 0, //备注文字限制,
form: {
delivery_method: 1, //来货方式1物流2送货3上门取货
logistics_company: '', //物流公司
logistics_number: '', //物流单号
info_pic: [], //收货图片
check_in_remark: '', //收货备注
erp_order_sn: '', //入仓号信息
supplier_name: '', //来货供应商
unusual_reason: '', //异常原因1.无入仓号信息2.来货外观破损3.其它
unusual_num: '', //登记数量
unit: '箱' //收货单位
}
};
},
methods: {
change(index, type) {
if (type == 'delivery_method') {
this.delivery_method_index = index;
this.form.delivery_method = index + 1;
} else if (type == 'unit') {
this.unit_index = index;
this.form.unit = this.unit_arr[index];
}
},
bindPickerChange: function(e) {
this.logistics_company_index = e.target.value;
this.form.logistics_company = this.logistics_company_arr[e.target.value];
},
bindPickerReasonChange: function(e) {
this.unusual_reason_index = e.target.value;
this.form.unusual_reason = parseInt(e.target.value) + 1;
},
inputChange() {
if (this.form.check_in_remark.length <= 200) {
this.limitword = this.form.check_in_remark.length;
}
},
previewChange(img, index) {
uni.previewImage({
current: index,
urls: img
});
},
deletePic(index) {
this.form.info_pic.splice(index, 1);
},
scanChangeErp() {
this.form.erp_order_sn = '';
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.erp_order_sns = res.result;
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败',
icon: 'error'
});
export default {
data() {
return {
logistics_company_arr: ['FedEx', 'DHL', 'UPS', '顺丰', 'Air'], //物流公司
logistics_company_index: -1, //物流索引,
unusual_reason_arr: ['无入仓号信息', '来货外观破损', '其他'], //异常原因
unusual_reason_index: -1,
delivery_method_arr: ['物流', '送货', '上门取货'], //来货方式
delivery_method_index: 0, //来货方式索引
unit_arr: ['箱', '卡板'], //单位
unit_index: 0, //单位索引
limitword: 0, //备注文字限制,
form: {
delivery_method: 1, //来货方式1物流2送货3上门取货
logistics_company: '', //物流公司
logistics_number: '', //物流单号
info_pic: [], //收货图片
check_in_remark: '', //收货备注
erp_order_sn: '', //入仓号信息
supplier_name: '', //来货供应商
unusual_reason: '', //异常原因1.无入仓号信息2.来货外观破损3.其它
unusual_num: '', //登记数量
unit: '箱' //收货单位
}
});
};
},
scanChange() {
this.form.logistics_number = '';
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.logistics_number = res.result;
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败',
icon: 'error'
});
methods: {
change(index, type) {
if (type == 'delivery_method') {
this.delivery_method_index = index;
this.form.delivery_method = index + 1;
} else if (type == 'unit') {
this.unit_index = index;
this.form.unit = this.unit_arr[index];
}
});
},
chooseImageChange() {
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.info_pic.length * 1;
if (maxNum > 4) {
uni.hideLoading();
},
bindPickerChange: function(e) {
this.logistics_company_index = e.target.value;
this.form.logistics_company = this.logistics_company_arr[e.target.value];
},
bindPickerReasonChange: function(e) {
this.unusual_reason_index = e.target.value;
this.form.unusual_reason = parseInt(e.target.value) + 1;
},
inputChange() {
if (this.form.check_in_remark.length <= 200) {
this.limitword = this.form.check_in_remark.length;
}
},
previewChange(img, index) {
uni.previewImage({
current: index,
urls: img
});
},
deletePic(index) {
this.form.info_pic.splice(index, 1);
},
scanChangeErp() {
this.form.erp_order_sn = '';
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.erp_order_sns = res.result;
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '图片不超过4张'
title: '扫码失败',
icon: 'error'
});
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.info_pic.push(data.data[0]);
} else {
uni.showToast({
title: data.message
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
},
scanChange() {
this.form.logistics_number = '';
uni.scanCode({
success: res => {
console.log(res);
if (res.errMsg == 'scanCode:ok') {
this.form.logistics_number = res.result;
}
},
fail: function(res) {
console.log(res);
uni.showToast({
title: '扫码失败',
icon: 'error'
});
}
}
});
},
submit() {
if (this.delivery_method_index == 0) {
if (!this.form.logistics_company) {
uni.showModal({
title: '提示',
content: '请选择物流公司',
showCancel: false
});
return false;
}
if (!this.form.logistics_number) {
uni.showModal({
title: '提示',
content: '请输入物流单号',
showCancel: false
});
return false;
}
}
if (this.form.info_pic.length <= 0) {
uni.showModal({
title: '提示',
content: '请上传收货图片',
showCancel: false,
success: res => {
if (res.confirm) {
} else if (res.cancel) {
console.log('用户点击取消');
});
},
chooseImageChange() {
var self = this;
var time = parseInt(new Date().getTime() / 1000);
uni.chooseMedia({
count: 4,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFiles;
let maxNum = tempFilePaths.length * 1 + self.form.info_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].tempFilePath,
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.info_pic.push(data.data[0]);
} else {
uni.showToast({
title: data.message
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
}
});
return false;
}
//如果选择的fedex就截取后12位
if (this.logistics_company_index == 0) {
let str = this.form.logistics_number;
this.form.logistics_number = str.substring(str.length - 12);
}
},
submit() {
if (this.delivery_method_index == 0) {
if (!this.form.logistics_company) {
uni.showModal({
title: '提示',
content: '请选择物流公司',
showCancel: false
});
return false;
}
//自动转成大写
if (this.form.erp_order_sn) {
this.form.erp_order_sn = titleCase(this.form.erp_order_sn);
}
if (!this.form.logistics_number) {
uni.showModal({
title: '提示',
content: '请输入物流单号',
showCancel: false
});
return false;
}
}
this.request(API.addUnusualCheckIn, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
if (this.form.info_pic.length <= 0) {
uni.showModal({
title: '提示',
content: '提交成功',
content: '请上传收货图片',
showCancel: false,
success: res => {
if (res.confirm) {
uni.switchTab({
url: '/pages/home/index'
});
} else if (res.cancel) {
if (res.confirm) {} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
uni.showModal({
title: '提示',
content: res.err_msg,
showCancel: false
});
return false;
}
//如果选择的fedex就截取后12位
if (this.logistics_company_index == 0) {
let str = this.form.logistics_number;
this.form.logistics_number = str.substring(str.length - 12);
}
//自动转成大写
if (this.form.erp_order_sn) {
this.form.erp_order_sn = titleCase(this.form.erp_order_sn);
}
});
this.request(API.addUnusualCheckIn, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
uni.showModal({
title: '提示',
content: '提交成功',
showCancel: false,
success: res => {
if (res.confirm) {
uni.switchTab({
url: '/pages/home/index'
});
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
uni.showModal({
title: '提示',
content: res.err_msg,
showCancel: false
});
}
});
}
}
}
};
};
</script>
<style scoped lang="scss">
@import '../../assets/css/goods/addExectionReceiving.scss';
</style>
@import '../../assets/css/goods/addExectionReceiving.scss';
</style>
\ No newline at end of file
......@@ -178,14 +178,16 @@
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
var self = this;
var time = parseInt(new Date().getTime() / 1000);
uni.chooseImage({
uni.chooseMedia({
count: 4,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
const tempFilePaths = chooseImageRes.tempFiles;
let maxNum = tempFilePaths.length * 1 + self.form.check_in_pic.length * 1;
if (maxNum > 4) {
uni.hideLoading();
......@@ -195,10 +197,9 @@
return false;
}
for (let i = 0; i < tempFilePaths.length; i++) {
console.log(tempFilePaths[i]);
uni.uploadFile({
url: API.upload,
filePath: tempFilePaths[i],
filePath: tempFilePaths[i].tempFilePath,
name: 'upload',
formData: {
source: '1',
......@@ -208,7 +209,6 @@
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 {
......@@ -220,7 +220,6 @@
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
......
......@@ -34,11 +34,13 @@
<view class="pic-list column">
<text class="title">问题图片</text>
<view class="list row verCenter">
<view class="box" @click="clickImg(operation_img, index)" v-for="(item, index) in operation_img" :key="index"><image :src="item" mode="aspectFill"></image></view>
<view class="box" @click="clickImg(operation_img, index)" v-for="(item, index) in operation_img" :key="index">
<image :src="item" mode="aspectFill"></image>
</view>
</view>
</view>
</view>
<view class="work-information">
<view class="work-information" v-if="warehouseOperationDetail.detail">
<view class="top row bothSide verCenter">
<view class="title row verCenter">
<text class="arrow row rowCenter verCenter"></text>
......@@ -72,7 +74,7 @@
</view>
</view>
<view class="camera disable row rowCenter verCenter" v-if="item.operation_img">已上传</view>
<view class="camera row rowCenter verCenter" @click="chooseImageChange()" v-else="item.operation_img">拍照</view>
<view class="camera row rowCenter verCenter" @click="chooseImageChange()" v-else-if="item.operation_img">拍照</view>
</view>
</view>
</view>
......@@ -81,136 +83,140 @@
</template>
<script>
import { API } from '@/util/api.js';
import w_md5 from '../../js_sdk/zww-md5/w_md5.js';
import { API } from '@/util/api.js';
import w_md5 from '../../js_sdk/zww-md5/w_md5.js';
export default {
data() {
return {
warehouseOperationDetail: {},
weonlt_id: '', //仓内作业列表ID
operation_img: [], //作业图片
actual_operation_num: [], //作业数量 来自 instructions_num
weondl_ids: [], //仓内作业详情ID,
noexebshowFalg: true //控制是否会触发生命周期
};
},
onLoad(options) {
this.weonlt_id = options.weonlt_id;
},
onShow() {
if (this.noexebshowFalg) {
this.getData();
}
},
methods: {
clickImg(img, index) {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.previewImage({
current: index,
urls: img
});
export default {
data() {
return {
warehouseOperationDetail: {},
weonlt_id: '', //仓内作业列表ID
operation_img: [], //作业图片
actual_operation_num: [], //作业数量 来自 instructions_num
weondl_ids: [], //仓内作业详情ID,
noexebshowFalg: true //控制是否会触发生命周期
};
},
chooseImageChange() {
uni.chooseImage({
count: 1,
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFilePaths;
const time = parseInt(new Date().getTime() / 1000);
console.log(tempFilePaths);
uni.uploadFile({
url: API.upload,
filePath: tempFilePaths[0],
name: 'upload',
formData: {
source: '1',
k1: time,
k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi')
},
success: uploadFileRes => {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.hideLoading();
var data = JSON.parse(uploadFileRes.data);
if (data.code === 200) {
this.operation_img.push(data.data[0]);
} else {
uni.showToast({
title: data.message,
icon: 'error'
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
});
onLoad(options) {
this.weonlt_id = options.weonlt_id;
},
submit() {
this.request(
API.execWarehouseOperation,
'POST',
{
weonlt_id: this.weonlt_id,
'weondl_id[]': this.weondl_ids.join(','),
operation_img: this.operation_img.join(','),
'actual_operation_num[]': this.actual_operation_num.join(',')
},
true
).then(res => {
if (res.err_code === 0) {
this.getData();
uni.showToast({
title: res.err_msg,
icon: 'success'
});
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
onShow() {
if (this.noexebshowFalg) {
this.getData();
}
},
getData() {
this.request(API.warehouseOperationDetail, 'POST', { weonlt_id: this.weonlt_id }, false).then(res => {
if (res.err_code === 0) {
this.weondl_ids = [];
this.actual_operation_num = [];
this.operation_img = [];
methods: {
clickImg(img, index) {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
uni.previewImage({
current: index,
urls: img
});
},
chooseImageChange() {
uni.chooseMedia({
count: 1,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
uni.showLoading({
title: '上传中...'
});
const tempFilePaths = chooseImageRes.tempFiles;
const time = parseInt(new Date().getTime() / 1000);
uni.uploadFile({
url: API.upload,
filePath: tempFilePaths[0].tempFilePath,
name: 'upload',
formData: {
source: '1',
k1: time,
k2: w_md5.hex_md5_32(w_md5.hex_md5_32(String(time)) + 'fh6y5t4rr351d2c3bryi')
},
success: uploadFileRes => {
this.noexebshowFalg = false; //不允许再次触发onshow这个生命周期
this.warehouseOperationDetail = res.data;
uni.hideLoading();
var data = JSON.parse(uploadFileRes.data);
if (res.data.list.operation_img != '') {
this.operation_img = res.data.list.operation_img.split(',');
if (data.code === 200) {
this.operation_img.push(data.data[0]);
} else {
uni.showToast({
title: data.message,
icon: 'error'
});
}
},
fail: error => {
uni.hideLoading();
console.log(error);
}
});
}
});
},
submit() {
this.request(
API.execWarehouseOperation,
'POST', {
weonlt_id: this.weonlt_id,
'weondl_id[]': this.weondl_ids.join(','),
operation_img: this.operation_img.join(','),
'actual_operation_num[]': this.actual_operation_num.join(',')
},
true
).then(res => {
if (res.err_code === 0) {
this.getData();
uni.showToast({
title: res.err_msg,
icon: 'success'
});
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
},
getData() {
this.request(API.warehouseOperationDetail, 'POST', { weonlt_id: this.weonlt_id }, false).then(res => {
if (res.err_code === 0) {
this.weondl_ids = [];
this.actual_operation_num = [];
this.operation_img = [];
this.warehouseOperationDetail = res.data;
//组装weondl_id[] actual_operation_num[]
if (res.data.detail.length > 0) {
for (let i = 0; i < res.data.detail.length; i++) {
this.weondl_ids.push(res.data.detail[i].weondl_id);
this.actual_operation_num.push(res.data.detail[i].instructions_num);
if (res.data.list.operation_img != '') {
this.operation_img = res.data.list.operation_img.split(',');
}
//组装weondl_id[] actual_operation_num[]
if (res.data.detail.length > 0) {
for (let i = 0; i < res.data.detail.length; i++) {
this.weondl_ids.push(res.data.detail[i].weondl_id);
this.actual_operation_num.push(res.data.detail[i].instructions_num);
}
}
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
});
}
}
}
};
};
</script>
<style scoped lang="scss">
@import '../../assets/css/goods/warehouseOperationConfirm.scss';
</style>
@import '../../assets/css/goods/warehouseOperationConfirm.scss';
</style>
\ No newline at end of file
......@@ -171,20 +171,20 @@
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
uni.chooseMedia({
count: this.maxNum,
mediaType: ['image'],
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
const imagePaths = chooseImageRes.tempFiles;
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
......@@ -201,7 +201,7 @@
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
src: imagePath.tempFilePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
......
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