This commit is contained in:
2025-08-06 18:19:22 +08:00
parent 1e06bc56b7
commit 5a8f25b428
4 changed files with 88 additions and 90 deletions

View File

@@ -30,9 +30,7 @@
<td @tap="toCheck(e)"><uni-icons :type="e.checked ? 'checkbox' : 'circle'" size="24" color="#4e6ef2"></uni-icons></td>
<td>{{e.material_name}}</td>
<td>{{e.material_code}}</td>
<!-- <td>{{e.qty}}</td>
<td>{{e.pcsn}}</td> -->
<td><input type="number" class="sin_input" v-model="e.qty"></td>
<td><input type="number" class="sin_input" v-model="e.qty" @blur="handleBlur(e)"></td>
<td><input type="text" class="sin_input" v-model="e.pcsn"></td>
</tr>
</tbody>
@@ -44,7 +42,7 @@
<view class="zd-row submit-bar">
<button class="zd-col-5 button-default" @tap="toEmpty">清空</button>
<button class="zd-col-8 button-primary" @tap="searchList">查询</button>
<button class="zd-col-8 button-primary" :class="{'button-info': !pkId}" @tap="toSure">确认</button>
<button class="zd-col-8 button-primary" :class="{'button-info': !checkedArr.length}" @tap="toSure">确认</button>
</view>
</view>
</template>
@@ -63,10 +61,11 @@
title: '',
val1: '',
dataList: [],
// dataList: [{material_name: 'name1', checked: false, qty:'100', pcsn:'p001'},{material_name: 'name2', checked: false},{material_name: 'name3', checked: false}],
// dataList: [{material_name: 'name1', checked: false, qty:1, pcsn:'p001'},{material_name: 'name2', checked: false},{material_name: 'name3', checked: false}],
pkId: '',
pkObj: {},
allCheck: false,
checkedArr: [],
reload: false,
status: 'more',
contentText: {
@@ -84,6 +83,21 @@
// this.searchList()
},
methods: {
handleBlur (e) {
if (e.qty) {
if (e.qty < 0) {
e.qty = 0
} else {
e.qty = e.qty.replace(/[^0-9]/g, '')
e.qty = e.qty.replace(/^0+/, '') || '0'
}
} else {
uni.showToast({
title: '数量必填',
icon: 'none'
})
}
},
searchList () {
this.dataList = []
this.pageNum = 1
@@ -127,8 +141,8 @@
},
toCheck (e) {
e.checked = !e.checked
let arr = this.dataList.filter(el => el.checked === true)
this.allCheck = arr.length === this.dataList.length
this.checkedArr = this.dataList.filter(el => el.checked === true)
this.allCheck = this.checkedArr.length === this.dataList.length
},
toEmpty () {
this.val1 = ''
@@ -137,10 +151,18 @@
this.pkId = ''
},
toSure () {
let arr = this.dataList.filter(el => el.checked === true)
if (arr.length) {
this.$store.dispatch('setPublicArr', arr)
if (!this.checkedArr.length) {
return
}
const allValid = this.checkedArr.every(item => item.qty !== '');
if (allValid) {
this.$store.dispatch('setPublicArr', this.checkedArr)
uni.navigateBack()
} else {
uni.showToast({
title: '数量必填',
icon: 'none'
})
}
}
}