出库优化
This commit is contained in:
parent
b709dd283f
commit
f79565ea5a
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Reference in New Issue