You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.0 KiB

<template>
<page-meta root-font-size="18px"></page-meta>
<view class="">
<win-blank-view @goScan='openScanPopup' v-if="itemList.length==0"></win-blank-view>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-detail" @scrolltoupper="upper"
@scrolltolower="lower" @scroll="scroll">
<view class="detail-list" v-for="(item,index) in itemList">
<uni-swipe-action>
<uni-swipe-action-item :right-options="options" :auto-close="false"
@click="swipeClick($event,index)">
<com-base-info :dataContent='item'></com-base-info>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
</scroll-view>
<view class="new_btn_bot" v-if="itemList.length>0">
<button class="new_save_btn" @click="submit()">提交</button>
</view>
<comMessage ref="comMessage"></comMessage>
<win-scan-button @goScan='openScanPopup' v-if="itemList.length>0"></win-scan-button>
<com-scan-unpick ref="scanPopup" @goScan='openScanPopup' @confirm='afterScan'></com-scan-unpick>
</view>
</template>
<script>
import {
inventoryTransfer
} from '@/api/index.js';
import {
showConfirmMsg,
goHome,
getRemoveOption
} from '@/common/basic.js';
import winBlankView from '@/mycomponents/wincom/winBlankView.vue'
import winScanButton from '@/mycomponents/wincom/winScanButton.vue'
import comScanUnpick from '@/mycomponents/scan/comScanUnpick.vue'
import comBaseItem from '@/mycomponents/comItem/comBaseItem.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
export default {
name: 'unpick',
components: {
winBlankView,
winScanButton,
comScanUnpick,
comBaseInfo,
comMessage
},
data() {
return {
options: [],
itemList: [],
fromLocationCode: '',
toLocationCode: '',
scrollTop: 0,
old: {
scrollTop: 0
},
};
},
mounted() {
this.options = getRemoveOption();
},
onLoad() {},
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
filters: {
statusStyle: function(val) {
return getInventoryTypeStyle(val);
},
statusColor: function(val) {
return getInventoryStatusDesc(val);
},
},
methods: {
openScanPopup() {
if (this.itemList.length > 0) {
showConfirmMsg('已经有零件信息,是否要重新扫描?', confirm => {
if (confirm) {
this.itemList = [];
this.$refs.scanPopup.openScanPopup();
}
})
} else {
this.$refs.scanPopup.openScanPopup();
}
},
//提示是否移除选择的行?
swipeClick(e, index) {
let {
content
} = e;
if (content.text === '移除') {
uni.showModal({
title: '提示',
content: '是否移除选择的行?',
success: res => {
if (res.confirm) {
this.itemList.splice(index, 1);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
},
afterScan(items) {
this.itemList = items;
},
submit() {
let that = this;
uni.showLoading({
title: "提交中...",
mask: true
});
let item = {
worker: localStorage.userName,
warehouseCode: localStorage.warehouseCode,
jobNumber: "",
supplierCode: "",
company: localStorage.company,
number: "",
details: []
}
items.forEach(r => {
r.toContainerCode = '';
r.worker = localStorage.userName;
item.details.push(r);
})
let params = JSON.stringify(item);
console.log('params', params);
inventoryTransfer(params)
.then(res => {
that.showMessage('提交成功');
that.clearInfo();
uni.hideLoading();
})
.catch(err => {
that.showMessage(err.message);
uni.hideLoading();
});
},
clearInfo() {
let that = this;
that.itemList = [];
},
upper: function(e) {
// console.log(e)
},
lower: function(e) {
// console.log(e)
},
scroll: function(e) {
// console.log(e)
this.old.scrollTop = e.detail.scrollTop;
},
showMessage(message) {
this.$refs.comMessage.showMessage(message);
}
}
};
</script>
<style scoped lang="scss">
</style>