Files
FTC25009/pda/pages/warehouse/inbound/emptyTray.vue

299 lines
8.0 KiB
Vue

<template>
<view class="page-container">
<view class="form-section">
<text class="form-title">空托盘入库</text>
<view class="form-item">
<text class="form-label">仓库</text>
<picker class="form-picker" mode="selector" :range="warehouseOptions" range-key="warehouseName"
:value="warehouseIndex" @change="handleWarehouseChange">
<view class="picker-value" :class="{ placeholder: !warehouseId }">
{{ selectedWarehouseName || '请选择仓库' }}
</view>
</picker>
</view>
<view class="form-item">
<text class="form-label">托盘号</text>
<input class="form-input" v-model="trayCode" placeholder="请扫描托盘号" />
</view>
<view class="form-tip" v-if="!warehouseId || !trayCode">请先选择仓库和扫描托盘号</view>
<template v-else>
<view class="form-item">
<text class="form-label">入库点位</text>
<picker class="form-picker" mode="selector" :range="stationPointOptions" range-key="pointName"
:value="stationPointIndex" @change="handleStationPointChange">
<view class="picker-value" :class="{ placeholder: !stationPointId }">
{{ selectedStationPointName || '请选择入库点位' }}
</view>
</picker>
</view>
</template>
</view>
<view class="summary-section">
<view class="summary-row">
<text class="summary-label">作业类型</text>
<text class="summary-value">空容器入库</text>
</view>
<view class="summary-row">
<text class="summary-label">绑定物料</text>
<text class="summary-value muted">无需绑定</text>
</view>
</view>
<view class="btn-section">
<button class="btn btn-primary" :disabled="!canSubmit || submitting" @click="submitEmptyTray">
{{ submitting ? '提交中...' : '确认生成空托入库作业' }}
</button>
<button class="btn btn-default" @click="resetPayload">重置</button>
</view>
</view>
</template>
<script>
import { getInboundStationPointOptions, getWarehouseOptions, submitEmptyTrayInbound } from '@/api/warehouse/inbound'
export default {
data() {
return {
warehouseOptions: [],
warehouseIndex: 0,
warehouseId: '',
warehouseName: '',
trayCode: '',
stationPointOptions: [],
stationPointIndex: 0,
stationPointId: '',
stationPointName: '',
submitting: false
}
},
computed: {
selectedWarehouseName() {
if (this.warehouseName) return this.warehouseName
var selected = this.warehouseOptions[this.warehouseIndex]
return selected && selected.warehouseId === this.warehouseId ? selected.warehouseName : ''
},
selectedStationPointName() {
if (this.stationPointName) return this.stationPointName
var selected = this.stationPointOptions[this.stationPointIndex]
return selected && selected.pointId === this.stationPointId ? (selected.pointName || selected.pointId) : ''
},
canSubmit() {
return !!(this.warehouseId && this.trayCode && this.stationPointId)
}
},
watch: {
trayCode: function() {
this.resetStationPoint()
this.loadStationPointOptions()
}
},
onLoad() {
this.loadWarehouseOptions()
},
methods: {
loadWarehouseOptions() {
var that = this
getWarehouseOptions().then(function(res) {
that.warehouseOptions = res.data || res.rows || []
}).catch(function() {
that.warehouseOptions = []
})
},
handleWarehouseChange(e) {
var index = Number(e.detail.value)
var selected = this.warehouseOptions[index]
if (!selected) return
this.warehouseIndex = index
this.warehouseId = selected.warehouseId
this.warehouseName = selected.warehouseName
this.resetStationPoint()
this.loadStationPointOptions()
},
loadStationPointOptions() {
var that = this
if (!this.warehouseId || !this.trayCode) {
this.stationPointOptions = []
return
}
getInboundStationPointOptions(this.warehouseId, this.trayCode).then(function(res) {
that.stationPointOptions = res.data || res.rows || []
if (that.stationPointOptions.length === 1) {
that.stationPointIndex = 0
that.stationPointId = that.stationPointOptions[0].pointId
that.stationPointName = that.stationPointOptions[0].pointName || that.stationPointOptions[0].pointId
}
}).catch(function() {
that.resetStationPoint()
that.stationPointOptions = []
})
},
handleStationPointChange(e) {
var index = Number(e.detail.value)
var selected = this.stationPointOptions[index]
if (!selected) return
this.stationPointIndex = index
this.stationPointId = selected.pointId
this.stationPointName = selected.pointName || selected.pointId
},
resetStationPoint() {
this.stationPointIndex = 0
this.stationPointId = ''
this.stationPointName = ''
this.stationPointOptions = []
},
submitEmptyTray() {
if (!this.canSubmit) {
this.$modal.msg('请补全仓库、托盘号和入库点位')
return
}
var data = {
warehouseId: this.warehouseId,
trayCode: this.trayCode,
stationPointId: this.stationPointId
}
var that = this
this.$modal.confirm('是否确认生成空托入库作业?').then(function() {
that.submitting = true
return submitEmptyTrayInbound(data)
}).then(function(res) {
that.$modal.msgSuccess(res.msg || '空托入库作业生成成功')
that.resetPayload()
}).catch(function() {}).finally(function() {
that.submitting = false
})
},
resetPayload() {
this.trayCode = ''
this.stationPointOptions = []
this.resetStationPoint()
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #f5f7fa;
min-height: 100%;
}
.page-container {
padding: 24rpx;
padding-bottom: 60rpx;
}
.form-section,
.summary-section {
background: #fff;
border-radius: 16rpx;
padding: 28rpx;
margin-bottom: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}
.form-title {
display: block;
font-size: 30rpx;
font-weight: 500;
color: #333;
margin-bottom: 24rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.form-item {
display: flex;
align-items: center;
padding: 16rpx 0;
}
.form-label {
width: 160rpx;
flex-shrink: 0;
font-size: 28rpx;
color: #666;
}
.form-input,
.form-picker {
flex: 1;
width: 0;
min-width: 0;
box-sizing: border-box;
}
.form-input,
.picker-value {
width: 100%;
min-height: 72rpx;
padding: 16rpx;
border: 1rpx solid #e8e8e8;
border-radius: 8rpx;
background: #fff;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
.picker-value.placeholder {
color: #c0c4cc;
}
.form-tip {
padding: 8rpx 0 16rpx 160rpx;
font-size: 24rpx;
color: #909399;
line-height: 1.4;
}
.summary-row {
display: flex;
justify-content: space-between;
padding: 12rpx 0;
}
.summary-label {
font-size: 26rpx;
color: #999;
}
.summary-value {
font-size: 26rpx;
color: #333;
}
.summary-value.muted {
color: #52c41a;
}
.btn-section {
padding: 8rpx 0 24rpx;
}
.btn {
font-size: 30rpx;
border-radius: 12rpx;
margin-bottom: 20rpx;
}
.btn-primary {
background: #1890ff;
color: #fff;
}
.btn-primary[disabled] {
background: #b0d4f5;
color: #fff;
}
.btn-default {
background: #fff;
color: #666;
border: 1rpx solid #d9d9d9;
}
</style>