<template>
|
<view class="overflow">
|
<cu-custom bgColor="bg-white" :isBack="true">
|
<block slot="backText">
|
</block>
|
<block slot="content">工量具归还</block>
|
</cu-custom>
|
<view class="flex justify-end align-center padding_right30rpx padding_top12rpx">
|
<text class="fontSize12rpx"> 操作人:{{operator}} </text>
|
</view>
|
<modal-code ref="resmodal" :rescode='rescode' :resmessage='resmessage' />
|
<view class="">
|
<u-form labelPosition="top" :model="warehouse" ref="warehouseRef">
|
<u-row class="border_bottom margin_top10rpx padding10" style="background-color: #fff;">
|
<u-col span="12">
|
<u-form-item label="借用人:" prop="name" required
|
style="font-size: 16px;font-weight: bold;padding: 0;">
|
<u-input v-model="warehouse.name" @click="showPerson = true" type="select" placeholder="选择借用人"
|
style="font-weight: bolder;margin-left: 15rpx;"
|
class="width padding_left25rpx">
|
</u-input>
|
</u-form-item>
|
</u-col>
|
</u-row>
|
</u-form>
|
<view class="ware_content">
|
<view v-for="(item, eindex) in singlist" :key="item.code" style="margin-top: 10rpx;">
|
<u-swipe-action :show="item.show" :index="eindex" @click="longpress" @open="open" :options="options" style="width: 100vw;">
|
<view class="ware_item" :class="item.showItem ? 'bg_item' : ''" style="width: 100vw;">
|
<u-row>
|
<u-col span="1">
|
<view class="circle">
|
{{eindex+1}}
|
</view>
|
</u-col>
|
<u-col span="10">
|
<view class="color_f18202">
|
{{item.code}} ({{item.name}})
|
</view>
|
</u-col>
|
</u-row>
|
<u-row>
|
<u-col span="6">
|
<view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
|
借用数:{{item.borrowQuantity}}
|
</view>
|
</u-col>
|
<u-col span="6">
|
<view class="" style="padding: 10rpx 0 10rpx 45rpx;color: #808080;">
|
已归还数:{{item.returnQuantity}}
|
</view>
|
</u-col>
|
</u-row>
|
|
<u-row>
|
<u-col span="6" class="flex">
|
<view class="" style="color: #808080;">
|
本次归还数:
|
</view>
|
<input
|
class="border_bottom_f18202 text-left color_f18202 fontSize32rpx"
|
style="background-color: #f2f2f2;height: 70rpx;width: 115rpx;" v-model="item.returnNum"
|
type="number" @focus="item.returnNum = ''" @blur="changeNum(item)"
|
/>
|
</u-col>
|
<u-col span="6" class="flex">
|
<view class="" style="color: #808080;padding: 10rpx 0 10rpx 45rpx;">
|
归还人:
|
</view>
|
<u-input
|
class="border_bottom_f18202 text-left color_f18202 fontSize32rpx"
|
type="select"
|
placeholder="请选择"
|
style="background-color: #f2f2f2;height: 70rpx;width: 115rpx;" v-model="item.createdUserName"
|
@click="selectPerson(eindex)"/>
|
</u-col>
|
</u-row>
|
</view>
|
</u-swipe-action>
|
</view>
|
</view>
|
<u-select v-model="show" :list="borrowPersonList" value-name="name" label-name="name" @confirm="confirm"></u-select>
|
<u-select v-model="showPerson" :list="borrowPersonList" value-name="name" label-name="name" @confirm="confirmPerson"></u-select>
|
<!-- <button-modal :empTytowerShow='true' cleaningTitle="重置" garmenTitle='提交' @submit='submit' @reset='rest' /> -->
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import ButtonModal from '../../components/buttonModal.vue'
|
import ModalCode from '../../components/ModalCode.vue'
|
import {getUnReturnList,getWarePersonList,wareReturn} from '../../api/wareTool/index.js'
|
import {getDate} from '../../utils/dateTime.js'
|
export default {
|
data() {
|
return {
|
renameFocus: true,
|
rescode: 0,
|
resmessage: "",
|
singlist: [], //物料详情
|
options: [
|
{
|
text: '归还',
|
style: {
|
backgroundColor: '#fc9f35'
|
}
|
}
|
],
|
showPerson: false, //选择借用人
|
warehouse: {
|
name: ''
|
},
|
warehouseRules: {
|
name: [{
|
required: true,
|
message: '借用人不能为空',
|
trigger: 'blur'
|
}],
|
},
|
activeIndex: 100,
|
show: false,
|
borrowPersonList: [],
|
operator: '',
|
};
|
},
|
components: {
|
ButtonModal,
|
ModalCode
|
},
|
onLoad(){
|
//获取借用人列表
|
this.getPersonList();
|
},
|
onReady() {
|
this.$refs.warehouseRef.setRules(this.warehouseRules)
|
},
|
mounted() {
|
this.operator = JSON.parse(uni.getStorageSync('userInfo')).name
|
},
|
methods: {
|
//获取借用人/归还列表
|
getPersonList() {
|
getWarePersonList().then(res => {
|
if(res.data.rows.length == 0){
|
return;
|
}
|
this.borrowPersonList = res.data.rows;
|
})
|
},
|
//借用人选择
|
confirmPerson(con) {
|
this.warehouse.name = con[0].value;
|
this.getOutWarehouse();
|
},
|
//归还数
|
changeNum(item) {
|
let num1 = Number(Number(item.borrowQuantity) - Number(item.returnQuantity)).toFixed(3) //必须保留3位小数 -否则会造成剩余物料是小数的时候,无法收货
|
if(Number(item.returnNum) > Number(num1)) {
|
this.rescode = 400
|
this.resmessage = `本次归还数不能大于借用数减去已归还数`
|
this.$refs.resmodal.show = true
|
item.returnNum = '';
|
}
|
},
|
// 借用人选择
|
selectPerson(index) {
|
this.activeIndex = index;
|
this.show = true;
|
},
|
//借用人确定
|
confirm(con) {
|
this.singlist[this.activeIndex].createdUserName = con[0].value;
|
},
|
//获取当前借用人名下借用工量具列表
|
getOutWarehouse() {
|
this.$refs.warehouseRef.validate(valid => {
|
if (valid) {
|
getUnReturnList(this.warehouse).then(res => {
|
if(res.data.rows.length == 0) {
|
this.rescode = 400
|
this.resmessage = `当前借用人没有需要归还工量具`
|
this.$refs.resmodal.show = true
|
return;
|
}
|
|
const index = res.data.rows.reduce((curr,item) => {
|
if(item.borrowQuantity == item.returnQuantity) {
|
curr++
|
}
|
return curr;
|
},0)
|
if(index == res.data.rows.length) {
|
this.rescode = 400
|
this.resmessage = `当前借用人没有需要归还工量具`
|
this.$refs.resmodal.show = true
|
return;
|
}
|
|
res.data.rows.map(item => {
|
item.returnNum = '';
|
item.createdUserName = '';
|
item.show = false;
|
item.showItem = false;
|
})
|
|
this.singlist = res.data.rows.filter(item => item.borrowQuantity != item.returnQuantity)
|
})
|
}
|
})
|
},
|
//打开当前,关闭其他
|
open(index) {
|
this.singlist[index].show = true;
|
this.singlist.map((val, idx) => {
|
if (index != idx) this.singlist[idx].show = false;
|
})
|
},
|
// 点击事件
|
longpress(index,eindex){
|
const matInfo = this.singlist[eindex];
|
if(matInfo.returnNum == '' || matInfo.returnNum <= 0 || matInfo.createdUserName == '') {
|
this.rescode = 400
|
this.resmessage = `归还数量或者归还人数据异常`
|
this.$refs.resmodal.show = true
|
return;
|
}
|
|
const arr = [{
|
orderId: matInfo.id,
|
quantity: matInfo.returnNum,
|
returnId: this.borrowPersonList.find(person => person.name == matInfo.createdUserName).nickName,
|
returnName: matInfo.createdUserName,
|
remark: "string"
|
}]
|
|
wareReturn(arr).then(res => {
|
this.rescode = 200
|
this.resmessage = `归还成功`
|
this.$refs.resmodal.show = true
|
this.getOutWarehouse();
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.ware_content {
|
width: 100vw;
|
height: auto;
|
margin: 15rpx 0 10rpx 0;
|
.ware_item {
|
background: #fff;
|
margin: 10rpx auto;
|
padding: 8rpx;
|
font-size: 16px;
|
box-sizing: border-box;
|
.circle {
|
width: 40rpx;
|
height: 40rpx;
|
border-radius: 50%;
|
background: #f18202;
|
color: #fff;
|
font-size: 30rpx;
|
line-height:40rpx;
|
text-align: center;
|
}
|
.u-col {
|
font-size: 40rpx;
|
}
|
}
|
}
|
.bg_item {
|
background: #FFEBCD !important;
|
}
|
|
</style>
|