<template>
	<view>
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" leftText="详情" @clickLeft="back">
			<template slot="float">
				<view class="nav-icon-caozuo iconfont icon-caozuo" @click="setOptionShow"></view>
			</template>
		</uni-nav-bar>
		<!-- 进度组件 根据状态显示不同列表  -->
		<popupOper :optionShow="optionShow" @operate="operate" :operationList="operationList"></popupOper>
		<view style="padding-bottom: 110rpx;" v-if="worksheetInfo">
			<uni-collapse ref="collapse">
				<uni-collapse-item :open="false" :typeOpen="1" title="基本信息">
					<view class="bg" >
						<CellInfo label="工单单号" :value="worksheetInfo.code"></CellInfo>
						<CellInfo label="计划单号" :value="worksheetInfo.type.name"></CellInfo>
						<CellInfo label="巡检部门" :value="worksheetInfo.maintainDept"></CellInfo>
						<CellInfo label="保养名称" :value="worksheetInfo.maintainName"></CellInfo>
						<CellInfo label="保养类型" :value="worksheetInfo.maintainType == '1' ? '普通保养' : '润滑保养'"></CellInfo>
						<CellInfo label="保养负责人" :value="worksheetInfo.maintainPrincipal.name"></CellInfo>
						<CellInfo label="保养人员" :value="worksheetInfo.maintainPerson"></CellInfo>
						<CellInfo label="计划开始时间" :value="worksheetInfo.appointTime"></CellInfo>
						<CellInfo label="计划结束时间" :value="worksheetInfo.finishTime"></CellInfo>
						<CellInfo label="创建人" :value="worksheetInfo.creator.name"></CellInfo>
						<CellInfo label="创建部门" value="null"></CellInfo>
						<CellInfo label="创建时间" :value="worksheetInfo.createTime"></CellInfo>
					</view>
				</uni-collapse-item>
			</uni-collapse>
			<!-- 巡点检明细 -->
			<template >
				<CellTip title="保养明细"> </CellTip>
				<OrderDetail
					v-for="item in worksheetInfo.details" :key="item.id" :border="true"
					:value1="item.equipmentName"  :value2="item.equipmentPlace"
					:value3="worksheetInfo.executor.name"  :value4="item.maintainPart"
					
				></OrderDetail>
			</template>
			<!-- 执行信息 -->
			<template>
				<CellTip title="执行信息"> </CellTip>
				<CellInfo label="确认结果" :value="worksheetInfo.mainStatus.name"></CellInfo>
				<CellInfo label="实际开始时间" :value="worksheetInfo.acceptTime"></CellInfo>
				<CellInfo label="实际结束时间" :value="worksheetInfo.endTime"></CellInfo>
			</template>
			<!-- 执行处理结果 -->
			<template>
				<CellTip title="执行处理结果"> </CellTip>
				<OrderDetail  :border="true"
					value1="数控机床"  value2="TO5636633221653"
					value3="通用设备-机床"  value4="DFRTE-896365"
					value5="一车间"  value6="x1"
				></OrderDetail>
			</template>
			
		</view>
	</view>
</template>

<script>
	import {
		get
	} from "@/utils/api.js"
	import CellTip from '@/components/CellTip.vue'
	import CellInfo from '@/components/CellInfo.vue'
	import OrderDetail from '../components/OrderDetail.vue'
	import popupOper from '@/components/PopupOper.vue'
	export default {
		components: {
			popupOper,
			OrderDetail,
			CellTip,
			CellInfo
		},
		data() {
			return {
				pageId:"",
				worksheetInfo: null,
				optionShow: false,
				operationList: [{
						title: '报工',
						class: 'iconfont icon-zhuanpai',
						type: 1
					},
					{
						title: '转派',
						class: 'iconfont icon-zhuanpai',
						type: 2
					}
				],
			}
		},
		onLoad(options) {
			this.pageId = options.id;
			this.getInfo();
		},
		methods: {
			getInfo(){
				get(this.apiUrl+ "/maintain/worksheet/info",{id: this.pageId}).then(res=>{
					console.log(res)
					this.worksheetInfo = res.data;
				})
			},
			//选择对应的操作
			operate(type) {
				if (type === 2) { //转派
					uni.navigateTo({
						url: "../turn_send/turn_send?id=" + this.pageId
					})
				} else if (type === 1) { //报工
					uni.navigateTo({
						url: "../submitted_ministry/submitted_ministry?id=" + this.pageId
					})

				}
			},
			//点击显示弹窗
			setOptionShow() {
				this.optionShow = !this.optionShow;
			},
			
		}
	}
</script>

<style>

</style>
