批量退料-二维码添加

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

View File

@ -140,10 +140,10 @@
</uni-col>
</uni-row> -->
<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">
<eselect
v-model="selectTypeId"
:value="selectTypeId"
style="width: 100%; height: 90rpx; margin: 10px 0"
ref="treeSelect"
:options="typeOptions"
@ -151,6 +151,12 @@
></eselect>
</uni-col>
</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-col :span="6">外观判定</uni-col>
@ -198,9 +204,10 @@
</uni-col>
</uni-row>
<scroll-view
v-if="typeList.length > 0"
scroll-y
@scrolltolower="onScrollTolower"
style="flex: 1; overflow: auto; min-height: 160px"
style="flex: 1; overflow: auto"
>
<div class="card" style="margin-top: 10px">
<uni-row
@ -362,9 +369,20 @@ const getCodeList = async () => {
}
})
typeList.value.forEach((item) => {
item.checked = selectCodeList.value.some((selected) => selected.maCode === item.maCode)
})
const combinedList = [...selectCodeList.value, ...typeList.value]
// 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)
} catch (error) {
@ -377,10 +395,13 @@ const getCodeList = async () => {
//
const changeType = (e) => {
if (selectTypeId.value != e.typeId) {
selectCodeList.value = []
console.log('🚀 ~ changeType ~ e:', e)
typeName.value = e.materialName
selectTypeId.value = e.typeId
console.log('🚀 ~ changeType ~ :', selectTypeId.value)
}
getCodeList()
}
@ -396,7 +417,7 @@ const handleItemChecked = (item) => {
console.log('🚀 ~ handleItemChecked ~ item:', item)
item.checked = !item.checked
if (item.checked) {
selectCodeList.value.push(item)
selectCodeList.value.unshift(item)
} else {
selectCodeList.value = selectCodeList.value.filter((el) => el.maCode !== item.maCode)
}
@ -481,6 +502,8 @@ const getMaInfo = () => {
const qrCode = ref('') //
//
const scanStart = async () => {
qrCode.value = '201909-00100'
getMaInfoScan()
qrCode.value = ''
if (scanQrCodeRef.value) {
scanQrCodeRef.value.scanQrCode()
@ -528,16 +551,57 @@ const getMaInfoScan = () => {
}
console.log('xxxxxxxxxxxxxxxx', res)
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.data[0])
maCode.value = res.data[0].maCode
console.log('333333333333', maCode.value)
console.log('codeList:', JSON.stringify(codeList.value))
// maCode.value = res.data[0].maCode
typeName.value = res.data[0].typeName
materialName.value = res.data[0].typeModelName
maStatusName.value = res.data[0].maStatusName
maId.value = res.data[0].maId
typeId.value = res.data[0].typeId
// maStatusName.value = res.data[0].maStatusName
// maId.value = res.data[0].maId
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
} else {
uni.showModal({
@ -545,11 +609,6 @@ const getMaInfoScan = () => {
content: res.msg,
showCancel: false, //
confirmText: '关闭',
success: (res) => {
// if (res.confirm) {
// console.log('')
// }
},
})
}
},
@ -664,7 +723,9 @@ const submitCode = () => {
imgList.value = []
selectCodeList.value = []
// getMaCodeList()
if (selectTypeId.value) {
getCodeList()
}
// uni.navigateBack({
// delta: 1 //
// });
@ -888,7 +949,7 @@ onLoad((options) => {
background-color: #f7f8fa;
display: flex;
flex-direction: column;
min-height: 100vh; //
height: 100vh; //
//
.card {