Files
FT541-WMS/RuoYi-App-master/pages/pandian/confirm.vue
2026-01-08 10:29:44 +08:00

650 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="container">
<view class="input-group">
<text class="input-label">仓库</text>
<uni-data-select
v-model="warehouseId"
:localdata="warehouseList"
:clear="false"
placeholder="请选择仓库"
/>
</view>
<view class="input-group">
<view class="input-label">托盘条码:</view>
<uni-easyinput
v-model="trayCode"
placeholder="请输入或扫码输入托盘条码"
:clearable="true"
@input="handleInput"
@clear="handleClear"
ref="trayCodeInput"
>
</uni-easyinput>
</view>
<view class="materials-list">
<view v-for="(item, index) in materialList" :key="index" class="material-card">
<view class="material-header">
<text class="material-title">{{ item.productName }}</text>
<view class="material-code-section">
<view class="code-input-group">
<text class="code-label">物料编码:</text>
<uni-easyinput
v-model="item.productId"
placeholder="请输入物料编码"
class="code-input"
@input="handleMaterialCodeChange(index, $event)"
/>
</view>
<view class="code-input-group">
<text class="code-label">盘点数量:</text>
<uni-easyinput
v-model="item.countQuantity"
type="number"
placeholder="请输入盘点数量"
class="code-input"
@input="handleMaterialQtyChange(index, $event)"
/>
</view>
<text class="quantity-info">系统数量: {{ item.outQuantity }}件</text>
</view>
</view>
</view>
<button class="add-button" @click="showAddMaterialPopup">新增</button>
</view>
<view class="button-group" v-if="materialList.length > 0">
<button class="confirm-button" @click="handleConfirm">确认盘点</button>
</view>
<!-- 新增物料弹窗 -->
<uni-popup ref="addMaterialPopup" type="center">
<view class="popup-content">
<view class="popup-title">新增物料</view>
<view class="popup-form grid">
<view class="form-row">
<view class="form-col">
<text class="form-label">物料编码</text>
<uni-easyinput v-model="newMaterial.productId" placeholder="请输入物料编码" />
</view>
<view class="form-col">
<text class="form-label">数量</text>
<uni-easyinput v-model="newMaterial.inQuantity" type="number" placeholder="请输入数量" />
</view>
</view>
<view class="form-row">
<view class="form-col">
<text class="form-label">合同号</text>
<uni-easyinput v-model="newMaterial.spare6" placeholder="请输入合同号" />
</view>
<view class="form-col">
<text class="form-label">产品号</text>
<uni-easyinput v-model="newMaterial.spare7" placeholder="请输入产品号" />
</view>
</view>
<view class="form-row">
<view class="form-col">
<text class="form-label">代号</text>
<uni-easyinput v-model="newMaterial.spare9" placeholder="请输入代号" />
</view>
<view class="form-col">
<text class="form-label">台次</text>
<uni-easyinput v-model="newMaterial.spare5" placeholder="请输入台次" />
</view>
</view>
<view class="form-row">
<view class="form-col">
<text class="form-label">规格</text>
<uni-easyinput v-model="newMaterial.spec" placeholder="请输入规格" />
</view>
</view>
</view>
<view class="popup-buttons">
<button class="cancel-btn" @click="hideAddMaterialPopup">取消</button>
<button class="submit-btn" @click="handleAddMaterial">确定</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import { confirmPandian,getTaskDetail } from '@/api/pandian/confirm.js'
export default {
onReady() {
setTimeout(() => {
this.$nextTick(() => {
this.$refs.trayCodeInput.onFocus()
})
}, 100)
},
data() {
return {
selectedExit: '',
exitOptions: [
{ value: '1', text: '1' },
{ value: '1', text: '1' }
],
productStatus:[
{ value:'1',text:'优秀'},
{ value:'2',text:'良好'},
{ value:'3',text:'合格'},
{ value:'4',text:'不合格'}
],
origin_type:[
{ value:'1',text:'国产'},
{ value:'2',text:'进口'}
],
turnover_type:[
{ value:'1',text:'正常'},
{ value:'2',text:'积压'}
],
account_type:[
{ value:'1',text:'帐内'},
{ value:'2',text:'帐外'}
],
purpose_type:[
{ value:'1',text:'民用'},
{ value:'2',text:'军用'}
],
trayCode: '',
warehouseId:null,
materialList: [],
warehouseList: [
{ value: '01', text: '三联' },
{ value: '02', text: '二联' }
],
newMaterial: {
productId: '',
inQuantity: '',
spare5:'',//台次
spare6:'',//合同号
spare7:'',//件次
spare8:'',//质量等级
spare9:'',//管理号
spare1:'',//来源
spare2:'',//状态
spare3:'',//套账
spare4:'',//用途
supplierId:'',
printDate:''
}
}
},
methods: {
// 处理输入事件
handleInput(value) {
if (value) {
this.fetchTrayInfo(value)
}
},
// 处理清除事件
handleClear() {
this.materialList = []
},
// 处理物料编码变化
handleMaterialCodeChange(index, value) {
this.materialList[index].productId = value
},
// 处理盘点数量变化
handleMaterialQtyChange(index, value) {
const num = Number(value)
if (Number.isNaN(num) || num < 0) {
this.materialList[index].countQuantity = 0
uni.showToast({ title: '数量需为非负数字', icon: 'none' })
} else {
this.materialList[index].countQuantity = num
}
},
// 处理扫码事件
// handleScan() {
// uni.scanCode({
// success: (res) => {
// this.trayCode = res.result
// this.fetchTrayInfo(res.result)
// }
// })
// },
// 获取托盘信息
async fetchTrayInfo(trayCode) {
try {
const response = await getTaskDetail({trayCode:trayCode})
this.materialList = response.data.map(item => ({
...item,
countQuantity: item.outQuantity
}))
} catch (error) {
uni.showToast({
title: '获取托盘信息失败',
icon: 'none'
})
}
},
// 显示新增物料弹窗
showAddMaterialPopup() {
this.$refs.addMaterialPopup.open()
},
// 隐藏新增物料弹窗
hideAddMaterialPopup() {
this.$refs.addMaterialPopup.close()
this.newMaterial = {
productId: '',
inQuantity: '',
spare5:'',//台次
spare6:'',//合同号
spare7:'',//件次
spare8:'',//质量等级
spare9:'',//管理号
spare1:'',//来源
spare2:'',//状态
spare3:'',//套账
spare4:'',//用途
supplierId:'',
printDate:''
}
},
// 处理新增物料
handleAddMaterial() {
if (!this.newMaterial.productId || !this.newMaterial.inQuantity) {
uni.showToast({
title: '请填写完整信息',
icon: 'none'
})
return
}
this.materialList.push({
productId: this.newMaterial.productId,
countQuantity: Number(this.newMaterial.inQuantity),
outQuantity: 0,
stockId: null,
spare5:this.newMaterial.spare5,//台次
spare6:this.newMaterial.spare6,//合同号
spare7:this.newMaterial.spare7,//件次
spare8:this.newMaterial.spare8,//质量等级
spare9:this.newMaterial.spare9,//管理号
spare1:this.newMaterial.spare1,//来源
spare2:this.newMaterial.spare2,//状态
spare3:this.newMaterial.spare3,//套账
spare4:this.newMaterial.spare4,//用途
supplierId:this.newMaterial.supplierId,
printDate:this.newMaterial.printDate
})
this.hideAddMaterialPopup()
uni.showToast({
title: '新增成功',
icon: 'success'
})
},
// 确认盘点
async handleConfirm() {
// 验证仓库选择
if (!this.warehouseId) {
uni.showToast({
title: '请选择仓库',
icon: 'none'
})
return
}
try {
const data = {
trayCode: this.trayCode,
warehouseId: this.warehouseId,
// exitId: this.selectedExit,
materials: this.materialList.map(item => ({
stockId: item.stockId,
productId:item.productId,
jobDetailId:item.jobDetailId,
inQuantity: Number(item.countQuantity) || 0,
inOrOutDId:item.inOrOutDId,
spare5:item.spare5,//台次
spare6:item.spare6,//合同号
spare7:item.spare7,//件次
spare8:item.spare8,//质量等级
spare9:item.spare9,//管理号
spare1:item.spare1,//来源
spare2:item.spare2,//状态
spare3:item.spare3,//套账
spare4:item.spare4,//用途
supplierId:item.supplierId,
printDate:item.printDate
}))
}
const response=await confirmPandian(data)
if(response.code==200){
uni.showToast({
title: '盘点成功',
icon: 'success'
})
// 清空数据
this.trayCode = ''
this.materialList = []
this.selectedExit = ''
this.warehouseId=null
}
} catch (error) {
uni.showToast({
title: '盘点失败',
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;
}
.input-label {
font-size: 28rpx;
color: #333;
margin-bottom: 16rpx;
display: block;
font-weight: 500;
}
.select-input {
:deep(.uni-data-select) {
background-color: #f8f8f8;
border-radius: 8rpx;
height: 80rpx;
padding: 0 24rpx;
}
}
.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: 12rpx;
}
.material-code-section {
display: flex;
flex-direction: column;
gap: 8rpx;
}
.code-input-group {
display: flex;
align-items: center;
gap: 12rpx;
}
.code-label {
font-size: 28rpx;
color: #666;
min-width: 140rpx;
flex-shrink: 0;
}
.code-input {
flex: 1;
:deep(.uni-easyinput__content) {
background-color: #f8f9fa;
border-radius: 6rpx;
height: 60rpx;
padding: 0 16rpx;
border: 1rpx solid #e9ecef;
&:focus-within {
border-color: #3B7FFF;
background-color: #fff;
}
}
:deep(.uni-easyinput__content-input) {
font-size: 26rpx;
color: #333;
}
}
.quantity-info {
font-size: 26rpx;
color: #666;
margin-left: 152rpx;
}
.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-label {
font-size: 28rpx;
color: #333;
margin-bottom: 10rpx;
display: block;
}
/* 弹窗两列表单布局 */
.popup-form.grid {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.form-row {
display: flex;
gap: 20rpx;
}
.form-col {
flex: 1;
}
.form-col :deep(.uni-easyinput__content),
.form-col :deep(.uni-data-select) {
background-color: #f8f8f8;
border-radius: 8rpx;
height: 72rpx;
padding: 0 20rpx;
}
.form-col :deep(.uni-easyinput__content-input) {
font-size: 26rpx;
color: #333;
}
.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>