Files
hht-xinrui-mes/src/pages/xinrui/storage/instorage/RemnantInStoreGroup.vue
2022-06-27 10:21:54 +08:00

175 lines
4.9 KiB
Vue

<template>
<section>
<nav-bar title="零头粉入库组盘"></nav-bar>
<section class="content mgt186 mgb70">
<div class="filter-wraper">
<search-box
label="载具码"
v-model="val1"
@handleChange="handleChange1"
></search-box>
<search-box
label="桶码"
:focused="true"
v-model="val2"
@handleChange="handleChange2"
></search-box>
</div>
<div class="grid-wraper">
<div class="left_fixed">
<table class="layout-t left_layout_t">
<tr>
<th>桶码</th>
</tr>
<tr v-for="e in dataList" :key="e.bucketunique" @click="toCheck(e)" :class="{'checked': e.bucketunique === pkId}">
<td>{{e.bucketunique}}</td>
</tr>
</table>
</div>
<div class="slide">
<table class="layout-t">
<tr>
<th>产品编码</th>
<th>批次</th>
<th>重量kg</th>
</tr>
<tr v-for="e in dataList" :key="e.bucketunique" @click="toCheck(e)" :class="{'checked': e.bucketunique === pkId}">
<td>{{e.material_code}}</td>
<td>{{e.pcsn}}</td>
<td>{{e.storage_qty | numeric(3)}}</td>
</tr>
</table>
</div>
</div>
</section>
<section class="calc_value_wraper">
<div class="bottom-filter-tip">
<div class="filter-label txtjustify">总重量</div>
<div class="fxcol mgl20">
<input type="text" class="filter-input filter-scan-input" v-model="val3">
</div>
<div class="mgl20">KG</div>
</div>
</section>
<section class="submit-bar">
<button class="btn submit-button" :class="{'btn-disabled': this.pkId === ''}" @click="deleteList">删除行</button>
<button class="btn submit-button" :disabled="disabled" :class="{'btn-disabled': dataList.length === 0}" @click="toSure">确认组盘</button>
</section>
</section>
</template>
<script>
import NavBar from '@components/NavBar.vue'
import SearchBox from '@components/SearchBox.vue'
import {checkVehicle, checkBucket, confirmVehicle} from '@config/getData2.js'
import {accAdd} from '@config/mUtils.js'
export default {
name: 'RemnantInStoreGroup',
components: {
NavBar,
SearchBox
},
data () {
return {
val1: '',
vehicle: {},
val2: '',
val3: '',
dataList: [],
pkId: '',
pkObj: '',
disabled: false
}
},
methods: {
handleChange1 (e, type) {
if (type) {
this._checkVehicle(e, '6')
}
},
handleChange2 (e, type) {
if (type) {
this._checkBucket(e, '6')
}
},
toCheck (e) {
this.pkId = this.pkId === e.bucketunique ? '' : e.bucketunique
this.pkObj = this.pkId === e.bucketunique ? e : {}
},
/** 删除行 */
deleteList () {
if (this.pkId !== '') {
this.dataList.map((el, i) => {
if (el.bucketunique === this.pkId) {
this.dataList.splice(i, 1)
}
})
this.val3 = '0.000'
this.dataList.map(el => {
this.val3 = accAdd(this.val3, el.storage_qty)
})
this.val3 = Number(this.val3).toFixed(3) + ''
this.pkId = ''
this.pkObj = {}
}
},
/** 确认组盘 */
toSure () {
this.disabled = true
if (this.dataList.length === 0) {
this.disabled = false
return
}
this._confirmVehicle()
},
/** 查询载具码 */
async _checkVehicle (code, type) {
let res = await checkVehicle(code, type)
if (res.code === '1') {
this.vehicle = res.vehicle_jo
this.val1 = res.vehicle_jo.storagevehicle_code
} else {
this.Dialog(res.desc)
}
},
/** 查询桶信息 */
async _checkBucket (code, type) {
let res = await checkBucket(code, type)
if (res.code === '1') {
if (this.dataList.length) {
let arr = this.dataList.filter(el => { return el.bucketunique === res.bucket_jo.bucketunique })
if (arr.length) {
this.toast('桶码已存在')
} else {
this.dataList.push(res.bucket_jo)
}
} else {
this.dataList.push(res.bucket_jo)
}
this.val3 = '0.000'
this.dataList.map(el => {
this.val3 = accAdd(this.val3, el.storage_qty)
})
this.val3 = Number(this.val3).toFixed(3) + ''
} else {
this.Dialog(res.desc)
}
},
async _confirmVehicle () {
try {
let res = await confirmVehicle('6', this.vehicle, this.dataList, '')
if (res.code === '1') {
this.toast(res.desc)
Object.assign(this.$data, this.$options.data())
} else {
this.Dialog(res.desc)
}
this.disabled = false
} catch (e) {
this.disabled = false
}
}
}
}
</script>