Files
2026-03-20 17:56:17 +08:00

123 lines
3.4 KiB
Vue
Raw Permalink 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>
<navbar-back title="用完标记"></navbar-back>
<view class="pl8 pr8 pt8">
<up-input
style="padding-top: 20px"
border="bottom"
v-model="materialCode"
placeholder="请扫描需要标记的物料编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="getMaterialList"
>
</up-input>
<uni-section v-if="materialList.length > 0" type="line" title="标记明细" titleFontSize="15px">
<template #right> <up-text type="error" size="18" bold :text="materialList.length"></up-text></template>
<scroll-view style="height: 60vh" scroll-y scroll-with-animation>
<uni-card margin="5px" v-for="item in materialList" class="sample-item">
<view class="mt4">
<view
>物料编号<text class="black">{{ item.code }}</text></view
>
</view>
<view class="mt4">
<view
>物料名称<text class="black">{{ item.name }}</text></view
>
</view>
<view class="mt4"
>规格型号<text class="black">{{ item.modelNo }}</text></view
>
<!-- <view class="mt4"
>单位<text class="black">{{ item.unit }}</text></view
> -->
</uni-card>
</scroll-view>
<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, onMounted } from 'vue'
import { debounce } from 'lodash'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
const btnLoading = ref(false)
let materialCode = ref('')
let materialList = ref([])
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/material/useUpMark/index') return
try {
materialCode.value = val
getMaterialList()
} catch (error) {
uni.showToast({
title: '请扫描正确的物料编码',
icon: 'none'
})
}
}, 300)
onShow(() => {
scanQRInfo.value = ''
})
async function getMaterialList() {
if (materialCode.value === '') return
let params = {
code: materialCode.value,
usageStatus: 1,
useEndFlag: 0,
businessType:'used_mark'
}
const data = await nx.$api.material.queryMaterialInfo(params)
if (!data) return uni.showToast({ title: '未查询到该物料信息', icon: 'none' })
const existingCodes = new Set(materialList.value.map(item => item.id))
if (existingCodes.has(data.id)) {
return uni.showToast({ title: '该物料已存在,无需重复添加', icon: 'none' })
}
materialList.value.push(data)
}
async function handleSubmit() {
btnLoading.value = true
let params = {
businessType: '用完标记',
detailList: materialList.value.map(item => ({infomationId:item.id}))
}
await nx.$api.material.addUseOver(params).finally(() => {
btnLoading.value = false
})
uni.showToast({
title: '标记成功',
icon: 'none'
})
handleReset()
}
function handleReset() {
materialCode.value = ''
materialList.value = []
}
onMounted(async () => {})
</script>
<style lang="scss" scoped>
.sample-item {
position: relative;
pointer-events: none;
}
:deep(.uni-select__input-placeholder) {
font-size: 16px;
}
</style>