zhengkaixin 2 týždňov pred
rodič
commit
1e193fdd21
2 zmenil súbory, kde vykonal 177 pridanie a 141 odobranie
  1. 11 0
      apis/pagejs/pagesInspection.js
  2. 166 141
      pages/inspection/add.vue

+ 11 - 0
apis/pagejs/pagesInspection.js

@@ -10,11 +10,22 @@ export function recordList(data) {
 	})
 }
 
+export function teamMembers(data) {
+	var url='/mobile/inspectionUser/teamMembers';
+	return request({
+		method: 'post',
+		data: data,
+		url: url
+	})
+}
+
+
 
 export function recordReport(data) {
 	var url='/mobile/inspectionRecord/recordReport';
 	return request({
 		method: 'post',
+		header:{'Content-Type':'application/json'},
 		data: data,
 		url: url
 	})

+ 166 - 141
pages/inspection/add.vue

@@ -2,8 +2,8 @@
 	<view class="jpmain  ">
 		<u-navbar title="维修结果" title-color="#101010"></u-navbar>
 
-		<u-picker mode="time" v-model="completionTimeShow" @confirm="completionTimeConfirm"
-			:default-time="taskInfo.completionTime" :params="params"></u-picker>
+		<u-picker mode="time" v-model="inspectionTimeShow" @confirm="inspectionTimeConfirm"
+			:default-time="taskInfo.inspectionTime" :params="params"></u-picker>
 
 
 		<view class="list">
@@ -35,14 +35,14 @@
 			</view>
 			<view class="item item-plus">
 				<view class="name">
-					处理人员
+				<span style="color: red;">*</span>	处理人员
 
 				</view>
 
 				<view class="value  ">
 
 					<u-checkbox-group>
-						<u-checkbox v-model="item.checked" v-for="(item, index) in memberList" :key="index"
+						<u-checkbox v-model="item.checked" v-for="(item, index) in memberList" :key="index"  @change="memberListchange"
 							:name="item.name">{{item.name}}</u-checkbox>
 					</u-checkbox-group>
 
@@ -52,15 +52,15 @@
 
 			<view class="item item-plus" style="    align-items: center;">
 				<view class="name">
-					处理时间
+					<span style="color: red;">*</span>处理时间
 
 				</view>
 
-				<view class="value  " @click="completionTimeShow=true">
+				<view class="value  " @click="inspectionTimeShow=true">
 					<view class="valueclock">
 						<u-icon name="clock" size="32" color="#BBBBBB"></u-icon>
 
-						{{taskInfo.completionTime}}
+						{{taskInfo.inspectionTime}}
 					</view>
 
 
@@ -69,23 +69,7 @@
 
 
 
-			<view class="item item-plus" v-if="0">
-				<view class="name">
-					现场照片
-
-
-				</view>
-				<view class="value" v-if="floorlockErrorRecord.status==0">
-					<u-upload name="photoFile" ref="uUpload" :form-data="formData" :header="header" :action="action"
-						:file-list="listPic"></u-upload>
-				</view>
-				<view class="value" v-else>
-
-					<img class="viewImg" v-for="(item,i) in repairImageList" @click="previewImage(i,'repairImageList')"
-						:key="i" :src="item" mode=""></img>
-
-				</view>
-			</view>
+			
 
 		</view>
 		
@@ -94,7 +78,7 @@
 			{{index+1}}	{{item.name}}
 		
 			</view>
-			<view class="item item-plus">
+			<view class="item item-plus"  v-if="item.btn&&item.btn.length">
 				<view class="name">
 					<span style="color: red;">*</span>检测结果
 
@@ -117,26 +101,43 @@
 				</view>
 			</view>
 			
-			<view class="item item-plus">
+			<view class="item item-plus" v-if="submitcontent[index].result==0">
 				<view class="name">
-					{{item.desc}}
+					<span style="color: red;" v-if="item.field" >*</span>{{item.desc}}
 			
 				</view>
 			
 				<view class="value  ">
 			
-					<u-input style="background-color: #888888;" :placeholder="item.descP"></u-input>
+					<u-input style="background-color: #f1f2f5;" 
+					 v-model="submitcontent[index].content"
+					:placeholder="item.descP"></u-input>
 			
 			
 				</view>
 			</view>
+			
+			<view class="item item-plus" v-if="item.imageRequired">
+				<view class="name">
+					<span style="color: red;">*</span>拍照上传(请上传设备状态照片)
+
+				</view>
+				<view class="value" >
+					<u-upload name="photoFile"   :class="'uUpload'+index" 
+					:ref="'uUpload'+index"  :width="100" :height="100" uploadText=""
+					:form-data="formData" :header="header"
+					 :action="action"
+						:file-list="listPic[index]"></u-upload>
+				</view>
+				
+			</view>
 			
 		</view>
 		
 		
 		
 		
-		<view class="floating-button" v-if="floorlockErrorRecord.status==0">
+		<view class="floating-button" >
 			<view class="button" @click="submit">
 
 				提交
@@ -147,7 +148,7 @@
 </template>
 
 <script>
-	import * as API from '@/apis/pagejs/pagesTask.js'
+	import * as API from '@/apis/pagejs/pagesInspection.js'
 	import * as WxJsApi from '@/apis/utils/wxJsApi.js'
 
 	import {
@@ -158,7 +159,8 @@
 
 	export default {
 		data() {
-			return {
+			return {
+				record:{},
 				memberList: [
 
 				],
@@ -192,37 +194,16 @@
 					id: "",
 					desc: "",
 					images: "",
-					completionTime: "",
+					inspectionTime: "",
 
 				},
 				codeList: [],
 				id: "",
 				imgList: [],
 				repairImageList: [],
-				completionTimeShow: false,
+				inspectionTimeShow: false,
 				content: [
-					"变压器外观是否正常无损坏?",
-					"配线柜内线缆是否完好,接头是否有过热或烧伤痕迹?",
-					"断路器是否有异响,是否有异味(烧焦的味道)?",
-					{
-						name:"电度表读数(否完远程电表)?",
-						btn:[{
-							name:"是",
-							value:"1"
-						},{
-							name:"数字输入",
-							value:"-1"
-						}],
-						desc:"电度表读数",
-						descP:"例如:000-217",
-					},
-					"充电桩外观是否正常无损坏,枪头是否正常无损坏,无积水、无异物?",
-					"散热板是否清洁?",
-					"充电桩箱体内接头是否有过热或烧伤痕迹?",
-					"充电电缆是否无破损?",
-					"基座是否完好、无损坏,无积水?",
-					"消防设施是否完好?",
-					"充电桩是否有异响动,外观是否干净清洁,附近是否有易燃、易爆或可燃材料、化学品、可燃蒸汽等危险物品?",
+					
 				],
 				contentList:[],
 				submitcontent:[]
@@ -237,36 +218,10 @@
 				'Authorization': token
 			}
 			this.id = op.id
-			this.taskInfo.completionTime = parseUnixTime(currentTimeStamp())
-			//this.errDetails()
-			
-			this.contentList=this.content.map(item=>{
-				if(typeof item === "string" ){
-					return {
-						name:item,
-						btn:[{
-							name:"正常",
-							value:"1"
-						},{
-							name:"异常",
-							value:"0"
-						}],
-						desc:"问题描述",
-						descP:"请简单描述发现的问题",
-					}
-				}else{
-					return item
-				}
-			})
+			this.taskInfo.inspectionTime = parseUnixTime(currentTimeStamp())
+			this.errDetails()
 			
-			this.submitcontent=this.contentList.map(item=>{
-				return {
-					name:item.name,
-					result:"1",
-					image:"",
-					extended1:""
-				}
-			})
+		
 			
 			this.getteamMembers()
 
@@ -279,7 +234,11 @@
 				//(res)
 			})
 		},
-		methods: {
+		methods: {
+			memberListchange(e){
+				console.log(e)
+				this.$forceUpdate()
+			},
 			getteamMembers() {
 				uni.showLoading({
 					title: "加载中",
@@ -311,10 +270,10 @@
 				})
 
 			},
-			completionTimeConfirm(e) {
-				console.log(e)
+			inspectionTimeConfirm(e) {
+				
 
-				this.taskInfo.completionTime = parseUnixTime(new Date(e.timestamp * 1000))
+				this.taskInfo.inspectionTime = parseUnixTime(new Date(e.timestamp * 1000))
 			},
 			previewImage(i, name) {
 				let imgs = this[name];
@@ -329,7 +288,7 @@
 				if (!(this.parkingInfo.latitude && this.parkingInfo.longitude)) {
 					return
 				}
-				//console.log(item)
+				
 				uni.showLoading({
 
 				})
@@ -360,21 +319,14 @@
 					mask: true,
 				})
 
-				API.errDetails({
+				API.recordDetails({
 					id: this.id
 				}).then((res) => {
-					this.floorlockErrorRecord = res.data.floorlockErrorRecord
-					this.floorlockInfo = res.data.floorlockInfo
-					this.parkingInfo = res.data.parkingInfo
-					if (this.floorlockErrorRecord.errorImage) {
-						this.imgList = this.floorlockErrorRecord.errorImage.split(',')
-					}
-					if (this.floorlockErrorRecord.repairImage) {
-						this.repairImageList = this.floorlockErrorRecord.repairImage.split(',')
-					}
-
+					
+					this.content=res.data.content
+					this.record=res.data.record
 					uni.hideLoading();
-
+					this.contentMethod()
 				}).catch(error => {
 
 					uni.hideLoading();
@@ -383,32 +335,57 @@
 						icon: "none"
 					})
 				})
-			},
+			},
+			contentMethod(){
+				this.listPic=[]
+				this.contentList=this.content.map(item=>{
+					this.listPic.push([])
+					
+					var obj={
+						dataId:item.dataId,
+						name:item.name,
+						btn:[{
+							name:"正常",
+							value:"1"
+						},{
+							name:"异常",
+							value:"0"
+						}],
+						desc:"问题描述",
+						descP:"请简单描述发现的问题",
+					}
+					
+					if(item.extended1){
+						var extended1=JSON.parse(item.extended1)
+						
+						Object.keys(extended1).forEach(key1 => {
+							
+							obj[key1]=extended1[key1]
+						})
+					}
+					
+					return obj
+				})
+				
+				this.submitcontent=this.contentList.map(item=>{
+					return {
+						dataId:item.dataId,
+						name:item.name,
+						result:"1",
+						image:"",
+						content:""
+					}
+				})
+			},
+			
 			submitApi() {
-				let files = [];
-				// 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
-				files = this.$refs.uUpload.lists.filter(val => {
-					return val.progress == 100;
-				})
-				// 如果您不需要进行太多的处理,直接如下即可
-				// files = this.$refs.uUpload.lists;
-
-				//(files);
-
-				var imgUrl = files.map(item => {
-					return item.response.data;
-				})
-				//(imgUrl);
-				this.taskInfo.images = imgUrl.join(',');
-				this.taskInfo.id = this.id;
-
-
+				
 				uni.showLoading({
 					title: "加载中",
 					mask: true,
 				})
-
-				API.updateErr(this.taskInfo).then((res) => {
+				this.taskInfo.content=this.submitcontent
+				API.recordReport(this.taskInfo).then((res) => {
 
 					const eventChannel = this.getOpenerEventChannel();
 
@@ -439,25 +416,73 @@
 				})
 			},
 			submit() {
-
-				if (!this.taskInfo.desc) {
-					uni.showModal({
-						title: '提示',
-						showCancel: true,
-						cancelText: "返回填写",
-						confirmText: "继续提交",
-						content: "未填写处理步骤,是否继续提交",
-						success: res1 => {
-							if (res1.confirm) {
-								this.submitApi()
-							} else if (res1.cancel) {
-								//('用户点击取消');
-							}
-						}
-					})
-				} else {
-					this.submitApi()
-				}
+				
+				var mp=this.memberList.filter(item=>{
+					return item.checked
+				}).map(item=>{
+					return item.id
+				})
+				
+				if (mp.length==0) {
+					uni.showToast({
+						title: "请选择上报人员"
+					})
+					return
+				}
+				this.taskInfo.userIds=mp.join()
+				this.taskInfo.id=this.id
+				this.taskInfo.status=0
+				this.taskInfo.stationId=this.record.stationId
+				
+				
+				
+				
+				var i =0
+				var bl=false
+				this.contentList.forEach(item=>{
+					if(bl==true){
+						return
+					}
+					if(item.imageRequired&&0){
+						let files = [];
+						console.log(this.$refs)
+						console.log(item.imageRequired,i,this.$refs['uUpload'+i])
+						// 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
+						files = this.$refs['uUpload'+i][0].lists.filter(val => {
+							return val.progress == 100;
+						})
+						var imgUrl = files.map(item => {
+							return item.response.data;
+						})
+						if(imgUrl.length==0){
+							uni.showToast({
+								title: "请上传设备状态照片(第"+(i+1)+"项)"
+							})
+							bl=true;
+						}
+						this.submitcontent[i].image=imgUrl.join(',');
+						
+					}
+					if(item.field){
+						if(this.submitcontent[i].result==0&&!this.submitcontent[i].content){
+							uni.showToast({
+								title: "请填写"+item.name
+							})
+							bl=true;
+						}
+						this.taskInfo[item.field]=this.submitcontent[i].content
+					}
+					
+					
+					i++;
+				})
+				
+				if(bl==true){
+					return
+				}
+				console.log(this.taskInfo)
+				console.log(this.submitcontent)
+				this.submitApi()