lanan-repair-app/pages-warehouse/inOutWarehouse/inOutWarehouse.vue

423 lines
11 KiB
Vue
Raw Normal View History

2024-10-21 21:04:47 +08:00
<template>
<view class="container">
2024-10-23 17:59:56 +08:00
<VNavigationBar background-color="#fff" title="单据处理" title-color="#333"></VNavigationBar>
2024-11-15 16:25:44 +08:00
<!-- <view class="tabs">-->
<!-- <view v-for="(item, index) in tabs" :key="index" :class="{'active': item.value === active}" class="tab-item">-->
<!-- {{ item.name }}-->
<!-- </view>-->
<!-- </view>-->
<view class="body-top">
<view class="body-top-search">
<input class="body-top-search-input" v-model="query" placeholder="配件名称"
placeholder-style="font-size: 28rpx"
type="text">
<text @click="handleSearch">搜索</text>
</view>
</view>
2024-10-21 21:04:47 +08:00
<view class="listBox">
<view class="list">
2024-10-23 17:59:56 +08:00
<view v-for="(item, index) in wares" :key="index" class="listItem">
<view class="repairName">{{ item.waresName }}</view>
2024-10-21 21:04:47 +08:00
<view class="repairBottom">
<text class="repairDesc">单位
2024-10-25 18:52:01 +08:00
<text class="repairUnit">{{ item.wares.unit }}</text>
2024-10-23 17:59:56 +08:00
</text>
2024-10-25 18:52:01 +08:00
<text class="repairDesc">申请数量
<text class="repairUnit">{{ item.waresCount }}</text>
2024-10-21 21:04:47 +08:00
</text>
<view class="repairBtns" v-if="isToBeReviewed">
2024-10-21 21:04:47 +08:00
<u-icon name="minus-circle-fill" size="24" @click="delNum(item)"></u-icon>
2024-10-25 18:52:01 +08:00
<text class="repairNum">{{ item.thisNum }}</text>
2024-10-21 21:04:47 +08:00
<u-icon color="#0174F6" name="plus-circle-fill" size="24" @click="addNum(item)"></u-icon>
</view>
</view>
2024-10-25 18:52:01 +08:00
<view class="repairBottom">
<text class="repairDesc">库存
<text class="repairUnit">{{ item.wares.stock }}</text>
</text>
<text class="repairDesc">已领取
<text class="repairUnit">{{ item.waresAlreadyCount }}</text>
</text>
<view class="repairBtns"></view>
</view>
2024-10-21 21:04:47 +08:00
</view>
</view>
</view>
<view class="footer" v-if="isToBeReviewed">
2024-10-23 17:59:56 +08:00
<text class="label"></text>
<text class="repairNum"></text>
2024-11-15 16:25:44 +08:00
<view class="submit" @click="toPart">采购</view>
<view class="submit" @click="submit">{{ isReceive ? '通知领料' : '通知退料' }}</view>
2024-10-21 21:04:47 +08:00
</view>
</view>
</template>
<script>
import VNavigationBar from "@/components/VNavigationBar.vue";
2024-10-23 17:59:56 +08:00
import request from '@/utils/request';
2024-10-25 18:52:01 +08:00
import {
2024-11-15 16:25:44 +08:00
getJSONData, setJSONData
2024-10-25 18:52:01 +08:00
} from '@/utils/auth'
2024-11-15 16:25:44 +08:00
import {getDictTextByCodeAndValue, createUniqueCodeByHead} from "@/utils/utils";
2024-10-21 21:04:47 +08:00
export default {
components: {VNavigationBar},
data() {
return {
2024-10-23 17:59:56 +08:00
//配件申请单id
2024-11-15 16:25:44 +08:00
twId: '',
2024-10-23 17:59:56 +08:00
//配件列表
2024-11-15 16:25:44 +08:00
wares: [],
2024-10-25 18:52:01 +08:00
//true 领料 false 退料
2024-11-15 16:25:44 +08:00
isReceive: true,
2024-10-23 17:59:56 +08:00
//父组件传入的数据
2024-11-15 16:25:44 +08:00
formData: {},
active: '',
isToBeReviewed: true,
query: null
2024-10-21 21:04:47 +08:00
};
},
2024-10-23 17:59:56 +08:00
onLoad(data) {
2024-11-15 16:25:44 +08:00
if (getJSONData("applyWaresForm")) {
2024-10-25 18:52:01 +08:00
this.formData = getJSONData("applyWaresForm")
this.isReceive = this.formData.isReceive
2024-10-23 17:59:56 +08:00
this.twId = this.formData.id
2024-10-25 18:52:01 +08:00
this.init()
2024-10-23 17:59:56 +08:00
}
if (data.isToBeReviewed) {
this.isToBeReviewed = JSON.parse(data.isToBeReviewed)
}
2024-10-23 17:59:56 +08:00
},
2024-10-23 23:18:50 +08:00
computed: {},
2024-10-21 21:04:47 +08:00
methods: {
handleSearch(){
this.init()
},
2024-10-23 17:59:56 +08:00
/**
* 初始化配件数据
*/
2024-10-21 21:04:47 +08:00
init() {
2024-10-23 17:59:56 +08:00
const params = {
twId: this.formData.id,
query: this.query
2024-10-23 17:59:56 +08:00
}
request({
url: '/admin-api/repair/twi/list',
method: 'get',
params: params
2024-11-15 16:25:44 +08:00
}).then((res) => {
this.wares = res.data
if (this.isToBeReviewed){
this.wares = this.wares.filter(item => item.waresStatus === '1')
this.wares = this.wares.filter(item => this.isReceive ? (item.waresCount > item.waresAlreadyCount) : (item.waresAlreadyCount > 0))
}
this.wares.forEach(item => {
if (!item.wares.stock){
item.wares.stock = 0
2024-10-25 18:52:01 +08:00
}
2024-11-15 16:25:44 +08:00
if (this.isReceive) {
2024-10-25 18:52:01 +08:00
//领料,最大可领取数量为申请数量-已领取数量,同时不能大于库存数量,默认数量就是最大可领取数量
item.maxNum = parseInt(item.waresCount) - parseInt(item.waresAlreadyCount)
2024-11-15 16:25:44 +08:00
if (item.maxNum > item.wares.stock) {
2024-10-25 18:52:01 +08:00
item.maxNum = item.wares.stock
}
item.thisNum = item.maxNum
2024-11-15 16:25:44 +08:00
} else {
2024-10-25 18:52:01 +08:00
//退料最大数量为已领取数量最小数量为0,默认数量为0
item.maxNum = item.waresAlreadyCount
item.thisNum = 0
}
2024-10-23 17:59:56 +08:00
})
2024-11-15 16:25:44 +08:00
// res.data.map((item)=>{
// if(!item.waresAlreadyCount){
// item.waresAlreadyCount = 0
// }
// if(!item.wares.stock){
// item.wares.stock=0
// }
// if(this.isReceive){
// //领料,最大可领取数量为申请数量-已领取数量,同时不能大于库存数量,默认数量就是最大可领取数量
// item.maxNum = parseInt(item.waresCount) - parseInt(item.waresAlreadyCount)
// if(item.maxNum >item.wares.stock){
// item.maxNum = item.wares.stock
// }
// item.thisNum = item.maxNum
// }else{
// //退料最大数量为已领取数量最小数量为0,默认数量为0
// item.maxNum = item.waresAlreadyCount
// item.thisNum = 0
// }
// })
// this.wares = res.data;
2024-10-21 21:04:47 +08:00
})
},
2024-10-23 17:59:56 +08:00
/**
*
*/
2024-10-21 21:04:47 +08:00
addNum(repair) {
2024-11-15 16:25:44 +08:00
if ((repair.thisNum + 1) > repair.maxNum) {
2024-10-25 18:52:01 +08:00
uni.showToast({
title: '超过库存数量或最大申请数量!',
icon: 'none'
})
return
}
this.$set(repair, 'thisNum', repair.thisNum + 1)
2024-11-15 16:25:44 +08:00
const findIndex = this.wares.findIndex(f => f.id === repair.id);
if (findIndex !== -1) {
this.$set(this.wares, findIndex, repair);
2024-10-21 21:04:47 +08:00
}
2024-11-15 16:25:44 +08:00
// const find = this.wares.find(f => f.id == repair.id)
// if (find) {
// find.thisNum = repair.thisNum
// } else {
// this.wares.push(JSON.parse(JSON.stringify(repair)))
// }
2024-10-21 21:04:47 +08:00
},
2024-10-23 17:59:56 +08:00
/**
*
*/
2024-10-21 21:04:47 +08:00
delNum(repair) {
2024-10-25 18:52:01 +08:00
if (repair.thisNum == 0) {
//已经等于0了没法再减了
2024-10-21 21:04:47 +08:00
return
}
2024-10-25 18:52:01 +08:00
this.$set(repair, 'thisNum', repair.thisNum - 1)
2024-11-15 16:25:44 +08:00
const findIndex = this.wares.findIndex(f => f.id === repair.id);
if (findIndex !== -1) {
this.$set(this.wares, findIndex, repair);
2024-10-21 21:04:47 +08:00
}
2024-11-15 16:25:44 +08:00
// const find = this.wares.find(f => f.id == repair.id)
// if (find) {
// find.thisNum = repair.thisNum
// } else {
// this.wares.push(JSON.parse(JSON.stringify(repair)))
// }
2024-10-21 21:04:47 +08:00
},
2024-10-23 17:59:56 +08:00
/**
* 出库
*/
2024-10-21 21:04:47 +08:00
submit() {
2024-10-23 17:59:56 +08:00
this.formData.repairSo = {
2024-11-15 16:25:44 +08:00
soType: this.isReceive ? '02' : '04',
soNo: createUniqueCodeByHead(this.isReceive ? 'LL' : 'TL'),
userId: this.formData.repairId,
userName: this.formData.repairName,
soStatus: this.isReceive ? '04' : '07'
2024-10-23 17:59:56 +08:00
}
2024-11-15 16:25:44 +08:00
// 过滤一下thisNum不等0才行
const flag = this.wares.filter(item => item.thisNum > 0)
if (!flag || flag.length === 0){
uni.showToast({
title: '请设置配件数量!',
icon: 'none'
})
return
}
this.wares = flag
this.formData.repairSois = [...this.wares.map(item => {
2024-10-23 17:59:56 +08:00
return {
2024-10-25 18:52:01 +08:00
soiType: this.isReceive ? '02' : "04",
2024-10-23 17:59:56 +08:00
goodsId: item.waresId,
2024-10-25 18:52:01 +08:00
goodsCount: item.thisNum,
2024-10-23 17:59:56 +08:00
}
})]
2024-11-15 16:25:44 +08:00
if (this.isReceive) {
2024-10-23 17:59:56 +08:00
this.formData.items = [...this.wares.map(item => {
return {
id: item.id,
}
})]
}
request({
url: '/admin-api/repair/tw/pass',
method: 'post',
2024-11-15 16:25:44 +08:00
data: this.formData
}).then((res) => {
if (res.code === 200) {
2024-10-23 17:59:56 +08:00
uni.showToast({
title: '通知成功!',
icon: 'none'
})
2024-11-15 16:25:44 +08:00
setTimeout(() => {
2024-10-23 17:59:56 +08:00
uni.navigateBack()
2024-11-15 16:25:44 +08:00
}, 700)
2024-10-23 17:59:56 +08:00
}
})
2024-10-23 23:18:50 +08:00
},
/**
* 跳转采购页面
*/
2024-11-15 16:25:44 +08:00
toPart() {
2024-10-23 23:18:50 +08:00
const formData = this.formData;
formData.items = this.wares;
2024-11-15 16:25:44 +08:00
setJSONData("applyWaresForm", formData)
2024-10-23 23:18:50 +08:00
uni.navigateTo({
2024-10-25 18:52:01 +08:00
url: '/pages-warehouse/inOutWarehouse/part'
2024-10-23 23:18:50 +08:00
})
2024-10-21 21:04:47 +08:00
}
2024-10-23 23:18:50 +08:00
2024-10-21 21:04:47 +08:00
}
}
</script>
<style lang="scss">
.container {
height: 100%;
background-color: #F3F5F7;
display: flex;
flex-direction: column;
}
.search {
padding: 0 40rpx;
background-color: #fff;
& > .searchBox {
height: 84rpx;
background: #F3F5F7;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin: 0 auto;
padding: 0 30rpx;
font-size: 28rpx;
color: #0174F6;
display: flex;
align-items: center;
}
.searchInput {
flex: 1;
width: 0;
color: #333;
}
}
.tabs {
background-color: #fff;
padding: 30rpx 40rpx;
margin: 0 auto;
display: flex;
align-items: center;
column-gap: 30rpx;
overflow: auto;
.tab-item {
flex-shrink: 0;
padding: 16rpx 30rpx;
font-size: 28rpx;
color: #113A68;
background: #F2F2F7;
border-radius: 30rpx 30rpx 30rpx 30rpx;
&.active {
background: #0174F6;
color: #fff;
}
}
}
.listBox {
padding: 30rpx 32rpx;
flex: 1;
height: 0;
.list {
background-color: #fff;
padding: 0 30rpx;
height: 100%;
overflow: auto;
}
.listItem {
padding: 30rpx 0;
border-bottom: 2rpx solid #DDDDDD;
2024-11-15 16:25:44 +08:00
2024-10-21 21:04:47 +08:00
&:last-child {
border-bottom: none;
}
2024-11-15 16:25:44 +08:00
2024-10-21 21:04:47 +08:00
.repairName {
font-size: 32rpx;
color: #333333;
margin-bottom: 20rpx;
}
.repairBottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.repairDesc {
font-size: 28rpx;
color: #858BA0;
}
.repairUnit {
color: #333333;
}
.repairBtns {
2024-10-25 18:52:01 +08:00
width: 65px;
2024-10-21 21:04:47 +08:00
display: flex;
align-items: center;
column-gap: 10rpx;
}
}
}
.footer {
padding: 14rpx 32rpx;
background-color: #fff;
display: flex;
align-items: center;
.repairNum {
flex: 1;
width: 0;
margin-right: 10rpx;
}
.submit {
width: 208rpx;
height: 72rpx;
background: #0174F6;
border-radius: 38rpx 38rpx 38rpx 38rpx;
text-align: center;
line-height: 72rpx;
font-size: 32rpx;
color: #FFFFFF;
2024-10-25 18:52:01 +08:00
margin-left: 20rpx;
2024-10-21 21:04:47 +08:00
}
}
.body-top {
//width: 686rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
margin: 30rpx 30rpx 0;
.body-top-search {
height: 84rpx;
background: #F3F5F7;
border-radius: 12rpx 12rpx 12rpx 12rpx;
margin: 0 auto;
padding: 0 30rpx;
font-size: 28rpx;
display: flex;
align-items: center;
column-gap: 10rpx;
.body-top-search-input {
flex: 1;
width: 0;
}
}
}
2024-10-21 21:04:47 +08:00
</style>