<template>
	<div class="content-main">
		<h2
			style="text-align:center;font-weight:600;padding-top:10px;padding-bottom:10px;"
		>
			企业备案申请新增
		</h2>
		<table
			width="1200"
			cellspacing="1"
			border="2"
			:data="tablemodel"
			style="margin:0 auto"
		>
			<tr>
				<td style="padding:8px;width:80px;">单位名称</td>
				<td colspan="3" style="width:200px;">
					{{ tablemodel.qymc }}
				</td>
				<td style="padding:8px;">企业代码</td>
				<td style="width:200px;">
					{{ tablemodel.dwdm }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">地址</td>
				<td colspan="3" style="width:200px;">
					{{ tablemodel.qygszcd }}
				</td>
				<td style="padding:8px;">邮政编码</td>
				<td style="width:200px;">
					{{ tablemodel.qyyb }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">法定代表人或负责人</td>
				<td>
					{{ tablemodel.fddbr }}
				</td>
				<td style="padding:8px;">联系电话</td>
				<td>
					{{ tablemodel.bgdh }}
				</td>
				<td style="padding:8px;">手机号码</td>
				<td>
					{{ tablemodel.frsjh }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">电子信箱</td>
				<td colspan="3">
					{{ tablemodel.qydzyx }}
				</td>
				<td style="padding:8px;">企业性质</td>
				<td>
					{{ tablemodel.qyxz }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">通讯地址</td>
				<td colspan="3">
					{{ tablemodel.qytxdz }}
				</td>
				<td style="padding:8px;">隶属关系</td>
				<td>
					{{ tablemodel.qylsgx }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">经营范围</td>
				<td colspan="3">
					{{ tablemodel.jyfw }}
				</td>
				<td style="padding:8px;">主营业务</td>
				<td>
					{{ tablemodel.qyzyyw }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">占地面积(平方)</td>
				<td>
					{{ tablemodel.sszdmj }}
				</td>
				<td style="padding:8px;">库区个数(个)</td>
				<td>
					{{ tablemodel.kqsl }}
				</td>
				<td style="padding:8px;">总仓容(吨)</td>
				<td>
					{{ tablemodel.zcr }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">其中有效仓容</td>
				<td>
					{{ tablemodel.yxcr }}
				</td>
				<td style="padding:8px;">需大修仓容</td>
				<td>
					{{ tablemodel.zdxcr }}
				</td>
				<td style="padding:8px;">待报废仓容</td>
				<td>
					{{ tablemodel.dbfcr }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">油罐个数(个)</td>
				<td>
					{{ tablemodel.ygsl }}
				</td>
				<td style="padding:8px;">总罐容(吨)</td>
				<td>
					{{ tablemodel.gr }}
				</td>
				<td style="padding:8px;">其中有效罐容</td>
				<td>
					{{ tablemodel.yxgr }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">从业人员(个)</td>
				<td>
					{{ tablemodel.qycyrys }}
				</td>
				<td style="padding:8px;">其中:保管员(人)</td>
				<td>
					{{ tablemodel.bgyrs }}
				</td>
				<td style="padding:8px;">质量检验员(人)</td>
				<td>
					{{ tablemodel.jhyyrs }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">基本条件</td>
				<td colspan="5" style="padding:8px;">
					<p
						v-for="(item, index) in jbtj"
						:key="index"
						style="text-align:left;"
					>
						{{ item.key }}
						<el-radio-group v-model="item.val" disabled>
							<el-radio label="是"></el-radio>
							<el-radio label="否"></el-radio>
						</el-radio-group>
					</p>
				</td>
			</tr>
			<tr>
				<td style="padding:8px;">单位收储粮油主要品种</td>
				<td colspan="5">
					{{ tablemodel.qysclszypz }}
				</td>
			</tr>
			<tr>
				<td align="center">序号</td>
				<td align="center">库点名称</td>
				<td colspan="2" align="center">库点详细地址</td>
				<td colspan="2" align="center" style="padding:8px;">
					库点仓容(吨)
				</td>
			</tr>
			<tr
				v-for="(item, index) in tablemodel.grainDepot"
				:key="index"
				style="padding:8px 0"
			>
				<td align="center" v-if="index == 0">主库区</td>
				<td align="center" v-if="index > 0">{{ index }}库区</td>
				<td align="center" style="padding:8px 0">
					{{ item.kdmc }}
				</td>
				<td colspan="2" align="center" style="padding:8px 0">
					{{ item.kddz }}
				</td>
				<td colspan="2" align="center" style="padding:8px 0">
					{{ item.kdcz }}
				</td>
			</tr>
			<tr>
				<td style="padding:8px;"></td>
				<td></td>
				<td colspan="2"></td>
				<td colspan="2"></td>
			</tr>
			<tr>
				<td style="padding:8px;">填表人:</td>
				<td>
					{{ tablemodel.tbr }}
				</td>
				<td style="padding:8px;">联系电话:</td>
				<td>
					{{ tablemodel.lxdh }}
				</td>
				<td style="padding:8px;">手机:</td>
				<td>
					{{ tablemodel.sjh }}
				</td>
			</tr>
			<tr>
				<td colspan="6" style="padding:8px 80px;">
					{{
						tablemodel.createDate &&
							tablemodel.createDate.slice(0, 10)
					}}
				</td>
			</tr>
		</table>

		<el-row class="sub_title">
			审核
		</el-row>

		<el-form
			:model="auditData"
			inline
			label-position="right"
			label-width="5em"
		>
			<el-row type="flex" justify="space-around">
				<el-col :span="10">
					<el-form-item label="审核结果">
						<el-radio-group v-model="auditData.shjg">
							<el-radio label="1">通过</el-radio>
							<el-radio label="0">驳回</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-col>
				<el-col :span="10">
					<el-form-item label="审核意见">
						<el-input
							v-model="auditData.shyj"
							style="min-width:300px;"
							clearable
						></el-input
					></el-form-item>
				</el-col>
			</el-row>
			<el-row type="flex" justify="space-around">
				<el-col :span="10">
					<el-form-item label="审核人"
						><el-input
							style="min-width:300px;"
							v-model="auditData.qybashr"
							disabled
						></el-input
					></el-form-item>
				</el-col>
				<el-col :span="10">
					<el-form-item label="审核时间">
						<el-date-picker
							style="min-width:300px;"
							type="date"
							value-format="yyyy-MM-dd"
							format="yyyy-MM-dd"
							disabled
							v-model="auditData.shrq"
						></el-date-picker
					></el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<div
			slot="footer"
			class="dialog-footer"
			style="text-align:center;margin-top:15px;"
		>
			<el-button
				type="primary"
				size="small"
				class="iconfont icontijiao"
				@click="handleSubmit"
				>提交</el-button
			>
			<el-button
				type="primary"
				size="small"
				class="iconfont iconfanhui"
				@click="dialogTableVisible"
				>返回</el-button
			>
		</div>
		<!-- </el-form> -->
	</div>
</template>

<script>
// import { selectPageByEntity, deleteByEntity, saves } from '@/api/grainReserves/outInManagement/outInAccApply/index'
// import { getPzOptions } from '@/api/grainReserves/rotationPlanImple/rotationPrice'
import {
	detail,
	audit
} from '@/api/grainCoManage/warehousingLogistics/dynamicFiling/index.js'
import { getNowDate } from '@/utils/index'
export default {
	data() {
		return {
			tablemodel: {},
			qyxzs: [],
			auditData: {},
			isXian: false,
			isQu: false,
			id: '',
			jbtj: [
				{
					key:
						'拥有固定经营场地,符合有关污染源,危险源安全距离的规定:',
					val: ''
				},
				{
					key:
						'拥有与从事粮油仓储活动相适应的设施设备,并符合粮油储藏技术规范的要求:',
					val: ''
				},
				{
					key: '拥有相应的专业技术管理人员:',
					val: ''
				}
			],
			auditData: {
				lx: 'c',
				lxId: '',
				shr: sessionStorage.userName,
				qybashr: sessionStorage.userName,
				shrq: getNowDate(),
				qybm: '1',
				qymc: '',
				shyj: '',
				shjg: '1'
			}
			//0，驳回，1，通过
		}
	},
	created() {
		let code = sessionStorage.orgCode + ''
		// 5,8,11,14
		// 区(省),市,县,企业
		this.isXian = code.length == 11
		this.isQu = code.length == 8
		let { page, id ,state} = this.$route.query
		this.id = id
		this.auditData.lxId = id
		this.auditData.qybabh = id
		this.auditData.dqsh = state
		this.auditData.userCodes=[];
		let userRole = sessionStorage.getItem("userRole").split(",")
		for(let item in userRole){
			this.auditData.userCodes.push(userRole[item])
		}
		// console.log(this.auditData.userCodes)
		// this.auditData.userCodes.push(sessionStorage.getItem("userCode"))
		if (page == 'add') {
			this.initAdd()
		} else {
			this.getDetail()
		}

		let name = sessionStorage.userName

		// if (this.$route.query.type === 'detail') {
		// }
	},
	directives: {},
	methods: {
		getDetail() {
			detail(this.id).then((res) => {
				if (res.infoCode == 200) {
					console.info(
						'detail',
						JSON.stringify(res.data, ['jbtj'], 4)
					)
					this.tablemodel = res.data
					if (res.data.jbtj) {
						this.jbtj = JSON.parse(res.data.jbtj)
					}
				}
			})
		},
		initAdd() {
			initAdd(sessionStorage.tyshxydm).then((res) => {
				console.info('initadd', res.data)
				if (res.infoCode == 200) {
					let { jbtj } = res.data
					if (jbtj) {
						try {
							this.jbtj = JSON.parse(jbtj)
						} catch (err) {
							console.info('基本条件返回错误', err.msessage)
						}
					}
					this.tablemodel = {
						...res.data,
						createDate: getNowDate(),
						creator: sessionStorage.userName
					}
				}
			})
		},
		dialogTableVisible() {
			this.$router.push('index')
		},
		handleSubmit() {
			audit(this.auditData).then((res) => {
				if (res.infoCode == 200) {
					this.$message.success(res.msg)
					this.$router.push('index')
				} else {
					this.$message.error('操作失败')
				}
			})
		},
		// 保存
		saveSubmit() {},
		// 提交
		sendSubmit() {},
		// 取消
		cancelSubmit() {
			this.$router.push({ path: '/basq/qybasq' })
		}
	}
}
</script>
<style lang="scss" scoped>
$content_width: 90%;
table {
	border-collapse: collapse;
	margin: 0 auto;
	text-align: center;
	width: $content_width;
	tr {
		th {
			text-align: center;
			padding: 8px 0;
			font-weight: 500;
		}
		td:first-child {
			text-align: right;
			padding-right: 10px;
		}
	}
	&.audit {
		td {
			padding: 8px 0;
			&:first-child {
				text-align: center;
			}
		}
	}
}
.footer_btn {
	text-align: center;
	margin: 20px;
}
.sub_title {
	height: 2.5em;
	line-height: 2.5em;
	color: white;
	text-align: center;
	margin: 20px auto;
	width: $content_width;
	background-color: #49a2fa;
}
</style>
