<template>
    <view class="container">
        <!-- 底部扫码输入框 -->
        <view class="fixed-bottom pad-20" style="background: #ffffff;">
            <u-search placeholder="请输入库位编号" :searchIconSize="24" bgColor="#f6f7f6" @search="onSearch"
                v-model="positionCode" :clearabled="true" :focus="false" :showAction="false" :height="42"></u-search>

            <u-icon name="scan" size="32" color="#19be6b" @click="openScan"></u-icon>
        </view>
    </view>
</template>

<script setup>
import {
    ref
} from 'vue'
import {
    onLoad
} from '@dcloudio/uni-app'

const positionCode = ref('')

const onSearch = () => {
    if (positionCode.value) {
        uni.navigateTo({
            url: '/pages/index/wms/location-order-list?positionCode=' + positionCode.value
        })
    } else {
        uni.$u.toast('请输入库位编号')
    }
}

function openScan() {
    uni.scanCode({
        success: (res) => {
            positionCode.value = res.result
            onSearch()
        }
    })
}

onLoad(() => {
    // #ifdef APP-PLUS
    uni.$u.useGlobalEvent((e) => {
        if (e.barcode) {
            positionCode.value = e.barcode
            onSearch()
        }
    })
    // #endif
})
</script>

<style lang="scss" scoped>
.header {
    display: flex;
    justify-content: space-between;
    padding: 20rpx 30rpx;
    background-color: #ffffff;
}

.status {
    color: green;
}


.log-item {
    display: flex;
    justify-content: space-between;
    padding: 20rpx 30rpx;
    border-bottom: 1px solid #e0e0e0;
}
</style>