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

312 lines
7.2 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>
<!-- <view class="tabs">-->
<!-- <view v-for="(item, index) in tabs" :key="index" :class="{'active': item.value === active}" class="tab-item">-->
<!-- {{ item.name }}-->
<!-- </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-23 17:59:56 +08:00
<text class="repairUnit">{{ item.unitStr }}</text>
</text>
<text class="repairDesc">库存
<text class="repairUnit">{{ item.wares.stock }}</text>
2024-10-21 21:04:47 +08:00
</text>
<view class="repairBtns">
<u-icon name="minus-circle-fill" size="24" @click="delNum(item)"></u-icon>
2024-10-23 17:59:56 +08:00
<text class="repairNum">{{ item.waresCount }}</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>
</view>
</view>
</view>
<view class="footer">
2024-10-23 17:59:56 +08:00
<text class="label"></text>
<text class="repairNum"></text>
2024-10-23 23:18:50 +08:00
<view class="submit" v-if="type" @click="toPart">采购</view>
2024-10-23 17:59:56 +08:00
<view class="submit" @click="submit">{{type?'通知领料':'通知退料'}}</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';
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
twId:'',
//配件列表
wares:[],
//01零配件、02退配件
type:true,
//父组件传入的数据
formData:{},
2024-10-21 21:04:47 +08:00
repairList: [],
selectedRepairList: [
{name: '炫驰全合成机油S7 4L/ALL', num: 3, unit: '桶', id: 3}
],
active: ''
};
},
2024-10-23 17:59:56 +08:00
onLoad(data) {
if (data.formData){
this.formData = JSON.parse(decodeURIComponent(data.formData))
this.type = this.formData.isBack
this.twId = this.formData.id
}
this.init()
},
2024-10-23 23:18:50 +08:00
computed: {},
2024-10-21 21:04:47 +08:00
methods: {
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
}
request({
url: '/admin-api/repair/twi/list',
method: 'get',
params: params
}).then((res)=>{
const items = res.data;
items.map((item)=>{
const count = item.waresAlreadyCount ? parseInt(item.waresCount) - parseInt(item.waresAlreadyCount) : item.waresCount
item.waresCount = this.type ? count : item.waresAlreadyCount
item.isStock = this.type ? count <= item.wares.stock : true
getDictTextByCodeAndValue("repair_unit",item.wares.unit).then(value => {
item.unitStr = value
}).catch(error => {
item.unitStr = "未知"
});
})
this.wares = items;
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-10-23 17:59:56 +08:00
this.$set(repair, 'waresCount', repair.waresCount + 1)
const find = this.wares.find(f => f.id === repair.id)
2024-10-21 21:04:47 +08:00
if (find) {
2024-10-23 17:59:56 +08:00
find.waresCount = repair.waresCount
2024-10-21 21:04:47 +08:00
} else {
2024-10-23 17:59:56 +08:00
this.wares.push(JSON.parse(JSON.stringify(repair)))
2024-10-21 21:04:47 +08:00
}
console.log('repair', repair)
},
2024-10-23 17:59:56 +08:00
/**
*
*/
2024-10-21 21:04:47 +08:00
delNum(repair) {
2024-10-23 17:59:56 +08:00
if (repair.waresCount <= 0) {
2024-10-21 21:04:47 +08:00
return
}
2024-10-23 17:59:56 +08:00
this.$set(repair, 'waresCount', repair.waresCount - 1)
const findIndex = this.wares.findIndex(f => f.id === repair.id)
2024-10-21 21:04:47 +08:00
if (findIndex > -1 && repair.num <= 0) {
2024-10-23 17:59:56 +08:00
this.wares.splice(findIndex, 1)
2024-10-21 21:04:47 +08:00
} else if (repair.num > 0) {
2024-10-23 17:59:56 +08:00
this.$set(this.wares[findIndex], 'waresCount', repair.waresCount)
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 = {
soType:this.type?'02':'04',
soNo:createUniqueCodeByHead(this.type?'LL':'TL'),
userId:this.formData.repairId,
userName:this.formData.repairName,
soStatus:this.type?'04':'07'
}
this.formData.repairSois = [...this.wares.map(item =>{
return {
soiType: this.type ? '02' : "04",
goodsId: item.waresId,
goodsCount: item.waresCount,
}
})]
if (this.type){
this.formData.items = [...this.wares.map(item => {
return {
id: item.id,
}
})]
}
request({
url: '/admin-api/repair/tw/pass',
method: 'post',
data:this.formData
}).then((res)=>{
if (res.code === 200){
uni.showToast({
title: '通知成功!',
icon: 'none'
})
setTimeout(()=>{
uni.navigateBack()
},700)
}
})
2024-10-23 23:18:50 +08:00
},
/**
* 跳转采购页面
*/
toPart(){
const formData = this.formData;
formData.items = this.wares;
uni.navigateTo({
url: '/pages-warehouse/inOutWarehouse/part?formData='+encodeURIComponent(JSON.stringify(formData))
})
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;
&:last-child {
border-bottom: none;
}
.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 {
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;
}
}
</style>