Commit 755f316e authored by 何远江's avatar 何远江

添加销售拣货缓存功能

parent b2cae7a8
...@@ -50,31 +50,12 @@ export default { ...@@ -50,31 +50,12 @@ export default {
data() { data() {
return { return {
bgSrc: require('@/static/images/qrcode.png'), bgSrc: require('@/static/images/qrcode.png'),
number: 0,
show: true,
nlpla: '',
wxparams: '', wxparams: '',
btnArr: [
{
style: '',
type: 'primary',
text: '扫描单号',
way: 'scanning'
},
// {
// style: '',
// type: 'warning',
// text: '查询单号',
// way: 'goClick'
// }
],
goodsList: [],
isFocus: false, isFocus: false,
isDisabled: false isDisabled: false
}; };
}, },
created() { created() {
// this.getPlnr('80000033');
}, },
methods: { methods: {
getBtnHandle(row) { getBtnHandle(row) {
...@@ -102,13 +83,11 @@ export default { ...@@ -102,13 +83,11 @@ export default {
}) })
.then((res) => { .then((res) => {
if (res && res.BKDT.length) { if (res && res.BKDT.length) {
this.goodsList = res.BKDT
uni.navigateTo({ uni.navigateTo({
url: `/pages/salesOutbound/salesOutboundList?order=${JSON.stringify(this.goodsList)}` url: `/pages/salesOutbound/salesOutboundList?order=${VBELN}`
}); });
} else { } else {
// res.forEach(element => { // 删除本地缓存的单号
// });
this.$u.toast(res.MSG[0].MESSAGE); this.$u.toast(res.MSG[0].MESSAGE);
} }
this.loading = false; this.loading = false;
......
<template> <template>
<view class="lists page"> <view class="lists page">
<StickyNavBar class="listTitle"> <StickyNavBar class="listTitle">
<NavBar title="销售拣货"></NavBar> <NavBar title="销售拣货"></NavBar>
<!-- <view class="selectSheet"> <view class="headerTitle">
<u-tabs :list="list" :is-scroll="false" :current="current" @change="changeTab"></u-tabs> <view class="items">交货单号:{{ vbeln }}</view>
</view> --> <view class="items">8|李XXXXXXX体</view>
<view class="headerTitle"> <view class="items">计划日期:9999/99/99</view>
<view class="items">交货单号:{{ vbeln }}</view> </view>
<view class="items">8|李XXXXXXX体</view> <view class="">
<view class="items">计划日期:9999/99/99</view> <view class="btn">
</view> <uni-easyinput prefixIcon="search" :disabled="isDisabled" v-model="wxparams" :focus="isFocus"
<view class=""> placeholder="请扫描产品包装条码/外箱码" @input="handleInputPlnr"></uni-easyinput>
<view class="btn">
<!-- <uni-easyinput prefixIcon="search" class="topSearch" v-model="nlpla" focus placeholder="请扫描库位" @change="handleInputNlpla"></uni-easyinput> -->
<uni-easyinput
prefixIcon="search"
:disabled="isDisabled"
v-model="wxparams"
:focus="isFocus"
placeholder="请扫描产品包装条码/外箱码"
@input="handleInputPlnr"
></uni-easyinput>
</view>
<view class="total">
<view class="left">明细</view>
<view class="right">
<!-- 物料数量: -->
<text class="blue">{{ totalNum }}</text>
<text class="line">/</text>
<text class="">{{ goodsList.length }}</text>
</view>
</view>
</view>
</StickyNavBar>
<ContentLoadingMore class="contentMore" :list="goodsList">
<view class="cardbox">
<view
class="cardContent"
v-for="(item, index) in goodsList"
:key="item.PLNR"
>
<scanningList :item="item" :list="item.ZPLDT" />
</view>
</view>
<!-- <view class="cardbox" v-else>
<view class="cardContent" v-for="(item, index) in goodsList">
<stockList :item='item' />
</view> </view>
</view> --> <view class="total">
</ContentLoadingMore> <view class="left">明细</view>
<BottomBtn :btnArr="btnArr" @getBtnHandle="getBtnHandle"></BottomBtn> <view class="right">
</view> <!-- 物料数量: -->
<text class="blue">{{ totalNum }}</text>
<text class="line">/</text>
<text class="">{{ goodsList.length }}</text>
</view>
</view>
</view>
</StickyNavBar>
<ContentLoadingMore class="contentMore" :list="goodsList">
<view class="cardbox">
<view class="cardContent" v-for="(item, index) in goodsList" :key="item.PLNR">
<scanningList :item="item" :list="item.ZPLDT" />
</view>
</view>
</ContentLoadingMore>
<BottomBtn :btnArr="btnArr" @getBtnHandle="getBtnHandle"></BottomBtn>
</view>
</template> </template>
<script> <script>
import StickyNavBar from "@/components/StickyNavBar/index.vue"; import StickyNavBar from "@/components/StickyNavBar/index.vue";
import ContentLoadingMore from "@/components/ContentLoadingMore/index.vue"; import ContentLoadingMore from "@/components/ContentLoadingMore/index.vue";
import BottomBtn from "@/components/BottomBtn/index.vue"; import BottomBtn from "@/components/BottomBtn/index.vue";
import scanningList from "./scanningList.vue"; import scanningList from "./scanningList.vue";
import stockList from "./stockList.vue"; import stockList from "./stockList.vue";
import { parseTime } from "@/utils/ruoyi"; import {
export default { parseTime
components: { } from "@/utils/ruoyi";
StickyNavBar, export default {
ContentLoadingMore, components: {
BottomBtn, StickyNavBar,
scanningList, ContentLoadingMore,
stockList, BottomBtn,
}, scanningList,
data() { stockList,
return { },
value: "", data() {
type: "select", return {
border: true, value: "",
current: 0, type: "select",
status: "loadmore", border: true,
btnArr: [ current: 0,
{ status: "loadmore",
style: "", btnArr: [{
type: "warning", style: "",
text: "返回", type: "primary",
way: "goBack", text: "保存",
}, way: "goSave",
{ },
style: "", {
type: "primary", style: "",
text: "提交", type: "primary",
way: "goSubmit", text: "提交",
}, way: "goSubmit",
], },
isFocus: false, ],
isDisabled: false, isFocus: false,
nlpla: "", isDisabled: false,
wxparams: "", nlpla: "",
goodsList: [], wxparams: "",
orderItem: {}, goodsList: [],
resFlag: false, pls: [], // 已经扫码的pl号
}; resFlag: false,
}, };
created() { },
// this.getPlnr('10000820240325000001|10000320100'); created() {},
}, onLoad(option) {
onLoad(option) { /**
if (option && option.order) { * 查询缓存中是否有单号,有单号读取扫描PL的数据
const arr = [...JSON.parse(option.order)]; */
console.log(arr, "------"); this.getInfo(option.order);
// 有SIZE行就取ZINSNUM+ZLOSSC,没有SIZE行的就是取交货单行的LFIMG this.vbeln = option.order
arr.forEach((ele) => { },
if (ele.ZSIZE.length) { computed: {
this.goodsList.push( totalNum() {
...ele.ZSIZE.map((item) => { const count = this.goodsList.filter((item) => item.checkedBox).length;
return { return count || 0;
KDAUF: ele.KDAUF, },
KDPOS: ele.KDPOS, /**
LFIMG: ele.LFIMG, * 缓存的扫描过的pl条目
MEINS: ele.MEINS, */
WERKS: ele.WERKS, catchPL() {
...item, return this.vuex_sales_outbound[this.vbeln] || null
MATNR: ele.MATNR, },
MAKTX: ele.MAKTX, },
sumNum: item.ZINSNUM+item.ZLOSSC methods: {
}; goSubmit() {
}) if (!this.goodsList.length) return;
); if (this.resFlag) {
} else { return this.$u.toast("当前单据已经提交成功!无需继续提交!");
ele.ZSIZE = ""; }
ele.sumNum = ele.LFIMG; const flag = this.goodsList.every((ele) => {
// ele.ZINSNUM = ele.LFIMG; return (
this.goodsList.push(ele); ele.sumNum == ele?.ZPLDT?.reduce((acc, cur) => acc + cur.PACMG, 0)
this.$u.toast(`物料编号:${ele.MATNR}--没有尺码信息`); );
} });
});
}
},
computed: {
totalNum() {
const count = this.goodsList.filter((item) => item.checkedBox).length;
return count || 0;
},
vbeln() {
return this.goodsList[0]?.VBELN || "";
},
},
methods: {
goSubmit() {
if (!this.goodsList.length) return;
if (this.resFlag) {
return this.$u.toast("当前单据已经提交成功!无需继续提交!");
}
const flag = this.goodsList.every((ele) => {
return (
ele.sumNum == ele?.ZPLDT?.reduce((acc, cur) => acc + cur.PACMG, 0)
);
});
if (!flag) { if (!flag) {
return this.$u.toast("请确认所有包装数量是否正确"); return this.$u.toast("请确认所有包装数量是否正确");
} }
const params = this.goodsList.reduce((acc, cur, index) => { const params = this.goodsList.reduce((acc, cur, index) => {
if (index == 0) { if (index == 0) {
acc.push(JSON.parse(JSON.stringify(cur))); acc.push(JSON.parse(JSON.stringify(cur)));
} else { } else {
const item = acc.find((v) => v.POSNR === cur.POSNR); const item = acc.find((v) => v.POSNR === cur.POSNR);
if (item) { if (item) {
item.ZPLDT.push(...cur.ZPLDT); item.ZPLDT.push(...cur.ZPLDT);
} else { } else {
acc.push(JSON.parse(JSON.stringify(cur))); acc.push(JSON.parse(JSON.stringify(cur)));
} }
} }
return acc; return acc;
}, []); }, []);
this.$u.api.sapApi.sapPickingDn(params).then((res) => { this.$u.api.sapApi.sapPickingDn(params).then((res) => {
this.loading = false; this.loading = false;
if (!Array.isArray(res)) { if (!Array.isArray(res)) {
return; return;
} }
const flag = res.some((item) => { const flag = res.some((item) => {
const f = item.TYPE == "E"; const f = item.TYPE == "E";
if (f) { if (f) {
this.$u.toast(item.MESSAGE); this.$u.toast(item.MESSAGE);
} }
return f; return f;
}); });
if (!flag) { if (!flag) {
this.$u.toast("提交成功"); this.$u.toast("提交成功");
// this.resFlag = true // 如果有缓存PL,提交成功将要清楚当前缓存
setTimeout(() => { if (this.catchPL) {
this.goBack(); const sales_outbound = {
}, 1000); ...this.vuex_sales_outbound
} }
}); delete sales_outbound[this.vbeln]
}, this.$u.vuex('vuex_sales_outbound', sales_outbound)
getPlnr(plnr) { }
let params = { setTimeout(() => {
ZCODE: plnr.includes("BL") ? plnr : "", this.goBack();
plnr: plnr.includes("BL") ? "" : plnr, }, 1000);
}; }
this.$u.api.sapApi.sapBlpl(params).then((res) => { });
if (res && res.MSG[0].TYPE === "S") { },
// 循环BLPL合并相同的物料号和size goSave() {
res.BLPL.forEach((ele) => { console.log(this.vuex_sales_outbound, 'this.vuex_sales_outbound')
ele.TOMNG = ele.PACMG; // 缓存以单号为key,扫描的pl为value
const item = this.goodsList.find( const pls = this.goodsList.reduce((acc, cur) => {
(v) => v.ZSIZE == ele.ZSIZE && ele.MATNR == v.MATNR cur.ZPLDT && acc.push(...cur.ZPLDT)
); return acc
if (item) { }, [])
if (Reflect.has(item, "ZPLDT")) { // 如果已经扫描pl执行缓存
item.ZPLDT.push(ele); if (pls.length) {
} else { const sales_outbound = {
this.$set(item, "ZPLDT", [ele]); ...(this.vuex_sales_outbound || {}),
} [this.vbeln]: pls
} }
}); this.$u.vuex('vuex_sales_outbound', sales_outbound)
} else { this.$u.toast('保存成功!')
this.$u.toast(res.MSG[0].MESSAGE); }
} },
setTimeout(() => { getInfo(VBELN) {
this.isFocus = true; this.$u.api.sapApi
this.isDisabled = false; .sapSchDn({
this.wxparams = ""; VBELN
}, 1000); }).then(res => {
this.loading = false; this.initGoodsList(res.BKDT)
}); console.log(this.catchPL, 'this.catchPL')
}, this.catchPL && this.setSalesBoundPL(this.catchPL)
// 加载更多 })
onReachBottom() { },
console.log("加载更多inventoryCounting"); initGoodsList(arr) {
}, // 有SIZE行就取ZINSNUM+ZLOSSC,没有SIZE行的就是取交货单行的LFIMG
getBtnHandle(row) { arr.forEach((ele) => {
console.log("getBtnHandle", row); if (ele.ZSIZE.length) {
this[row.way](); this.goodsList.push(
}, ...ele.ZSIZE.map((item) => {
goBack() { return {
console.log("进来"); KDAUF: ele.KDAUF,
uni.navigateBack(); KDPOS: ele.KDPOS,
}, LFIMG: ele.LFIMG,
changeTab(index) { MEINS: ele.MEINS,
this.current = index; WERKS: ele.WERKS,
}, ...item,
handleInputNlpla(e) {}, MATNR: ele.MATNR,
handleInputPlnr(e) { MAKTX: ele.MAKTX,
this.isFocus = false; sumNum: item.ZINSNUM + item.ZLOSSC
e && this.getPlnr(e); };
}, })
}, );
}; } else {
ele.ZSIZE = "";
ele.sumNum = ele.LFIMG;
// ele.ZINSNUM = ele.LFIMG;
this.goodsList.push(ele);
this.$u.toast(`物料编号:${ele.MATNR}--没有尺码信息`);
}
});
},
setSalesBoundPL(pls) {
console.log(pls, 'pls')
// 循环BLPL合并相同的物料号和size
pls.forEach((ele) => {
if (!this.pls.includes(ele.PLNR) || !this.pls.includes(ele.ZCODE)) {
ele.PLNR && this.pls.push(ele.PLNR)
ele.ZCODE && this.pls.push(ele.ZCODE)
}
ele.TOMNG = ele.PACMG;
const item = this.goodsList.find(
(v) => v.ZSIZE == ele.ZSIZE && ele.MATNR == v.MATNR
);
if (item) {
if (Reflect.has(item, "ZPLDT")) {
item.ZPLDT.push(ele);
} else {
this.$set(item, "ZPLDT", [ele]);
}
}
});
},
getPlnr(plnr) {
let params = {
ZCODE: plnr.includes("BL") ? plnr : "",
plnr: plnr.includes("BL") ? "" : plnr,
};
this.$u.api.sapApi.sapBlpl(params).then((res) => {
if (res && res.MSG[0].TYPE === "S") {
this.setSalesBoundPL(res.BLPL)
} else {
this.$u.toast(res.MSG[0].MESSAGE);
}
setTimeout(() => {
this.isFocus = true;
this.isDisabled = false;
this.wxparams = "";
}, 1000);
this.loading = false;
});
},
// 加载更多
onReachBottom() {
console.log("加载更多inventoryCounting");
},
getBtnHandle(row) {
console.log("getBtnHandle", row);
this[row.way]();
},
goBack() {
console.log("进来");
uni.navigateBack();
},
changeTab(index) {
this.current = index;
},
handleInputNlpla(e) {},
handleInputPlnr(e) {
if (!e) return
this.isFocus = false;
console.log(this.pls, 'this.pls')
if (this.pls.includes(e)) {
return this.$u.toast('请勿重复扫描!')
}
this.getPlnr(e);
},
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
.selectSheet { .selectSheet {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
} }
/deep/ .u-sticky { /deep/ .u-sticky {
top: 0 !important; top: 0 !important;
background: #fff; background: #fff;
} }
.tabTwo { .tabTwo {
/deep/ .u-sticky-wrap { /deep/ .u-sticky-wrap {
height: 330rpx !important; height: 330rpx !important;
} }
} }
.listTitle { .listTitle {}
}
.contentMore { .contentMore {
margin: 20rpx; margin: 20rpx;
} }
page { page {
background: #f8f8f8; background: #f8f8f8;
} }
.headerTitle { .headerTitle {
padding: 20rpx; padding: 20rpx;
font-weight: 600; font-weight: 600;
.items { .items {
line-height: 40rpx; line-height: 40rpx;
} }
} }
.btn { .btn {
padding: 20rpx; padding: 20rpx;
background: #fff; background: #fff;
.topSearch { .topSearch {
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
} }
.total { .total {
background: #fff; background: #fff;
color: #000; color: #000;
padding: 0rpx 40rpx; padding: 0rpx 40rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-size: 32rpx; font-size: 32rpx;
.line { .line {
margin: 0px 10rpx; margin: 0px 10rpx;
} }
} }
.cardbox { .cardbox {
min-height: calc(100vh - 410rpx); min-height: calc(100vh - 410rpx);
padding: 0rpx 20rpx; padding: 0rpx 20rpx;
margin-top: 20rpx; margin-top: 20rpx;
} }
.cardContent { .cardContent {
border-radius: 8px; border-radius: 8px;
background: #fff; background: #fff;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
</style> </style>
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
import config from '@/common/config.js'; import config from '@/common/config.js';
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
let lifeData = {}; let lifeData = {};
try{ try {
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的 // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData = uni.getStorageSync('lifeData'); lifeData = uni.getStorageSync('lifeData');
}catch(e){ } catch (e) {
} }
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = ['vuex_user', 'vuex_user_factory','vuex_token', 'vuex_remember', 'vuex_locale','vuex_isAgent','vuex_workstation','vuex_task']; let saveStateKeys = ['vuex_user', 'vuex_user_factory', 'vuex_token', 'vuex_remember', 'vuex_locale', 'vuex_isAgent',
'vuex_workstation', 'vuex_task', 'vuex_sales_outbound'
// 保存变量到本地存储中 ];
const saveLifeData = function(key, value){
// 判断变量名是否在需要存储的数组中 // 保存变量到本地存储中
if(saveStateKeys.indexOf(key) != -1) { const saveLifeData = function(key, value) {
// 获取本地存储的lifeData对象,将变量添加到对象中 // 判断变量名是否在需要存储的数组中
let tmp = uni.getStorageSync('lifeData'); if (saveStateKeys.indexOf(key) != -1) {
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象 // 获取本地存储的lifeData对象,将变量添加到对象中
tmp = tmp ? tmp : {}; let tmp = uni.getStorageSync('lifeData');
tmp[key] = value; // 第一次打开APP,不存在lifeData变量,故放一个{}空对象
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中 tmp = tmp ? tmp : {};
uni.setStorageSync('lifeData', tmp); tmp[key] = value;
} // 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
} uni.setStorageSync('lifeData', tmp);
// 简化 vuex 操作,文档:https://uviewui.com/components/vuexDetail.html }
const store = new Vuex.Store({ }
state: { // 简化 vuex 操作,文档:https://uviewui.com/components/vuexDetail.html
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量 const store = new Vuex.Store({
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然 state: {
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {userName: 'Aidex'}, // 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '', // 加上vuex_前缀,是防止变量名冲突,也让人一目了然
vuex_remember: lifeData.vuex_remember ? lifeData.vuex_remember : '', vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {
vuex_locale: lifeData.vuex_locale ? lifeData.vuex_locale : '', userName: 'Aidex'
vuex_isAgent: lifeData.vuex_isAgent ? lifeData.vuex_isAgent : '', },
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
vuex_remember: lifeData.vuex_remember ? lifeData.vuex_remember : '',
vuex_locale: lifeData.vuex_locale ? lifeData.vuex_locale : '',
vuex_isAgent: lifeData.vuex_isAgent ? lifeData.vuex_isAgent : '',
vuex_user_factory: lifeData.vuex_user_factory || '1000', vuex_user_factory: lifeData.vuex_user_factory || '1000',
vuex_sales_outbound: lifeData.vuex_sales_outbound || {},
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_config: config, // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
//当前设备绑定的工作站 vuex_config: config,
vuex_workstation: null, //当前设备绑定的工作站
vuex_workunit: null, vuex_workstation: null,
//当前工作站正在进行的生产任务 vuex_workunit: null,
vuex_task: null, //当前工作站正在进行的生产任务
vuex_task: null,
// 自定义tabbar数据
// vuex_tabbar: [{ // 自定义tabbar数据
// iconPath: "/static/uview/example/component.png", // vuex_tabbar: [{
// selectedIconPath: "/static/uview/example/component_select.png", // iconPath: "/static/uview/example/component.png",
// text: '组件', // selectedIconPath: "/static/uview/example/component_select.png",
// pagePath: '/pages/example/components' // text: '组件',
// }, // pagePath: '/pages/example/components'
// { // },
// iconPath: "/static/uview/example/js.png", // {
// selectedIconPath: "/static/uview/example/js_select.png", // iconPath: "/static/uview/example/js.png",
// text: '工具', // selectedIconPath: "/static/uview/example/js_select.png",
// midButton: true, // text: '工具',
// pagePath: '/pages/example/js' // midButton: true,
// }, // pagePath: '/pages/example/js'
// { // },
// iconPath: "/static/uview/example/template.png", // {
// selectedIconPath: "/static/uview/example/template_select.png", // iconPath: "/static/uview/example/template.png",
// text: '模板', // selectedIconPath: "/static/uview/example/template_select.png",
// pagePath: '/pages/example/template' // text: '模板',
// } // pagePath: '/pages/example/template'
// ] // }
}, // ]
mutations: { },
$uStore(state, payload) { mutations: {
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1 $uStore(state, payload) {
let nameArr = payload.name.split('.'); // 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
let saveKey = ''; let nameArr = payload.name.split('.');
let len = nameArr.length; let saveKey = '';
if(len >= 2) { let len = nameArr.length;
let obj = state[nameArr[0]]; if (len >= 2) {
for(let i = 1; i < len - 1; i ++) { let obj = state[nameArr[0]];
obj = obj[nameArr[i]]; for (let i = 1; i < len - 1; i++) {
} obj = obj[nameArr[i]];
obj[nameArr[len - 1]] = payload.value; }
saveKey = nameArr[0]; obj[nameArr[len - 1]] = payload.value;
} else { saveKey = nameArr[0];
// 单层级变量,在state就是一个普通变量的情况 } else {
state[payload.name] = payload.value; // 单层级变量,在state就是一个普通变量的情况
saveKey = payload.name; state[payload.name] = payload.value;
} saveKey = payload.name;
// 保存变量到本地,见顶部函数定义 }
saveLifeData(saveKey, state[saveKey]) // 保存变量到本地,见顶部函数定义
} saveLifeData(saveKey, state[saveKey])
} }
}) }
})
export default store export default store
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 to comment