334 lines
8.6 KiB
Vue
334 lines
8.6 KiB
Vue
<template>
|
|
<view class="container">
|
|
<view class="form-card">
|
|
<uni-forms>
|
|
<uni-forms-item :label="$t('outbound.emptyPalletBox.emptyPallet.warehouse')">
|
|
<uni-data-select
|
|
v-model="formData.warehouseId"
|
|
:localdata="warehouseList"
|
|
:clear="false"
|
|
:placeholder="$t('outbound.emptyPalletBox.emptyPallet.warehousePlaceholder')"
|
|
@change="handleWarehouseChange"
|
|
/>
|
|
</uni-forms-item>
|
|
<view class="cargo-space-container" v-if="currentWarehouseType == '1'">
|
|
<uni-forms-item :label="$t('outbound.emptyPalletBox.emptyPallet.cargoSpace')">
|
|
<view class="cargo-input-group">
|
|
<uni-easyinput
|
|
v-model="formData.cargoSpaceName"
|
|
:placeholder="$t('outbound.emptyPalletBox.emptyPallet.cargoSpacePlaceholder')"
|
|
:clearable="true"
|
|
@input="handleCargoSpaceInput"
|
|
/>
|
|
<button class="recommend-btn" @click="handleRecommendCargoSpace">{{ $t('outbound.emptyPalletBox.emptyPallet.recommendCargoSpace') }}</button>
|
|
</view>
|
|
</uni-forms-item>
|
|
</view>
|
|
<view v-if="currentWarehouseType == '1' && cargoSpaceHeight" class="cargo-space-info">
|
|
<text class="cargo-space-height">{{ $t('outbound.emptyPalletBox.emptyPallet.cargoSpaceHeight') }}{{ cargoSpaceHeight }}{{ $t('outbound.emptyPalletBox.emptyPallet.meter') }}</text>
|
|
</view>
|
|
<view class="cargo-space-container" v-if="currentWarehouseType == '2'">
|
|
<uni-forms-item :label="$t('outbound.emptyPalletBox.emptyPallet.exit')">
|
|
<uni-data-select
|
|
v-model="formData.exitId"
|
|
:localdata="exitList"
|
|
:clear="false"
|
|
:placeholder="$t('outbound.emptyPalletBox.emptyPallet.exitPlaceholder')"
|
|
/>
|
|
</uni-forms-item>
|
|
</view>
|
|
|
|
<button class="submit-button" hover-class="button-hover" @click="handleSubmit">{{ $t('outbound.emptyPalletBox.emptyPallet.submit') }}</button>
|
|
</uni-forms>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getBasWarehouList, getFullCargoSpaceListByWarehouse,getCargoSpaceList } from '@/api/bas/bas.js'
|
|
import{emptyTrayOut} from '@/api/out/ktpout.js'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
formData: {
|
|
warehouseId: '',
|
|
cargoSpaceId: '',
|
|
exitId: '',
|
|
cargoSpaceName: ''
|
|
},
|
|
warehouseList: [],
|
|
cargoSpaceList: [],
|
|
exitList: [],
|
|
currentWarehouseType: '',
|
|
cargoSpaceHeight:''
|
|
}
|
|
},
|
|
onReady() {
|
|
this.getWarehouseList()
|
|
},
|
|
methods: {
|
|
async getWarehouseList() {
|
|
try {
|
|
const res = await getBasWarehouList({
|
|
pageNum:1,
|
|
pageSize:100,
|
|
typeData:['1','2']
|
|
})
|
|
if (res.code === 200) {
|
|
this.warehouseList = res.rows.map(item => ({
|
|
value: item.warehouseId,
|
|
text: item.warehouseName,
|
|
type: item.warehouseType
|
|
}))
|
|
}
|
|
} catch (error) {
|
|
console.error(this.$t('outbound.emptyPalletBox.emptyPallet.getWarehouseListFailed'), error)
|
|
}
|
|
},
|
|
async handleWarehouseChange(warehouseId) {
|
|
if (!warehouseId) return
|
|
const selectedWarehouse = this.warehouseList.find(item => item.value === warehouseId)
|
|
this.currentWarehouseType = selectedWarehouse ? selectedWarehouse.type : ''
|
|
this.formData.exitId = ''
|
|
|
|
if (this.currentWarehouseType == '2') {
|
|
// 模拟出口数据,实际项目中应该从后端获取
|
|
this.exitList = [
|
|
{ value: '1', text: this.$t('outbound.emptyPalletBox.emptyPallet.exit') + '1' },
|
|
{ value: '2', text: this.$t('outbound.emptyPalletBox.emptyPallet.exit') + '2' },
|
|
{ value: '3', text: this.$t('outbound.emptyPalletBox.emptyPallet.exit') + '3' }
|
|
]
|
|
}
|
|
},
|
|
handleCargoSpaceSelect(item) {
|
|
this.formData.cargoSpaceId = item.value
|
|
},
|
|
async handleRecommendCargoSpace() {
|
|
if (!this.formData.warehouseId) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.selectWarehouse'),
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
// try {
|
|
const response = await getFullCargoSpaceListByWarehouse({ warehouseId: this.formData.warehouseId })
|
|
if (response.code === 200 && response.data.length > 0) {
|
|
// 获取第一个推荐货位
|
|
this.formData.cargoSpaceId = response.data[0].cargoSpaceId
|
|
this.formData.cargoSpaceName = response.data[0].cargoSpaceName
|
|
// 手动触发handleCargoSpaceInput方法获取货位高度信息
|
|
await this.handleCargoSpaceInput(response.data[0].cargoSpaceName)
|
|
|
|
} else {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.noAvailableCargoSpace'),
|
|
icon: 'none'
|
|
})
|
|
}
|
|
// } catch (error) {
|
|
// console.error('获取推荐货位失败:', error)
|
|
// uni.showToast({
|
|
// title: '获取推荐货位失败',
|
|
// icon: 'none'
|
|
// })
|
|
// }
|
|
},
|
|
// 处理货位选择
|
|
async handleCargoSpaceInput(value) {
|
|
if (value) {
|
|
try {
|
|
const response = await getCargoSpaceList({ cargoSpaceName: value, warehouseId: this.formData.warehouseId })
|
|
if (response.code === 200 && response.rows.length > 0) {
|
|
this.formData.cargoSpaceId = response.rows[0].cargoSpaceId
|
|
this.cargoSpaceHeight = response.rows[0].cargoHight
|
|
console.log(this.formData.cargoSpaceId)
|
|
} else {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.getCargoSpaceInfoFailed'),
|
|
icon: 'none'
|
|
})
|
|
this.formData.cargoSpaceId = ''
|
|
this.cargoSpaceHeight = null
|
|
}
|
|
} catch (error) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.getCargoSpaceInfoFailed'),
|
|
icon: 'none'
|
|
})
|
|
this.formData.cargoSpaceId = ''
|
|
this.cargoSpaceHeight = null
|
|
}
|
|
} else {
|
|
this.formData.cargoSpaceId = ''
|
|
this.cargoSpaceHeight = null
|
|
}
|
|
},
|
|
async handleSubmit() {
|
|
if (!this.formData.warehouseId) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.selectWarehouse'),
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.currentWarehouseType == '1' && !this.formData.cargoSpaceId) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.selectCargoSpace'),
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
if (this.currentWarehouseType == '2' && !this.formData.exitId) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.selectExit'),
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
|
|
// try {
|
|
const response = await emptyTrayOut(this.formData)
|
|
|
|
if (response.code === 200) {
|
|
uni.showToast({
|
|
title: this.$t('outbound.emptyPalletBox.emptyPallet.outboundSuccess'),
|
|
icon: 'success'
|
|
})
|
|
// 重置表单数据
|
|
this.formData = {
|
|
warehouseId: '',
|
|
cargoSpaceId: '',
|
|
exitId: ''
|
|
}
|
|
this.cargoSpaceList = []
|
|
this.exitList = []
|
|
this.currentWarehouseType = ''
|
|
this.cargoSpaceHeight = ''
|
|
} else {
|
|
uni.showToast({
|
|
title: response.msg || this.$t('outbound.emptyPalletBox.emptyPallet.outboundOperationFailed'),
|
|
icon: 'none'
|
|
})
|
|
}
|
|
// }
|
|
// catch (error) {
|
|
// console.error('出库失败:',error)
|
|
// uni.showToast({
|
|
// title: '出库失败',
|
|
// icon: 'none'
|
|
// })
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.container {
|
|
padding: 30rpx;
|
|
background-color: #f5f5f5;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.form-card {
|
|
background-color: #fff;
|
|
border-radius: 16rpx;
|
|
padding: 40rpx 30rpx;
|
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
:deep(.uni-forms-item) {
|
|
padding-bottom: 30rpx;
|
|
|
|
.uni-forms-item__label {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
font-weight: 500;
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
.uni-easyinput__content {
|
|
background-color: #f8f8f8;
|
|
border-radius: 8rpx;
|
|
height: 80rpx;
|
|
padding: 0 24rpx;
|
|
}
|
|
}
|
|
|
|
.cargo-space-container {
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.cargo-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 20rpx;
|
|
padding: 20rpx;
|
|
background-color: #f8f8f8;
|
|
border-radius: 8rpx;
|
|
}
|
|
|
|
.cargo-item {
|
|
padding: 20rpx;
|
|
text-align: center;
|
|
background-color: #fff;
|
|
border-radius: 8rpx;
|
|
border: 2rpx solid #e5e5e5;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
|
|
&:hover {
|
|
background-color: #f0f7ff;
|
|
border-color: #3B7FFF;
|
|
}
|
|
}
|
|
|
|
.selected-item {
|
|
background-color: #3B7FFF;
|
|
color: #fff;
|
|
border-color: #3B7FFF;
|
|
|
|
&:hover {
|
|
background-color: #2c6be6;
|
|
}
|
|
}
|
|
|
|
.submit-button {
|
|
margin-top: 40rpx;
|
|
width: 100%;
|
|
background-color: #3B7FFF;
|
|
color: #fff;
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
font-size: 32rpx;
|
|
border-radius: 44rpx;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.button-hover {
|
|
background-color: #2c6be6;
|
|
transform: translateY(2rpx);
|
|
}
|
|
|
|
.cargo-input-group {
|
|
display: flex;
|
|
gap: 20rpx;
|
|
align-items: center;
|
|
}
|
|
|
|
.recommend-btn {
|
|
flex-shrink: 0;
|
|
padding: 0 30rpx;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
background-color: #3B7FFF;
|
|
color: #fff;
|
|
border-radius: 8rpx;
|
|
font-size: 28rpx;
|
|
}
|
|
</style>
|