Files
hht-xzhy-uni/pages/outbound/bill-out-store.vue
2025-09-01 17:18:37 +08:00

243 lines
7.7 KiB
Vue

<template>
<view class="zd_container">
<!-- 单据出库 -->
<nav-bar :title="title" :inner="true"></nav-bar>
<view class="zd_content">
<view v-if="JSON.stringify(currentData) !== '{}'" class="zd_wrapper">
<view class="zd-row border-bottom filter_input_disabled">
<view class="zd-col-6"><span class="filter_label">单据编码</span></view>
<view class="zd-col-6"><span class="filter_input">{{currentData.code}}</span></view>
<view class="zd-col-6"><span class="filter_label">单据类型</span></view>
<view class="zd-col-6"><span class="filter_input">{{formTypeName}}</span></view>
</view>
<view class="zd-row border-bottom filter_input_disabled">
<view class="zd-col-6"><span class="filter_label">创建时间</span></view>
<view class="zd-col-6"><span class="filter_input">{{currentData.create_time}}</span></view>
<view class="zd-col-6"><span class="filter_label">创建人</span></view>
<view class="zd-col-6"><span class="filter_input">{{currentData.create_name}}</span></view>
</view>
<!-- <view class="zd-row border-bottom filter_input_disabled">
<view class="zd-col-6"><span class="filter_label">物料编码</span></view>
<view class="zd-col-6"><span class="filter_input">{{currentData.material_code}}</span></view>
<view class="zd-col-6"><span class="filter_label">单位</span></view>
<view class="zd-col-6"><span class="filter_input">{{currentData.unit_name}}</span></view>
</view> -->
<view class="zd-row border-bottom">
<view class="zd-col-6"><span class="filter_label">仓库</span></view>
<view class="zd-col-6 filter_select">
<uni-data-select v-model="index1" :localdata="options1" @change="selectChange1"></uni-data-select>
</view>
<view class="zd-col-6"><span class="filter_label">车间</span></view>
<view class="zd-col-6 filter_select">
<uni-data-select v-model="currentData.product_area" :localdata="options2"></uni-data-select>
</view>
</view>
<view class="zd-row jcflexstart">
<view class="zd-col-6">
<span class="filter_label">加急单据</span>
</view>
<view class="relative zd-col-6">
<switch :checked="isChecked" color="#4e6ef2" style="transform:scale(0.8); transform-origin: left;"/>
<text @tap="setWStatus" style="position: absolute;display: inline-block;width: 52px; height: 32px;left: 0;"></text>
</view>
</view>
</view>
<view v-if="JSON.stringify(currentData) !== '{}'" class="grid-wraper">
<view class="slide_new">
<table>
<thead>
<tr>
<th @tap="toAllCheck"><uni-icons :type="allCheck ? 'checkbox' : 'circle'" size="24" color="#4e6ef2"></uni-icons></th>
<th class="td_3">
<view class="td_3">
物料名称
</view>
</th>
<th>物料编码</th>
<th>计划数量</th>
<th>申请数量</th>
<th>库存数量</th>
<th>出库数量</th>
<th>已分配数量</th>
<th>已领数量</th>
<th>批次号</th>
<th>单位</th>
</tr>
</thead>
<tbody>
<tr v-for="(e, i) in dataList" :key="i">
<td @tap="toCheck(e)"><uni-icons :type="e.checked ? 'checkbox' : 'circle'" size="24" color="#4e6ef2"></uni-icons></td>
<td class="td_3">{{e.material_name}}</td>
<td>{{e.material_code}}</td>
<td>{{e.plan_qty}}</td>
<td>{{e.qty}}</td>
<td>{{e.sto_qty}}</td>
<td><input type="number" class="sin_input" v-model="e.now_assign_qty" @blur="handleBlur(e)"></td>
<td>{{e.assign_qty}}</td>
<td>{{e.actual_qty}}</td>
<td><input type="text" class="sin_input" v-model="e.pcsn"></td>
<td>{{e.unit_name}}</td>
</tr>
</tbody>
</table>
</view>
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-6 button-primary" @tap="toEmpty">返回</button>
<button class="zd-col-16 button-primary" :class="{'button-info': JSON.stringify(currentData) === '{}'}" :disabled="disabled" @tap="_outStorageConfirm">出库确认</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {outStorageOrder, outStorageConfirm, outStorageOrderConfirm} from '@/utils/getData2.js'
export default {
components: {
NavBar,
SearchBox
},
data() {
return {
title: '',
currentData: {},
dataList: [],
disabled: false,
options1: [{value: 'FStockPallet', text: '托盘库'}, {value: 'FStockId', text: '料箱库'}],
index1: '',
options2: [{value: 'A1', text: 'A1车间'}, {value: 'A2', text: 'A2车间'}, {value: 'A3', text: 'A3车间'}],
allCheck: false,
formTypeName: '',
isChecked: false
};
},
onLoad (options) {
this.title = options.title
},
onShow () {
if (this.$store.getters.publicObj !== '') {
this.currentData = this.$store.getters.publicObj
this._outStorageOrder()
this.dataList = [...this.currentData.children]
this.dataList.map(el => {
this.$set(el, 'now_assign_qty', el.qty)
this.$set(el, 'checked', false)
})
this.index1 = this.currentData.stor_code
this.$store.dispatch('setPublicObj', '')
}
},
methods: {
setWStatus () {
this.isChecked = !this.isChecked
},
// 出库单类型
async _outStorageOrder () {
let res = await outStorageOrder()
res.map(el => {
if (el.value === this.currentData.form_type) {
this.formTypeName = el.text
}
})
},
selectChange1 (e) {
if (e) {
this._outStorageOrderConfirm(e)
}
},
async _outStorageOrderConfirm (e) {
try {
let res = await outStorageOrderConfirm(this.currentData.code, e)
if (res.code === '200') {
if (res.content.length > 0) {
this.currentData = res.content[0]
this.dataList = [...this.currentData.children]
this.dataList.map(el => {
this.$set(el, 'now_assign_qty', el.qty)
this.$set(el, 'checked', false)
})
}
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
} catch (e) {
console.log(e)
}
},
handleBlur (e) {
if (e.now_assign_qty < 0 || e.now_assign_qty > e.qty) {
e.now_assign_qty = e.qty
}
if (parseFloat(e.sto_qty) < parseFloat(e.now_assign_qty) && e.checked) {
e.checked = false
}
},
toEmpty () {
uni.navigateBack()
},
toAllCheck () {
this.allCheck = !this.allCheck
this.dataList.map(el => {
el.checked = this.allCheck
})
},
toCheck (e) {
if (parseFloat(e.sto_qty) < parseFloat(e.now_assign_qty)) {
return
}
e.checked = !e.checked
let arr = this.dataList.filter(el => el.checked === true)
this.allCheck = arr.length === this.dataList.length
},
async _outStorageConfirm () {
this.disabled = true
if (JSON.stringify(this.currentData) === '{}') {
this.disabled = false
return
}
let arr = this.dataList.filter(el => el.checked === true)
let urgent = this.isChecked ? '1' : '0'
let obj = Object.assign(this.currentData, {children: arr, stor_code: this.index1, urgent: urgent})
try {
let res = await outStorageConfirm(obj)
if (res.code === '200') {
uni.showToast({
title: res.msg,
icon: 'none'
})
this.toEmpty()
}
this.disabled = false
uni.showToast({
title: res.msg,
icon: 'none'
})
} catch (e) {
this.disabled = false
}
}
}
}
</script>
<style lang="stylus" scoped>
.filter_input
font-size 26rpx
.filter_label
font-size: 26rpx;
.slide_new
// padding-bottom 110px
.slide_new table td
overflow visible
/deep/ .uni-select__input-text
width calc(100% - 25px)
/deep/ .zd_icon_wraper
width 25px
/deep/ .uni-icons
vertical-align: bottom;
</style>