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

223 lines
4.9 KiB

<template>
<!-- <u-navbar title="离线扫描" placeholder border=true :autoBack="true" leftIconSize='35'></u-navbar> -->
<u-navbar title="离线扫描" bgColor='#D3832A' leftIconColor='#ffffff' titleStyle='color:#ffffff' placeholder
:autoBack="true" leftIconSize='35'></u-navbar>
<scroll-view scroll-y="true" class="scview">
<view class="maxbx">
<view class="item" v-for="(item,index) in details.scandate">
<view>{{item}}</view>
<view class="but">
<!-- <view>编辑</view> -->
<view @click="remove(index)">删除</view>
</view>
</view>
</view>
</scroll-view>
<view class="buts">
<view @click="inputnumb">输入包条码</view>
<view @click="submitsave">保存</view>
</view>
<tips ref="tip"></tips>
<tiplist ref="tiplists"></tiplist>
<!-- #ifdef APP -->
<saomiao2 :ishidestop="scanState !== 0"></saomiao2>
<!-- #endif -->
</template>
<script lang="ts" setup>
import {
onLoad,
onShow,
onHide,
onUnload
} from '@dcloudio/uni-app'
import { reactive, ref } from "vue";
import useSystemSettingsStore from '@/store/useSystemSettingsStore';
import { storeToRefs } from 'pinia';
const { scanState } = storeToRefs(useSystemSettingsStore())
let details = reactive({
taskname: '',
scandate: [],
editindex: ''
})
const tiplists = ref(null)
const tip = ref(null)
onLoad((op) => {
details.taskname = op.name
details.editindex = op.editindex
if (details.editindex) {
details.scandate = uni.getStorageSync('HistoryDate')[details.editindex]['numberarr']
}
})
onShow(() => {
// #ifdef APP
uni.$off('scancodedate')
uni.$on('scancodedate', function (code) {
if (code) {
console.log(code);
details.scandate.push(code)
}
})
// #endif
})
/* onHide(() => {
uni.$off('scancodedate')
}) */
function inputnumb() {
tiplists.value.setdetails({
tipstate: 1,
title: '请输入包件码',
placeholder: '请输入包件码',
inputtext: '',
isshow: true,
success: (detai) => {
details.scandate.push(detai.inputtext)
tiplists.value.setdetails({ isshow: false })
},
cancel: () => {
tiplists.value.setdetails({ isshow: false })
},
close: () => {
tiplists.value.setdetails({ isshow: false })
},
})
}
function submitsave() {
if (details.scandate.length == 0) {
uni.showToast({
title: '请先扫描包件码再进行保存',
duration: 1500,
icon: 'none'
})
return
}
if (!details.editindex) {
let HistoryDatearr = uni.getStorageSync('HistoryDate')
if (HistoryDatearr) {
HistoryDatearr.push({
name: details.taskname,
numberarr: details.scandate,
})
} else {
HistoryDatearr = [{
name: details.taskname,
numberarr: details.scandate,
}]
}
uni.setStorageSync('HistoryDate', HistoryDatearr)
} else {
let HistoryDatearr = uni.getStorageSync('HistoryDate')
HistoryDatearr.splice(Number(details.editindex), 1, {
name: details.taskname,
numberarr: details.scandate,
})
uni.setStorageSync('HistoryDate', HistoryDatearr)
}
uni.showToast({
title: '保存成功',
duration: 1500,
icon: 'none'
})
const timer = setTimeout(() => {
uni.navigateBack()
clearTimeout(timer)
}, 1500)
}
function remove(index : number) {
tip.value.setdetails({
content: '确认删除?',
isshow: true,
confirmTxt: '删除',
success: () => {
details.scandate.splice(index, 1)
tip.value.setdetails({ isshow: false })
},
cancel: () => {
tip.value.setdetails({ isshow: false })
},
close: () => {
tip.value.setdetails({ isshow: false })
},
})
}
</script>
<style lang="scss">
.buts {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
margin-top: 30upx;
>view {
width: 320upx;
height: 88upx;
background: #D3832A;
border-radius: 8upx;
font-size: 32upx;
font-weight: 400;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
}
}
.maxbx {
display: flex;
flex-direction: column;
align-items: center;
.item {
width: 680upx;
background-color: #FFFFFF;
padding: 20upx 30upx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20upx 15upx;
box-sizing: border-box;
border-radius: 8upx;
box-shadow: 0upx 1upx 10upx 0upx #e2e2e3;
margin-top: 30upx;
font-size: 28upx;
>.but {
display: flex;
align-items: center;
justify-content: center;
>view {
font-size: 26upx;
width: 120upx;
height: 60upx;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8upx;
&:nth-of-type(1) {
margin-right: 20upx;
background-color: #e20000;
}
&:nth-of-type(2) {
background-color: #e20000;
}
}
}
}
}
.scview {
width: 100%;
height: 80vh;
// padding: 30upx 0;
box-sizing: border-box;
// background-color: #ffffff;
}
</style>