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