<template>
	<view class="page-wrap" v-bind:style="{paddingBottom:paddingBottom+'px'}">
		<view class="background"></view>
		<view class="card">
			<!-- <uni-card margin="0" :is-shadow="true"> -->
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" :model="model" class="demo-ruleForm">
				<view style="position: relative;">
					<view style="position: absolute;left: -10px;color: #3d4b70;top: -3px;">*</view>
				</view>

				<view style="font-size: 15px; font-weight: bold;color: #3d4b70;margin-bottom: 10px;">基本信息</view>

				<u-form-item label="检修时间" prop="ENDTIME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.OVERHAUL_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="检修人员" prop="ENDTIME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-if="model.Nav_User" v-model="model.Nav_User.NAME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="报修时间" prop="ENDTIME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-if="model.Nav_Repair" v-model="model.Nav_Repair.CREATE_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="报修人" prop="ENDTIME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-if="model.Nav_Repair&&model.Nav_Repair.Nav_User" v-model="model.Nav_Repair.Nav_User.NAME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="设备设施名称" prop="Nav_Device.NAME" borderBottom>
					<u--input disabled disabledColor="#ffffff" fontSize="14px" v-model="model.Nav_Device.NAME" border="none" inputAlign="right" v-if="model.Nav_Device"></u--input>

				</u-form-item>
				<u-form-item label="设备设施编号" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.MACHINE_CODE" border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>
				<u-form-item label="规格/型号" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.SPEC" border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>
				<u-form-item label="设备设施位置" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.POSITION" border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>
				<u-form-item label="故障描述" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.MALFUCTION" border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>

				<u-form-item label="检修意见" prop="Product_Unit" borderBottom>
					<u--input v-model="model.OPINIONShow" disabledColor="#ffffff" disabled border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>
				<u-form-item label="检修情况描述" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.DESCRIPTION" border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>
				<u-form-item label="故障照片" prop="POSITION">
				</u-form-item>
				<full-upload v-model="model.Nav_RepairFiles" :isShowBtn="false" :listProp="listPropUpload" :listPropVal="listPropValUpload"></full-upload>


				<u-form-item label="检修后照片" prop="POSITION">
				</u-form-item>
				<full-upload v-model="model.Nav_Files" :isShowBtn="false" :listProp="listPropUpload" :listPropVal="listPropValUpload"></full-upload>
				<u-form-item label="验收意见" prop="Product_Unit" borderBottom>
					<u--input disabledColor="#ffffff" v-model="model.CHECK_OPINIONShow" disabled border="none" inputAlign="right" fontSize="14px">
					</u--input>
				</u-form-item>

			</u--form>

			<!-- <check-action v-if="isLoadOK&&tableKey==1&&isAudit" :okApi="okApi" :refuseApi="refuseApi" :dataSource="auditModel"></check-action> -->
		</view>
		<view class="bottom-button" style="padding: 10px 16px;" v-if="isLoadOK&&(tableKey==1||tableKey==4)&&this.isSign">
			<u-button type="primary" @click="onTableBtnAgree" color="#3d4b70">审阅</u-button>
		</view>

	</view>
</template>

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

	import {
		DMDeviceOverhaulGet,
		DMDeviceOverhaulSign
	} from '../../../../services/apply/subPages/DM/dm';
	import '../../../../utils/showMsg.js'
	import color from '../../../../uni_modules/uview-ui/libs/config/color'
	import config from '../../../../config/common'
	import {
		getEnum
	} from '../../../../services/common';

	export default {
		data() {
			return {
				model: {
					Nav_Department: {
						NAME: ''
					},
					Nav_User: {
						NAME: ''
					},
					Nav_Details: [{
						Nav_Device: {
							NAME: ''
						},
						Nav_Category: {
							NAME: ''
						},
						Nav_Type: {
							NAME: ''
						},
					}]

				},
				listPropUpload: ['PARENT_ID'],
				listPropValUpload: [],
				paddingBottom: '150',
				TaskID: "",
				tableKey: '0',
				isLoadOK: false,
				isSign: true,
				isAudit: true,
				DEALOPINION: "",
				ORG_ID: uni.getStorageSync('orgId'),
				listISORNOT: [], //是否涉及
				listISORNOTText: [],
			}
		},
		onLoad(option) {
			this.ID = option.ID;
			this.TaskID = option.taskID;
			this.tableKey = option.tableKey ? option.tableKey : '0'
			this.okApi = option.okApi
			this.refuseApi = option.refuseApi
			this.auditModel = {
				...this.$store.state.auditModel,
				TaskID: option.taskID ? option.taskID : ''
			}
			this.getEnums()
		},
		methods: {
			getEnums() {
				var dataParm = {
					'name': "DMRepairOpinionEnum"
				}
				getEnum(dataParm).then(res => {
					this.listISORNOT = res
					this.listISORNOTText = []
					this.listISORNOT.forEach(e => {
						e.name = e.NAME
						e.code = e.ID
						this.listISORNOTText.push(e.NAME)
					})
					this.getConclusion()
				})
			},
			getConclusion() {
				var dataParm = {
					'name': "CheckOptionEnum"
				}
				getEnum(dataParm).then(res => {
					this.listResult = res
					this.listResultText = []
					this.listResult.forEach(e => {
						e.name = e.NAME
						e.code = e.ID
						this.listResultText.push(e.NAME)
			
					})
					this.loadData()
				})
			},
			loadData() {
				const json = initFilter(this.ORG_ID)
				extendRule(json, 'ID', 1, this.ID);
				extendIgnoreDataRule(json)
				DMDeviceOverhaulGet(json).then(res => {
					this.model = res
					this.model.OPINIONShow = this.listISORNOT.find(item => item.code === this.model.OPINION).name
					this.model.CHECK_OPINIONShow = this.listResult.find(item => item.code === this.model.CHECK_OPINION).name
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				const json = {
					ID: this.ID,
					TaskID: this.TaskID
				}
				DMDeviceOverhaulSign(json).then(res => {
					if (res) {
						uni.$showMsgFunc('操作成功!', () => {
							uni.navigateBack()
						}, 'success', 1000)
					}
				})
			}

		}
	}
</script>

<style>
	/* @import url("../../../../style/css/editTemplate.css"); */
	@import url("../../../../style/css/newTemplate.css");
</style>