<template>
	<view class="page-wrap">
		<view class="list-wrap">
			<view class="content">
				<view class="field">
					<view class="title">编号：</view>
					<view class="value">{{dataSource.CODE}}</view>
				</view>
				<view class="field">
					<view class="title">作业环节：</view>
					<view class="value">{{dataSource.Nav_OperationStep ? dataSource.Nav_OperationStep.NAME : ''}}</view>
				</view>
				<view class="field">
					<view class="title">相关岗位：</view>
					<view class="value">{{dataSource.POST}}</view>
				</view>
				<view class="field">
					<view class="title">是否关键任务：</view>
					<view class="value">{{dataSource.IS_IMPORTANT === 1 ? '是' : '否'}}</view>
				</view>
				<view class="field">
					<view class="title">作业许可类别：</view>
					<view class="value">{{dataSource.Nav_WorkPermitType ? dataSource.Nav_WorkPermitType.NAME : ''}}</view>
				</view>
				<view class="field">
					<view class="title">许可作业审批层级：</view>
					<view class="value">{{numConversionZh(dataSource.AUDIT_LEVEL)}}</view>
				</view>
				<view class="field">
					<view class="title">作业前安全确认：</view>
					<view class="value">
						<view class="list" v-for="(item, key) in dataSource.Nav_SafeConfirms" :key="key">
							{{`${key + 1}. ${item.NAME}`}}
						</view>
					</view>
				</view>
				<view class="field">
					<view class="title">作业流程及安全措施：</view>
					<view class="value">
						<view class="list" v-for="(item, key) in dataSource.Nav_SafeMeasures" :key="key">
							{{`${key + 1}. ${item.NAME}`}}
						</view>
					</view>
				</view>
				<view class="field">
					<view class="title">作业后处理措施：</view>
					<view class="value">
						<view class="list" v-for="(item, key) in dataSource.Nav_DealMeasures" :key="key">
							{{`${key + 1}. ${item.NAME}`}}
						</view>
					</view>
				</view>
				<view class="field">
					<view class="title">添加时间：</view>
					<view class="value">{{dataSource.CREATE_TIME}}</view>
				</view>
				<view class="field">
					<view class="title">状态：</view>
					<view class="value">{{dataSource.STATUS === 0 ? '启用' : '停用'}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		initFilter,
		extendRule,
		extendInclude
	} from '../../../../utils/common'

	import {
		getOperationLinkGetEdit
	} from '../../../../services/apply/HMServices/HMServices.js'

	export default {
		data() {
			return {
				dataSource: {},
				filterModel: {
					operationStep: {},
					TASK_LEVEL: {},
					IS_IMPORTANT: {},
					STATUS: {},
					AUDIT_LEVEL: {},
					CYCLE_TYPE: {},
					POST: {}
				}
			}
		},
		onLoad(option) {
			this.currId = option.id
			this.loadData(option.id)
		},
		methods: {
			async loadData(id) {
				const orgId = uni.getStorageSync('orgId')
				const json = initFilter(orgId, "", "", 0, 1)
				extendRule(json, 'ID', 1, id)
				getOperationLinkGetEdit(json).then(res => {
					if (res.IsSuccessful) {
						this.dataSource = res.Data
					}
				})
			},
			numConversionZh(num) {
				const zh = ['', '一', '二', '三', '四', '五', '六', '七', '八']
				if (num === 0) {
					return '无审批层级'
				}
				return zh[num] + '级审批'
			},
			typeConversionText(type) {
				const text = ['', '一般任务', '关键任务非许可作业', '许可作业']
				return text[type]
			},
			cycleConversionText(cycle) {
				switch(cycle) {
					case 0:
					return '需求作业';
					case 10:
					return '每日作业';
					default:
					return ''
				}
			}
		}
	}
</script>


<style scoped>
	@import url("../../../../style/css/editTemplate.css");
	.filter-form {
		padding: 16px;
	}
	.filter-row {
		margin-bottom: 8px;
	}
	.filter-field-title {
		font-size: 14px;
		color: #8f9ca2;
		margin-bottom: 8px;
		display: flex;
		flex-direction: row;
	}
	.search-bar {
		margin-bottom: 10px;
		text-align: right;
	}
	.btn-groups {
		display: flex;
		justify-content: space-between;
	}
	.btn-groups button {
		width: 48%;
	}
	.content-list {
		padding: 10px 0;
	}

	.content .field {
		font-size: 14px;
		margin-bottom: 12px;
		line-height: 22px;
		border-bottom: 1px solid #c9c9c9;
		padding-bottom: 12px;
	}

	.content .field .title {
		color: #333;
		font-size: 16px;
		font-weight: 500;
		line-height: 22px;
		margin-bottom: 8px;
	}

	.content .field .value {
		color: #666666;
		font-size: 14px;
		font-weight: 400;
		line-height: 22px;
	}
</style>
