<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="Nav_Project.NAME" borderBottom>
					<u--input disabledColor="#fff" disabled v-model="model.CODE" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="申购部门" prop="Nav_Project.NAME" borderBottom>
					<u--input disabledColor="#fff" disabled v-if="model.Nav_Department" v-model="model.Nav_Department.NAME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
				<u-form-item label="申购人" prop="USER_ID" borderBottom>
					<u--input disabledColor="#fff" disabled 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="USER_ID" borderBottom>
					<u--input disabledColor="#fff" disabled v-model="model.CREATE_TIME" border="none" inputAlign="right" fontSize="14px"></u--input>
				</u-form-item>
			</u--form>
			<u--form labelPosition="left" labelWidth="auto" labelAlign="center" errorType="border-bottom" ref="sForm" class="sub-form" style="margin-top: 10px;">
				<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>

				<uni-collapse :border="false" accordion>
					<view v-for="(item, index) in model.Nav_Details" :key="index">
						<uni-collapse-item title-border="none" :border="false">
							<template v-slot:title>
								<view class="uni-collapse-item__title-box">
									<view class="uni-collapse-item__title-text">
										{{index+1+'.'+item.DEVICE_TYPEShow}}
									</view>
								</view>
							</template>
							<view class="content">

								<u-form-item class="subRequired" required label="类别" prop="DEVICE_TYPE" borderBottom>
									<u--input disabled disabledColor="#fff" fontSize="14px" v-model="item.DEVICE_TYPEShow" border="none" inputAlign="right">
									</u--input>
								</u-form-item>
								<u-form-item class="subRequired" required label="设备名称" prop="Nav_Device.NAME" borderBottom>
									<u--input disabled fontSize="14px" disabledColor="#fff" v-if="item.Nav_Device" v-model="item.Nav_Device.NAME" border="none" inputAlign="right"></u--input>
								</u-form-item>
								<u-form-item class="subRequired" required label="系统分类" prop="Nav_Category.NAME" borderBottom> <u--input disabled fontSize="14px" disabledColor="#fff" v-if="item.Nav_Category"
										v-model="item.Nav_Category.NAME" border="none" inputAlign="right"></u--input></u-form-item>
								<u-form-item class="subRequired" required label="类型" prop="Nav_Type.NAME" borderBottom> <u--input disabled fontSize="14px" disabledColor="#fff" v-if="item.Nav_Type"
										v-model="item.Nav_Type.NAME" border="none" inputAlign="right"></u--input></u-form-item>
								<u-form-item label="是否为应急物资" prop="IS_EMERGENCY" borderBottom> <u--input disabledColor="#ffffff" v-model="item.IS_EMERGENCYShow" border="none" inputAlign="right" fontSize="14px"
										disabled></u--input></u-form-item>
								<u-form-item label="设备设施需求描述" prop="REMARK" borderBottom> <u--input disabledColor="#ffffff" v-model="item.REMARK" border="none" inputAlign="right" fontSize="14px" disabled></u--input>
								</u-form-item>
								<u-form-item label="数量" prop="QTY" borderBottom> <u--input disabled disabledColor="#ffffff" v-model="item.QTY" border="none" inputAlign="right" fontSize="14px"></u--input>
								</u-form-item>
								<u-form-item label="单位" prop="UNIT" borderBottom> <u--input disabled disabledColor="#ffffff" v-model="item.UNIT" border="none" inputAlign="right" fontSize="14px"></u--input>
								</u-form-item>
								<view class="upload-title">设备设施资料附件</view><full-upload v-model="item.Nav_Files" :isShowBtn="false" :listProp="listPropUpload" :listPropVal="listPropValUpload"></full-upload>

							</view>


						</uni-collapse-item>
					</view>
				</uni-collapse>
			</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 {
		DMDBPShowGet
	} 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': "DMDeviceTypeEnum"
				}
				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.loadData()
				})
			},
			transLevel(level) {
				if (level == 0) {
					return '否';
				}
				if (level == 1) {
					return '是 ';
				}
			},
			loadData() {
				const json = initFilter(this.ORG_ID)
				extendRule(json, 'ID', 1, this.ID);
				extendIgnoreDataRule(json)
				extendInclude(json, 'Nav_Department');
				extendInclude(json, 'Nav_User');
				extendInclude(json, 'Nav_Details');
				extendInclude(json, 'Nav_Details.Nav_Department');
				extendInclude(json, 'Nav_Details.Nav_User');
				extendInclude(json, 'Nav_Details.Nav_Post');
				extendInclude(json, 'Nav_Details.Nav_Device');
				extendInclude(json, 'Nav_Details.Nav_Category');
				extendInclude(json, 'Nav_Details.Nav_Type');
				extendInclude(json, 'Nav_Details.Nav_Files');
				extendInclude(json, 'Nav_Details.Nav_Files.Nav_ImgFile');
				extendInclude(json, 'Nav_Details.Nav_ReceiptFiles');
				extendInclude(json, 'Nav_Details.Nav_ReceiptFiles.Nav_ImgFile');
				DMDBPShowGet(json).then(res => {
					this.model = res
					// if (this.model.STATUS == 30) {
					// 	this.isSign = true;
					// 	this.isAudit = false;
					// } else if (this.model.STATUS == 20) {
					// 	this.isSign = false;
					// 	this.isAudit = true;
					// }
					this.model.Nav_Details.map(item => {
						item.DEVICE_TYPEShow = this.listISORNOT.find(items => items.code === item.DEVICE_TYPE).name;
						item.IS_EMERGENCYShow = item.IS_EMERGENCY ? '是' : '否'
					})
					this.isLoadOK = true
				})
			},
			onTableBtnAgree() {
				const json = initFilter(this.ORG_ID)
				json.Parameter1 = this.ID;
				json.Parameter2 = this.TaskID;
				json.Parameter3 = uni.getStorageSync('appInfo')?.User?.ID || ''
				WBRecordSign(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>