材料站优化
This commit is contained in:
parent
9b2a54c26c
commit
9717361482
|
|
@ -84,11 +84,11 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="table-list-item" v-if="!queryParamsTemp.isBack">
|
<view class="table-list-item">
|
||||||
<uni-row :gutter="24" class="flex">
|
<uni-row :gutter="24" class="flex">
|
||||||
<uni-col :span="6">出库方式:</uni-col>
|
<uni-col :span="6">出库方式:</uni-col>
|
||||||
<uni-col :span="6">
|
<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>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<button class="item-btn" type="primary" @click="handleRfid">RFID识别</button>
|
<button class="item-btn" type="primary" @click="handleRfid">RFID识别</button>
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
@scanSuccess="handleScanSuccess"
|
@scanSuccess="handleScanSuccess"
|
||||||
@scanError="handleScanError"
|
@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-row :gutter="24" style="display: flex; align-items: center">
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view> 设备编码 </view>
|
<view> 设备编码 </view>
|
||||||
|
|
@ -118,6 +118,21 @@
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</view>
|
</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">
|
<scroll-view scroll-y style="padding-bottom: 90rpx; height: 70vh">
|
||||||
<view class="table-list-item" v-for="(item, index) in codeDeviceList" :key="item.maId">
|
<view class="table-list-item" v-for="(item, index) in codeDeviceList" :key="item.maId">
|
||||||
<uni-row :gutter="24">
|
<uni-row :gutter="24">
|
||||||
|
|
@ -184,6 +199,7 @@ const queryParamsTemp = ref({
|
||||||
typeId: '',
|
typeId: '',
|
||||||
isAddCode: false,
|
isAddCode: false,
|
||||||
})
|
})
|
||||||
|
const codeRange = ref([]) // 编码列表
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
const codeDeviceList = ref([])
|
const codeDeviceList = ref([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
|
|
@ -228,6 +244,7 @@ onLoad((opt) => {
|
||||||
if (queryParamsTemp.value.maCodeList && queryParamsTemp.value.maCodeList.length > 0) {
|
if (queryParamsTemp.value.maCodeList && queryParamsTemp.value.maCodeList.length > 0) {
|
||||||
allChecked.value = queryParamsTemp.value.maCodeList.every((e) => e.checked)
|
allChecked.value = queryParamsTemp.value.maCodeList.every((e) => e.checked)
|
||||||
}
|
}
|
||||||
|
getCodeDeviceListData()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -250,8 +267,9 @@ onShow((opt) => {
|
||||||
const getCodeList = async () => {
|
const getCodeList = async () => {
|
||||||
const params = {
|
const params = {
|
||||||
teamId: queryParamsTemp.value.teamId,
|
teamId: queryParamsTemp.value.teamId,
|
||||||
proId: queryParamsTemp.value.proId,
|
proId: queryParamsTemp.value.projectId,
|
||||||
typeId: queryParamsTemp.value.typeId,
|
typeId: queryParamsTemp.value.typeId,
|
||||||
|
maCode: queryCodeParams.value.maCode,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getMachineByIdApi(params)
|
const res = await getMachineByIdApi(params)
|
||||||
|
|
@ -291,17 +309,62 @@ const getCodeDeviceListData = async () => {
|
||||||
mask: true,
|
mask: true,
|
||||||
})
|
})
|
||||||
const res = await getCodeDeviceListAPI(queryCodeParams.value)
|
const res = await getCodeDeviceListAPI(queryCodeParams.value)
|
||||||
console.log('🚀 ~ getCodeDeviceListData ~ res:', res)
|
if (res.data && res.data.length > 0) {
|
||||||
codeDeviceList.value.push(...res.data)
|
codeRange.value = res.data.map((item) => {
|
||||||
if (codeDeviceList.value.length > 0) {
|
return {
|
||||||
codeDeviceList.value = codeDeviceList.value.map((e) => {
|
text: item.maCode,
|
||||||
return { ...e, checked: false, outType: 0, checked: false }
|
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(() => {
|
setTimeout(() => {
|
||||||
uni.hideLoading()
|
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) {
|
} catch (error) {
|
||||||
console.log('🚀 ~ getCodeDeviceListData ~ error:', error)
|
console.log('🚀 ~ getCodeDeviceListData ~ error:', error)
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|
@ -313,7 +376,12 @@ const onCodeSearch = () => {
|
||||||
queryCodeParams.value.pageNum = 1
|
queryCodeParams.value.pageNum = 1
|
||||||
codeDeviceList.value = []
|
codeDeviceList.value = []
|
||||||
allChecked.value = false
|
allChecked.value = false
|
||||||
getCodeDeviceListData()
|
// 退料
|
||||||
|
if (queryParams.value.isBack) {
|
||||||
|
getCodeList()
|
||||||
|
} else {
|
||||||
|
getCodeDeviceListData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全选复选框事件
|
// 全选复选框事件
|
||||||
|
|
@ -447,14 +515,29 @@ const handleQrCode = async (qrCode) => {
|
||||||
const params = {
|
const params = {
|
||||||
qrCode,
|
qrCode,
|
||||||
typeId: queryParams.value.typeId,
|
typeId: queryParams.value.typeId,
|
||||||
proId: queryParamsTemp.value.proId,
|
proId: queryParamsTemp.value.proId || queryParamsTemp.value.projectId,
|
||||||
teamId: queryParamsTemp.value.teamId,
|
teamId: queryParamsTemp.value.teamId,
|
||||||
}
|
}
|
||||||
console.log('🚀 ~ success: ~ queryParams.value.isAddCode:', queryParams.value.isAddCode)
|
|
||||||
try {
|
try {
|
||||||
let res = null
|
let res = null
|
||||||
if (queryParamsTemp.value.isBack) {
|
if (queryParamsTemp.value.isBack) {
|
||||||
res = await getMachine(params)
|
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 {
|
} else {
|
||||||
res = await getCodeScanAPI(params)
|
res = await getCodeScanAPI(params)
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +607,7 @@ const ocrClick = () => {
|
||||||
|
|
||||||
.table-list-item {
|
.table-list-item {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 32rpx;
|
padding: 32rpx 18rpx;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||||
margin-bottom: 24rpx;
|
margin-bottom: 24rpx;
|
||||||
|
|
@ -535,8 +618,8 @@ const ocrClick = () => {
|
||||||
}
|
}
|
||||||
// 针对手机(如宽度小于768px)设置不同的 padding-top
|
// 针对手机(如宽度小于768px)设置不同的 padding-top
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
width: 80px;
|
// width: 95px;
|
||||||
font-size: 14px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
:class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'"
|
:class="placement == 'bottom' ? 'uni-popper__arrow_bottom' : 'uni-popper__arrow_top'"
|
||||||
></view>
|
></view>
|
||||||
|
|
||||||
<!-- 🔍 搜索输入框,受 searchable 控制 -->
|
<!-- 🔍 搜索输入框,受 filterable 控制 -->
|
||||||
<view v-if="searchable" class="uni-select__search-box">
|
<view v-if="filterable" class="uni-select__search-box">
|
||||||
<uni-easyinput
|
<uni-easyinput
|
||||||
v-model="searchValue"
|
v-model="searchValue"
|
||||||
placeholder="请输入关键词"
|
placeholder="请输入关键词"
|
||||||
|
|
@ -69,7 +69,7 @@
|
||||||
* @value top 顶部弹出
|
* @value top 顶部弹出
|
||||||
* @value bottom 底部弹出(default)
|
* @value bottom 底部弹出(default)
|
||||||
* @event {Function} change 选中发生变化触发
|
* @event {Function} change 选中发生变化触发
|
||||||
* @property {Boolean} searchable 是否显示搜索框
|
* @property {Boolean} filterable 是否显示搜索框
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
name: 'uni-data-select',
|
name: 'uni-data-select',
|
||||||
|
|
@ -121,7 +121,7 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'bottom',
|
default: 'bottom',
|
||||||
},
|
},
|
||||||
searchable: {
|
filterable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
|
@ -158,14 +158,14 @@ export default {
|
||||||
},
|
},
|
||||||
textShow() {
|
textShow() {
|
||||||
const text = this.current
|
const text = this.current
|
||||||
return text.length > 10 ? text.slice(0, 25) + '...' : text
|
return text.length > 13 ? text.slice(0, 20) + '...' : text
|
||||||
},
|
},
|
||||||
getOffsetByPlacement() {
|
getOffsetByPlacement() {
|
||||||
return this.placement === 'top' ? 'bottom:calc(100% + 12px);' : 'top:calc(100% + 12px);'
|
return this.placement === 'top' ? 'bottom:calc(100% + 12px);' : 'top:calc(100% + 12px);'
|
||||||
},
|
},
|
||||||
filteredData() {
|
filteredData() {
|
||||||
const keyword = this.searchValue.trim().toLowerCase()
|
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) =>
|
return this.mixinDatacomResData.filter((item) =>
|
||||||
this.formatItemName(item).toLowerCase().includes(keyword),
|
this.formatItemName(item).toLowerCase().includes(keyword),
|
||||||
)
|
)
|
||||||
|
|
@ -246,7 +246,7 @@ export default {
|
||||||
toggleSelector() {
|
toggleSelector() {
|
||||||
if (this.disabled) return
|
if (this.disabled) return
|
||||||
this.showSelector = !this.showSelector
|
this.showSelector = !this.showSelector
|
||||||
if (!this.showSelector && this.searchable) this.searchValue = ''
|
if (!this.showSelector && this.filterable) this.searchValue = ''
|
||||||
},
|
},
|
||||||
onSearchInput(val) {
|
onSearchInput(val) {
|
||||||
this.searchValue = val
|
this.searchValue = val
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue