feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-21 17:56:33 +08:00
parent 7ee3df9ab9
commit 753766893b
24 changed files with 818 additions and 218 deletions

View File

@@ -1,6 +1,10 @@
<template>
<navbar-back title="样品调拨"></navbar-back>
<view class="pl8 pr8">
<view class="pl8 pr8 pt8">
<view class="x-f">
<text class="pl6">领取人</text>
<uni-data-select v-model="receiverId" :localdata="range" placeholder="请选择样品领取人"></uni-data-select>
</view>
<view class="border-b p6 x-f"
><view class="pr16">库管员</view><text>{{ userInfo.nickname }}</text></view
>
@@ -12,6 +16,7 @@
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="getScanSample"
>
</up-input>
@@ -33,48 +38,96 @@
>
</uni-card>
</scroll-view>
<up-button :disabled="!receiver" type="primary" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
<up-button type="primary" :loading="btnLoading" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
</uni-section>
</view>
</template>
<script setup>
import { computed, ref, toRefs, watch } from 'vue'
import { computed, ref, toRefs, watch, onMounted } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
const btnLoading = ref(false)
let sampleCode = ref('')
let sampleList = ref([])
let receiver = ref('')
const range = ref([])
const userInfo = computed(() => nx.$store('user').userInfo)
const receiverId = ref('')
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (!newVal) return
debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchInternal/index') return
try {
sampleCode.value = newVal
sampleCode.value = val
getScanSample()
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
})
}, 300)
onShow(() => {
scanQRInfo.value = ''
})
let dispatchTempId = ref('')
// 创建临时数据
async function createDispatchTempData() {
const data = await nx.$api.sampleWarehouse.createDispatchTempData()
dispatchTempId.value = data.id
}
async function getScanSample() {
if (sampleCode.value === '') return
await nx.$api.sampleWarehouse.addDispatchSample({ id: dispatchTempId.value, sampleReturnCode: sampleCode.value })
getSampleList()
}
async function getSampleList() {
const { list } = await nx.$api.sampleWarehouse.querySampleDispatchApplyDetail({
pageSize: 999,
pageNo: 1,
parentId: dispatchTempId.value
})
sampleList.value = list
}
async function handleSubmit() {
await nx.$api.sampleWarehouse.execSampleDispatch({})
if (receiverId.value === '') {
return uni.showToast({
title: '请选择样品领取人',
icon: 'none'
})
}
btnLoading.value = true
const receiver = range.value.find(item => item.value === receiverId.value)?.nickname
await nx.$api.sampleWarehouse
.execSampleDispatch({
id: dispatchTempId.value,
applyUserId: receiverId.value,
applyUser: receiver
})
.finally(() => {
btnLoading.value = false
})
uni.showToast({
title: '调拨成功',
icon: 'none'
})
uni.navigateBack()
}
function handleReset() {
sampleCode.value = ''
sampleList.value = []
createDispatchTempData()
}
onMounted(async () => {
const data = await nx.$api.user.getAssignUserList()
range.value = data.map(item => ({ text: item.nickname, value: item.id }))
handleReset()
})
</script>
<style lang="scss" scoped>
@@ -87,4 +140,7 @@ async function handleSubmit() {
top: 5px;
}
}
:deep(.uni-select__input-placeholder) {
font-size: 16px;
}
</style>