Commit 2bdbf0b1 by LJM

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

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