feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-20 17:23:48 +08:00
parent 0494d224be
commit 7ee3df9ab9
32 changed files with 910 additions and 235 deletions

View File

@@ -33,17 +33,17 @@ const popupShow = ref(false)
const menuItemList = ref([
{
url: '/pages/analysis/sample/sample-work-list',
otherConf: { icon: '/static/images/menus/sampleAnalysis.png' },
otherConf: { icon: '/static/images/menus/样品分析.png' },
name: '样品分析'
},
{
url: '/pages/analysis/sample/sample-report-search',
otherConf: { icon: '/static/images/menus/records.png' },
otherConf: { icon: '/static/images/menus/记录.png' },
name: '分析记录'
},
{
url: '/pages/analysis/auncel/auncel-status',
otherConf: { icon: '/static/images/menus/balance.png' },
otherConf: { icon: '/static/images/menus/天平查看.png' },
name: '天平查看'
}
])

View File

@@ -366,6 +366,7 @@ const parameterClassifyChange = v => {
const fieldClick = (field, key) => {
if (!field.isEdit) return
currentFillingIndex.value = 0
if (currentFillingWay.value === 'input') {
inputValue.value = field.value
}

View File

@@ -13,9 +13,9 @@ import { reactive, ref, computed, onMounted } from 'vue'
import nx from '@/nx'
import { useGridCol } from '@/nx/hooks/useGridCol'
let list = reactive([
{ url: '/pages/lims/index/index', name: '设备管理', icon: 'device' },
{ url: '/pages/analysis/index/index', name: '分析管理', icon: 'analyse' },
{ url: '/pages/sampleWarehouse/index/index', name: '样品库管理', icon: 'sampleWarehouse' }
{ url: '/pages/lims/index/index', name: '设备管理', icon: '设备管理' },
{ url: '/pages/analysis/index/index', name: '分析管理', icon: '分析管理' },
{ url: '/pages/sampleWarehouse/index/index', name: '样品库管理', icon: '样品库管理' }
])
// const sysMenus = computed(() => nx.$store('user').sysMenus)

View File

@@ -0,0 +1,7 @@
<template>
<view> </view>
</template>
<script setup></script>
<style lang="scss" scoped></style>

View File

@@ -1,19 +1,10 @@
<template>
<view class="p8">
<navbar-back title="库位变更"></navbar-back>
<uni-section type="line" title="库位信息修改"> </uni-section>
<up-input
v-model="locationCode"
placeholder="请扫描库位编码"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
</up-input>
<up-radio-group v-model="changeType">
<uni-section type="line" title="库位信息修改" titleFontSize="15px"> </uni-section>
<up-radio-group v-model="changeType" size="20px" @change="handleChangeType">
<up-radio
:customStyle="{ marginBottom: '8px' }"
:customStyle="{ marginLeft: '8px' }"
v-for="(item, index) in changeTypeOptions"
:key="index"
:label="item.label"
@@ -22,30 +13,56 @@
</up-radio>
</up-radio-group>
<up-input
v-model="sampleCode"
:placeholder="`请扫描${changeType == 'sample' ? '样品编号' : '库位码'}`"
v-model="changeCode"
:placeholder="`请扫描${changeType == 'sample' ? '样品编号' : '(原)库位码'}`"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="getSampleList()"
>
</up-input>
<up-input
v-if="changeCode !== '' && sampleList.length > 0"
class="mt20"
v-model="targetLocation"
placeholder="请扫描变更后库位码"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
</up-input>
<uni-section type="line" title="样品及当前归库信息">
<uni-card>
<view
>样品名称<text>{{ sampleData.sampleName }}</text></view
>
<view class="mt4"
>样品名称<text>{{ sampleData.sampleCode }}</text></view
>
<view class="mt4"
>归库编码<text>{{ sampleData.sampleCode }}</text></view
>
<view class="mt4"
>()库位编码<text>{{ sampleData.sampleCode }}</text></view
>
</uni-card>
<uni-section v-if="sampleList.length > 0" type="line" title="样品及当前归库信息" titleFontSize="15px">
<template #right> <up-text type="error" size="18" bold :text="sampleList.length"></up-text></template>
<scroll-view style="height: 43vh" scroll-y scroll-with-animation>
<uni-card v-for="item in sampleList">
<view
>样品名称<text>{{ item.sampleName }}</text></view
>
<view class="mt4"
>归库编码<text>{{ item.sampleReturnCode }}</text></view
>
<view class="mt4"
>归库时间<text>{{ nx.$dayjs(item.returnTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view
>
<view class="mt4"
>样品库名称<text>{{ item.warehouseName }}</text></view
>
<view class="mt4"
>()库位码<text>{{ item.warehouseLocationCode }}</text></view
>
</uni-card>
</scroll-view>
</uni-section>
<up-button class="mt20" type="primary" style="width: 50%" text="提交" @click="handleReset"></up-button>
<up-button
v-if="targetLocation"
:loading="btnLoading"
class="mt20"
type="primary"
style="width: 50%"
text="提交"
@click="handleSubmit"
></up-button>
</view>
</template>
@@ -61,87 +78,122 @@ const changeTypeOptions = reactive([
label: '按样品变更'
},
{
name: 'location',
name: 'warehouseLocation',
label: '按库位变更'
}
])
function isJsonString(str) {
if (typeof str !== 'string') return false
let targetLocation = ref('')
let changeCode = ref('')
let sampleList = ref([])
try {
const parsed = JSON.parse(str)
return typeof parsed === 'object' && parsed !== null
} catch (e) {
return false
}
}
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (newVal && nx.$router.getCurrentPage().route == 'pages/sampleWarehouse/returnToStock/index') {
try {
if (!isJsonString(newVal)) {
if (!locationCode.value) {
uni.showToast({
title: '请先扫描库位码',
icon: 'none'
})
scanQRInfo.value = ''
return
} else {
if (changeType.value == 'sample') {
sampleCode.value = newVal
} else {
}
// 执行
// handleReturnToStock()
}
} else {
const codeObj = JSON.parse(newVal)
locationCode.value = codeObj.code
}
scanQRInfo.value = ''
} catch (error) {
scanQRInfo.value = ''
uni.showToast({
title: '请扫描样品编码',
icon: 'none'
})
}
watch(changeCode, newVal => {
if (newVal === '') {
sampleList.value = []
targetLocation.value = ''
isFirstInput.value = true
}
})
async function getSampleList() {
if (changeCode.value === '') return
let params = { pageSize: 999, pageNo: 1, returnStatus: 'completed' }
if (changeType.value === 'sample') {
params.sampleReturnCode = changeCode.value
} else {
params.warehouseLocationCode = changeCode.value
}
const { list } = await nx.$api.sampleWarehouse.queryReturnToStockSample(params)
sampleList.value = list
if (list.length === 0) {
uni.showToast({ title: '未查询到该样品信息', icon: 'none' })
isFirstInput.value = true
} else {
isFirstInput.value = false
}
}
const btnLoading = ref(false)
async function handleSubmit() {
let params = {
actionWay: changeType.value,
targetLocation: targetLocation.value
}
if (changeType.value === 'sample') {
params.sampleReturnCode = changeCode.value
} else {
params.warehouseLocationCode = changeCode.value
}
btnLoading.value = true
await nx.$api.sampleWarehouse.execChangeLocation(params).finally(() => {
btnLoading.value = false
})
uni.showToast({ title: '变更成功', icon: 'none' })
handleReset()
}
function handleChangeType(e) {
handleReset()
}
let isFirstInput = ref(true)
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/execChangeLocation/index') return
try {
console.log(newVal)
const isJson = nx.$helper.isJsonString(newVal)
console.log(isJson)
if (isFirstInput.value) {
handleFirstScan(newVal, isJson)
} else {
handleSecondScan(newVal, isJson)
}
} catch (error) {
uni.showToast({ title: '扫码内容解析失败', icon: 'none' })
}
})
function handleFirstScan(rawValue, isJson) {
if (changeType.value === 'sample') {
// 按样品变更:首扫应为纯字符串(样品编号)
if (isJson) {
isFirstInput.value = true
uni.showToast({ title: '请先扫描样品编号', icon: 'none' })
return
} else {
changeCode.value = rawValue
}
} else {
// 按库位变更:首扫应为 JSON原库位码
if (!isJson) {
isFirstInput.value = true
uni.showToast({ title: '请先扫描(原)库位码', icon: 'none' })
return
} else {
const codeObj = JSON.parse(rawValue)
changeCode.value = codeObj.code
}
}
getSampleList()
}
function handleSecondScan(rawValue, isJson) {
// 第二次扫描必须是 JSON目标库位码
if (!isJson) {
uni.showToast({ title: '请扫描变更后库位码', icon: 'none' })
return
}
const codeObj = JSON.parse(rawValue)
targetLocation.value = codeObj.code
}
onShow(() => {
scanQRInfo.value = ''
})
let needPrint = ref(false)
let locationCode = ref('')
let sampleCode = ref('')
function handleReturnToStock() {
nx.$api.sampleWarehouse
.execReturnToStock({
warehouseLocationCode: locationCode.value,
sampleCode: sampleCode.value
})
.then(res => {
successCount.value++
if (res.print) {
uni.showToast({
title: `归库成功,归库码为【${res.code}`,
duration: 3000,
icon: 'none'
})
// 执行打印
}
})
}
const successCount = ref(2)
function handleReset() {
locationCode.value = ''
sampleCode.value = ''
successCount.value = 0
targetLocation.value = ''
changeCode.value = ''
sampleList.value = []
btnLoading.value = false
isFirstInput.value = true
}
</script>

View File

@@ -34,18 +34,38 @@ const popupShow = ref(false)
const menuItemList = ref([
{
url: '/pages/sampleWarehouse/sampleSearch/index',
otherConf: { icon: '/static/images/menus/records.png' },
otherConf: { icon: '/static/images/menus/记录.png' },
name: '样品查询'
},
{
url: '/pages/sampleWarehouse/returnToStock/index',
otherConf: { icon: '/static/images/menus/returnToStock.png' },
otherConf: { icon: '/static/images/menus/样品归库.png' },
name: '样品归库'
},
{
url: '/pages/sampleWarehouse/execChangeLocation/index',
otherConf: { icon: '/static/images/menus/execChangeLocation.png' },
otherConf: { icon: '/static/images/menus/库位变更.png' },
name: '库位变更'
},
{
url: '/pages/sampleWarehouse/sampleDispatchInternal/index',
otherConf: { icon: '/static/images/menus/内部调拨.png' },
name: '内部调拨'
},
{
url: '/pages/sampleWarehouse/sampleDispatchExternal/index',
otherConf: { icon: '/static/images/menus/外部调拨.png' },
name: '外部调拨'
},
{
url: '/pages/sampleWarehouse/dispatchGiveBack/index',
otherConf: { icon: '/static/images/menus/调拨归还.png' },
name: '调拨归还'
},
{
url: '/pages/sampleWarehouse/sampleTakeOff/index',
otherConf: { icon: '/static/images/menus/样品下架.png' },
name: '样品下架'
}
])
@@ -56,26 +76,26 @@ const userInfo = computed(() => nx.$store('user').userInfo)
const goTo = url => {
nx.$router.go(url)
}
onShow(() => {
//连接打印服务
let printList = uni.getStorageSync('KEY_PRINT_LIST')
if (printList && printList.length > 0) {
for (let print of printList) {
nx.$print.open(print.printIp, print.printPort)
}
} else {
uni.showModal({
title: '提示',
showCancel: false,
content: '打印服务未配置,请在系统设置中配置打印服务',
success: function (res) {
uni.navigateTo({
url: '/pages/setting/print'
})
}
})
}
})
// onShow(() => {
// //连接打印服务
// let printList = uni.getStorageSync('KEY_PRINT_LIST')
// if (printList && printList.length > 0) {
// for (let print of printList) {
// nx.$print.open(print.printIp, print.printPort)
// }
// } else {
// uni.showModal({
// title: '提示',
// showCancel: false,
// content: '打印服务未配置,请在系统设置中配置打印服务',
// success: function (res) {
// uni.navigateTo({
// url: '/pages/setting/print'
// })
// }
// })
// }
// })
// 生命周期
onMounted(() => {})
// 动态设置 grid 列数

View File

@@ -1,7 +1,7 @@
<template>
<view class="p8">
<navbar-back title="样品归库"></navbar-back>
<uni-section type="line" title="库位编码"> </uni-section>
<uni-section type="line" title="库位编码" titleFontSize="15px"> </uni-section>
<up-input
v-model="locationCode"
placeholder="请扫描库位编码"
@@ -10,7 +10,7 @@
prefixIconStyle="font-size: 30px;"
>
</up-input>
<uni-section type="line" title="样品编号"> </uni-section>
<uni-section type="line" title="样品编号" titleFontSize="15px"> </uni-section>
<up-input
v-model="sampleCode"
placeholder="请扫描样品编号"
@@ -31,46 +31,30 @@ import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import nx from '@/nx'
function isJsonString(str) {
if (typeof str !== 'string') return false
try {
const parsed = JSON.parse(str)
return typeof parsed === 'object' && parsed !== null
} catch (e) {
return false
}
}
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (newVal && nx.$router.getCurrentPage().route == 'pages/sampleWarehouse/returnToStock/index') {
try {
if (!isJsonString(newVal)) {
if (!locationCode.value) {
uni.showToast({
title: '请先扫描库位码',
icon: 'none'
})
scanQRInfo.value = ''
return
} else {
sampleCode.value = newVal
// 执行归库
handleReturnToStock()
}
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/returnToStock/index') return
try {
if (nx.$helper.isJsonString(newVal)) {
const codeObj = JSON.parse(newVal)
locationCode.value = codeObj.code
} else {
if (!locationCode.value) {
uni.showToast({
title: '请先扫描库位码',
icon: 'none'
})
return
} else {
const codeObj = JSON.parse(newVal)
locationCode.value = codeObj.code
sampleCode.value = newVal
// 执行归库
handleReturnToStock()
}
scanQRInfo.value = ''
} catch (error) {
scanQRInfo.value = ''
uni.showToast({
title: '请扫描样品编码',
icon: 'none'
})
}
} catch (error) {
uni.showToast({ title: '扫码内容解析失败', icon: 'none' })
}
})
onShow(() => {
@@ -100,7 +84,7 @@ function handleReturnToStock() {
})
}
const successCount = ref(2)
const successCount = ref(0)
function handleReset() {
locationCode.value = ''
sampleCode.value = ''

View File

@@ -0,0 +1,131 @@
<template>
<navbar-back title="样品调拨"></navbar-back>
<view class="pl8 pr8">
<view class="border-b p6 x-f"
><view class="pr16">申请人</view><text>{{ applyData.applyUser }}</text></view
>
<view class="border-b p6"
><text>申请时间</text><text>{{ nx.$dayjs(applyData.applyTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view
>
<view class="border-b p6"
><text>申请事由</text><text>{{ applyData.applyContent }}</text></view
>
<up-input
style="padding-top: 20px"
border="bottom"
v-model="sampleCode"
placeholder="请扫描样品编号来确认样品"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
</up-input>
<uni-section type="line" title="申请调拨样品明细" titleFontSize="15px">
<scroll-view style="height: 49vh" scroll-y scroll-with-animation>
<up-checkbox-group v-model="checkedSampleCodes" placement="column">
<uni-card margin="5px" v-for="item in sampleList" class="sample-item">
<view
>样品名称<text class="black">{{ item.sampleName }}</text></view
>
<view class="mt4"
>归库编码<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text class="black">{{ item.warehouseName }}</text></view
>
<view class="mt4"
>库位码<text class="black">{{ item.warehouseLocationCode }}</text></view
>
<up-checkbox class="item-checkbox" :name="item.sampleReturnCode"> </up-checkbox>
</uni-card>
</up-checkbox-group>
</scroll-view>
<up-button
type="primary"
:disabled="checkedSampleCodes.length !== sampleList.length"
style="width: 50%"
text="提交"
@click="handleSubmit"
></up-button>
</uni-section>
</view>
</template>
<script setup>
import { computed, ref, toRefs, watch } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
let sampleCode = ref('')
let applyData = ref({ applyUser: '张三', applyTime: '2021-01-01 10:10:10', applyContent: '测试' })
let sampleList = ref([])
async function getDetailList() {
const { list } = await nx.$api.sampleWarehouse.querySampleDispatchApplyDetail({
parentId: applyData.value.id,
pageSize: 999
})
sampleList.value = list
}
let checkedSampleCodes = ref([])
const { flagInfo, scanQRInfo } = toRefs(nx.$store('biz'))
onLoad(async options => {
applyData.value = flagInfo
getDetailList()
})
watch(scanQRInfo, newVal => {
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return
try {
sampleCode.value = newVal
if (
sampleCode.value === sampleList.value.find(item => item.sampleReturnCode === sampleCode.value)?.sampleReturnCode
) {
if (!checkedSampleCodes.value.includes(sampleCode.value)) {
checkedSampleCodes.value.push(sampleCode.value)
} else {
uni.showToast({
title: '请勿重复扫描',
icon: 'none'
})
}
} else {
uni.showToast({
title: '该样品不在申请范围内',
icon: 'none'
})
}
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
})
onShow(() => {
scanQRInfo.value = ''
})
async function handleSubmit() {
await nx.$api.sampleWarehouse.execSampleDispatch({ id: applyData.value.id })
uni.showToast({
title: '调拨成功',
icon: 'none'
})
uni.navigateBack()
}
</script>
<style lang="scss" scoped>
.sample-item {
position: relative;
pointer-events: none;
.item-checkbox {
position: absolute;
right: 5px;
top: 5px;
}
}
</style>

View File

@@ -0,0 +1,80 @@
<template>
<navbar-back title="样品调拨"></navbar-back>
<view class="p8">
<up-subsection
activeColor="#0055A2"
mode="subsection"
:list="list"
:current="current"
@change="changeTab"
></up-subsection>
<scroll-view style="height: 82vh" scroll-y scroll-with-animation @scrolltolower="handleScrolltolower">
<view class="data-item" v-for="(item, index) in listData" @click="handleDetail(item)">
<view
>申请人<text>{{ item.applyUser }}</text></view
>
<view
>申请时间<text>{{ nx.$dayjs(item.applyTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view
>
<view
>申请事由<text>{{ item.applyContent }}</text></view
>
</view>
<up-loadmore v-if="listData.length > 0" :status="loadStatus" />
<up-empty v-else mode="data" text="暂无数据" marginTop="50"> </up-empty>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue'
import { useListData } from '@/nx/hooks/usePageListData'
import nx from '@/nx'
const list = ref(['待处理', '已处理'])
let dataList = ref([])
const current = ref(0)
function changeTab(index) {
current.value = index
getInitData()
}
const searchParams = computed(() => {
if (current.value === 0) {
return {
finishStatus: 'pending'
}
} else {
return {
finishStatus: 'completed'
}
}
})
const { listData, scrollToLower, loadStatus, getInitData } = useListData({
searchParams,
api: nx.$api.sampleWarehouse.querySampleDispatchApply,
needInitListData: true
})
function handleScrolltolower() {
scrollToLower()
}
function handleDetail(item) {
nx.$store('biz').flagInfo = item
uni.navigateTo({
url: '/pages/sampleWarehouse/sampleDispatchExternal/detail'
})
}
</script>
<style lang="scss" scoped>
.data-item {
padding: 8px;
border-bottom: 1px solid #eee;
color: #909399;
text {
color: #000;
}
}
</style>

View File

@@ -0,0 +1,90 @@
<template>
<navbar-back title="样品调拨"></navbar-back>
<view class="pl8 pr8">
<view class="border-b p6 x-f"
><view class="pr16">库管员</view><text>{{ userInfo.nickname }}</text></view
>
<up-input
style="padding-top: 20px"
border="bottom"
v-model="sampleCode"
placeholder="请扫描需要调拨的样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
</up-input>
<uni-section v-if="sampleList.length > 0" type="line" title="调拨样品明细" titleFontSize="15px">
<template #right> <up-text type="error" size="18" bold :text="sampleList.length"></up-text></template>
<scroll-view style="height: 49vh" scroll-y scroll-with-animation>
<uni-card margin="5px" v-for="item in sampleList" class="sample-item">
<view
>样品名称<text class="black">{{ item.sampleName }}</text></view
>
<view class="mt4"
>归库编码<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text class="black">{{ item.warehouseName }}</text></view
>
<view class="mt4"
>库位码<text class="black">{{ item.warehouseLocationCode }}</text></view
>
</uni-card>
</scroll-view>
<up-button :disabled="!receiver" type="primary" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
</uni-section>
</view>
</template>
<script setup>
import { computed, ref, toRefs, watch } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
let sampleCode = ref('')
let sampleList = ref([])
let receiver = ref('')
const userInfo = computed(() => nx.$store('user').userInfo)
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return
try {
sampleCode.value = newVal
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
})
onShow(() => {
scanQRInfo.value = ''
})
async function handleSubmit() {
await nx.$api.sampleWarehouse.execSampleDispatch({})
uni.showToast({
title: '调拨成功',
icon: 'none'
})
uni.navigateBack()
}
</script>
<style lang="scss" scoped>
.sample-item {
position: relative;
pointer-events: none;
.item-checkbox {
position: absolute;
right: 5px;
top: 5px;
}
}
</style>

View File

@@ -7,6 +7,7 @@
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="handleSearch"
>
<template #suffix>
<!-- <up-button type="primary" text="查询" icon="search"></up-button> -->
@@ -14,31 +15,43 @@
</template>
</up-input>
<uni-section type="line" title="样品详情">
<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 :text="sampleData.returnStatus_dictText"></up-tag>
<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.sampleCode }}</text></view
>归库编码<text>{{ sampleData.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text>{{ sampleData.sampleCode }}</text></view
>样品库名称<text>{{ sampleData.warehouseName }}</text></view
>
<view class="mt4"
>库位信息<text>{{ sampleData.sampleCode }}</text></view
>库位信息<text>{{ sampleData.warehouseLocationCode }}</text></view
>
</view>
</uni-card>
</uni-section>
<up-button type="primary" style="width: 90%" text="打印归库标签" @click="handlePrint"></up-button>
<up-button
v-if="sampleData.id"
type="primary"
style="width: 90%"
text="打印归库标签"
@click="handlePrint"
></up-button>
</view>
</template>
@@ -49,18 +62,17 @@ import nx from '@/nx'
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (newVal && nx.$router.getCurrentPage().route == 'pages/sampleWarehouse/sampleSearch/index') {
try {
sampleCode.value = newVal
handleSearch()
scanQRInfo.value = ''
} catch (error) {
scanQRInfo.value = ''
uni.showToast({
title: '请扫描样品编码',
icon: 'none'
})
}
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleSearch/index') return
try {
sampleCode.value = newVal
handleSearch()
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
})
onShow(() => {
@@ -73,7 +85,25 @@ function handleSearch() {
let sampleData = ref({})
async function getSampleDetail() {
sampleData.value = await nx.$api.sample.getSampleDetail({ sampleReturnCode: sampleCode.value })
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() {}
</script>

View File

@@ -0,0 +1,169 @@
<template>
<navbar-back title="样品下架"></navbar-back>
<view class="pl8 pr8">
<view class="border-b p8 x-f"
><view class="pr16">下架人</view><text>{{ userInfo.nickname }}</text></view
>
<up-radio-group class="mt10" v-model="takeOffType" size="20px" @change="handleTakeOffType">
<up-radio
:customStyle="{ marginLeft: '8px' }"
v-for="(item, index) in takeOffTypeOptions"
:key="index"
:label="item.label"
:name="item.name"
>
</up-radio>
</up-radio-group>
<up-input
class="mt10"
v-model="targetCode"
placeholder="请扫描需要调拨的样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="getSampleList"
>
</up-input>
<uni-section v-if="sampleList.length > 0" type="line" title="调拨样品明细" titleFontSize="15px">
<template #right> <up-text type="error" size="18" bold :text="sampleList.length"></up-text></template>
<scroll-view style="height: 49vh" scroll-y scroll-with-animation>
<uni-card margin="5px" v-for="item in sampleList" class="sample-item">
<view
>样品名称<text class="black">{{ item.sampleName }}</text></view
>
<view class="mt4"
>归库编码<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text class="black">{{ item.warehouseName }}</text></view
>
<view class="mt4"
>库位码<text class="black">{{ item.warehouseLocationCode }}</text></view
>
</uni-card>
</scroll-view>
<up-button :loading="btnLoading" type="primary" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
</uni-section>
</view>
</template>
<script setup>
import { computed, ref, toRefs, watch, reactive } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
const takeOffType = ref('sample')
const takeOffTypeOptions = reactive([
{
name: 'sample',
label: '按样品下架'
},
{
name: 'warehouseLocation',
label: '按库位下架'
}
])
function handleTakeOffType() {
handleReset()
}
let targetCode = ref('')
let sampleList = ref([])
const btnLoading = ref(false)
const userInfo = computed(() => nx.$store('user').userInfo)
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
if (!newVal) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleTakeOff/index') return
try {
const isJson = nx.$helper.isJsonString(newVal)
const isSample = takeOffType.value === 'sample'
if (isJson) {
if (isSample) {
return uni.showToast({
title: '请扫描正确的样品编号',
icon: 'none'
})
}
const codeObj = JSON.parse(newVal)
targetCode.value = codeObj.code
} else {
if (isSample) {
targetCode.value = newVal
} else {
return uni.showToast({
title: '请扫描正确库位码',
icon: 'none'
})
}
}
getSampleList()
} catch (error) {
uni.showToast({
title: '扫码内容解析失败',
icon: 'none'
})
}
})
onShow(() => {
scanQRInfo.value = ''
})
async function getSampleList() {
if (targetCode.value === '') return
let params = { pageSize: 999, pageNo: 1, returnStatus: 'completed', dispatchStatus: '0' }
if (takeOffType.value === 'sample') {
params.sampleReturnCode = targetCode.value
} else {
params.warehouseLocationCode = targetCode.value
}
const { list } = await nx.$api.sampleWarehouse.queryReturnToStockSample(params)
if (list.length === 0) {
return uni.showToast({ title: '未查询到该样品信息', icon: 'none' })
}
const existingCodes = new Set(sampleList.value.map(item => item.id)) // 假设唯一标识是 `code`
const newItems = list.filter(item => !existingCodes.has(item.id))
if (newItems.length === 0) {
return uni.showToast({ title: '该样品已存在,无需重复添加', icon: 'none' })
}
sampleList.value.push(...newItems)
}
async function handleSubmit() {
let params = { actionWay: takeOffType.value }
if (takeOffType.value === 'warehouseLocation') {
params.locationCode = targetCode.value
} else {
params.sampleCode = targetCode.value
}
btnLoading.value = true
await nx.$api.sampleWarehouse.execTakeOff(params).finally(() => {
btnLoading.value = false
})
uni.showToast({
title: '下架成功',
icon: 'none'
})
handleReset()
}
function handleReset() {
targetCode.value = ''
sampleList.value = []
}
</script>
<style lang="scss" scoped>
.sample-item {
position: relative;
pointer-events: none;
.item-checkbox {
position: absolute;
right: 5px;
top: 5px;
}
}
</style>