项目初始化
This commit is contained in:
459
RuoYi-App-master/pages/in/ktpin.vue
Normal file
459
RuoYi-App-master/pages/in/ktpin.vue
Normal file
@@ -0,0 +1,459 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="input-group">
|
||||
<text class="input-label">{{ $t('inbound.emptyPalletBox.emptyPallet.trayCode') }}</text>
|
||||
<uni-easyinput
|
||||
v-model="formData.trayCode"
|
||||
:placeholder="$t('inbound.emptyPalletBox.emptyPallet.trayCodePlaceholder')"
|
||||
:clearable="true"
|
||||
@clear="handleClear"
|
||||
@confirm="handleConfirm"
|
||||
ref="trayCodeInput"
|
||||
|
||||
>
|
||||
<template #right>
|
||||
<text class="scan-icon" @click="handleScan">📷</text>
|
||||
</template>
|
||||
</uni-easyinput>
|
||||
</view>
|
||||
<view class="input-group">
|
||||
<text class="input-label">{{ $t('inbound.emptyPalletBox.emptyPallet.warehouse') }}</text>
|
||||
<uni-data-select
|
||||
v-model="formData.warehouseId"
|
||||
:localdata="warehouseList"
|
||||
:clear="false"
|
||||
:placeholder="$t('inbound.emptyPalletBox.emptyPallet.warehousePlaceholder')"
|
||||
@change="handleWarehouseChange"
|
||||
/>
|
||||
</view>
|
||||
<view class="input-group" v-if="currentWarehouseType == '1'">
|
||||
<text class="input-label">{{ $t('inbound.emptyPalletBox.emptyPallet.cargoSpace') }}</text>
|
||||
<view class="cargo-input-group">
|
||||
<uni-easyinput
|
||||
v-model="formData.cargoSpaceName"
|
||||
:placeholder="$t('inbound.emptyPalletBox.emptyPallet.cargoSpacePlaceholder')"
|
||||
:clearable="true"
|
||||
@input="handleCargoSpaceInput"
|
||||
/>
|
||||
<button class="recommend-btn" @click="handleRecommendCargoSpace">{{ $t('inbound.emptyPalletBox.emptyPallet.recommendCargoSpace') }}</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="currentWarehouseType == '1' && cargoSpaceHeight" class="cargo-space-info">
|
||||
<text class="cargo-space-height">{{ $t('inbound.emptyPalletBox.emptyPallet.cargoSpaceHeight') }}{{ cargoSpaceHeight }}{{ $t('inbound.emptyPalletBox.emptyPallet.meter') }}</text>
|
||||
</view>
|
||||
<view class="button-group">
|
||||
<button class="submit-button" @click="handleSubmit">{{ $t('inbound.emptyPalletBox.emptyPallet.submit') }}</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { emptyTrayIn } from '@/api/in/ktpin.js'
|
||||
import { getBasWarehouList,getCargoSpaceList } from '@/api/bas/bas.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
trayCode: '',
|
||||
warehouseId: '',
|
||||
cargoSpaceId: '',
|
||||
cargoSpaceName:'',
|
||||
|
||||
},
|
||||
warehouseList: [],
|
||||
cargoSpaceId: '',
|
||||
cargoSpaceList: [],
|
||||
currentWarehouseType: null,
|
||||
cargoSpaceHeight:''
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
setTimeout(() => {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.trayCodeInput.onFocus()
|
||||
})
|
||||
}, 100)
|
||||
|
||||
// 获取仓库列表
|
||||
this.getWarehouseList()
|
||||
},
|
||||
methods: {
|
||||
// 获取仓库列表
|
||||
async getWarehouseList() {
|
||||
try {
|
||||
const response = await getBasWarehouList({
|
||||
pageNum:1,
|
||||
pageSize:100,
|
||||
typeData:['1','2']
|
||||
})
|
||||
if (response.code === 200) {
|
||||
this.warehouseList = response.rows.map(item => ({
|
||||
value: item.warehouseId,
|
||||
text: item.warehouseName,
|
||||
type: item.warehouseType
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取仓库列表失败:', error)
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.getWarehouseListFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleClear() {
|
||||
this.formData.trayCode = ''
|
||||
},
|
||||
handleConfirm() {
|
||||
// 处理确认事件
|
||||
},
|
||||
handleScan() {
|
||||
// 调用扫码功能
|
||||
uni.scanCode({
|
||||
success: (res) => {
|
||||
this.formData.trayCode = res.result
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleWarehouseChange(warehouseId) {
|
||||
if (!warehouseId) return
|
||||
const selectedWarehouse = this.warehouseList.find(item => item.value === warehouseId)
|
||||
this.currentWarehouseType = selectedWarehouse ? selectedWarehouse.type : null
|
||||
|
||||
},
|
||||
// 处理货位选择
|
||||
async handleRecommendCargoSpace() {
|
||||
// try {
|
||||
const response = await getCargoSpaceList({ warehouseId: this.formData.warehouseId, status: 1 })
|
||||
if (response.code === 200 && response.rows.length > 0) {
|
||||
// 获取第一个推荐货位
|
||||
this.formData.cargoSpaceId = response.rows[0].cargoSpaceId
|
||||
this.formData.cargoSpaceName = response.rows[0].cargoSpaceName
|
||||
// 手动触发handleCargoSpaceInput方法获取货位高度信息
|
||||
await this.handleCargoSpaceInput(response.rows[0].cargoSpaceName)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.noAvailableCargoSpace'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// } catch (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('inbound.emptyPalletBox.emptyPallet.getCargoSpaceInfoFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
this.formData.cargoSpaceId = ''
|
||||
this.cargoSpaceHeight = null
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.getCargoSpaceInfoFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
this.formData.cargoSpaceId = ''
|
||||
this.cargoSpaceHeight = null
|
||||
}
|
||||
} else {
|
||||
this.formData.cargoSpaceId = ''
|
||||
this.cargoSpaceHeight = null
|
||||
}
|
||||
},
|
||||
async handleSubmit() {
|
||||
if (!this.formData.trayCode) {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.enterTrayCode'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!this.formData.warehouseId) {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.selectWarehouse'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.currentWarehouseType === '1' && (!this.formData.cargoSpaceId || this.formData.cargoSpaceId === null)) {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.selectCargoSpace'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await emptyTrayIn(this.formData).then(response => {
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.inboundSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
// 清空表单
|
||||
this.formData = {
|
||||
trayCode: '',
|
||||
warehouseId: '',
|
||||
cargoSpaceId: '',
|
||||
cargoSpaceName: ''
|
||||
}
|
||||
this.cargoSpaceHeight=''
|
||||
this.currentWarehouseType=null
|
||||
// 重新聚焦到托盘条码输入框
|
||||
setTimeout(() => {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.trayCodeInput.onFocus()
|
||||
})
|
||||
}, 100)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || this.$t('inbound.emptyPalletBox.emptyPallet.inboundOperationFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('入库失败:', error)
|
||||
uni.showToast({
|
||||
title: this.$t('inbound.emptyPalletBox.emptyPallet.inboundFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.container {
|
||||
padding: 30rpx;
|
||||
background-color: #f8f9fc;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 30rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.input-label {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
width: 160rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
:deep(.uni-easyinput__content) {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
border: 2rpx solid #e8e8e8;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #2979ff;
|
||||
box-shadow: 0 4rpx 16rpx rgba(41, 121, 255, 0.1);
|
||||
transform: translateY(-2rpx);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.uni-easyinput__content-input) {
|
||||
height: 88rpx;
|
||||
padding: 0 30rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.scan-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
font-size: 40rpx;
|
||||
color: #2979ff;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
}
|
||||
|
||||
.button-group {
|
||||
padding: 30rpx;
|
||||
margin-top: 20rpx;
|
||||
|
||||
.submit-button {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
background-color: #2979ff;
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(41, 121, 255, 0.2);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 2rpx 8rpx rgba(41, 121, 255, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cargo-info {
|
||||
padding: 0 30rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.cargo-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.cargo-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.cargo-value {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
margin: 20rpx 30rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.selected-row {
|
||||
background-color: #e6f0ff !important;
|
||||
}
|
||||
|
||||
:deep(.uni-table-tr) {
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
}
|
||||
|
||||
.cargo-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.cargo-item {
|
||||
background-color: #fff;
|
||||
padding: 30rpx 20rpx;
|
||||
text-align: center;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.selected-item {
|
||||
background-color: #e6f0ff;
|
||||
border: 2rpx solid #2979ff;
|
||||
transform: translateY(-2rpx);
|
||||
box-shadow: 0 4rpx 16rpx rgba(41, 121, 255, 0.1);
|
||||
}
|
||||
|
||||
.cargo-input-group {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
|
||||
:deep(.uni-easyinput__content) {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.recommend-btn {
|
||||
padding: 0 30rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
background-color: #2979ff;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(41, 121, 255, 0.2);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
width: 600rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 20rpx;
|
||||
margin-top: 30rpx;
|
||||
|
||||
button {
|
||||
padding: 0 40rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background-color: #2979ff;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user