材料站优化

This commit is contained in:
bb_pan 2025-07-09 13:12:07 +08:00
parent 9b2a54c26c
commit 9717361482
2 changed files with 107 additions and 24 deletions

View File

@ -84,11 +84,11 @@
</view>
</view>
<view class="table-list-item" v-if="!queryParamsTemp.isBack">
<view class="table-list-item">
<uni-row :gutter="24" class="flex">
<uni-col :span="6">出库方式</uni-col>
<uni-col :span="6">
<button class="item-btn" type="primary" @click="scanStart">二维码出库</button>
<button class="item-btn" type="primary" @click="scanStart">二维码识别</button>
</uni-col>
<uni-col :span="6">
<button class="item-btn" type="primary" @click="handleRfid">RFID识别</button>
@ -103,7 +103,7 @@
@scanSuccess="handleScanSuccess"
@scanError="handleScanError"
/>
<view class="table-list-item">
<view class="table-list-item" v-if="queryParams.isBack">
<uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="6">
<view> 设备编码 </view>
@ -118,6 +118,21 @@
</uni-col>
</uni-row>
</view>
<div class="table-list-item" v-else>
<uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="6">
<view> 设备编码 </view>
</uni-col>
<uni-col :span="18">
<uni-data-select
v-model="queryCodeParams.maCode"
:localdata="codeRange"
:filterable="false"
@change="changeCode"
></uni-data-select>
</uni-col>
</uni-row>
</div>
<scroll-view scroll-y style="padding-bottom: 90rpx; height: 70vh">
<view class="table-list-item" v-for="(item, index) in codeDeviceList" :key="item.maId">
<uni-row :gutter="24">
@ -184,6 +199,7 @@ const queryParamsTemp = ref({
typeId: '',
isAddCode: false,
})
const codeRange = ref([]) //
const formData = ref({})
const codeDeviceList = ref([])
const total = ref(0)
@ -228,6 +244,7 @@ onLoad((opt) => {
if (queryParamsTemp.value.maCodeList && queryParamsTemp.value.maCodeList.length > 0) {
allChecked.value = queryParamsTemp.value.maCodeList.every((e) => e.checked)
}
getCodeDeviceListData()
}
})
@ -250,8 +267,9 @@ onShow((opt) => {
const getCodeList = async () => {
const params = {
teamId: queryParamsTemp.value.teamId,
proId: queryParamsTemp.value.proId,
proId: queryParamsTemp.value.projectId,
typeId: queryParamsTemp.value.typeId,
maCode: queryCodeParams.value.maCode,
}
try {
const res = await getMachineByIdApi(params)
@ -291,17 +309,62 @@ const getCodeDeviceListData = async () => {
mask: true,
})
const res = await getCodeDeviceListAPI(queryCodeParams.value)
console.log('🚀 ~ getCodeDeviceListData ~ res:', res)
codeDeviceList.value.push(...res.data)
if (codeDeviceList.value.length > 0) {
codeDeviceList.value = codeDeviceList.value.map((e) => {
return { ...e, checked: false, outType: 0, checked: false }
if (res.data && res.data.length > 0) {
codeRange.value = res.data.map((item) => {
return {
text: item.maCode,
value: item.maCode,
}
})
}
total.value = res.total
console.log('🚀 ~ getCodeDeviceListData ~ res:', res)
// codeDeviceList.value.push(...res.data)
// if (codeDeviceList.value.length > 0) {
// codeDeviceList.value = codeDeviceList.value.map((e) => {
// return { ...e, checked: false, outType: 0, checked: false }
// })
// }
// total.value = res.total
setTimeout(() => {
uni.hideLoading()
}, 500)
}, 300)
} catch (error) {
console.log('🚀 ~ getCodeDeviceListData ~ error:', error)
uni.hideLoading()
}
}
const changeCode = (value) => {
console.log('🚀 ~ changeCode ~ value:', value)
if (!value) return
queryCodeParams.value.maCode = value
getCodeInfoData()
}
const getCodeInfoData = async () => {
try {
uni.showLoading({
title: '加载中...',
mask: true,
})
const res = await getCodeDeviceListAPI(queryCodeParams.value)
const newItem = {
...res.data[0],
checked: true,
outType: 0,
}
// maCode
const exists = codeDeviceList.value.some((item) => item.maCode === newItem.maCode)
if (exists) {
uni.showToast({ title: '设备已添加', icon: 'none' })
} else {
codeDeviceList.value.unshift(newItem)
}
allChecked.value = codeDeviceList.value.every((e) => e.checked)
setTimeout(() => {
uni.hideLoading()
}, 300)
} catch (error) {
console.log('🚀 ~ getCodeDeviceListData ~ error:', error)
uni.hideLoading()
@ -313,7 +376,12 @@ const onCodeSearch = () => {
queryCodeParams.value.pageNum = 1
codeDeviceList.value = []
allChecked.value = false
getCodeDeviceListData()
// 退
if (queryParams.value.isBack) {
getCodeList()
} else {
getCodeDeviceListData()
}
}
//
@ -447,14 +515,29 @@ const handleQrCode = async (qrCode) => {
const params = {
qrCode,
typeId: queryParams.value.typeId,
proId: queryParamsTemp.value.proId,
proId: queryParamsTemp.value.proId || queryParamsTemp.value.projectId,
teamId: queryParamsTemp.value.teamId,
}
console.log('🚀 ~ success: ~ queryParams.value.isAddCode:', queryParams.value.isAddCode)
try {
let res = null
if (queryParamsTemp.value.isBack) {
res = await getMachine(params)
console.log('🚀 ~ handleQrCode ~ res:', res)
if (res.data && res.data.length > 0) {
codeDeviceList.value.forEach((item) => {
const checkedItem = res.data.find((e) => e.maCode === item.maCode)
console.log('🚀 ~ codeDeviceList.value.forEach ~ checkedItem:', checkedItem)
if (checkedItem) {
item.checked = true
uni.showToast({
title: `设备编码 ${item.maCode} 已勾选`,
icon: 'none',
})
}
})
}
return
} else {
res = await getCodeScanAPI(params)
}
@ -524,7 +607,7 @@ const ocrClick = () => {
.table-list-item {
background: #fff;
padding: 32rpx;
padding: 32rpx 18rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
margin-bottom: 24rpx;
@ -535,8 +618,8 @@ const ocrClick = () => {
}
// 768px padding-top
@media (max-width: 767px) {
width: 80px;
font-size: 14px;
// width: 95px;
font-size: 13px;
}
}

View File

@ -21,8 +21,8 @@
:class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'"
></view>
<!-- 🔍 搜索输入框 searchable 控制 -->
<view v-if="searchable" class="uni-select__search-box">
<!-- 🔍 搜索输入框 filterable 控制 -->
<view v-if="filterable" class="uni-select__search-box">
<uni-easyinput
v-model="searchValue"
placeholder="请输入关键词"
@ -69,7 +69,7 @@
* @value top 顶部弹出
* @value bottom 底部弹出default)
* @event {Function} change 选中发生变化触发
* @property {Boolean} searchable 是否显示搜索框
* @property {Boolean} filterable 是否显示搜索框
*/
export default {
name: 'uni-data-select',
@ -121,7 +121,7 @@ export default {
type: String,
default: 'bottom',
},
searchable: {
filterable: {
type: Boolean,
default: true,
},
@ -158,14 +158,14 @@ export default {
},
textShow() {
const text = this.current
return text.length > 10 ? text.slice(0, 25) + '...' : text
return text.length > 13 ? text.slice(0, 20) + '...' : text
},
getOffsetByPlacement() {
return this.placement === 'top' ? 'bottom:calc(100% + 12px);' : 'top:calc(100% + 12px);'
},
filteredData() {
const keyword = this.searchValue.trim().toLowerCase()
if (!this.searchable || !keyword) return this.mixinDatacomResData
if (!this.filterable || !keyword) return this.mixinDatacomResData
return this.mixinDatacomResData.filter((item) =>
this.formatItemName(item).toLowerCase().includes(keyword),
)
@ -246,7 +246,7 @@ export default {
toggleSelector() {
if (this.disabled) return
this.showSelector = !this.showSelector
if (!this.showSelector && this.searchable) this.searchValue = ''
if (!this.showSelector && this.filterable) this.searchValue = ''
},
onSearchInput(val) {
this.searchValue = val