Files
property-manager-side/wuye-manager-uniapp/pageSubPack/inspection/inspection_upload.vue
2026-05-09 17:10:50 +08:00

327 lines
8.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page_padding">
<view class="inspection_upload_box flex flex-col">
<view class="inspection_info_box">
<view class="inspection_title flex flex-between">
<view class="title flex">
<text class="line"></text>
<text>幸福苑小区- B1层地下车库</text>
</view>
<view class="status">
<text>未巡检</text>
</view>
</view>
<view class="inspection_item_info_box">
<view class="inspection_item">
<text>巡检项目:</text>
<text>设备巡检</text>
</view>
<view class="inspection_item">
<text>巡检时间:</text>
<text>07:00:00 - 09:00:00</text>
</view>
<view class="inspection_item">
<text>巡检小区:</text>
<text>幸福苑小区</text>
</view>
<view class="inspection_item">
<text>巡检路线:</text>
<text>常规巡检路线1</text>
</view>
<view class="inspection_item">
<text>巡检点:</text>
<text>安全巡检点1;</text>
<text>安全巡检点2;</text>
<text>安全巡检点3;</text>
<text>安全巡检点4;</text>
</view>
</view>
</view>
<view class="inspection_info_upload_box">
<view class="header"> <text>巡检结果</text> </view>
<view class="info_body" :key="index" v-for="(item, index) in baseFormData">
<view class="info_title" style="margin-bottom: 20rpx"> {{ item.name }} </view>
<uni-forms :modelValue="item" :rules="rules" label-position="left" label-width="150">
<uni-forms-item label="巡检状态" required>
<uni-data-checkbox
:disabled="item.complated"
v-model="item.status"
:localdata="statuslist"
/>
</uni-forms-item>
<uni-forms-item label="巡检描述">
<uni-easyinput
type="textarea"
:disabled="item.complated"
:input-border="true"
v-model="item.desition"
placeholder="请输入"
></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="巡检时间">
<uni-datetime-picker
type="datetime"
:disabled="item.complated"
return-type="timestamp"
v-model="item.datetimesingle"
/>
</uni-forms-item>
<!-- <uni-forms-item label="巡检照片">
<uni-file-picker
@delete="deleteFile"
@select="select"
mode="grid"
v-model="item.files"
:auto-upload="false"
:sourceType="['camera']"
file-mediatype="image"
>
<view class="filePicker flex-center">
<uni-icons color="#a6a6a6" type="plusempty" size="25"> </uni-icons>
</view>
</uni-file-picker>
</uni-forms-item> -->
<view class="items_picker_box">
<view class="label"> 巡检照片 </view>
<view class="filePickerbox" v-if="!item.complated">
<filePicker
v-model="item.files"
:sourceType="['camera']"
file-field-name="file"
:extra-data="uploadParams"
@success="onUploadSuccess"
@fail="onUploadFail"
></filePicker>
</view>
<view class="filePickerbox showimagegrid" v-else>
<image
class="img"
mode="scaleToFill"
v-for="(ite, ind) in item.files"
lazy-load
:key="ind"
:src="ite"
@tap="previewImages(item.files, index)"
></image>
</view>
</view>
</uni-forms>
<view class="submitbox" @tap="handleSubmit(item.id)">
<text>提交</text>
</view>
<view class="line" v-if="index + 1 !== baseFormData.length"> </view>
</view>
<!-- <view class="submitbox">
<text>提交</text>
</view> -->
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import filePicker from '@/components/filePicker/filePicker.vue'
const statuslist = [
{
text: '正常',
value: 0
},
{
text: '异常',
value: 1
}
]
const baseFormData = ref([])
const info = ref({
point: Array.from({ length: 4 }).map((_, index) => {
let obj1 = {
name: `巡检点${index + 1}`,
id: index + ''
}
let obj = {
id: index,
name: obj1.name,
desition: '', // 描述
datetimesingle: '', // 时间
status: 0, // 状态 0正常1异常
files: [], // 图片
complated: false, // 巡检点完成检查
fileUrls: '' // 图片
}
baseFormData.value.push(obj)
return obj1
})
})
const rules = {
status: {
rules: [
{
required: true,
errorMessage: '巡检状态不能为空'
}
]
}
}
// ----------------------------------------------
const uploadParams = ref({
type: 'repair', // 上传类型:报修
businessId: '123456', // 关联业务ID
userId: '789' // 用户ID
})
// 选择文件
function onUploadSuccess(e) {
console.log('上传成功', e)
}
function onUploadFail(e) {
console.log('上传失败', e)
}
function submit() {
console.log('最终要提交的图片URL', imageList.value)
// 这里调用你的提交接口
}
/** 提交巡检点 检查情况 */
function handleSubmit(id) {
console.log(typeof id, id, baseFormData.value)
const find = baseFormData.value.find(item => item.id === id)
if (find) {
find.complated = true
}
}
/**
* 预览图片
* @param {Array} images - 所有图片的URL数组
* @param {Number} currentIndex - 当前点击的图片索引
*/
function previewImages(images, currentIndex) {
uni.previewImage({
urls: [
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80',
'https://picsum.photos/80'
],
current: currentIndex
})
}
</script>
<style scoped lang="scss">
.inspection_upload_box {
background: #f9f9f9;
padding: 20rpx 40rpx;
position: relative;
flex: 1;
overflow: hidden;
box-sizing: border-box;
.inspection_info_box {
background-color: #ffffff;
padding: 20rpx 40rpx;
margin-bottom: 20rpx;
border-radius: 16rpx;
.inspection_title {
margin-bottom: 20rpx;
.title {
font-size: 32rpx;
color: #333333;
line-height: 40rpx;
height: 40rpx;
.line {
display: block;
width: 6rpx;
height: 28rpx;
background: #4d5dfa;
margin-right: 10rpx;
margin-top: 6rpx;
}
}
.status {
font-weight: 400;
font-size: 28rpx;
color: #4d5dfa;
line-height: 36rpx;
}
}
.inspection_item_info_box {
width: 100%;
.inspection_item {
margin-bottom: 20rpx;
font-weight: 400;
font-size: 28rpx;
color: #333333;
line-height: 36rpx;
}
}
}
.inspection_info_upload_box {
border-radius: 16rpx;
background-color: #fff;
padding: 30rpx 40rpx;
flex: 1;
box-sizing: border-box;
overflow: hidden;
overflow-y: auto;
.header {
font-weight: 500;
font-size: 32rpx;
color: #222222;
line-height: 40rpx;
margin-bottom: 20rpx;
}
.info_body {
margin-bottom: 40rpx;
}
.info_title {
font-weight: 550;
}
.line {
width: 100%;
border: 1rpx dashed #ccc;
}
.items_picker_box {
.label {
text-align: left;
font-size: 14px;
color: #606266;
height: 36px;
padding: 0 12px 0 0;
vertical-align: middle;
box-sizing: border-box;
}
.showimagegrid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20rpx;
width: 100%;
.img {
width: 160rpx;
height: 160rpx;
}
}
}
}
.submitbox {
height: 80rpx;
background: #4d5dfa;
border-radius: 8rpx 8rpx 8rpx 8rpx;
text-align: center;
font-weight: 400;
font-size: 28rpx;
color: #ffffff;
line-height: 80rpx;
margin-top: 40rpx;
margin-bottom: 40rpx;
}
}
</style>