出库优化

This commit is contained in:
bb_pan 2025-07-26 10:54:54 +08:00
parent b709dd283f
commit f79565ea5a
2 changed files with 70 additions and 39 deletions

View File

@ -242,7 +242,8 @@ const getCodeDetailData = async (id, publishTask, typeId) => {
//
const getCodeDeviceListData = async () => {
const checkedIdSet = new Set(checkedIds.value)
const ids = checkedIds.value.map(item => item.maId)
const checkedIdSet = new Set(ids)
const res = await getCodeDeviceListAPI(queryCodeParams.value)
const newRows = res.rows || []
const map = new Map()
@ -290,9 +291,9 @@ const finish = computed(() => {
const onChangeChecked = (item) => {
item.checked = !item.checked
if (item.checked) {
checkedIds.value.push(item.maId)
checkedIds.value.push(item)
} else {
checkedIds.value = checkedIds.value.filter((maId) => maId !== item.maId)
checkedIds.value = checkedIds.value.filter((check) => check.maId !== item.maId)
}
}
@ -310,7 +311,7 @@ const isSelectNum = computed(() => {
//
const onHandleOutbound = async () => {
const isSelect = codeDeviceList.value.some((e) => e.checked === true)
const isSelect = checkedIds.value.length > 0
if (!isSelect) {
uni.showToast({
title: '请勾选需要出库的设备',
@ -331,19 +332,17 @@ const onHandleOutbound = async () => {
const { typeId, parentId, publishTask } = queryParams.value
//
const paramsList = []
codeDeviceList.value.map((e) => {
if (e.checked) {
paramsList.push({
leaseType: 0,
maId: e.maId,
maCode: e.maCode,
manageType: 0,
outNum: 1,
parentId,
typeId,
publishTask,
})
}
checkedIds.value.map((e) => {
paramsList.push({
leaseType: 0,
maId: e.maId,
maCode: e.maCode,
manageType: 0,
outNum: 1,
parentId,
typeId,
publishTask,
})
})
console.log('mmmmmmmmmmmmmmmm', paramsList)
try {
@ -522,6 +521,8 @@ const onCodeIdentify = () => {
//
const scanStart = () => {
// qrCodeScan.value = '201809-00026'
// getMaInfoScan()
if (maxNum.value == 0) {
uni.showToast({
title: '待出库数量已为0',
@ -589,6 +590,16 @@ const getMaInfoScan = async () => {
console.log(res)
if (res.code == 200) {
if (res.data && res.data.recordList.length > 0) {
if(res.data.recordList[0].typeModelName != queryParams.value.typeName) {
uni.showModal({
title: '提示',
content: '当前扫描到的物资规格与当前任务规格不一致, 请仔细检查核对',
confirmText: '关闭',
confirmColor: '#FF0000',
showCancel: false,
})
return
}
codeData.value = res.data.recordList[0]
confirmCodeOutBound()
// uni.showModal({

View File

@ -119,7 +119,7 @@
</view>
<view class="loading-text">
{{ '没有更多数据了~' }}
{{ finish ? '没有更多数据了~' : '正在加载...' }}
</view>
</scroll-view>
</scroll-view>
@ -150,6 +150,7 @@ const maxNum = ref(0)
const total = ref(0)
const boxCode = ref('')
const boxInfo = ref({})
const checkedIds = ref([])
//
const queryCodeParams = ref({
pageNum: 1,
@ -171,6 +172,7 @@ const toggleForm = () => {
onLoad((options) => {
console.log(queryParams.value)
queryParams.value = JSON.parse(options.queryParams)
checkedIds.value = queryParams.value.maCodeList || []
})
onShow(() => {
@ -195,18 +197,28 @@ const getCodeDetailData = async (id, publishTask, typeId) => {
//
const getCodeDeviceListData = async () => {
// ID
const ids = checkedIds.value.map(item => item.maId)
const checkedIdSet = new Set(ids)
const res = await getInfoByTypeId(queryCodeParams.value)
codeDeviceList.value = res.data
if (queryParams.value.maCodeList.length > 0) {
const checkedIds = queryParams.value.maCodeList.map((e) => e.maId)
codeDeviceList.value.forEach((item) => {
item.checked = checkedIds.includes(item.maId)
const newRows = res.data.rows || []
const map = new Map()
total.value = res.data.total || 0
//
codeDeviceList.value.forEach((item) => {
map.set(item.maId, item)
})
// checked
newRows.forEach((item) => {
map.set(item.maId, {
...item,
checked: checkedIdSet.has(item.maId),
})
} else {
codeDeviceList.value.forEach((item) => {
item.checked = false
})
}
})
//
codeDeviceList.value = Array.from(map.values())
}
//
@ -218,7 +230,11 @@ const onCodeSearch = () => {
//
const onScrollTolower = debounce(() => {
// console.log('--')
console.log('滚动触底--')
if (total.value > codeDeviceList.value.length) {
queryCodeParams.value.pageSize += 10
getCodeDeviceListData()
}
}, 500)
// <EFBFBD><EFBFBD>
@ -229,6 +245,11 @@ const finish = computed(() => {
//
const onChangeChecked = (item) => {
item.checked = !item.checked
if (item.checked) {
checkedIds.value.push(item)
} else {
checkedIds.value = checkedIds.value.filter((check) => check.maId !== item.maId)
}
}
//
@ -245,8 +266,9 @@ const isSelectNum = computed(() => {
//
const onHandleOutbound = async () => {
const isSelect = codeDeviceList.value.some((e) => e.checked === true)
if (!isSelect) {
console.log('添加编码',checkedIds.value)
const isSelect = checkedIds.value.length === 0
if (isSelect) {
uni.showToast({
title: '请添加编码',
icon: 'none',
@ -263,14 +285,12 @@ const onHandleOutbound = async () => {
loading.value = true
//
const maCodeList = []
codeDeviceList.value.map((e) => {
if (e.checked) {
maCodeList.push({
maId: e.maId,
maCode: e.maCode,
typeId: queryParams.value.typeId,
})
}
checkedIds.value.map((e) => {
maCodeList.push({
maId: e.maId,
maCode: e.maCode,
typeId: queryParams.value.typeId,
})
})
console.log('maCodeList', maCodeList)
uni.$emit('maCodeList', { maCodeList })