<template>
	<view class="wrap">
		<view class="view_data">
			<uni-list-item title="编码" :rightText="viewData.snapshotCode" ></uni-list-item>	
			<uni-list-item title="状态" :rightText="snapshotStatus(viewData.status)" ></uni-list-item>	
			<uni-list-item title="问题描述" :rightText="viewData.snapshotContent" ></uni-list-item>
			<uni-list-item title="提交人员" :rightText="submitName(viewData)" ></uni-list-item>	
			<view class="attach-wrap">
				<view class="lable">附件</view>
				<view class="attach-cont">
					<image :src="attach.fileUrl" class="attach" mode="widthFix" v-for="(attach,index) in viewData.attachList" @click="showImg(index,viewData.attachList)"></image>							
				</view>		
			</view>
		</view>
		<uni-steps :options="eventList" active-color="#007AFF" :active="active" direction="column" />
		<button type="primary" @click="handle" class="submit-BT" v-if="handVisable">处理</button>	
	</view>
</template>

<script>	
   import { getSnapshotById } from '@/api/aqpt/snapshotApi'
   import { getTaskEventByTaskId } from '@/api/system/taskEventApi'
	export default {
		data() {
			return {
				active:0,
				snapshotId:undefined,
				eventList:[],
				viewData:{},
				handVisable:false
			}
		},
		onLoad(options) {
			this.snapshotId=options.id	
			this.getTaskEventByTaskId()
			this.getSnapshotById()
		},
		methods: {
			snapshotStatus(val){
			  if (val >= 0) {
				const strs = [
				  '待处理',
				  '已处理'
				]
				return strs[val]
			  } else {
				return '已撤销'
			  }
			},
			submitName(viewData){
				if(!viewData.wxId){
					return `${ viewData.submitGroupName } - ${ viewData.submitAccountName }( ${ viewData.submitPositionName } )`
				}
				return  viewData.wxName
			},
			getTaskEventByTaskId(){
				getTaskEventByTaskId(this.snapshotId).then((res)=>{
					let eventList=res.data.map((item)=>{
						let remark=item.remark?item.remark:''
						return{
							title:item.eventTime,
							desc:`${item.eventTitle} \n ${remark}`
						}
					})
					this.eventList=eventList
				})
			},
			getSnapshotById(){
				getSnapshotById(this.snapshotId).then((res)=>{
					this.viewData=res.data
					this.handVisable=uni.getStorageSync('wxId')===(res.data.wxId||res.data.handleAccountId)
				})
			},
			showImg(current,attachList){
				let urls=attachList.map(item=>{
					return item.fileUrl
				})
				uni.previewImage({
					urls,
					current
				})
			},
			handle(){
				uni.redirectTo({
					url:`/pages/app_views/problem_feedback/form/form?id=${this.snapshotId}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.wrap{
	padding: 32rpx;
	padding-bottom: 200rpx;
	.submit-BT {
		width: 750rpx;
		height:156rpx;
		line-height:88rpx;
		color: #4D73FF;
		text-align: center;
		font-size: 32rpx;
		padding-bottom: 68rpx;
		background-color: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 99;
		box-shadow: 0px 0px 12px 0px #0000000A;
		border-radius: 8px 8px 0px 0px
	}
	.attach-wrap{
		padding:0 20rpx 20rpx 20rpx;
		.lable{
			font-size: 14px;
			color: #3b4144;
			overflow: hidden;	
			text-indent: 8px;
		}
		.attach-cont{
			display: flex;
			flex-wrap: wrap;
			.attach{
				display: block;
				width: 100rpx;
				height: 100rpx;
				margin: 15rpx;
			}			
		}
	}
}
</style>
