feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-19 11:02:11 +08:00
parent 06210e79fd
commit 0494d224be
33 changed files with 1282 additions and 673 deletions

View File

@@ -0,0 +1,148 @@
<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">
<up-radio
:customStyle="{ marginBottom: '8px' }"
v-for="(item, index) in changeTypeOptions"
:key="index"
:label="item.label"
:name="item.name"
>
</up-radio>
</up-radio-group>
<up-input
v-model="sampleCode"
:placeholder="`请扫描${changeType == 'sample' ? '样品编号' : '库位编码'}`"
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>
<up-button class="mt20" type="primary" style="width: 50%" text="提交" @click="handleReset"></up-button>
</view>
</template>
<script setup>
import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import nx from '@/nx'
const changeType = ref('sample')
const changeTypeOptions = reactive([
{
name: 'sample',
label: '按样品变更'
},
{
name: 'location',
label: '按库位变更'
}
])
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 {
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'
})
}
}
})
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
}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,89 @@
<template>
<view>
<navbar-back
title="样品库管理"
titleWidth="800"
:autoBack="false"
leftIcon=""
:leftText="`您好!${userInfo.nickname}`"
>
<u-icon @click="popupShow = true" size="28" color="#FFF" name="setting-fill" />
</navbar-back>
<up-grid :col="gridCol" :border="false">
<up-grid-item class="mb20 mt20" v-for="item in menuItemList" :key="item.url" @click="goTo(item.url)">
<u-icon :name="item.otherConf.icon" color="#0055A2" size="80" />
<view class="grid-text">{{ item.name }}</view>
</up-grid-item>
</up-grid>
<mePopup :show="popupShow" @update:show="val => (popupShow = val)" />
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useGridCol } from '@/nx/hooks/useGridCol'
import mePopup from '@/pages/index/me-popup.vue'
// 响应式数据
const popupShow = ref(false)
const menuItemList = ref([
{
url: '/pages/sampleWarehouse/sampleSearch/index',
otherConf: { icon: '/static/images/menus/records.png' },
name: '样品查询'
},
{
url: '/pages/sampleWarehouse/returnToStock/index',
otherConf: { icon: '/static/images/menus/returnToStock.png' },
name: '样品归库'
},
{
url: '/pages/sampleWarehouse/execChangeLocation/index',
otherConf: { icon: '/static/images/menus/execChangeLocation.png' },
name: '库位变更'
}
])
// 计算属性
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'
})
}
})
}
})
// 生命周期
onMounted(() => {})
// 动态设置 grid 列数
const { gridCol } = useGridCol([400], [2, 3])
</script>
<style scoped lang="scss">
.grid-text {
font-size: 24px;
}
</style>

View File

@@ -0,0 +1,111 @@
<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>
<uni-section type="line" title="样品编号"> </uni-section>
<up-input
v-model="sampleCode"
placeholder="请扫描样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
<template #suffix>
<view class="fs18 font-bold" style="color: red" v-if="successCount > 0">{{ successCount }}</view>
</template>
</up-input>
<up-button class="mt20" type="primary" style="width: 50%" text="清空" @click="handleReset"></up-button>
</view>
</template>
<script setup>
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()
}
} else {
const codeObj = JSON.parse(newVal)
locationCode.value = codeObj.code
}
scanQRInfo.value = ''
} catch (error) {
scanQRInfo.value = ''
uni.showToast({
title: '请扫描样品编码',
icon: 'none'
})
}
}
})
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
}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,85 @@
<template>
<view class="p4 pt8">
<navbar-back title="样品查询"></navbar-back>
<up-input
v-model="sampleCode"
placeholder="请扫描或者输入样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
>
<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 type="line" title="样品详情">
<uni-card>
<view>
<view class="x-bc">
<view
>样品名称<text>{{ sampleData.sampleName }}</text></view
>
<up-tag :text="sampleData.returnStatus_dictText"></up-tag>
</view>
<view
>样品编号<text>{{ sampleData.sampleCode }}</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
>
</view>
</uni-card>
</uni-section>
<up-button 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 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'
})
}
}
})
onShow(() => {
scanQRInfo.value = ''
})
let sampleCode = ref('')
function handleSearch() {
getSampleDetail()
}
let sampleData = ref({})
async function getSampleDetail() {
sampleData.value = await nx.$api.sample.getSampleDetail({ sampleReturnCode: sampleCode.value })
}
function handlePrint() {}
</script>
<style lang="scss" scoped>
text {
color: #000;
}
</style>