Commit 2bdbf0b1 by LJM

供应链wms-理货确认-产地拆分多选

parent 1f6030f0
......@@ -11,6 +11,14 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-jianshao:before {
content: "\e8c5";
}
.icon-xinzeng-:before {
content: "\e678";
}
.icon-a-10cangkucangchu3:before {
content: "\e7a0";
}
......
......@@ -42,13 +42,19 @@
<text class="text-prompt">KG</text>
</view>
</view>
<navigator class="box row bothSide verCenter" :url="'/pages/tallyGoods/originSplit?erp_order_sn=' + form.erp_order_sn" hover-class="none">
<text class="label">产地拆分(选填)</text>
<view class="input-wrap-width row bothSide verCenter">
<text class="text">{{ form.detail_json.length > 0 ? '已拆分' + form.detail_json.length : '请选择' }}</text>
<text class="iconfont icon-sanjiaoxing2"></text>
</view>
</navigator>
<view style="border-bottom: 1px solid #e6edf0;">
<navigator class="box row bothSide verCenter" :url="'/pages/tallyGoods/originSplit?erp_order_sn=' + form.erp_order_sn+'&originIndex='+index" hover-class="none" v-for="(item,index) in form.detail_json" :key="index">
<view class="row verCenter">
<text class="label">产地拆分{{index+1}}(选填)</text>
<text class="iconfont icon-xinzeng-" style="color: #197adb;font-size: 44rpx;" @click.stop="add" v-if="index === form.detail_json.length - 1"></text>
<text class="iconfont icon-jianshao" style="color: #197adb;font-size: 46rpx;" @click.stop="reduce(index)" v-if="index != 0"></text>
</view>
<view class="input-wrap-width row bothSide verCenter">
<text class="text">{{ form.detail_json[index].length > 0 ? '已拆分' + form.detail_json[index].length : '请选择' }}</text>
<text class="iconfont icon-sanjiaoxing2"></text>
</view>
</navigator>
</view>
<navigator class="box row bothSide verCenter" :url="'/pages/tallyGoods/manualMerge?erp_order_sn=' + form.erp_order_sn + '&fix_erp_order_sn=' + form.fix_erp_order_sn" hover-class="none">
<text class="label">手动合箱(选填)</text>
<view class="input-wrap-width row verCenter">
......@@ -132,14 +138,19 @@
maxNum: 4, //最大上传图片数量
disabled: false,
switchFlag: false,
paramsOrigin: [
[]
], //产地拆分数据存储
form: {
erp_order_sn: '', //入仓号
erp_order_sn: 'B51590', //入仓号
customs_clearance_price: 0, //清关费
box_num: '0', //箱子
board_num: '0', //板子
gross_weight: '', //合计毛重
pic_json: [], //商检图片
detail_json: [], //产地拆分数据
detail_json: [
[]
], //产地拆分数据
fix_erp_order_sn: '', //手动合箱
pur_pic: '' //采购单上传
}
......@@ -170,9 +181,11 @@
//更新产地拆分国家的数据
uni.$on('updateOriginData', data => {
if (data) {
this.form.detail_json = data.detail_json;
let originIndex = Number(data.originIndex); //转成数字
this.$set(this.form.detail_json, originIndex, data.detail_json);
this.$set(this.paramsOrigin, originIndex, data);
uni.removeStorageSync('paramsOrigin');
uni.setStorageSync('paramsOrigin', data);
uni.setStorageSync('paramsOrigin', this.paramsOrigin);
}
});
},
......@@ -210,6 +223,20 @@
}, 800);
},
/**
* 产地拆分-新增
*/
add() {
this.form.detail_json.push([]);
this.paramsOrigin.push([]);
},
/**
* 产地拆分-减去
*/
reduce(index) {
this.form.detail_json.splice(index, 1);
this.paramsOrigin.splice(index, 1);
},
/**
* 检测入仓号是否理货
*/
checkErpOrderSnIsTally() {
......@@ -456,6 +483,10 @@
this.currentIndex = index;
this.form.customs_clearance_price = index;
},
checkEntryID(detail_json) {
const firstEntryID = detail_json[0][0].entryID;
return detail_json.every(item => item[0].entryID === firstEntryID);
},
/**
* @param {Object} type 1提交并打印
* 提交
......@@ -518,6 +549,17 @@
}
}
const entryIDs = this.form.detail_json.map(array => (array.length > 0 ? array[0].entryID : null));
let result = new Set(entryIDs).size < entryIDs.length;
if (result) {
uni.showModal({
content: '产地拆分所选型号有重复,请检查',
showCancel: false
});
return false;
}
this.request(API.submitTallyGoods, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
uni.showModal({
......
......@@ -87,212 +87,215 @@
</template>
<script>
import { API } from '@/util/api.js';
import { createArray } from '@/util/util.js';
import { API } from '@/util/api.js';
import { createArray } from '@/util/util.js';
export default {
data() {
return {
curr: -1, //当前打开的是哪个产地
erp_order_sn: '',
goods_index: -1,
goods_list: [],
num_arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
index: -1,
filter_status: [], //控制状态
origin_list: [], //产地
origin: '', //搜索国家携带的参数
tally_num: 0, //拆分数量
detail_json: [], //收集的数据
dataStates: {}, // 用于记录数据状态的对象
total: 0
};
},
onLoad(options) {
this.erp_order_sn = options.erp_order_sn || '';
// 从本地缓存中获取数据
const dataFromSourcePage = uni.getStorageSync('paramsOrigin');
// 使用Object.assign()将dataFromSourcePage的属性合并到data中
Object.assign(this.$data, dataFromSourcePage);
},
onShow() {
this.getData();
this.getOrigin();
},
methods: {
open(index) {
this.curr = index;
this.filter_status.fill(false);
this.$refs.popup.open('bottom');
},
/**
* 找出false对应的下标
* @param {Object} arr
* @param {Object} target
*/
findIndex(arr, target) {
const result = [];
arr.map((item, index) => {
if (item === target) {
result.push(index);
}
});
return result;
export default {
data() {
return {
originIndex: 0, //默认第一个
curr: -1, //当前打开的是哪个产地
erp_order_sn: '',
goods_index: -1,
goods_list: [],
num_arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
index: -1,
filter_status: [], //控制状态
origin_list: [], //产地
origin: '', //搜索国家携带的参数
tally_num: 0, //拆分数量
detail_json: [], //收集的数据
dataStates: {}, // 用于记录数据状态的对象
total: 0
};
},
onInputNum() {
const total = this.detail_json.reduce((sum, item) => {
if (item.tally_num) {
return sum + item.tally_num * 1;
} else {
return sum * 1;
}
}, 0);
onLoad(options) {
this.erp_order_sn = options.erp_order_sn || '';
this.originIndex = options.originIndex;
var num = this.goods_list[this.goods_index].qty * 1;
if (total > num) {
uni.showModal({
title: '错误提示',
content: '拆分数量总和必须等于订单数量(不可大于或者小于)',
showCancel: false
});
return false;
}
// 从本地缓存中获取数据
const dataFromSourcePage = uni.getStorageSync('paramsOrigin');
this.total = total;
// 使用Object.assign()将dataFromSourcePage的属性合并到data中
Object.assign(this.$data, dataFromSourcePage[this.originIndex]);
},
onInput() {
// 清除之前的定时器
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.origin_list = []; //数组清空
this.getOrigin();
}, 800);
onShow() {
this.getData();
this.getOrigin();
},
bindPickerChange: function(e, type) {
console.log('picker发送选择改变,携带值为', e.target.value);
if (type == 1) {
this.goods_index = e.target.value;
} else if (type == 2) {
this.tally_num = parseInt(e.target.value) + 1;
this.index = e.target.value;
this.total = 0;
this.detail_json = Array.from({ length: this.tally_num }, () => ({ origin: '', tally_num: '', entryID: this.goods_list[this.goods_index].entryID }));
}
},
getOrigin() {
this.request(API.getOrigin, 'GET', { origin: this.origin }, true).then(res => {
if (res.err_code === 0) {
this.origin_list = Object.values(res.data);
this.filter_status = createArray(this.origin_list.length, false);
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
},
getData() {
this.request(API.getTallyGoods, 'GET', { erp_order_sn: this.erp_order_sn }, true).then(res => {
if (res.err_code === 0) {
if (res.data.entrys.length > 0) {
this.goods_list = res.data.entrys;
methods: {
open(index) {
this.curr = index;
this.filter_status.fill(false);
this.$refs.popup.open('bottom');
},
/**
* 找出false对应的下标
* @param {Object} arr
* @param {Object} target
*/
findIndex(arr, target) {
const result = [];
arr.map((item, index) => {
if (item === target) {
result.push(index);
}
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
return result;
},
onInputNum() {
const total = this.detail_json.reduce((sum, item) => {
if (item.tally_num) {
return sum + item.tally_num * 1;
} else {
return sum * 1;
}
}, 0);
var num = this.goods_list[this.goods_index].qty * 1;
if (total > num) {
uni.showModal({
title: '错误提示',
content: '拆分数量总和必须等于订单数量(不可大于或者小于)',
showCancel: false
});
return false;
}
});
},
/**
*筛选过滤出选中的元素
*/
filterChange(index) {
this.$set(this.filter_status, index, (this.filter_status[index] = !this.filter_status[index]));
let filter_arr = this.findIndex(this.filter_status, true);
var name = filter_arr.map(i => this.origin_list[i]);
this.detail_json[this.curr].origin = name[0];
this.$forceUpdate();
this.$refs.popup.close();
},
confirmChange() {
this.$refs.popup.close();
},
/**
* 判断是否有重复的产地
*/
hasDuplicateOrigin(arr) {
const uniqueOrigins = new Set();
for (const item of arr) {
if (uniqueOrigins.has(item.origin)) {
return true;
this.total = total;
},
onInput() {
// 清除之前的定时器
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.origin_list = []; //数组清空
this.getOrigin();
}, 800);
},
bindPickerChange: function(e, type) {
console.log('picker发送选择改变,携带值为', e.target.value);
if (type == 1) {
this.goods_index = e.target.value;
} else if (type == 2) {
this.tally_num = parseInt(e.target.value) + 1;
this.index = e.target.value;
this.total = 0;
this.detail_json = Array.from({ length: this.tally_num }, () => ({ origin: '', tally_num: '', entryID: this.goods_list[this.goods_index].entryID }));
}
uniqueOrigins.add(item.origin);
}
return false;
},
submit() {
if (this.goods_index == -1) {
uni.showToast({
title: '请选择型号',
icon: 'none'
},
getOrigin() {
this.request(API.getOrigin, 'GET', { origin: this.origin }, true).then(res => {
if (res.err_code === 0) {
this.origin_list = Object.values(res.data);
this.filter_status = createArray(this.origin_list.length, false);
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
return false;
}
if (this.tally_num == 0) {
uni.showToast({
title: '请选择拆分数量',
icon: 'none'
},
getData() {
this.request(API.getTallyGoods, 'GET', { erp_order_sn: this.erp_order_sn }, true).then(res => {
if (res.err_code === 0) {
if (res.data.entrys.length > 0) {
this.goods_list = res.data.entrys;
}
} else {
uni.showToast({
title: res.err_msg,
icon: 'error'
});
}
});
},
/**
*筛选过滤出选中的元素
*/
filterChange(index) {
this.$set(this.filter_status, index, (this.filter_status[index] = !this.filter_status[index]));
let filter_arr = this.findIndex(this.filter_status, true);
var name = filter_arr.map(i => this.origin_list[i]);
this.detail_json[this.curr].origin = name[0];
this.$forceUpdate();
this.$refs.popup.close();
},
confirmChange() {
this.$refs.popup.close();
},
/**
* 判断是否有重复的产地
*/
hasDuplicateOrigin(arr) {
const uniqueOrigins = new Set();
for (const item of arr) {
if (uniqueOrigins.has(item.origin)) {
return true;
}
uniqueOrigins.add(item.origin);
}
return false;
}
const shouldContinue = !this.detail_json.some(item => {
if (!item.origin) {
},
submit() {
if (this.goods_index == -1) {
uni.showToast({
title: '请选择拆分国家',
title: '请选择型号',
icon: 'none'
});
return true;
return false;
}
if (this.tally_num == 0) {
uni.showToast({
title: '请选择拆分数量',
icon: 'none'
});
return false;
}
return false;
});
const hasDuplicates = this.hasDuplicateOrigin(this.detail_json);
if (hasDuplicates) {
uni.showToast({
title: '不允许有相同产地,请重新选择产地',
icon: 'none'
const shouldContinue = !this.detail_json.some(item => {
if (!item.origin) {
uni.showToast({
title: '请选择拆分国家',
icon: 'none'
});
return true;
}
return false;
});
return false;
}
if (shouldContinue) {
const totalTallyNum = this.detail_json.reduce((total, item) => total + parseInt(item.tally_num), 0);
const total = this.goods_list[this.goods_index].qty * 1;
if (totalTallyNum != total) {
uni.showModal({
title: '错误提示',
content: '拆分数量总和必须等于订单数量(不可大于或者小于)',
showCancel: false
const hasDuplicates = this.hasDuplicateOrigin(this.detail_json);
if (hasDuplicates) {
uni.showToast({
title: '不允许有相同产地,请重新选择产地',
icon: 'none'
});
return false;
}
}
uni.$emit('updateOriginData', this.$data);
uni.navigateBack({
delta: 1
});
if (shouldContinue) {
const totalTallyNum = this.detail_json.reduce((total, item) => total + parseInt(item.tally_num), 0);
const total = this.goods_list[this.goods_index].qty * 1;
if (totalTallyNum != total) {
uni.showModal({
title: '错误提示',
content: '拆分数量总和必须等于订单数量(不可大于或者小于)',
showCancel: false
});
return false;
}
}
uni.$emit('updateOriginData', this.$data);
uni.navigateBack({
delta: 1
});
}
}
}
};
};
</script>
<style scoped lang="scss">
@import '../../assets/css/tallyGoods/originSplit.scss';
</style>
@import '../../assets/css/tallyGoods/originSplit.scss';
</style>
\ No newline at end of file
No preview for this file type
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