This commit is contained in:
2026-01-12 11:25:07 +08:00
parent f2231c9329
commit 6138ee3d95
8 changed files with 169 additions and 73 deletions

View File

@@ -44,7 +44,7 @@
<view class="zd-col-13">
<search-box v-model="suppData.supp_code"/>
</view>
<button class="mini-btn" type="primary" @tap="toJump('supplier?title=供应商维护')">查询</button>
<button class="mini-btn" type="primary" @tap="toJump2('supplier?title=供应商维护')">查询</button>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-6">
@@ -140,6 +140,11 @@
url: `/pages/hdyy/wbc/${name}`
})
},
toJump2 (name) {
uni.navigateTo({
url: `/pages/hdyy/tygn/${name}`
})
},
toEmpty () {
this.val1 = ''
this.index1 = ''

View File

@@ -14,6 +14,16 @@
/>
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-7">
<span class="filter_label">袋码</span>
</view>
<view class="zd-col-24 filter_select">
<search-box
v-model="bagCode"
/>
</view>
</view>
<view class="zd-row">
<button class="zd-col-11 button-primary ftsize1" @tap="toScanAdd">扫码插入</button>
<button class="zd-col-11 button-primary ftsize1" @tap="toDel">删除行</button>
@@ -36,7 +46,7 @@
</tr>
</thead>
<tbody>
<tr v-for="(e, i) in dataList" :key="i">
<tr v-for="(e, i) in dataList" :key="i" :class="{'checked': e.bag_code === pkId}" @tap="toCheck(e)">
<td>{{i+1}}</td>
<td>{{e.bag_code}}</td>
<td>{{e.material_code}}</td>
@@ -72,6 +82,9 @@
return {
title: '',
val1: '',
bagCode: '',
pkId: '',
pkObj: {},
dataList: [],
// dataList: [{material_code: 'm001', qty: 100, checked: false, initialQty: 100}, {material_code: 'm002', qty: 200, checked: false, initialQty: 200}],
disabled: false
@@ -82,71 +95,32 @@
},
methods: {
toScanAdd () {
uni.scanCode({
success: (res) => {
// console.log('扫码成功:', res.result);
if (res.result.includes(';')) {
const parts = res.result.split(';')
if (parts.length !== 5) {
uni.showToast({
title: '二维码格式不正确,请扫描符合格式的二维码',
icon: 'none'
})
return
}
let currObj = {
mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
container_code: parts[0],
material_code: parts[1],
material_name: parts[2],
qty: parts[3],
measure_unit_id: parts[4],
}
// 检查是否已存在相同卷号
const exists = this.dataList.some(item => item.container_code === currObj.container_code)
if (exists) {
uni.showToast({
title: '已存在',
icon: 'none'
})
return
}
this.dataList.push(currObj)
} else {
let currObj = {
mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9),
container_code: res.result,
material_code: '',
material_name: '',
qty: '',
measure_unit_id: ''
}
// 检查是否已存在相同卷号
const exists = this.dataList.some(item => item.container_code === currObj.container_code)
if (exists) {
uni.showToast({
title: '已存在',
icon: 'none'
})
return
}
this.dataList.push(currObj)
}
},
fail: (err) => {
console.log('扫码失败:', err)
// uni.showToast({
// title: err + '扫码失败',
// icon: 'none'
// })
}
})
if (this.bagCode) {
this._getBagAssembly2(this.bagCode)
}
// uni.scanCode({
// success: (res) => {
// // console.log('扫码成功:', res.result);
// this._getPalletAssembly(res.result)
// },
// fail: (err) => {
// console.log('扫码失败:', err)
// // uni.showToast({
// // title: err + '扫码失败',
// // icon: 'none'
// // })
// }
// })
},
toDel () {
if (!this.pkId) {
return
}
this.dataList = this.dataList.filter(item => item.mid !== this.pkObj.mid)
this.dataList = this.dataList.filter(item => item.bag_code !== this.pkObj.bag_code)
},
toCheck (e) {
this.pkId = this.pkId === e.bag_code ? '' : e.bag_code
this.pkObj = this.pkId === e.bag_code ? e : {}
},
toEmpty () {
this.val1 = ''
@@ -165,6 +139,24 @@
this.dataList = []
}
},
async _getBagAssembly2 () {
try {
let res = await getBagAssembly(this.bagCode)
if (res) {
const existingItem = this.dataList.find(item => item.bag_code === res.data.bag_code)
if (existingItem) {
uni.showToast({
title: '袋码已存在,不能重复插入',
icon: 'none'
})
return
}
this.dataList.push(res.data)
} else {
}
} catch (e) {
}
},
async _confirmPalletAssembly () {
this.disabled = true
if (!this.val1 || !this.dataList.length) {