tsg-app/pages/wtcl/detail/index.vue

308 lines
8.5 KiB
Vue

<template>
<view :style="{height:'100vh',overflow:'auto'}">
<u-status-bar></u-status-bar>
<u-navbar title="问题处理" :autoBack="true" :titleStyle="{
fontSize:'18px'
}" :height='44' :safeAreaInsetTop=true leftIconSize='20' leftIconColor='rgb(153, 153, 153)'>
</u-navbar>
<view class="" style="margin-top: 44px;;background-color: #f0f0f0;border-top: 1px solid #f0f0f0;">
<view style="margin: 10px;background-color: #fff;padding: 10px;">
<view class="item">
<view class="blueTiao">
</view>
<view class="title">
巡检问题信息
</view>
</view>
<view class="contentItem">
<view class="itemC">
<text>巡查人</text>
<text>{{queItem.inspectUserName}}</text>
</view>
<view class="itemC">
<text>巡查时间</text>
<text>{{queItem.finishTime}}</text>
</view>
<view class="itemC">
<text>任务标题</text>
<text>{{queItem.taskTitle}}</text>
</view>
<view class="itemC">
<text>巡检点</text>
<text>{{queItem.name}}</text>
</view>
<view class="itemC">
<text>巡检项</text>
<text>{{queItem.itemDesc}}</text>
</view>
<view class="itemNo" style="flex-direction: column;">
<text>巡检问题描述</text>
<u--textarea v-model="queItem.problemDesc" placeholder="请输入内容" disabled ></u--textarea>
</view>
<view class="itemNo" style="flex-direction: column;">
<text>巡检图片</text>
<view class="" v-for="item in queItem.inspectPics">
<image :src="item.url" style="width: 80px;height: 80px;margin: 5px;" @click="previewImage(item)"></image>
</view>
</view>
<view class="itemNo" style="flex-direction: column;">
<text>巡检视频</text>
<view class="" v-for="item in queItem.inspectVideos">
<video :src="item.url" style="width: 80px;height: 80px;margin: 5px;" show-fullscreen-btn></video>
</view>
</view>
</view>
</view>
<view style="margin: 10px;background-color: #fff;padding: 10px;" class="">
<u--form labelPosition="left" :model="queItem" ref="uForm" label-width='80px'>
<view class="itemCc">
<u-form-item label="处理人" prop="handleUserName" borderBottom required >
<u--input v-model="queItem.handleUserName" disabled disabledColor="#ffffff"
placeholder="" border="none"></u--input>
</u-form-item>
<u-form-item label="处理时间" prop="handleTime" borderBottom required>
<u--input v-model="queItem.handleTime" disabled disabledColor="#ffffff"
placeholder="" border="none"></u--input>
</u-form-item>
<u-form-item label="处理内容" prop="handleDesc" borderBottom required labelPosition='top'>
<u--textarea v-model="queItem.handleDesc" placeholder="请输入内容" ></u--textarea>
</u-form-item>
<u-form-item label="处理图片" prop="handlePics" borderBottom required labelPosition='top'>
<u-upload accept="image" :fileList="queItem.handlePics || []"
@afterRead="(e)=>afterRead(e,queItem)"
@delete="(e)=>deletePic(e,queItem)" name="handlePics" multiple
:maxCount="10"></u-upload>
</u-form-item>
<u-form-item label="处理视频" prop="handleVideos" borderBottom labelPosition='top'>
<u-upload accept="video" :fileList="queItem.handleVideos"
@afterRead="(e)=>afterRead(e,queItem)"
@delete="(e)=>deletePic(e,queItem)" name="handleVideos" multiple
:maxCount="10"></u-upload>
</u-form-item>
</view>
<u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
</u--form>
</view>
</view>
</view>
</view>
</template>
<script>
import moment from 'moment'
export default {
data() {
return {
show: false,
model: {
stm: '',
etm: ''
},
queItem:{},
list: [{
title: '5-29日常巡检',
state: 0,
xjx: '上游坝面、坝顶',
name: '王自荣',
time: '2024-05-30 09:31:23'
},
{
title: '5-29日常巡检',
state: 1,
xjx: '上游坝面、坝顶',
name: '王自荣',
time: '2024-05-30 09:31:23'
},
]
};
},
onLoad(options) {
this.queItem = JSON.parse(options.item)
console.log(uni.getStorageSync('value'));
this.queItem.handleUserName = uni.getStorageSync('value').nickName
this.queItem.handleTime = moment().format('YYYY-MM-DD HH:mm:ss')
this.queItem.handleUserId = uni.getStorageSync('value').userId
// this.queItem.handlePics.map(item=>{
// item.url ='http://223.75.53.141:9102/test.by-lyf.tmp' + item.filePath
// return item
// })
this.queItem.inspectPics.map(item=>{
item.url ='http://223.75.53.141:9102/test.by-lyf.tmp' + item.filePath
return item
})
this.queItem.inspectVideos.map(item=>{
item.url ='http://223.75.53.141:9102/test.by-lyf.tmp' + item.filePath
return item
})
},
methods: {
submit(){
//
if(this.queItem.handlePics?.length < 0 || !this.queItem.handleDesc){
console.log(this.queItem);
uni.$showMsg('请填写处理内容和上传图片');
return;
}else{
console.log(this.queItem);
uni.$http.post('/gunshiApp/tsg/inspect/detail/handle', this.queItem).then(res => {
uni.$showMsg(res.data.description);
if(res.data.code == 200){
uni.navigateBack()
}
})
}
},
// 删除图片
deletePic(event, o) {
this.queItem[event.name].splice(event.index, 1)
},
// 新增图片
async afterRead(event, o) {
// let file
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
console.log(event,'2342132');
let lists = [].concat(event.file)
if(!this.queItem[event.name]){
this.queItem[event.name]=[]
}
let fileListLen = this.queItem[event.name]?.length
console.log(this.queItem[event.name]);
lists.map((item) => {
this.queItem[event.name].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url, event.name)
console.log(result);
let item = this.queItem[event.name][fileListLen]
this.queItem[event.name].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
...result
}))
fileListLen++
}
},
uploadFilePromise(url, name) {
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: 'http://local.gunshiiot.com:18083/gunshiApp/tsg/inspect/task/file/upload/singleSimple', // 仅为示例,非真实的接口地址
filePath: url,
name: 'file',
formData: {
user: 'test'
},
success: (res) => {
setTimeout(() => {
// this.listData[index].children[index1][name].push({...res.data.data,url:res.data.data.filePath})
console.log(res.data)
resolve(JSON.parse(res.data).data)
}, 1000)
}
});
// resolve(a)
})
},
confirm(e) {
console.log(e);
this.model.stm = e[0]
this.model.etm = e[1]
this.show = false
},
cancel() {
this.show = false
}
}
}
</script>
<style lang="scss" scoped>
.myTitleStyle {
font-size: 30px;
background-color: red;
height: 200px;
}
.tabsClass {
margin-top: 44px;
height: 44px;
padding: 0 40px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
}
.item {
padding-bottom: 10px;
display: flex;
align-items: center;
// justify-content: space-between;
.blueTiao{
background-color: #007aff;
width: 5px;
height: 16px;
margin-right: 10px;
}
.title {
border-width: 0px;
font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑', sans-serif;
font-weight: 700;
font-style: normal;
font-size: 15px;
color: #666666
}
.titleRight {
display: flex;
.border {
border-width: 0px;
background-color: rgba(236, 245, 255, 1);
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: rgba(187, 220, 255, 1);
border-radius: 5px;
box-shadow: none;
width: 58px;
height: 25px;
color: #689FFF;
text-align: center;
}
}
}
.itemCc{
// display: flex;
// justify-content: space-between;
// display: flex;
padding: 10px;
border-bottom: 1px solid #f0f0f0;
}
.contentItem{
.itemC{
display: flex;
justify-content: space-between;
display: flex;
color: #303133;;
padding: 10px;
border-bottom: 1px solid #f0f0f0;
}
.itemNo{
color: #303133;;
padding: 10px;
}
}
</style>