项目初始化
This commit is contained in:
409
RuoYi-App-master/pages/pandian/confirm.vue
Normal file
409
RuoYi-App-master/pages/pandian/confirm.vue
Normal file
@@ -0,0 +1,409 @@
|
||||
<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>
|
||||
105
RuoYi-App-master/pages/pandian/menu.vue
Normal file
105
RuoYi-App-master/pages/pandian/menu.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="function-list">
|
||||
<view class="function-item" @click="navigateTo('/pages/pandian/confirm')">
|
||||
<view class="icon-box blue">
|
||||
<image src="/static/images/tabbar/tray121.png" mode="aspectFit" class="icon-image" style="width: 40rpx; height: 40rpx;"></image>
|
||||
</view>
|
||||
<view class="function-text">
|
||||
<text class="title">{{ $t('stocktaking.confirm.title') }}</text>
|
||||
<text class="desc">{{ $t('stocktaking.confirm.desc') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="function-item" @click="navigateTo('/pages/pandian/pkconfirm')">
|
||||
<view class="icon-box blue">
|
||||
<image src="/static/images/tabbar/tray121.png" mode="aspectFit" class="icon-image" style="width: 40rpx; height: 40rpx;"></image>
|
||||
</view>
|
||||
<view class="function-text">
|
||||
<text class="title">{{ $t('stocktaking.confirmPK.title') }}</text>
|
||||
<text class="desc">{{ $t('stocktaking.confirmPK.desc') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tab from '@/plugins/tab'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
navigateTo(url) {
|
||||
tab.navigateTo(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
background-color: #f5f7fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.function-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.function-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
padding: 32rpx;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-4rpx);
|
||||
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-box {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 24rpx;
|
||||
|
||||
&.blue {
|
||||
background-color: rgba(59, 127, 255, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.function-text {
|
||||
flex: 1;
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
400
RuoYi-App-master/pages/pandian/pkconfirm.vue
Normal file
400
RuoYi-App-master/pages/pandian/pkconfirm.vue
Normal file
@@ -0,0 +1,400 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="warehouse-select">
|
||||
<uni-data-select
|
||||
v-model="selectedWarehouse"
|
||||
:localdata="warehouseList"
|
||||
:clear="false"
|
||||
:placeholder="$t('stocktaking.confirmPK.selectWarehouse')"
|
||||
@change="handleWarehouseChange"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="add-button-container" v-if="selectedWarehouse!=''">
|
||||
<button class="add-button" @click="showAddMaterialPopup">{{ $t('stocktaking.confirmPK.addMaterial') }}</button>
|
||||
</view>
|
||||
|
||||
<view class="inventory-list" v-if="inventoryList.length > 0">
|
||||
<view v-for="(item, index) in inventoryList" :key="index" class="inventory-card">
|
||||
<uni-card>
|
||||
<view class="card-content">
|
||||
<view class="info-row">
|
||||
<text class="label">{{ $t('stocktaking.confirmPK.materialCode') }}:</text>
|
||||
<text class="value">{{ item.extraField.productId }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">{{ $t('stocktaking.confirmPK.materialName') }}:</text>
|
||||
<text class="value">{{ item.extraField.materialDesc }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">{{ $t('stocktaking.confirmPK.inventoryQuantity') }}:</text>
|
||||
<text class="value">{{ item.quantity }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">{{ $t('stocktaking.confirmPK.countQuantity') }}:</text>
|
||||
<view class="value">
|
||||
<uni-easyinput
|
||||
v-model.number="item.newQuantity"
|
||||
type="number"
|
||||
:min="0"
|
||||
@input="handleQuantityInput($event, item)"
|
||||
style="width: 280rpx; display: inline-block;"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="button-row">
|
||||
<button class="confirm-button" @click="handleConfirm(item)">{{ $t('stocktaking.confirmPK.countButton') }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-card>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty-state" v-else>
|
||||
<text>{{ $t('stocktaking.confirmPK.noInventoryData') }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 新增物料弹窗 -->
|
||||
<uni-popup ref="addMaterialPopup" type="center">
|
||||
<view class="popup-content">
|
||||
<view class="popup-title">{{ $t('stocktaking.confirmPK.addMaterialTitle') }}</view>
|
||||
<view class="popup-form">
|
||||
<view class="form-item">
|
||||
<text class="form-label">{{ $t('stocktaking.confirmPK.materialCodeLabel') }}</text>
|
||||
<uni-easyinput v-model="newMaterial.productId" :placeholder="$t('stocktaking.confirm.materialCodePlaceholder')" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">{{ $t('stocktaking.confirmPK.quantityLabel') }}</text>
|
||||
<uni-easyinput v-model="newMaterial.newQuantity" type="number" :placeholder="$t('stocktaking.confirm.quantityPlaceholder')" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="popup-buttons">
|
||||
<button class="cancel-btn" @click="hideAddMaterialPopup">{{ $t('stocktaking.confirmPK.cancel') }}</button>
|
||||
<button class="submit-btn" @click="handleAddMaterial">{{ $t('stocktaking.confirmPK.confirm') }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getBasWarehouList } from '@/api/bas/bas.js'
|
||||
import { getInventoryList, confirmInventory } from '@/api/pandian/confirm.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
selectedWarehouse: '',
|
||||
warehouseList: [],
|
||||
inventoryList: [],
|
||||
// 新增物料表单数据
|
||||
newMaterial: {
|
||||
productId: '',
|
||||
newQuantity: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
onReady() {
|
||||
// 获取仓库列表
|
||||
this.getWarehouseList()
|
||||
},
|
||||
methods: {
|
||||
// 获取仓库列表
|
||||
async getWarehouseList() {
|
||||
try {
|
||||
const response = await getBasWarehouList({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
typeData:["3"]
|
||||
})
|
||||
if (response.code === 200) {
|
||||
this.warehouseList = response.rows.map(item => ({
|
||||
value: item.warehouseId,
|
||||
text: item.warehouseName
|
||||
}))
|
||||
|
||||
// 如果有仓库,默认选择第一个并加载库存数据
|
||||
if (this.warehouseList.length > 0) {
|
||||
this.selectedWarehouse = this.warehouseList[0].value
|
||||
this.getInventoryList()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取仓库列表失败:', error)
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.getWarehouseListFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取库存列表
|
||||
async getInventoryList() {
|
||||
try {
|
||||
const response = await getInventoryList({
|
||||
warehouseId: this.selectedWarehouse,
|
||||
pageNum: 1,
|
||||
pageSize: 100000000,
|
||||
productStatus:'1'
|
||||
})
|
||||
this.inventoryList = (response.rows || []).map(item => ({
|
||||
...item,
|
||||
newQuantity: item.quantity // 初始化盘点数量为库存数量
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('获取库存列表失败:', error)
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.getInventoryListFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 处理仓库选择变化
|
||||
handleWarehouseChange(warehouseId) {
|
||||
this.getInventoryList()
|
||||
},
|
||||
|
||||
// 处理盘点确认
|
||||
async handleConfirm(item) {
|
||||
if (!item.newQuantity || item.newQuantity < 0) {
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.enterValidCountQuantity'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if(item.newQuantity==item.quantity){
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.quantityMatch'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await confirmInventory({
|
||||
stockId: item.stockId,
|
||||
productId: item.extraField.productId,
|
||||
newQuantity: item.newQuantity,
|
||||
recordType: item.newQuantity === 0 ? 3 : 1
|
||||
})
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.countSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
// 刷新库存列表
|
||||
this.getInventoryList()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || this.$t('stocktaking.confirmPK.countFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('盘点失败:', error)
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.countFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 处理数量输入
|
||||
handleQuantityInput(value, item) {
|
||||
// 确保输入的是有效数字
|
||||
const numValue = Number(value)
|
||||
if (!isNaN(numValue)) {
|
||||
item.newQuantity = numValue
|
||||
}
|
||||
},
|
||||
|
||||
// 显示新增物料弹窗
|
||||
showAddMaterialPopup() {
|
||||
if(!this.selectedWarehouse)
|
||||
return uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.selectWarehouse'),
|
||||
icon: 'none'
|
||||
})
|
||||
this.$refs.addMaterialPopup.open()
|
||||
},
|
||||
|
||||
// 隐藏新增物料弹窗
|
||||
hideAddMaterialPopup() {
|
||||
this.$refs.addMaterialPopup.close()
|
||||
// 重置表单数据
|
||||
this.newMaterial = {
|
||||
productId: '',
|
||||
newQuantity: ''
|
||||
}
|
||||
},
|
||||
|
||||
// 处理新增物料
|
||||
async handleAddMaterial() {
|
||||
if (!this.newMaterial.productId || !this.newMaterial.newQuantity || this.newMaterial.newQuantity < 0) {
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.enterValidMaterialInfo'),
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// try {
|
||||
const response = await confirmInventory({
|
||||
productId: this.newMaterial.productId,
|
||||
newQuantity: Number(this.newMaterial.newQuantity),
|
||||
warehouseId: this.selectedWarehouse,
|
||||
recordType: 2
|
||||
})
|
||||
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
title: this.$t('stocktaking.confirmPK.addSuccess'),
|
||||
icon: 'success'
|
||||
})
|
||||
// 关闭弹窗并刷新列表
|
||||
this.hideAddMaterialPopup()
|
||||
this.getInventoryList()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || this.$t('stocktaking.confirmPK.addFailed'),
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// } catch (error) {
|
||||
// console.error('新增物料失败:', error)
|
||||
// uni.showToast({
|
||||
// title: '新增物料失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.warehouse-select {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.inventory-list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.inventory-card {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
margin-bottom: 10rpx;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: #666;
|
||||
width: 160rpx;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.confirm-button {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 10rpx 30rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.add-button-container {
|
||||
margin: 20rpx 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.add-button {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 10rpx 30rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
width: 600rpx;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.popup-form {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.cancel-btn,
|
||||
.submit-btn {
|
||||
width: 45%;
|
||||
padding: 16rpx 0;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background-color: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
background-color: #007AFF;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user