410 lines
9.0 KiB
Vue
410 lines
9.0 KiB
Vue
<template>
|
|
<view class="container">
|
|
<view class="input-group">
|
|
<uni-easyinput
|
|
v-model="trayCode"
|
|
:placeholder="$t('stocktaking.confirm.trayCodePlaceholder')"
|
|
:clearable="true"
|
|
@input="handleInput"
|
|
@clear="handleClear"
|
|
ref="trayCodeInput"
|
|
>
|
|
<template #right>
|
|
<text class="scan-icon" @click="handleScan">📷</text>
|
|
</template>
|
|
</uni-easyinput>
|
|
</view>
|
|
|
|
<view class="materials-list" v-if="materialList.length > 0">
|
|
<button class="add-button" @click="showAddMaterialPopup">{{ $t('stocktaking.confirm.addMaterial') }}</button>
|
|
<view v-for="(item, index) in materialList" :key="index" class="material-card">
|
|
<view class="material-header">
|
|
<text class="material-title">{{ item.extraField.materialDesc || item.productId }}</text>
|
|
<text class="material-code">{{ item.productId }} | {{ $t('stocktaking.confirm.systemQuantity') }}: {{ item.outQuantity }}{{ $t('stocktaking.confirm.unit') }}</text>
|
|
</view>
|
|
<view class="material-content">
|
|
<view class="quantity-control">
|
|
<button class="control-btn" @click="item.countQuantity = Math.max(0, Number(item.countQuantity) - 1)">-</button>
|
|
<text class="quantity-value">{{ item.countQuantity }}</text>
|
|
<button class="control-btn" @click="item.countQuantity = Number(item.countQuantity) + 1">+</button>
|
|
<text class="quantity-diff" :class="{ 'plus': item.countQuantity > item.outQuantity, 'minus': item.countQuantity < item.outQuantity,'equal':item.countQuantity==item.outQuantity }">{{ item.countQuantity > item.outQuantity ? $t('stocktaking.confirm.surplus') + (item.countQuantity - item.outQuantity) : item.countQuantity < item.outQuantity ? $t('stocktaking.confirm.loss') + (item.outQuantity - item.countQuantity) : $t('stocktaking.confirm.match') }}</text>
|
|
<button class="clear-btn" @click="item.countQuantity = 0">{{ $t('stocktaking.confirm.clearQuantity') }}</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="button-group" v-if="materialList.length > 0">
|
|
<button class="confirm-button" @click="handleConfirm">{{ $t('stocktaking.confirm.confirmStocktaking') }}</button>
|
|
</view>
|
|
|
|
<!-- 新增物料弹窗 -->
|
|
<uni-popup ref="addMaterialPopup" type="center">
|
|
<view class="popup-content">
|
|
<view class="popup-title">{{ $t('stocktaking.confirm.addMaterialTitle') }}</view>
|
|
<view class="popup-form">
|
|
<view class="form-item">
|
|
<text class="form-label">{{ $t('stocktaking.confirm.materialCodeLabel') }}</text>
|
|
<uni-easyinput v-model="newMaterial.productId" :placeholder="$t('stocktaking.confirm.materialCodePlaceholder')" />
|
|
</view>
|
|
<view class="form-item">
|
|
<text class="form-label">{{ $t('stocktaking.confirm.quantityLabel') }}</text>
|
|
<uni-easyinput v-model="newMaterial.inQuantity" type="number" :placeholder="$t('stocktaking.confirm.quantityPlaceholder')" />
|
|
</view>
|
|
</view>
|
|
<view class="popup-buttons">
|
|
<button class="cancel-btn" @click="hideAddMaterialPopup">{{ $t('stocktaking.confirm.cancel') }}</button>
|
|
<button class="submit-btn" @click="handleAddMaterial">{{ $t('stocktaking.confirm.confirm') }}</button>
|
|
</view>
|
|
</view>
|
|
</uni-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getTrayMaterials, confirmPandian } from '@/api/pandian/confirm.js'
|
|
|
|
export default {
|
|
onReady() {
|
|
setTimeout(() => {
|
|
this.$nextTick(() => {
|
|
this.$refs.trayCodeInput.onFocus()
|
|
})
|
|
}, 100)
|
|
},
|
|
data() {
|
|
return {
|
|
trayCode: '',
|
|
materialList: [],
|
|
newMaterial: {
|
|
productId: '',
|
|
inQuantity: ''
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
// 处理输入事件
|
|
handleInput(value) {
|
|
if (value) {
|
|
this.fetchTrayInfo(value)
|
|
}
|
|
},
|
|
// 处理清除事件
|
|
handleClear() {
|
|
this.materialList = []
|
|
},
|
|
// 处理扫码事件
|
|
handleScan() {
|
|
uni.scanCode({
|
|
success: (res) => {
|
|
this.trayCode = res.result
|
|
this.fetchTrayInfo(res.result)
|
|
}
|
|
})
|
|
},
|
|
// 获取托盘信息
|
|
async fetchTrayInfo(trayCode) {
|
|
try {
|
|
const response = await getTrayMaterials({trayCode:trayCode,inOut:'4'})
|
|
this.materialList = response.data.map(item => ({
|
|
...item,
|
|
countQuantity: item.outQuantity
|
|
}))
|
|
} catch (error) {
|
|
uni.showToast({
|
|
title: this.$t('stocktaking.confirm.getTrayInfoFailed'),
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
// 显示新增物料弹窗
|
|
showAddMaterialPopup() {
|
|
this.$refs.addMaterialPopup.open()
|
|
},
|
|
// 隐藏新增物料弹窗
|
|
hideAddMaterialPopup() {
|
|
this.$refs.addMaterialPopup.close()
|
|
this.newMaterial = {
|
|
productId: '',
|
|
inQuantity: ''
|
|
}
|
|
},
|
|
// 处理新增物料
|
|
handleAddMaterial() {
|
|
if (!this.newMaterial.productId || !this.newMaterial.inQuantity) {
|
|
uni.showToast({
|
|
title: this.$t('stocktaking.confirm.fillCompleteInfo'),
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
this.materialList.push({
|
|
productId: this.newMaterial.productId,
|
|
countQuantity: Number(this.newMaterial.inQuantity),
|
|
outQuantity: 0,
|
|
stockId: null,
|
|
extraField: {
|
|
materialDesc: ''
|
|
}
|
|
})
|
|
|
|
this.hideAddMaterialPopup()
|
|
uni.showToast({
|
|
title: this.$t('stocktaking.confirm.addSuccess'),
|
|
icon: 'success'
|
|
})
|
|
},
|
|
// 确认盘点
|
|
async handleConfirm() {
|
|
try {
|
|
const data = {
|
|
trayCode: this.trayCode,
|
|
materials: this.materialList.map(item => ({
|
|
stockId: item.stockId,
|
|
productId:item.productId,
|
|
jobDetailId:item.jobDetailId,
|
|
inQuantity: item.countQuantity,
|
|
inOrOutDId:item.inOrOutDId
|
|
}))
|
|
}
|
|
const response=await confirmPandian(data)
|
|
if(response.code==200){
|
|
uni.showToast({
|
|
title: this.$t('stocktaking.confirm.stocktakingSuccess'),
|
|
icon: 'success'
|
|
})
|
|
// 清空数据
|
|
this.trayCode = ''
|
|
this.materialList = []
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
uni.showToast({
|
|
title: this.$t('stocktaking.confirm.stocktakingFailed'),
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.container {
|
|
padding: 30rpx;
|
|
background-color: #f5f5f5;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.input-group {
|
|
background-color: #fff;
|
|
border-radius: 16rpx;
|
|
padding: 20rpx;
|
|
margin-bottom: 30rpx;
|
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
|
|
|
:deep(.uni-easyinput__content) {
|
|
background-color: #f8f8f8;
|
|
border-radius: 8rpx;
|
|
height: 80rpx;
|
|
padding: 0 24rpx;
|
|
}
|
|
}
|
|
|
|
.scan-icon {
|
|
font-size: 40rpx;
|
|
padding: 0 20rpx;
|
|
}
|
|
|
|
.materials-list {
|
|
padding: 0 20rpx;
|
|
}
|
|
|
|
.add-button {
|
|
width: 100%;
|
|
background-color: #4CAF50;
|
|
color: #fff;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
font-size: 28rpx;
|
|
border-radius: 40rpx;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.material-card {
|
|
background-color: #fff;
|
|
border-radius: 16rpx;
|
|
padding: 20rpx;
|
|
margin-bottom: 20rpx;
|
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
|
|
}
|
|
|
|
.material-header {
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.material-title {
|
|
font-size: 32rpx;
|
|
color: #333;
|
|
font-weight: 500;
|
|
display: block;
|
|
margin-bottom: 8rpx;
|
|
}
|
|
|
|
.material-code {
|
|
font-size: 28rpx;
|
|
color: #666;
|
|
display: block;
|
|
}
|
|
|
|
.material-content {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.quantity-control {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20rpx;
|
|
position: relative;
|
|
}
|
|
|
|
.control-btn {
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
line-height: 60rpx;
|
|
text-align: center;
|
|
background-color: #f5f5f5;
|
|
border-radius: 30rpx;
|
|
color: #333;
|
|
font-size: 36rpx;
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
.quantity-value {
|
|
font-size: 36rpx;
|
|
color: #333;
|
|
min-width: 80rpx;
|
|
text-align: center;
|
|
}
|
|
|
|
.quantity-diff {
|
|
font-size: 28rpx;
|
|
padding: 4rpx 16rpx;
|
|
border-radius: 8rpx;
|
|
background-color: #f0f0f0;
|
|
color: #666;
|
|
margin-right: 20rpx;
|
|
|
|
&.plus {
|
|
background-color: #e8f5e9;
|
|
color: #4caf50;
|
|
}
|
|
|
|
&.minus {
|
|
background-color: #ffebee;
|
|
color: #f44336;
|
|
}
|
|
|
|
&.equal {
|
|
background-color: #c3f4fa;
|
|
color: #109ef0;
|
|
}
|
|
}
|
|
|
|
.clear-btn {
|
|
width: 120rpx;
|
|
height: 48rpx;
|
|
line-height: 48rpx;
|
|
text-align: center;
|
|
background-color: #f44336;
|
|
border-radius: 24rpx;
|
|
color: #fff;
|
|
font-size: 24rpx;
|
|
padding: 0;
|
|
margin: 0;
|
|
position: absolute;
|
|
right: -140rpx;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
}
|
|
|
|
.button-group {
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
padding: 30rpx;
|
|
background-color: #fff;
|
|
box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
.confirm-button {
|
|
width: 100%;
|
|
background-color: #3B7FFF;
|
|
color: #fff;
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
font-size: 32rpx;
|
|
border-radius: 44rpx;
|
|
}
|
|
|
|
.popup-content {
|
|
background-color: #fff;
|
|
border-radius: 16rpx;
|
|
width: 600rpx;
|
|
padding: 30rpx;
|
|
}
|
|
|
|
.popup-title {
|
|
font-size: 32rpx;
|
|
color: #333;
|
|
font-weight: 500;
|
|
text-align: center;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.popup-form {
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.form-item {
|
|
margin-bottom: 20rpx;
|
|
}
|
|
|
|
.form-label {
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
margin-bottom: 10rpx;
|
|
display: block;
|
|
}
|
|
|
|
.popup-buttons {
|
|
display: flex;
|
|
gap: 20rpx;
|
|
}
|
|
|
|
.cancel-btn,
|
|
.submit-btn {
|
|
flex: 1;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
font-size: 28rpx;
|
|
border-radius: 40rpx;
|
|
}
|
|
|
|
.cancel-btn {
|
|
background-color: #f5f5f5;
|
|
color: #666;
|
|
}
|
|
|
|
.submit-btn {
|
|
background-color: #3B7FFF;
|
|
color: #fff;
|
|
}
|
|
</style>
|