Files
zgty-mas-m/pages/sampleWarehouse/sampleSearch/index.vue
2025-11-24 16:48:57 +08:00

123 lines
3.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="p4 pt8">
<navbar-back title="样品查询"></navbar-back>
<up-input
v-model="sampleCode"
placeholder="请扫描或者输入样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="handleSearch"
>
<template #suffix>
<!-- <up-button type="primary" text="查询" icon="search"></up-button> -->
<!-- <up-icon size="20" name="search" @click="handleSearch"></up-icon> -->
</template>
</up-input>
<uni-section v-if="sampleData.id" type="line" title="样品详情" titleFontSize="15px">
<uni-card>
<view>
<view class="x-bc">
<view
>样品名称<text>{{ sampleData.sampleName }}</text></view
>
<up-tag
plain
plainFill
size="mini"
:type="sampleData.returnStatus === 'completed' ? 'success' : 'info '"
:text="sampleData.returnStatus_dictText"
></up-tag>
</view>
<view
>样品编号<text>{{ sampleData.sampleCode }}</text></view
>
<view class="mt4"
>归库编码<text>{{ sampleData.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text>{{ sampleData.warehouseName }}</text></view
>
<view class="mt4"
>库位信息<text>{{ sampleData.warehouseLocationCode }}</text></view
>
</view>
</uni-card>
</uni-section>
<up-button
v-if="sampleData.id"
:disabled="sampleData.returnStatus !== 'completed'"
type="primary"
style="width: 90%"
text="打印归库标签"
@click="handlePrint"
></up-button>
</view>
</template>
<script setup>
import { ref, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
import nx from '@/nx'
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleSearch/index') return
try {
sampleCode.value = val
handleSearch()
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
}, 300)
onShow(() => {
scanQRInfo.value = ''
})
let sampleCode = ref('')
function handleSearch() {
getSampleDetail()
}
let sampleData = ref({})
async function getSampleDetail() {
sampleData.value = {}
const { list } = await nx.$api.sampleWarehouse.queryReturnToStockSample({
sampleReturnCode: sampleCode.value,
pageSize: 10,
pageNo: 1
})
if (list.length == 0) {
uni.showToast({
title: '未查询到该样品信息',
icon: 'none'
})
} else if (list.length > 1) {
uni.showToast({
title: '查询出重复的样品编号,请联系管理员',
icon: 'none'
})
} else {
sampleData.value = list[0]
}
}
function handlePrint() {
nx.$print.print(sampleData.value)
}
</script>
<style lang="scss" scoped>
text {
color: #000;
}
</style>