批量退料-二维码添加

This commit is contained in:
bb_pan 2025-07-31 11:03:23 +08:00
parent 2ce3ad0ab3
commit 1a503277e2
2 changed files with 390 additions and 297 deletions

View File

@ -7,8 +7,15 @@
<!-- 输入框区域 开始 --> <!-- 输入框区域 开始 -->
<view class="ep-input-box" @click="openOptions"> <view class="ep-input-box" @click="openOptions">
<!-- <view style="display: flex;align-items: center;min-height: 36px;font-size: 28rpx;">{{showLabel}}</view> --> <!-- <view style="display: flex;align-items: center;min-height: 36px;font-size: 28rpx;">{{showLabel}}</view> -->
<uni-easyinput v-model="showLabel" maxlength="20" :placeholder="placeholder" <uni-easyinput
style="width: 100%;font-size: 28rpx;" @input="inputChange" @clear="handleClear" :disabled="disabled"/> v-model="showLabel"
maxlength="20"
:placeholder="placeholder"
style="width: 100%; font-size: 28rpx"
@input="inputChange"
@clear="handleClear"
:disabled="disabled"
/>
<!-- <image src="@/static/img/select.png" mode="" style="width: 36rpx;height: 36rpx;"></image> --> <!-- <image src="@/static/img/select.png" mode="" style="width: 36rpx;height: 36rpx;"></image> -->
</view> </view>
<!-- 输入框区域 结束 --> <!-- 输入框区域 结束 -->
@ -31,39 +38,39 @@
</template> </template>
<script> <script>
import leoTree from '@/components/tree-select/tree/tree.vue'; import leoTree from '@/components/tree-select/tree/tree.vue'
export default { export default {
name: "eselect", name: 'eselect',
components: { components: {
leoTree leoTree,
}, },
data() { data() {
return { return {
show: false, show: false,
left: 0, left: 0,
showLabel:"", showLabel: '',
placeholder:"请选择", placeholder: '请选择',
selectData:[] selectData: [],
} }
}, },
props: { props: {
value: { value: {
type: [String, Number], type: [String, Number],
default: "" default: '',
}, },
options: { options: {
type: Array, type: Array,
default: function () { default: function () {
return [] return []
} },
}, },
value_key: { value_key: {
type: String, type: String,
default: "value" default: 'value',
}, },
label_key: { label_key: {
type: String, type: String,
default: "label" default: 'label',
}, },
defaultProps: { defaultProps: {
type: Object, type: Object,
@ -71,18 +78,27 @@
return { return {
id: 'id', id: 'id',
children: 'children', children: 'children',
label: 'name' label: 'name',
}
} }
}, },
},
detailValue: { detailValue: {
type: [String, Number], type: [String, Number],
default: "" default: '',
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false,
} },
},
// value
watch: {
value: {
immediate: true,
handler(newVal) {
this.updateShowLabel(newVal)
},
},
}, },
mounted() { mounted() {
setTimeout(() => { setTimeout(() => {
@ -95,27 +111,44 @@
}, 200) }, 200)
}, },
methods: { methods: {
updateShowLabel(val) {
const target = this.findNodeById(this.options, val)
this.showLabel = target ? target[this.defaultProps.label] : ''
},
findNodeById(list, id) {
for (const item of list) {
if (item[this.defaultProps.id] === id) {
return item
}
const children = item[this.defaultProps.children]
if (children && children.length) {
const result = this.findNodeById(children, id)
if (result) return result
}
}
return null
},
// //
openOptions() { openOptions() {
if (this.disabled) return if (this.disabled) return
if(this.showLabel==""){ if (this.showLabel == '') {
this.selectData = this.options this.selectData = this.options
} else { } else {
this.selectData = this.mapTree(this.showLabel, this.options) this.selectData = this.mapTree(this.showLabel, this.options)
} }
this.show = true; this.show = true
}, },
nodeClick(e) { nodeClick(e) {
if (!e.children) { if (!e.children) {
this.show = false; this.show = false
this.showLabel=e.name; this.showLabel = e.name
this.$emit('change', e) this.$emit('change', e)
} }
}, },
clearInput() { clearInput() {
this.showLabel=""; this.showLabel = ''
this.selectData=this.options; this.selectData = this.options
}, },
handleClear() { handleClear() {
this.$emit('clear') this.$emit('clear')
@ -123,7 +156,7 @@
// //
inputChange(e) { inputChange(e) {
// console.log(e) // console.log(e)
if(e==""){ if (e == '') {
this.selectData = this.options this.selectData = this.options
} else { } else {
this.selectData = this.mapTree(e, this.options) this.selectData = this.mapTree(e, this.options)
@ -131,26 +164,27 @@
// console.log(this.selectData) // console.log(this.selectData)
}, },
mapTree(value, arr) { mapTree(value, arr) {
let newarr = []; let newarr = []
arr.forEach(element => { arr.forEach((element) => {
if (element.name.indexOf(value) > -1) { // if (element.name.indexOf(value) > -1) {
newarr.push(element); //
newarr.push(element)
} else { } else {
if (element.children && element.children.length > 0) { if (element.children && element.children.length > 0) {
let redata = this.mapTree(value, element.children); let redata = this.mapTree(value, element.children)
if (redata && redata.length > 0) { if (redata && redata.length > 0) {
let obj = { let obj = {
...element, ...element,
children: redata, children: redata,
expanded: true // expanded: true, //
}; }
newarr.push(obj); newarr.push(obj)
} }
} }
} }
}); })
return newarr; return newarr
} },
}, },
} }
</script> </script>
@ -165,7 +199,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 20rpx; font-size: 20rpx;
color: #0F274B; color: #0f274b;
width: 130rpx; width: 130rpx;
height: 48rpx; height: 48rpx;
border-radius: 12rpx 12rpx 12rpx 12rpx; border-radius: 12rpx 12rpx 12rpx 12rpx;
@ -203,7 +237,7 @@
right: 5px; right: 5px;
font-size: 20px; font-size: 20px;
transform: translateY(-50%); transform: translateY(-50%);
color: #B8B8B8; color: #b8b8b8;
} }
/* 下拉容器样式 外层 */ /* 下拉容器样式 外层 */
@ -232,7 +266,7 @@
padding: 20rpx 12rpx 14rpx; padding: 20rpx 12rpx 14rpx;
font-size: 20rpx; font-size: 20rpx;
cursor: pointer; cursor: pointer;
border-bottom: 1rpx solid #DFDDDD; border-bottom: 1rpx solid #dfdddd;
word-break: break-all; word-break: break-all;
} }
@ -258,8 +292,6 @@
/* color: #007AFF; */ /* color: #007AFF; */
} }
/* 下拉容器指示箭头样式 */ /* 下拉容器指示箭头样式 */
.ep-picker-content-wrap .triangle { .ep-picker-content-wrap .triangle {
width: 0; width: 0;

View File

@ -140,10 +140,10 @@
</uni-col> </uni-col>
</uni-row> --> </uni-row> -->
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px"> <uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="6">物资类型</uni-col> <uni-col :span="6">规格型号</uni-col>
<uni-col :span="18"> <uni-col :span="18">
<eselect <eselect
v-model="selectTypeId" :value="selectTypeId"
style="width: 100%; height: 90rpx; margin: 10px 0" style="width: 100%; height: 90rpx; margin: 10px 0"
ref="treeSelect" ref="treeSelect"
:options="typeOptions" :options="typeOptions"
@ -151,6 +151,12 @@
></eselect> ></eselect>
</uni-col> </uni-col>
</uni-row> </uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="6">物资类型</uni-col>
<uni-col :span="16">
{{ typeName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px"> <uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="6">外观判定</uni-col> <uni-col :span="6">外观判定</uni-col>
@ -198,9 +204,10 @@
</uni-col> </uni-col>
</uni-row> </uni-row>
<scroll-view <scroll-view
v-if="typeList.length > 0"
scroll-y scroll-y
@scrolltolower="onScrollTolower" @scrolltolower="onScrollTolower"
style="flex: 1; overflow: auto; min-height: 160px" style="flex: 1; overflow: auto"
> >
<div class="card" style="margin-top: 10px"> <div class="card" style="margin-top: 10px">
<uni-row <uni-row
@ -362,9 +369,20 @@ const getCodeList = async () => {
} }
}) })
typeList.value.forEach((item) => { const combinedList = [...selectCodeList.value, ...typeList.value]
item.checked = selectCodeList.value.some((selected) => selected.maCode === item.maCode)
}) // maCode
const seen = new Set()
const uniqueList = []
for (const item of combinedList) {
if (!seen.has(item.maCode)) {
seen.add(item.maCode)
uniqueList.push(item)
}
}
// typeList
typeList.value = uniqueList
console.log('🚀 ~ getCodeList ~ typeList.value:', typeList.value) console.log('🚀 ~ getCodeList ~ typeList.value:', typeList.value)
} catch (error) { } catch (error) {
@ -377,10 +395,13 @@ const getCodeList = async () => {
// //
const changeType = (e) => { const changeType = (e) => {
if (selectTypeId.value != e.typeId) {
selectCodeList.value = [] selectCodeList.value = []
console.log('🚀 ~ changeType ~ e:', e) console.log('🚀 ~ changeType ~ e:', e)
typeName.value = e.materialName
selectTypeId.value = e.typeId selectTypeId.value = e.typeId
console.log('🚀 ~ changeType ~ :', selectTypeId.value) console.log('🚀 ~ changeType ~ :', selectTypeId.value)
}
getCodeList() getCodeList()
} }
@ -396,7 +417,7 @@ const handleItemChecked = (item) => {
console.log('🚀 ~ handleItemChecked ~ item:', item) console.log('🚀 ~ handleItemChecked ~ item:', item)
item.checked = !item.checked item.checked = !item.checked
if (item.checked) { if (item.checked) {
selectCodeList.value.push(item) selectCodeList.value.unshift(item)
} else { } else {
selectCodeList.value = selectCodeList.value.filter((el) => el.maCode !== item.maCode) selectCodeList.value = selectCodeList.value.filter((el) => el.maCode !== item.maCode)
} }
@ -481,6 +502,8 @@ const getMaInfo = () => {
const qrCode = ref('') // const qrCode = ref('') //
// //
const scanStart = async () => { const scanStart = async () => {
qrCode.value = '201909-00100'
getMaInfoScan()
qrCode.value = '' qrCode.value = ''
if (scanQrCodeRef.value) { if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode() scanQrCodeRef.value.scanQrCode()
@ -528,16 +551,57 @@ const getMaInfoScan = () => {
} }
console.log('xxxxxxxxxxxxxxxx', res) console.log('xxxxxxxxxxxxxxxx', res)
if (res.code == 200) { if (res.code == 200) {
if (selectTypeId.value && selectTypeId.value != Number(res.data[0].typeId)) {
//
uni.showModal({
title: '提示',
content: '请添加同一类型的设备',
showCancel: false,
confirmText: '关闭',
})
return
}
console.log(res) console.log(res)
console.log(res.data[0]) console.log(res.data[0])
maCode.value = res.data[0].maCode // maCode.value = res.data[0].maCode
console.log('333333333333', maCode.value)
console.log('codeList:', JSON.stringify(codeList.value))
typeName.value = res.data[0].typeName typeName.value = res.data[0].typeName
materialName.value = res.data[0].typeModelName materialName.value = res.data[0].typeModelName
maStatusName.value = res.data[0].maStatusName // maStatusName.value = res.data[0].maStatusName
maId.value = res.data[0].maId // maId.value = res.data[0].maId
typeId.value = res.data[0].typeId selectTypeId.value = Number(res.data[0].typeId)
console.log('🚀 ~ getMaInfoScan ~ selectTypeId.value:', selectTypeId.value)
if (typeList.value.some((item) => item.maId == Number(res.data[0].maId))) {
//
typeList.value.forEach((item) => {
if (item.maId == res.data[0].maId) {
item.checked = true
}
})
if (!selectCodeList.value.some((item) => item.maId === res.data[0].maId)) {
selectCodeList.value.unshift({
...res.data[0],
checked: true,
})
uni.showToast({ title: '添加成功', icon: 'none' })
} else {
uni.showToast({ title: '当前设备已添加', icon: 'none' })
}
} else {
typeList.value.unshift({
...res.data[0],
checked: true,
})
if (!selectCodeList.value.some((item) => item.maId === res.data[0].maId)) {
selectCodeList.value.unshift({
...res.data[0],
checked: true,
})
}
uni.showToast({ title: '添加成功', icon: 'none' })
}
isAllChecked()
flag.value = true flag.value = true
} else { } else {
uni.showModal({ uni.showModal({
@ -545,11 +609,6 @@ const getMaInfoScan = () => {
content: res.msg, content: res.msg,
showCancel: false, // showCancel: false, //
confirmText: '关闭', confirmText: '关闭',
success: (res) => {
// if (res.confirm) {
// console.log('')
// }
},
}) })
} }
}, },
@ -664,7 +723,9 @@ const submitCode = () => {
imgList.value = [] imgList.value = []
selectCodeList.value = [] selectCodeList.value = []
// getMaCodeList() // getMaCodeList()
if (selectTypeId.value) {
getCodeList() getCodeList()
}
// uni.navigateBack({ // uni.navigateBack({
// delta: 1 // // delta: 1 //
// }); // });
@ -888,7 +949,7 @@ onLoad((options) => {
background-color: #f7f8fa; background-color: #f7f8fa;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 100vh; // height: 100vh; //
// //
.card { .card {