货无忧
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.
 
 
 
 
 

534 lines
11 KiB

<template>
<BasicContainer ref="basicContainer" :option="option">
<template #head>
<view class="hdstop">
<view class="khxb">
<view>客户{{items.consignee}}</view>
<view>地址{{items.deliveryAddress}}</view>
<view>电话{{items.deliveryPhone}}</view>
<view class="butlur" @click="showsdqs">
录入包条码
</view>
</view>
<view class="tps">
<view>
<view>包件总数</view>
<view>{{details.datalist.length}}</view>
</view>
<view>
<view>已签包件</view>
<view>{{details.signNub}}</view>
</view>
<view>
<view>未签包件</view>
<view>{{details.noSingnNum}}</view>
</view>
</view>
</view>
</template>
<template #body>
<scroll-view class="main" @touchmove.stop :style="{height: details.scrollHeight}" :scroll-y="true"
:scroll-x="true">
<!-- 表格表头 -->
<view class="main_row main_title">
<view class="">
包条码
</view>
<view class="">
订单号
</view>
<view class="">
类型
</view>
<view class="">
签收状态
</view>
<view class="">
异常状态
</view>
</view>
<view :style="{height: details.jpScorllViewHeight}" code="id" class="jpScorllView">
<block v-for="item in datalist" :key="item.orderCode">
<view :class="{'main_row': true, 'red': item.isSignfor === 0, 'green': item.isSignfor === 1}">
<view class="">
{{item.type === 1? item.orderPackageCode: item.orderPackageCode || '未备货'}}
</view>
<view class="">
{{item.orderCode || '暂无数据'}}
</view>
<view class="">
{{item.type === 1 ? '定制品' : '库存品'}}
</view>
<view class="">
{{item.isSignfor === 1?'已签':'未签'}}
</view>
<view :class="{'red': item.isAbnormal === 1}">
{{item.isAbnormal === 1 ? '异常' : '/'}}
</view>
</view>
</block>
</view>
</scroll-view>
</template>
</BasicContainer>
<tips ref="tip"></tips>
<tiplist ref="tiplists"></tiplist>
<!-- #ifdef APP -->
<saomiao2 :ishidestop="scanState !== 0"></saomiao2>
<!-- #endif -->
</template>
<script lang="ts" setup>
import {
signfororder,
signforinventory,
signforsignfor,
signforsignforIn,
signforsignforcontinue,
signforSigningPackageDetail
} from '@/api/user.js'
import {
onLoad,
onShow,
} from '@dcloudio/uni-app'
import { computed, inject, nextTick, onMounted, reactive, ref, toRefs } from "vue";
import useSystemSettingsStore from '@/store/useSystemSettingsStore';
import { storeToRefs } from 'pinia';
import utils from '@/utils/utils.js';
const { scanState } = storeToRefs(useSystemSettingsStore())
const option = {
title: '客户包件扫描',
haveData: true,
async pullDownRefreshInitPage() {
return await initpage()
},
}
let details = reactive({
schanvalue: '',
typearr: [
{
value: 3,
label: '齐套'
},
{
value: 2,
label: '部分扫'
},
{
value: 1,
label: '未扫'
}
],
items: {} as any,
datalist: [] as any,
orderArr: [],
zeroArr: [],
stockArr: [],
id: '',
orderStatus: 1,
scancode: '',
deliveryId: '',
orderType: '' as string | number,
inputtxt: '',
listcheckindex: -1,
scrollHeight: '',
/** 计划件数 */
Plannednub: 0,
/** 滚动区高度 */
jpScorllViewHeight: '',
/** 签收数 */
signNub: 0,
/** 未签数 */
noSingnNum: 0
})
// 组件实例
const tiplists = ref(null)
const tip = ref(null)
const basicContainer = ref()
const ordNub = computed(() => {
let num = 0
num += details.orderArr.length
num += details.zeroArr.length
return num
})
onLoad(async (op) => {
console.log('op :>> ', op);
// #ifdef APP
utils.ttsspke('请扫描包条码')
// #endif
// 获取路由中传递数据
details.items = JSON.parse(op.item)
details.id = JSON.parse(op.item).id
details.deliveryId = op.deliveryId
})
onShow(async () => {
// #ifdef APP
uni.$off('scancodedate')
uni.$on('scancodedate', function (code) {
if (code) {
// 关闭弹窗
tip.value.setdetails({ isshow: false })
console.log(code);
details.scancode = code
scandata()
}
})
// #endif
await nextTick()
basicContainer.value.startPullDownRefresh()
})
// onHide(() => {
// uni.$off('scancodedate')
// })
onMounted(async () => {
await nextTick()
details.jpScorllViewHeight = await utils.getViewDistanceFormTop('.jpScorllView')
})
function goorderdetail(item) {
uni.navigateTo({
url: '/pagesHome/pages/orderDetails/orderDetails?orderCode=' + item.orderCode
})
}
/** 计算数据 */
function computedNum(orderPackageCode) {
details.signNub = 0
details.noSingnNum = 0
const _arr = [...details.datalist]
// 被扫描的包件在第一位, 中间是未扫描的包件, 最后为已扫描的包件
const _signArr = []
const _noSignArr = []
// 被扫描的包条
let _value : any
for (let item of _arr) {
if (!_value && item.orderPackageCode === orderPackageCode) _value = item
if (item.isSignfor === 1) {
details.signNub++
if (item !== _value) _signArr.push(item)
}
else {
details.noSingnNum++
if (item !== _value) _noSignArr.push(item)
}
}
console.log('_signArr :>> ', _signArr);
console.log('_signArr.length :>> ', _signArr.length);
details.datalist = _value ? [_value, ..._noSignArr, ..._signArr] : [..._noSignArr, ..._signArr]
}
async function scandata() {
let data = {
barcode: details.scancode,
deliveryId: details.deliveryId,
reservationId: details.id,
}
const _item = details.datalist.find(val => val.orderPackageCode === details.scancode)
// 定制品
if (!_item || _item.type === 1) {
let response = await signforsignfor(data)
console.log(response);
if (response.code === 200) {
// const num = details.datalist.reduce((curr, item) => curr + item.signforNub, 0)
// #ifdef APP
// utils.ttsspke(num + '件')
// #endif
}
else if (response.code == 3006) {
// #ifdef APP
utils.ttsspke('是否异常签收')
// #endif
tip.value.setdetails({
isshow: true,
content: '请确认是否异常签收',
success: async () => {
let data = {
barcode: details.scancode,
deliveryId: details.deliveryId,
reservationId: details.id
}
let response = await signforsignforcontinue(data)
if (response.code !== 200) return
console.log(response);
uni.showToast({
title: response.msg,
icon: 'none'
})
initpage(details.scancode)
tip.value.setdetails({ isshow: false })
},
cancel: () => {
tip.value.setdetails({ isshow: false })
},
close: () => {
tip.value.setdetails({ isshow: false })
}
})
return
} else {
uni.showToast({
title: response.msg,
icon: 'none'
})
}
} else {
// 库存品扫描
let response = await signforsignforIn(data)
console.log(response);
if (response.code == 3006) {
tip.value.setdetails({
isshow: true,
content: '请确认是否异常签收',
success: async () => {
let data = {
barcode: details.scancode,
deliveryId: details.deliveryId,
reservationId: details.id
}
let response = await signforsignforcontinue(data)
console.log(response);
if (response.code !== 200) return
uni.showToast({
title: response.msg,
icon: 'none'
})
initpage(details.scancode)
tip.value.setdetails({ isshow: false })
},
cancel: () => {
tip.value.setdetails({ isshow: false })
},
close: () => {
tip.value.setdetails({ isshow: false })
}
})
return
} else {
uni.showToast({
title: response.msg,
icon: 'none'
})
}
}
initpage(details.scancode)
}
function showsdqs() {
tiplists.value.setdetails({
isshow: true,
tipstate: 1,
title: '请输入扫描的码',
placeholder: '请输入扫描的码',
inputtext: '',
success: (detail) => {
details.scancode = detail.inputtext
scandata()
tiplists.value.setdetails({ isshow: false })
},
cancel: () => {
tiplists.value.setdetails({ isshow: false })
},
close: () => {
tiplists.value.setdetails({ isshow: false })
}
})
}
async function initpage(scancode = '') {
uni.showLoading({
mask: true
})
try {
// 初始化请求页面数据
let submitData = {
reservationId: details.items.id,
}
details.datalist = []
const res = await signforSigningPackageDetail(submitData)
const { code, data } = res
if (code !== 200) return
details.datalist = data.filter(val => val)
} catch (err) {
console.log('err :>> ', err);
//TODO handle the exception
} finally {
console.log('222 :>> ', 222);
computedNum(scancode)
uni.hideLoading()
return null
}
}
const { datalist, items } = toRefs(details)
</script>
<style lang="scss" scoped>
.butlur {
width: 200upx !important;
height: 64upx !important;
background: #D3832A;
border-radius: 8upx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32upx;
font-weight: 400;
color: #FFFFFF;
}
// 头部
.hdstop {
width: 100%;
padding: 20upx;
background-color: #fff;
box-sizing: border-box;
font-size: 28upx;
font-weight: 400;
color: #092C4D;
margin-bottom: 20upx;
word-break: break-all;
>.khxb {
display: flex;
align-items: flex-start;
margin-bottom: 10upx;
flex-wrap: wrap;
>view {
width: 50%;
margin-bottom: 20upx;
}
}
>.tps {
display: flex;
align-items: center;
justify-content: space-around;
>view {
display: flex;
align-items: center;
flex-direction: column;
&:nth-of-type(1) {
>view:nth-of-type(2) {
color: #092C4D;
font-size: 1.2rem;
}
}
&:nth-of-type(2) {
>view:nth-of-type(2) {
color: #0a0;
font-size: 1.2rem;
}
}
&:nth-of-type(3) {
>view:nth-of-type(2) {
color: #ff5500;
font-size: 1.2rem;
}
}
}
}
}
// 主体内容
.main {
background: #fff;
}
.main_title {
width: 100%;
>view {
background: #eee;
}
}
.main_row {
display: flex;
&.green {
color: #0a0;
}
&.red {
color: #ff5500
}
>view {
padding: 10upx 5upx;
font-size: 0.9rem;
word-break: break-all;
text-align: center;
border-bottom: 1upx dashed #999;
width: 240upx;
flex: none;
&:nth-child(3) {
width: 120upx;
flex: none;
}
&:last-child {
&.red {
background-color: #ff5500;
color: #fff;
}
}
.main_tip {}
}
}
// .jpScorllView {
// overflow-y: scroll;
// }
</style>