You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
505 lines
12 KiB
505 lines
12 KiB
<template>
|
|
<!-- 添加维修工单 -->
|
|
<view class="add-form-container">
|
|
<u-form :model="form" ref="form1" label-width="160rpx">
|
|
<u-form-item label="批次号" prop="number" required>
|
|
<u-input v-model="form.number" placeholder="请输入批次号" />
|
|
</u-form-item>
|
|
<u-form-item label="供应商" prop="supplierName" required>
|
|
<u-input v-model="form.supplierName" placeholder="请输入供应商" />
|
|
</u-form-item>
|
|
</u-form>
|
|
<view class="list">
|
|
<view class="title">
|
|
<span>*</span>订单信息
|
|
</view>
|
|
<view class="item " v-for="(item,index) in orderList" :key="index">
|
|
<view class="item-box">
|
|
<view class="spare-title">
|
|
<view class="title-txt">
|
|
备件名称:{{item.itemName}}
|
|
</view>
|
|
</view>
|
|
<u-row gutter="16">
|
|
<!-- <u-col :span="24">
|
|
<view class="dec">
|
|
库位:{{item.locationNumber}}
|
|
</view>
|
|
</u-col> -->
|
|
|
|
<u-col :span="24">
|
|
<view class="dec">
|
|
已入库数量:{{item.deliveryQty}}
|
|
</view>
|
|
</u-col>
|
|
<u-col :span="24">
|
|
<view class="dec">
|
|
采购数量:{{item.qty}}
|
|
</view>
|
|
</u-col>
|
|
</u-row>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="list">
|
|
<view class="title">
|
|
<span>*</span>申请备件
|
|
</view>
|
|
<view class="item " v-for="(item,index) in form.itemNumbers" :key="index">
|
|
<view class="item-box">
|
|
<view class="spare-title">
|
|
<view class="title-txt">
|
|
备件名称:{{item.itemName}}
|
|
</view>
|
|
</view>
|
|
<u-row gutter="16">
|
|
<u-col :span="24">
|
|
<view class="dec">
|
|
入库数量:{{item.qty}}
|
|
</view>
|
|
</u-col>
|
|
<u-col :span="24">
|
|
<view class="dec">
|
|
采购数量:{{item.applyQty}}
|
|
</view>
|
|
</u-col>
|
|
</u-row>
|
|
</view>
|
|
<u-icon name="minus-circle" color="#aaaaaa" size="60" @click="delSpareParts(index)"></u-icon>
|
|
</view>
|
|
<view class="add-btn">
|
|
<u-button type="primary" @click="open"><u-icon name="plus-circle" color="#ffffff"
|
|
size="36"></u-icon>添加备件</u-button>
|
|
</view>
|
|
</view>
|
|
<view class="footer">
|
|
<view class="btns">
|
|
<button class="reset" @click="reset">重置</button>
|
|
<button class="sure" @click="submit" :loading='loading' :disabled='loading'>确定</button>
|
|
</view>
|
|
<view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view>
|
|
</view>
|
|
<!-- 添加备件 -->
|
|
<u-popup v-model="isPopupShow" mode="center" border-radius="14">
|
|
<view class="popup-title">添加备件</view>
|
|
<view class="popup">
|
|
<u-form :model="form1" ref="form1" label-width="160rpx">
|
|
<u-form-item :label="`备件编号`" prop="itemNumber" required>
|
|
<view class="select">
|
|
<u-input v-model="form1.itemNumber" placeholder="请选择备件" disabled />
|
|
<view class="right-button" @click="chickRightButton1">
|
|
扫描
|
|
</view>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item :label="`备件名称`" prop="itemNumber" required class="disabled">
|
|
<view class="select">
|
|
<u-input v-model="form1.itemName" placeholder="请选择备件" disabled />
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="库位" prop="locationNumber" required v-if="isShow">
|
|
<u-input v-model="form1.locationNumber" placeholder="请选择库位" disabled/>
|
|
<view class="right-button" @click="chickRightButton">
|
|
扫描
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="采购数量" prop="applyQty" required class="disabled">
|
|
<u-input v-model="form1.applyQty" type="number" disabled placeholder="请输入采购数量" />
|
|
</u-form-item>
|
|
<u-form-item label="已入库数量" prop="deliveryQty" required class="disabled">
|
|
<u-input v-model="form1.deliveryQty" type="number" disabled placeholder="请输入已入库数量" />
|
|
</u-form-item>
|
|
<u-form-item label="入库数量" prop="qty" required>
|
|
<u-input v-model="form1.qty" type="number" placeholder="请输入入库数量" />
|
|
</u-form-item>
|
|
<u-form-item label="描述" prop="qty" required>
|
|
<u-input v-model="form1.describes" placeholder="请输入描述" />
|
|
</u-form-item>
|
|
</u-form>
|
|
</view>
|
|
<view class="popup-footer">
|
|
<view @click="isPopupShow = false">取消</view>
|
|
<view class="sure" @click="addSpare">确认</view>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import * as inLocationApi from "@/api/inLocation.js"
|
|
import * as sparePartsApi from "@/api/spareParts.js"
|
|
import * as locationApi from "@/api/location.js"
|
|
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
orderList: [], //订单信息
|
|
// 备件弹窗
|
|
isPopupShow: false,
|
|
field: '',
|
|
form: {
|
|
id: '',
|
|
number: '',
|
|
itemNumbers: []
|
|
},
|
|
form1: {
|
|
itemNumber: "",
|
|
itemName: '',
|
|
locationNumber: '',
|
|
applyQty: '',
|
|
deliveryQty: '',
|
|
qty: ''
|
|
},
|
|
isShow: false,
|
|
isInAccount: 'FALSE'
|
|
}
|
|
},
|
|
methods: {
|
|
// 触发提交表单
|
|
submit() {
|
|
// 校验
|
|
// if (!this.form.name) {
|
|
// this.$modal.showToast('请输入主题')
|
|
// return;
|
|
// }
|
|
if (this.form.itemNumbers.length === 0) {
|
|
this.$modal.showToast('请选择备件')
|
|
return;
|
|
}
|
|
this.$modal.confirm('是否添加入库信息').then(() => {
|
|
this.$modal.loading('加载中')
|
|
this.loading = true
|
|
inLocationApi.inLocationCreat(this.form).then((res) => {
|
|
this.$modal.closeLoading()
|
|
if (res.data) {
|
|
this.$modal.showToast('添加成功')
|
|
setTimeout(() => {
|
|
this.$tab.navigateBack()
|
|
this.loading = false
|
|
}, 1500)
|
|
} else {
|
|
this.$modal.showToast('添加失败')
|
|
this.loading = false
|
|
}
|
|
}).catch(() => {
|
|
this.$modal.closeLoading()
|
|
this.loading = false
|
|
})
|
|
})
|
|
|
|
},
|
|
// 重置
|
|
reset() {
|
|
if (this.form.id) {
|
|
this.form.classes = '';
|
|
this.form.faultType = ''
|
|
} else {
|
|
|
|
this.form = {}
|
|
}
|
|
},
|
|
|
|
// 获取订单信息详情
|
|
async getInLocationDetail() {
|
|
await inLocationApi.getInLocationDetail(this.form.id).then(res => {
|
|
this.orderList = res.data
|
|
})
|
|
},
|
|
// 打开弹窗
|
|
open() {
|
|
this.form1 = {
|
|
itemNumber: "",
|
|
itemName: '',
|
|
locationNumber: '',
|
|
applyQty: '',
|
|
deliveryQty: '',
|
|
qty: ''
|
|
}
|
|
this.isPopupShow = true
|
|
this.isShow= false
|
|
},
|
|
// 添加备件
|
|
addSpare() {
|
|
// 校验
|
|
if (!this.form1.itemNumber) {
|
|
this.$modal.showToast('请选择备件')
|
|
return;
|
|
}
|
|
if (!this.form1.itemName) {
|
|
this.$modal.showToast('找不到该备件')
|
|
return;
|
|
}
|
|
if (!this.form1.locationNumber) {
|
|
this.$modal.showToast('请选择库位')
|
|
return;
|
|
}
|
|
if (this.isInAccount == 'FALSE') {
|
|
this.$modal.showToast('该库位属于帐外库,请选择帐内库')
|
|
return;
|
|
}
|
|
if (this.itemNumber) {
|
|
this.$modal.showToast('该库位已绑定过备件')
|
|
return;
|
|
}
|
|
if (!this.form1.qty) {
|
|
this.$modal.showToast(`请输入数量`)
|
|
return;
|
|
}
|
|
console.log(this.form1)
|
|
if (Number(this.form1.qty) + Number(this.form1.deliveryQty) > Number(this.form1.applyQty)) {
|
|
this.$modal.showToast('已入库数量和入库数量不可大于采购数量')
|
|
return;
|
|
}
|
|
if (this.form.itemNumbers && this.form.itemNumbers.length > 0) {
|
|
let arr = this.form.itemNumbers.filter(item => item.itemNumber == this.form1.itemNumber)
|
|
if (arr && arr.length > 0) {
|
|
this.$modal.showToast('该备件已添加')
|
|
return;
|
|
}
|
|
let arr1 = orderList.filter(item => item.itemNumber == this.form1.itemNumber)
|
|
if (!arr1|| (arr1&&arr1.length == 0)) {
|
|
this.$modal.showToast('订单信息没有该备件')
|
|
return;
|
|
}
|
|
}
|
|
|
|
this.form.itemNumbers.push(this.form1)
|
|
this.isPopupShow = false
|
|
},
|
|
// 删除备件
|
|
delSpareParts(index) {
|
|
this.form.itemNumbers.splice(index, 1)
|
|
},
|
|
getLocation() {
|
|
locationApi.getLocation(this.form1.locationNumber).then(res => {
|
|
if(!res.data){
|
|
this.$modal.showToast('找不到该库位')
|
|
return;
|
|
}
|
|
this.form1.areaNumber = res.data.areaNumber;
|
|
this.isInAccount = res.data.isInAccount || ''
|
|
this.itemNumber = res.data.itemNumber || ''
|
|
})
|
|
},
|
|
blur() {
|
|
if (this.form1.locationNumber) {
|
|
this.getLocation()
|
|
}
|
|
},
|
|
// 获取备件信息
|
|
getSparePartsInfo() {
|
|
sparePartsApi.getSparePartsInfo({
|
|
number: this.form1.itemNumber,
|
|
id: this.form.id
|
|
}).then(res => {
|
|
if(!res.data){
|
|
this.$modal.showToast('找不到该备件')
|
|
this.itemNumber = ''
|
|
this.form1.areaNumber = ''
|
|
this.form1.locationNumber = '';
|
|
this.isInAccount = ''
|
|
this.form1.itemName = ''
|
|
return;
|
|
}
|
|
this.itemNumber = ''
|
|
this.form1.areaNumber = res.data.areaNumber || ''
|
|
this.form1.locationNumber = res.data.locationNumber;
|
|
this.isInAccount = res.data.isInAccount|| ''
|
|
this.form1.itemName = res.data.itemName
|
|
this.form1.deliveryQty = res.data.deliveryQty
|
|
this.form1.applyQty = res.data.applyQty
|
|
if (!this.form1.locationNumber) {
|
|
this.isShow = true
|
|
}
|
|
})
|
|
},
|
|
blur1() {
|
|
if (this.form1.itemNumber) {
|
|
this.getSparePartsInfo()
|
|
}
|
|
},
|
|
|
|
},
|
|
async onLoad(option) {
|
|
// if (option.id) this.form.id = option.id;
|
|
// if (option.number) this.form.number = option.number;
|
|
if (option.data && JSON.parse(decodeURIComponent(option.data)) && JSON.parse(decodeURIComponent(option
|
|
.data)).id) {
|
|
let form = JSON.parse(decodeURIComponent(option.data))
|
|
this.form.supplierName =form.supplierName
|
|
this.form.number =form.number
|
|
this.form.id =form.id
|
|
}
|
|
await this.getInLocationDetail()
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.add-form-container {
|
|
min-height: calc(100vh - 140rpx);
|
|
background: white;
|
|
padding: 0px 0rpx 140rpx;
|
|
}
|
|
|
|
.u-form-item {
|
|
padding: 20rpx 30rpx;
|
|
}
|
|
|
|
.disabled {
|
|
background: #f5f5f5;
|
|
}
|
|
|
|
.footer {
|
|
position: fixed;
|
|
bottom: 0px;
|
|
left: 0px;
|
|
width: 100%;
|
|
z-index: 22;
|
|
}
|
|
|
|
.btns {
|
|
display: flex;
|
|
|
|
|
|
button {
|
|
flex: 1;
|
|
}
|
|
|
|
.sure {
|
|
background: #409eff;
|
|
color: white;
|
|
border-radius: 0px;
|
|
|
|
&::after {
|
|
border: 1px solid #409eff;
|
|
border-radius: 0px;
|
|
}
|
|
}
|
|
|
|
.reset {
|
|
background: #F5F5F5;
|
|
border-radius: 0px;
|
|
|
|
&::after {
|
|
border-radius: 0px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.right-button {
|
|
background: #409eff;
|
|
color: white;
|
|
padding: 0rpx 30rpx;
|
|
border-radius: 16rpx;
|
|
text-align: center;
|
|
font-size: 28rpx;
|
|
}
|
|
|
|
.select {
|
|
display: flex;
|
|
align-items: center;
|
|
height: 72rpx;
|
|
width: 100%;
|
|
|
|
.input {
|
|
flex: 1;
|
|
font-size: 28rpx;
|
|
color: #000000;
|
|
}
|
|
|
|
.placeholder {
|
|
flex: 1;
|
|
font-size: 28rpx;
|
|
color: rgb(192, 196, 204);
|
|
|
|
}
|
|
}
|
|
|
|
.title {
|
|
padding: 32rpx 0rpx;
|
|
position: relative;
|
|
|
|
span {
|
|
position: absolute;
|
|
left: -16rpx;
|
|
color: #fa3534;
|
|
top: 19px;
|
|
}
|
|
}
|
|
|
|
.list {
|
|
padding: 0rpx 30rpx;
|
|
|
|
.item {
|
|
display: flex;
|
|
margin-bottom: 20rpx;
|
|
|
|
.item-box {
|
|
background: #F5F5F5;
|
|
border-radius: 12rpx;
|
|
flex: 1;
|
|
width: 0rpx;
|
|
}
|
|
|
|
.spare-title {
|
|
padding: 20rpx 30rpx;
|
|
border-bottom: 1px solid #e4e4e4;
|
|
|
|
.title-txt {
|
|
color: #409eff;
|
|
font-size: 30rpx;
|
|
font-weight: bold;
|
|
}
|
|
}
|
|
|
|
.dec {
|
|
color: #9c9c9c;
|
|
padding: 20rpx 30rpx 20rpx;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
.add-btn {
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
}
|
|
|
|
.popup-title {
|
|
text-align: center;
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
color: #409eff;
|
|
padding: 30rpx 30rpx 0px
|
|
}
|
|
|
|
.popup {
|
|
width: 600rpx;
|
|
padding: 30rpx 0rpx 30rpx;
|
|
|
|
}
|
|
|
|
.popup-footer {
|
|
display: flex;
|
|
border-top: 1px solid #e4e4e4;
|
|
|
|
view {
|
|
line-height: 100rpx;
|
|
flex: 1;
|
|
text-align: center;
|
|
|
|
&.sure {
|
|
color: #409eff;
|
|
}
|
|
}
|
|
}
|
|
|
|
::v-deep .u-checkbox-group {
|
|
display: grid !important;
|
|
}
|
|
</style>
|