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.
322 lines
7.5 KiB
322 lines
7.5 KiB
<template>
|
|
<!-- 添加维修工单 -->
|
|
<view class="add-form-container">
|
|
<u-form :model="form" ref="form1" label-width="160rpx">
|
|
<u-form-item :label="`备件`" prop="itemNumber" required>
|
|
<view class="select" @click="openSingleColumn('itemNumber',form.itemNumber,sparePartsList)">
|
|
<view class="input" v-if='form.itemNumber'>
|
|
{{selectFormat(form.itemNumber,sparePartsList)}}
|
|
</view>
|
|
<view class="placeholder" v-else>
|
|
请选择备件
|
|
</view>
|
|
<u-icon name="arrow-right" color="#aaaaaa" size="28"></u-icon>
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="库位" prop="locationNumber" required v-if="isShow">
|
|
<u-input v-model="form.locationNumber" placeholder="请选择库位" @blur="blur"/>
|
|
<view class="right-button" @click="chickRightButton">
|
|
扫描
|
|
</view>
|
|
</u-form-item>
|
|
<u-form-item label="数量" prop="qty" required>
|
|
<u-input v-model="form.qty" type="number" placeholder="请输入数量" />
|
|
</u-form-item>
|
|
<u-form-item label="维修结果" prop="reasons" required>
|
|
<u-radio-group v-model="form.result">
|
|
<u-radio :name="item.value" v-for="(item,index) in result" :key="index">{{item.label}}</u-radio>
|
|
</u-radio-group>
|
|
</u-form-item>
|
|
<u-form-item label="维修原因" prop="reasons" required>
|
|
<u-input v-model="form.reasons" placeholder="请输入维修原因" />
|
|
</u-form-item>
|
|
</u-form>
|
|
<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-select v-model="singleColumnShow" mode="single-column" :default-value='singleColumnDefaultValue'
|
|
:list="singleColumnList" @confirm="chooseSingleColumn"></u-select>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import * as sparePartsApi from "@/api/spareParts.js"
|
|
import * as sparePartsServiceWorkOrderListApi from "@/api/sparePartsServiceWorkOrderList.js"
|
|
import * as dictApi from "@/api/dict.js"
|
|
import * as locationApi from "@/api/location.js"
|
|
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
type: "",
|
|
form: {
|
|
itemNumber: "",
|
|
qty: '',
|
|
result: 'YES',
|
|
reasons: '',
|
|
locationNumber:'',
|
|
areaNumber:''
|
|
},
|
|
sparePartsList: [],
|
|
singleColumnShow: false,
|
|
singleColumnDefaultValue: [],
|
|
singleColumnList: [],
|
|
field: '',
|
|
result: [],
|
|
isShow:false
|
|
}
|
|
},
|
|
methods: {
|
|
// 触发提交表单
|
|
submit() {
|
|
// 校验
|
|
if (!this.form.itemNumber) {
|
|
this.$modal.showToast('请选择备件')
|
|
return;
|
|
}
|
|
if (this.isInAccount == 'TRUE') {
|
|
this.$modal.showToast('该库位属于帐内库,请选择帐外库')
|
|
return;
|
|
}
|
|
if (this.itemNumber) {
|
|
this.$modal.showToast('该库位已绑定过备件')
|
|
return;
|
|
}
|
|
if (!this.form.qty) {
|
|
this.$modal.showToast(`请输入数量`)
|
|
return;
|
|
}
|
|
if (!this.form.result) {
|
|
this.$modal.showToast('请选择维修结果')
|
|
return;
|
|
}
|
|
if (!this.form.reasons) {
|
|
this.$modal.showToast('请输入维修原因')
|
|
return;
|
|
}
|
|
this.$modal.confirm('是否添加备件维修工单').then(() => {
|
|
this.$modal.loading('加载中')
|
|
this.loading = true
|
|
sparePartsServiceWorkOrderListApi.sparePartsServiceWorkOrderListCreate(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 = {}
|
|
}
|
|
},
|
|
//
|
|
selectFormat(val, array) {
|
|
if (array.length > 0) {
|
|
let str = array.filter(item => item.value == val)[0].label
|
|
return str
|
|
} else {
|
|
return ''
|
|
}
|
|
},
|
|
// 单列模式
|
|
openSingleColumn(field, val, list) {
|
|
if (field == 'deviceNumber' && this.form.id) return;
|
|
this.singleColumnList = list
|
|
this.field = field
|
|
if (val) {
|
|
this.singleColumnDefaultValue = [list.findIndex(item => item.value == val)]
|
|
} else {
|
|
this.singleColumnDefaultValue = []
|
|
}
|
|
this.singleColumnShow = true
|
|
},
|
|
// 单列模式点击确定之后
|
|
chooseSingleColumn(e) {
|
|
console.log(this.field)
|
|
this.form[this.field] = e[0].value
|
|
if (this.field == 'itemNumber') {
|
|
this.choosesingleColumnItem = this.singleColumnList.filter(item => item.number == e[0].value)
|
|
this.form.locationNumber = this.choosesingleColumnItem[0].locationNumber
|
|
this.form.areaNumber = this.choosesingleColumnItem[0].areaNumber
|
|
if(!this.choosesingleColumnItem[0].locationNumber){
|
|
this.isShow = true
|
|
}
|
|
}
|
|
this.singleColumnShow = false
|
|
this.$emit('singleColumn', this.field, this.form[this.field])
|
|
this.$forceUpdate()
|
|
},
|
|
// 获取备件列表
|
|
async getServiceSparePartsList() {
|
|
await sparePartsApi.getServiceSparePartsList().then(res => {
|
|
res.data.map(item => {
|
|
item.value = item.number
|
|
item.label = item.name
|
|
})
|
|
this.sparePartsList = res.data
|
|
})
|
|
},
|
|
// 扫描设备条码
|
|
chickRightButton(field) {
|
|
uni.scanCode({
|
|
success: function(res) {
|
|
this.form.locationNumber = res.result
|
|
this.getLocation()
|
|
}
|
|
});
|
|
},
|
|
getLocation(){
|
|
locationApi.getLocation(this.form.locationNumber).then(res=>{
|
|
if(!res.data){
|
|
this.$modal.showToast('找不到该库位')
|
|
return;
|
|
}
|
|
this.form.areaNumber = res.data.areaNumber;
|
|
this.isInAccount = res.data.isInAccount
|
|
this.itemNumber = res.data.itemNumber
|
|
})
|
|
},
|
|
blur() {
|
|
if (this.form.locationNumber) {
|
|
this.getLocation()
|
|
}
|
|
},
|
|
},
|
|
async onLoad(option) {
|
|
if (option.type) this.type = option.type;
|
|
this.result = await dictApi.getDict('result')
|
|
await this.getServiceSparePartsList()
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.add-form-container {
|
|
min-height: calc(100vh - 140rpx);
|
|
background: white;
|
|
padding: 0px 30rpx 140rpx;
|
|
}
|
|
|
|
.list {
|
|
padding-bottom: 20rpx;
|
|
|
|
.item {
|
|
margin-top: 20rpx;
|
|
background: white;
|
|
padding: 30rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
image {
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
margin-right: 20rpx;
|
|
}
|
|
|
|
.title {
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.dec1 {
|
|
font-size: 28rpx;
|
|
margin-top: 16rpx;
|
|
color: #acacac;
|
|
}
|
|
|
|
.dec2 {
|
|
font-size: 28rpx;
|
|
margin-top: 6rpx;
|
|
color: #acacac;
|
|
}
|
|
}
|
|
}
|
|
|
|
.footer {
|
|
position: fixed;
|
|
bottom: 0px;
|
|
left: 0px;
|
|
width: 100%;
|
|
}
|
|
|
|
.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);
|
|
|
|
}
|
|
}
|
|
</style>
|