From 97173614822409a6aa974e19f337b7a9b381c84f Mon Sep 17 00:00:00 2001 From: bb_pan Date: Wed, 9 Jul 2025 13:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E6=96=99=E7=AB=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../materialsStation/toolsLease/codeOut.vue | 117 +++++++++++++++--- .../uni-data-select/uni-data-select.vue | 14 +-- 2 files changed, 107 insertions(+), 24 deletions(-) diff --git a/src/pages/materialsStation/toolsLease/codeOut.vue b/src/pages/materialsStation/toolsLease/codeOut.vue index fd9dc34..becfe70 100644 --- a/src/pages/materialsStation/toolsLease/codeOut.vue +++ b/src/pages/materialsStation/toolsLease/codeOut.vue @@ -84,11 +84,11 @@ - + 出库方式: - + @@ -103,7 +103,7 @@ @scanSuccess="handleScanSuccess" @scanError="handleScanError" /> - + 设备编码 @@ -118,6 +118,21 @@ +
+ + + 设备编码 + + + + + +
@@ -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; } } diff --git a/src/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue b/src/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue index 6bb5d79..b112803 100644 --- a/src/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue +++ b/src/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue @@ -21,8 +21,8 @@ :class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'" > - - + + 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