维修报废附件校验
This commit is contained in:
parent
74fa10a565
commit
1f1bcea02c
|
|
@ -1,81 +1,82 @@
|
|||
<template>
|
||||
<view class="page-container">
|
||||
<view class="table-list-item">
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">物资名称:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ queryParams.typeName }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">物资类型:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ queryParams.type }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">设备编码:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ selectedCodesDisplay }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24" style="display: flex;align-items: center">
|
||||
<uni-col :span="6">维修人员:</uni-col>
|
||||
<uni-col :span="18">
|
||||
<uni-data-select :localdata="repairPersonData" v-model="repairPerson" placeholder="请选择维修人员" />
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row
|
||||
:gutter="24"
|
||||
class="search-form"
|
||||
style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px"
|
||||
>
|
||||
<uni-col :span="24">
|
||||
<view class="btnBox complete" @click="saveCode"> 提交 </view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
</view>
|
||||
<scroll-view scroll-y style="padding-bottom: 20rpx">
|
||||
<!-- 维修报废 -->
|
||||
<view class="table-list-item" v-if="repairType == 3">
|
||||
<h2 style="padding: 4rpx 0; font-weight: bold">维修报废</h2>
|
||||
<uni-forms ref="baseForm" label-align="right">
|
||||
<uni-forms-item label="报废原因">
|
||||
<uni-easyinput
|
||||
placeholder="请填写报废原因"
|
||||
v-model="formRight.scrapReason"
|
||||
style="margin-bottom: 10px"
|
||||
/>
|
||||
<uni-data-select
|
||||
:localdata="scrapReasonList"
|
||||
v-model="formRight.scrapId"
|
||||
placeholder="请选择报废原因"
|
||||
@change="changeScrap"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="损坏原因">
|
||||
<uni-data-select
|
||||
:clearable="false"
|
||||
:localdata="damageReasonList"
|
||||
v-model="formRight.scrapType"
|
||||
placeholder="请选择损坏原因"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="附件">
|
||||
<div class="upload-container">
|
||||
<div class="upload" @click="uploadImg2" v-if="imgList2.length < 3">+</div>
|
||||
<div class="image-preview" v-for="(img, index) in imgList2" :key="index">
|
||||
<image :src="img.url" mode="aspectFill"></image>
|
||||
<view class="delete-btn" @click.stop="deleteImage2(index)">×</view>
|
||||
<PreviewImg :imgUrl="img.url" />
|
||||
</div>
|
||||
</div>
|
||||
</uni-forms-item>
|
||||
<div style="border-bottom: 1 solid #333;"></div>
|
||||
</uni-forms>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="page-container">
|
||||
<view class="table-list-item">
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">物资名称:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ queryParams.typeName }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">物资类型:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ queryParams.type }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24">
|
||||
<uni-col :span="6">设备编码:</uni-col>
|
||||
<uni-col :span="18"
|
||||
><view class="cont">{{ selectedCodesDisplay }}</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24" style="display: flex;align-items: center">
|
||||
<uni-col :span="6">维修人员:</uni-col>
|
||||
<uni-col :span="18">
|
||||
<uni-data-select :localdata="repairPersonData" v-model="repairPerson" placeholder="请选择维修人员" />
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row
|
||||
:gutter="24"
|
||||
class="search-form"
|
||||
style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px"
|
||||
>
|
||||
<uni-col :span="24">
|
||||
<view class="btnBox complete" @click="saveCode"> 提交 </view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
</view>
|
||||
<scroll-view scroll-y style="padding-bottom: 20rpx">
|
||||
<!-- 维修报废 -->
|
||||
<view class="table-list-item" v-if="repairType == 3">
|
||||
<h2 style="padding: 4rpx 0; font-weight: bold">维修报废</h2>
|
||||
<uni-forms ref="baseForm" label-align="right">
|
||||
<uni-forms-item label="报废原因">
|
||||
<uni-easyinput
|
||||
placeholder="请填写报废原因"
|
||||
v-model="formRight.scrapReason"
|
||||
style="margin-bottom: 10px"
|
||||
/>
|
||||
<uni-data-select
|
||||
:localdata="scrapReasonList"
|
||||
v-model="formRight.scrapId"
|
||||
placeholder="请选择报废原因"
|
||||
@change="changeScrap"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="损坏原因">
|
||||
<uni-data-select
|
||||
:clearable="false"
|
||||
:localdata="damageReasonList"
|
||||
v-model="formRight.scrapType"
|
||||
placeholder="请选择损坏原因"
|
||||
/>
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="附件" required>
|
||||
<div class="upload-container">
|
||||
<div class="upload" @click="uploadImg2" v-if="imgList2.length < 3">+</div>
|
||||
<div class="image-preview" v-for="(img, index) in imgList2" :key="index">
|
||||
<image :src="img.url" mode="aspectFill"></image>
|
||||
<view class="delete-btn" @click.stop="deleteImage2(index)">×</view>
|
||||
<PreviewImg :imgUrl="img.url" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- <view class="upload-tips" v-if="imgList2.length === 0">请至少上传一个附件</view>-->
|
||||
</uni-forms-item>
|
||||
<div style="border-bottom: 1 solid #333;"></div>
|
||||
</uni-forms>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
|
@ -94,34 +95,34 @@ const queryParams = ref({})
|
|||
const rowIndex = ref(-1)
|
||||
// 计算属性:将选中的编码用逗号拼接显示
|
||||
const selectedCodesDisplay = computed(() => {
|
||||
if (queryParams.value.selectedCodes && queryParams.value.selectedCodes.length > 0) {
|
||||
// 清理可能存在的双引号和其他字符
|
||||
const cleanCodes = queryParams.value.selectedCodes.map(code => {
|
||||
// 如果是字符串,移除首尾的双引号
|
||||
if (typeof code === 'string') {
|
||||
return code.replace(/^["']|["']$/g, '')
|
||||
}
|
||||
return String(code)
|
||||
})
|
||||
return cleanCodes.join(', ')
|
||||
}
|
||||
return ''
|
||||
if (queryParams.value.selectedCodes && queryParams.value.selectedCodes.length > 0) {
|
||||
// 清理可能存在的双引号和其他字符
|
||||
const cleanCodes = queryParams.value.selectedCodes.map(code => {
|
||||
// 如果是字符串,移除首尾的双引号
|
||||
if (typeof code === 'string') {
|
||||
return code.replace(/^["']|["']$/g, '')
|
||||
}
|
||||
return String(code)
|
||||
})
|
||||
return cleanCodes.join(', ')
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
onLoad((options) => {
|
||||
queryParams.value = JSON.parse(decodeURIComponent(options.batchParams))
|
||||
if (queryParams.value.selectedCodes) {
|
||||
queryParams.value.selectedCodes = queryParams.value.selectedCodes.map(code => {
|
||||
// 清理双引号
|
||||
if (typeof code === 'string') {
|
||||
return code.replace(/^["']|["']$/g, '')
|
||||
}
|
||||
return String(code)
|
||||
})
|
||||
}
|
||||
console.log('批量维修参数:', queryParams.value)
|
||||
console.log('选中的设备:', queryParams.value.selectedDevices)
|
||||
console.log('选中的编码:', queryParams.value.selectedCodes)
|
||||
queryParams.value = JSON.parse(decodeURIComponent(options.batchParams))
|
||||
if (queryParams.value.selectedCodes) {
|
||||
queryParams.value.selectedCodes = queryParams.value.selectedCodes.map(code => {
|
||||
// 清理双引号
|
||||
if (typeof code === 'string') {
|
||||
return code.replace(/^["']|["']$/g, '')
|
||||
}
|
||||
return String(code)
|
||||
})
|
||||
}
|
||||
console.log('批量维修参数:', queryParams.value)
|
||||
console.log('选中的设备:', queryParams.value.selectedDevices)
|
||||
console.log('选中的编码:', queryParams.value.selectedCodes)
|
||||
|
||||
getScrapReasonListData()
|
||||
})
|
||||
|
|
@ -133,8 +134,8 @@ const damageReasonList = ref([
|
|||
{ value: 1, text: '人为损坏' },
|
||||
])
|
||||
const isChargeList = ref([
|
||||
{ value: 1, text: '是' },
|
||||
{ value: 0, text: '否' },
|
||||
{ value: 1, text: '是' },
|
||||
{ value: 0, text: '否' },
|
||||
])
|
||||
|
||||
const { userInfo } = JSON.parse(uni.getStorageSync('member'))
|
||||
|
|
@ -230,6 +231,16 @@ const formRight = ref({
|
|||
})
|
||||
const imgBeseUrl2 = ref('') //图片展示
|
||||
const imgList2 = ref([]) // 图片列表,用于回显
|
||||
|
||||
// 校验附件是否已上传
|
||||
const validateAttachment = () => {
|
||||
if (imgList2.value.length === 0) {
|
||||
uni.showToast({ title: '请至少上传一个附件', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//上传
|
||||
const uploadImg2 = () => {
|
||||
uni.showActionSheet({
|
||||
|
|
@ -332,16 +343,19 @@ const deleteImage2 = (index) => {
|
|||
const rowData = ref({})
|
||||
//维修完成校验
|
||||
const saveCode = () => {
|
||||
if (repairType.value == 3) {
|
||||
console.log(formRight.value)
|
||||
if (repairPerson.value == '') {
|
||||
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
|
||||
} else if (!formRight.value.scrapReason && !formRight.value.scrapId) {
|
||||
uni.showToast({ title: '请填写报废原因', icon: 'none' })
|
||||
} else {
|
||||
saveCodeApi()
|
||||
}
|
||||
if (repairType.value == 3) {
|
||||
console.log(formRight.value)
|
||||
if (repairPerson.value == '') {
|
||||
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
|
||||
} else if (!formRight.value.scrapReason && !formRight.value.scrapId) {
|
||||
uni.showToast({ title: '请填写报废原因', icon: 'none' })
|
||||
} else if (!validateAttachment()) {
|
||||
// 附件校验不通过,直接返回
|
||||
return
|
||||
} else {
|
||||
saveCodeApi()
|
||||
}
|
||||
}
|
||||
}
|
||||
const loading = ref(false)
|
||||
//维修完成请求
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@
|
|||
<!-- <uni-forms-item label="其他原因">
|
||||
<uni-easyinput placeholder="请填写其他原因" />
|
||||
</uni-forms-item> -->
|
||||
<uni-forms-item label="附件">
|
||||
<uni-forms-item label="附件" required>
|
||||
<!-- <div class="upload" @click="uploadScrapImg" v-if="imgBeseUrl2 == ''">+</div>-->
|
||||
<!-- <div class="upload" @click="uploadScrapImg" v-else>-->
|
||||
<!-- <image-->
|
||||
|
|
@ -760,11 +760,24 @@ const saveCode = () => {
|
|||
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
|
||||
} else if (!formRight.value.scrapReason && !formRight.value.scrapId) {
|
||||
uni.showToast({ title: '请填写报废原因', icon: 'none' })
|
||||
} else if (!validateAttachment()) {
|
||||
// 附件校验不通过,直接返回
|
||||
return
|
||||
} else {
|
||||
saveCodeApi()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 校验附件是否已上传
|
||||
const validateAttachment = () => {
|
||||
if (imgList2.value.length === 0) {
|
||||
uni.showToast({ title: '请至少上传一个附件', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const isSubmit = ref(false)
|
||||
//维修完成请求
|
||||
const saveCodeApi = async () => {
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@
|
|||
<!-- <uni-forms-item label="其他原因">
|
||||
<uni-easyinput placeholder="请填写其他原因" />
|
||||
</uni-forms-item> -->
|
||||
<uni-forms-item label="附件">
|
||||
<uni-forms-item label="附件" required>
|
||||
<div class="upload-container">
|
||||
<div class="upload" @click="uploadImg2" v-if="imgList2.length < 3">+</div>
|
||||
<div class="image-preview" v-for="(img, index) in imgList2" :key="index">
|
||||
|
|
@ -720,6 +720,12 @@ const saveNumAll = async () => {
|
|||
return
|
||||
}
|
||||
|
||||
if (formRight.value.scrapNum > 0 && imgList2.value.length === 0) {
|
||||
uni.showToast({ title: '请至少上传一个附件', icon: 'none' })
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
Number(formLeft.value.repairNum) +
|
||||
Number(formMiddle.value.repairNum) +
|
||||
|
|
|
|||
Loading…
Reference in New Issue