|
|
@ -7,9 +7,7 @@ |
|
|
|
</u-form-item> |
|
|
|
</u-form> --> |
|
|
|
<view class="list"> |
|
|
|
<view class="title"> |
|
|
|
<span>*</span>申请备件 |
|
|
|
</view> |
|
|
|
<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"> |
|
|
@ -19,40 +17,31 @@ |
|
|
|
</view> |
|
|
|
<u-row gutter="16"> |
|
|
|
<u-col :span="24"> |
|
|
|
<view class="dec"> |
|
|
|
库位:{{item.locationNumber}} |
|
|
|
</view> |
|
|
|
<view class="dec"> 库位:{{ item.locationNumber }} </view> |
|
|
|
</u-col> |
|
|
|
<u-col :span="24"> |
|
|
|
<view class="dec"> |
|
|
|
数量:{{item.qty}} |
|
|
|
</view> |
|
|
|
<view class="dec"> 数量:{{ item.qty }} </view> |
|
|
|
</u-col> |
|
|
|
<u-col :span="24"> |
|
|
|
<view class="dec"> |
|
|
|
维修结果:{{item.result == 'YES'?'完成':'未完成'}} |
|
|
|
</view> |
|
|
|
<view class="dec"> 维修结果:{{ item.result == 'YES' ? '完成' : '未完成' }} </view> |
|
|
|
</u-col> |
|
|
|
<u-col :span="24"> |
|
|
|
<view class="dec"> |
|
|
|
维修原因:{{item.reasons}} |
|
|
|
</view> |
|
|
|
<view class="dec"> 维修原因:{{ item.reasons }} </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> |
|
|
|
<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> |
|
|
|
<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 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"> |
|
|
@ -61,28 +50,23 @@ |
|
|
|
<u-form :model="form1" ref="formRef" label-width="200rpx"> |
|
|
|
<u-form-item :label="`备件`" prop="itemNumber" required> |
|
|
|
<view class="select" @click="openSingleColumn('itemNumber', form1.itemNumber, sparePartsList)"> |
|
|
|
<view class="input" v-if='form1.itemNumber'> |
|
|
|
<view class="input" v-if="form1.itemNumber"> |
|
|
|
{{ form1.name }} |
|
|
|
</view> |
|
|
|
<view class="placeholder" v-else> |
|
|
|
请选择备件 |
|
|
|
</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="form1.locationNumber" placeholder="请输入库位" @blur="blur()" @confirm='blur()'/> |
|
|
|
<view class="right-button" @click="chickRightButton"> |
|
|
|
扫描 |
|
|
|
</view> |
|
|
|
<u-input v-model="form1.locationNumber" placeholder="请输入库位" @blur="blur()" @confirm="blur()" /> |
|
|
|
<view class="right-button" @click="chickRightButton"> 扫描 </view> |
|
|
|
</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="reasons" required> |
|
|
|
<u-radio-group v-model="form1.result"> |
|
|
|
<u-radio :name="item.value" v-for="(item,index) in result" |
|
|
|
:key="index">{{item.label}}</u-radio> |
|
|
|
<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> |
|
|
@ -95,26 +79,21 @@ |
|
|
|
<view class="sure" @click="addSpare">确认</view> |
|
|
|
</view> |
|
|
|
</u-popup> |
|
|
|
<u-select v-model="singleColumnShow" mode="single-column" :default-value='singleColumnDefaultValue' |
|
|
|
:list="singleColumnList" @confirm="chooseSingleColumn" @cancle='singleColumnShow = false'></u-select> |
|
|
|
<SelectItemList :isShowSelectItem='isShowSelectItem' :singleColumnList='singleColumnList' @searchItem='searchItem' @chooseItem1='chooseItem1'/> |
|
|
|
<u-select v-model="singleColumnShow" mode="single-column" :default-value="singleColumnDefaultValue" :list="singleColumnList" @confirm="chooseSingleColumn" @cancle="singleColumnShow = false"></u-select> |
|
|
|
<SelectItemList :isShowSelectItem="isShowSelectItem" :singleColumnList="singleColumnList" @searchItem="searchItem" @chooseItem1="chooseItem1" /> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { |
|
|
|
onLoad, |
|
|
|
} from '@dcloudio/uni-app' |
|
|
|
import { |
|
|
|
ref, |
|
|
|
getCurrentInstance |
|
|
|
} from 'vue' |
|
|
|
import * as sparePartsApi from "@/api/spareParts" |
|
|
|
import * as sparePartsServiceWorkOrderListApi from "@/api/sparePartsServiceWorkOrderList" |
|
|
|
import * as dictApi from "@/api/dict" |
|
|
|
import * as locationApi from "@/api/location" |
|
|
|
import SelectItemList from "../../components/item/slectItemList.vue" |
|
|
|
import {noPage} from "@/api/spareParts"; |
|
|
|
import { onLoad } from '@dcloudio/uni-app' |
|
|
|
import { ref, getCurrentInstance } from 'vue' |
|
|
|
import * as sparePartsApi from '@/api/spareParts' |
|
|
|
import * as sparePartsServiceWorkOrderListApi from '@/api/sparePartsServiceWorkOrderList' |
|
|
|
import * as dictApi from '@/api/dict' |
|
|
|
import * as locationApi from '@/api/location' |
|
|
|
import SelectItemList from '../../components/item/slectItemList.vue' |
|
|
|
import { noPage } from '@/api/spareParts' |
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() |
|
|
|
const loading = ref(false) |
|
|
|
const type = ref('') |
|
|
@ -131,7 +110,7 @@ |
|
|
|
itemNumbers: [] |
|
|
|
}) |
|
|
|
const form1 = ref({ |
|
|
|
itemNumber: "", |
|
|
|
itemNumber: '', |
|
|
|
qty: '', |
|
|
|
result: 'YES', |
|
|
|
reasons: '', |
|
|
@ -151,13 +130,14 @@ |
|
|
|
// 校验 |
|
|
|
if (form.value.itemNumbers == 0) { |
|
|
|
proxy.$modal.showToast('请选择备件') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
proxy.$modal.confirm('是否添加备件维修工单').then(() => { |
|
|
|
proxy.$modal.loading('加载中') |
|
|
|
loading.value = true |
|
|
|
sparePartsServiceWorkOrderListApi.sparePartsServiceWorkOrderListCreate(form.value).then(( |
|
|
|
res) => { |
|
|
|
sparePartsServiceWorkOrderListApi |
|
|
|
.sparePartsServiceWorkOrderListCreate(form.value) |
|
|
|
.then((res) => { |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
if (res.data) { |
|
|
|
proxy.$modal.showToast('添加成功') |
|
|
@ -173,7 +153,8 @@ |
|
|
|
} |
|
|
|
loading.value = false |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
proxy.$modal.closeLoading() |
|
|
|
loading.value = false |
|
|
|
}) |
|
|
@ -187,15 +168,11 @@ |
|
|
|
} |
|
|
|
// 单列模式 |
|
|
|
function openSingleColumn(fieldName, val, list) { |
|
|
|
if (fieldName == 'deviceNumber' && form.value.id) return; |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中....", |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
if (fieldName == 'deviceNumber' && form.value.id) return |
|
|
|
singleColumnList.value = list |
|
|
|
field.value = fieldName |
|
|
|
if (val) { |
|
|
|
singleColumnDefaultValue.value = [list.findIndex(item => item.value == val)] |
|
|
|
singleColumnDefaultValue.value = [list.findIndex((item) => item.value == val)] |
|
|
|
} else { |
|
|
|
singleColumnDefaultValue.value = [] |
|
|
|
} |
|
|
@ -205,7 +182,7 @@ |
|
|
|
function chooseSingleColumn(e) { |
|
|
|
form1.value[field.value] = e[0].value |
|
|
|
if (field.value == 'itemNumber') { |
|
|
|
choosesingleColumnItem.value = singleColumnList.value.filter(item => item.number == e[0].value) |
|
|
|
choosesingleColumnItem.value = singleColumnList.value.filter((item) => item.number == e[0].value) |
|
|
|
form1.value.name = e[0].label |
|
|
|
form1.value.locationNumber = choosesingleColumnItem.value[0].locationNumber |
|
|
|
form1.value.areaNumber = choosesingleColumnItem.value[0].areaNumber |
|
|
@ -221,31 +198,37 @@ |
|
|
|
// 获取备件列表 |
|
|
|
async function getServiceSparePartsList() { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中....", |
|
|
|
title: '加载中....', |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
await sparePartsApi.noPage({}).then(res => { |
|
|
|
res.data.map(item => { |
|
|
|
}) |
|
|
|
await sparePartsApi |
|
|
|
.noPage({}) |
|
|
|
.then((res) => { |
|
|
|
res.data.map((item) => { |
|
|
|
item.value = item.number |
|
|
|
item.label = item.name |
|
|
|
}) |
|
|
|
sparePartsList.value = res.data |
|
|
|
}).catch(() => { }).finally(()=>{ |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
|
|
|
|
.catch(() => {}) |
|
|
|
.finally(() => { |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
} |
|
|
|
// 扫描设备条码 |
|
|
|
function chickRightButton(field) { |
|
|
|
uni.scanCode({ |
|
|
|
success: function (res) { |
|
|
|
success(res) { |
|
|
|
form1.value.locationNumber = res.result |
|
|
|
getLocation() |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
function getLocation() { |
|
|
|
locationApi.getLocation(form1.value.locationNumber).then(res => { |
|
|
|
locationApi |
|
|
|
.getLocation(form1.value.locationNumber) |
|
|
|
.then((res) => { |
|
|
|
if (!res.data) { |
|
|
|
msg.value = res.msg ? res.msg : '找不到该库位' |
|
|
|
proxy.$modal.showToast(msg.value) |
|
|
@ -253,13 +236,14 @@ |
|
|
|
form1.value.areaNumber = '' |
|
|
|
isInAccount.value = '' |
|
|
|
itemNumber.value = '' |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
msg.value = '' |
|
|
|
form1.value.areaNumber = res.data.areaNumber; |
|
|
|
form1.value.areaNumber = res.data.areaNumber |
|
|
|
isInAccount.value = res.data.isInAccount |
|
|
|
itemNumber.value = res.data.itemNumber |
|
|
|
}).catch(() => { }) |
|
|
|
}) |
|
|
|
.catch(() => {}) |
|
|
|
} |
|
|
|
function blur() { |
|
|
|
if (form1.value.locationNumber) { |
|
|
@ -269,7 +253,7 @@ |
|
|
|
// 打开弹窗 |
|
|
|
function open() { |
|
|
|
form1.value = { |
|
|
|
itemNumber: "", |
|
|
|
itemNumber: '', |
|
|
|
qty: '', |
|
|
|
result: 'YES', |
|
|
|
reasons: '', |
|
|
@ -283,48 +267,48 @@ |
|
|
|
// 校验 |
|
|
|
if (!form1.value.itemNumber) { |
|
|
|
proxy.$modal.showToast('请选择备件') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form1.value.locationNumber) { |
|
|
|
proxy.$modal.showToast('请扫描库位') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (msg.value) { |
|
|
|
proxy.$modal.showToast(msg.value) |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (isInAccount.value == 'TRUE') { |
|
|
|
proxy.$modal.showToast('该库位属于帐内库,请选择帐外库') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form1.value.itemNumber && form1.value.itemNumber != itemNumber.value) { |
|
|
|
proxy.$modal.showToast('该库位与填写备件不一致') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form1.value.qty) { |
|
|
|
proxy.$modal.showToast(`请输入数量`) |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('请输入数量') |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form1.value.result) { |
|
|
|
proxy.$modal.showToast('请选择维修结果') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (!form1.value.reasons) { |
|
|
|
proxy.$modal.showToast('请输入维修原因') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
if (form.value.itemNumbers && form.value.itemNumbers.length > 0) { |
|
|
|
let arr = form.value.itemNumbers.filter(item => item.itemNumber == form1.value.itemNumber) |
|
|
|
const arr = form.value.itemNumbers.filter((item) => item.itemNumber == form1.value.itemNumber) |
|
|
|
if (arr && arr.length > 0) { |
|
|
|
proxy.$modal.showToast('该备件已添加') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if (form.value.itemNumbers && form.value.itemNumbers.length > 0) { |
|
|
|
let arr1 = form.value.itemNumbers.filter(item => item.locationNumber == form1.value.locationNumber) |
|
|
|
const arr1 = form.value.itemNumbers.filter((item) => item.locationNumber == form1.value.locationNumber) |
|
|
|
if (arr1 && arr1.length > 0) { |
|
|
|
proxy.$modal.showToast('该库位已经绑定备件') |
|
|
|
return; |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
form.value.itemNumbers.push(form1.value) |
|
|
@ -335,48 +319,47 @@ |
|
|
|
form.value.itemNumbers.splice(index, 1) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function searchItem(name) { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中....", |
|
|
|
title: '加载中....', |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
await getSparePartsList(name); |
|
|
|
}) |
|
|
|
await getSparePartsList(name) |
|
|
|
} |
|
|
|
|
|
|
|
// 获取备件列表 |
|
|
|
async function getSparePartsList(name) { |
|
|
|
let param = { |
|
|
|
name:name |
|
|
|
const param = { |
|
|
|
name |
|
|
|
} |
|
|
|
await sparePartsApi.noPage(param).then(res => { |
|
|
|
res.data.map(item => { |
|
|
|
await sparePartsApi |
|
|
|
.noPage(param) |
|
|
|
.then((res) => { |
|
|
|
res.data.map((item) => { |
|
|
|
item.value = item.number |
|
|
|
item.label = item.name |
|
|
|
}) |
|
|
|
sparePartsList.value = res.data |
|
|
|
singleColumnList.value = sparePartsList.value |
|
|
|
uni.hideLoading() |
|
|
|
}).catch(() => { |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function chooseItem1(type, form) { |
|
|
|
if (!form.value.number && type == 1) { |
|
|
|
proxy.$modal.showToast('请选择备件'); |
|
|
|
return; |
|
|
|
proxy.$modal.showToast('请选择备件') |
|
|
|
return |
|
|
|
} |
|
|
|
if (type == 1) { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中....", |
|
|
|
title: '加载中....', |
|
|
|
mask: true |
|
|
|
}); |
|
|
|
form1.value['itemNumber'] = form.value.number |
|
|
|
choosesingleColumnItem.value = sparePartsList.value.filter(item => item.number == form.value.number) |
|
|
|
}) |
|
|
|
form1.value.itemNumber = form.value.number |
|
|
|
choosesingleColumnItem.value = sparePartsList.value.filter((item) => item.number == form.value.number) |
|
|
|
form1.value.name = form.value.name |
|
|
|
form1.value.locationNumber = choosesingleColumnItem.value[0].locationNumber |
|
|
|
form1.value.areaNumber = choosesingleColumnItem.value[0].areaNumber |
|
|
@ -386,18 +369,17 @@ |
|
|
|
isShow.value = false |
|
|
|
itemNumber.value = '' |
|
|
|
} |
|
|
|
await getSparePartsList(null); |
|
|
|
isShowSelectItem.value = false; |
|
|
|
await getSparePartsList(null) |
|
|
|
isShowSelectItem.value = false |
|
|
|
uni.hideLoading() |
|
|
|
} else { |
|
|
|
isShowSelectItem.value = false; |
|
|
|
isShowSelectItem.value = false |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onLoad(async (option) => { |
|
|
|
if (option.type) type.value = option.type; |
|
|
|
if (option.type) type.value = option.type |
|
|
|
result.value = await dictApi.getDict('result') |
|
|
|
await getServiceSparePartsList() |
|
|
|
}) |
|
|
@ -429,7 +411,6 @@ |
|
|
|
.btns { |
|
|
|
display: flex; |
|
|
|
|
|
|
|
|
|
|
|
button { |
|
|
|
flex: 1; |
|
|
|
} |
|
|
@ -446,7 +427,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
.reset { |
|
|
|
background: #F5F5F5; |
|
|
|
background: #f5f5f5; |
|
|
|
border-radius: 0px; |
|
|
|
|
|
|
|
&::after { |
|
|
@ -480,7 +461,6 @@ |
|
|
|
flex: 1; |
|
|
|
font-size: 28rpx; |
|
|
|
color: rgb(192, 196, 204); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -504,7 +484,7 @@ |
|
|
|
margin-bottom: 20rpx; |
|
|
|
|
|
|
|
.item-box { |
|
|
|
background: #F5F5F5; |
|
|
|
background: #f5f5f5; |
|
|
|
border-radius: 12rpx; |
|
|
|
flex: 1; |
|
|
|
width: 0rpx; |
|
|
@ -525,7 +505,6 @@ |
|
|
|
color: #9c9c9c; |
|
|
|
padding: 20rpx 30rpx 20rpx; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -540,13 +519,12 @@ |
|
|
|
font-size: 32rpx; |
|
|
|
font-weight: bold; |
|
|
|
color: #409eff; |
|
|
|
padding: 30rpx 30rpx 0px |
|
|
|
padding: 30rpx 30rpx 0px; |
|
|
|
} |
|
|
|
|
|
|
|
.popup { |
|
|
|
width: 600rpx; |
|
|
|
padding: 30rpx 0rpx 30rpx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.popup-footer { |
|
|
|