<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.CODE" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="申请时间" prop="ENDTIME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.CREATE_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="申请部门" prop="Nav_Project.NAME" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.Nav_Department.NAME" border="none" inputAlign="right" fontSize="14px" v-if="model.Nav_Department"></u--input>
				</u-form-item>
				<u-form-item label="申请人员" prop="USER_ID" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.Nav_User.NAME" border="none" inputAlign="right" fontSize="14px" v-if="model.Nav_User"></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_DeviceBase.NAME" border="none" inputAlign="right" v-if="model.Nav_DeviceBase"></u--input>

				</u-form-item>
				<u-form-item label="设备编号" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.Nav_DeviceBase.MACHINE_CODE" border="none" inputAlign="right" fontSize="14px" v-if="model.Nav_DeviceBase">
					</u--input>
				</u-form-item>
				<u-form-item label="规格/型号" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.Nav_DeviceBase.SPEC" border="none" inputAlign="right" fontSize="14px" v-if="model.Nav_DeviceBase">
					</u--input>
				</u-form-item>
				<u-form-item label="存放位置" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.Nav_DeviceBase.POSITION" border="none" inputAlign="right" fontSize="14px" v-if="model.Nav_DeviceBase">
					</u--input>
				</u-form-item>
				<u-form-item label="报废原因" prop="POSITION" borderBottom>
					<u--input disabled disabledColor="#ffffff" v-model="model.REASON" 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!==2&&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 {
		DMDeviceScrap,
		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.loadData()
		},
		methods: {
			loadData() {
				const json = initFilter(this.ORG_ID)
				extendRule(json, 'ID', 1, this.ID);
				extendInclude(json, 'Nav_Department');
				extendInclude(json, 'Nav_User');
				extendInclude(json, 'Nav_DeviceBase');
				extendIgnoreDataRule(json)
				DMDeviceScrap(json).then(res => {
					this.model = res
					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>