<template>
	<div class="content-main">
		<el-row>
			<el-form :inline="true" :model="formInline" class="search-bm-boder" label-width="6em">
				<el-row>
					<el-form-item label="单位名称:">
						<el-input clearable v-model="formInline.qymc" placeholder="请输入" style="width:170px;"></el-input>
					</el-form-item>
					<el-form-item label="企业性质:">
						<el-input clearable v-model="formInline.qyxz" placeholder="请输入"></el-input>
					</el-form-item>
					<el-form-item label="经营范围:">
						<el-input clearable v-model="formInline.jyfw" placeholder="请输入"></el-input>
					</el-form-item>
					<el-form-item>
						<div class="search-button">
							<span class="search-line"></span>
							<div
								class="search-select"
								@click="
									searchShowMoreBool = !searchShowMoreBool
								"
							>
								更多条件
								<i class="el-icon-arrow-up" v-show="searchShowMoreBool"></i>
								<i class="el-icon-arrow-down" v-show="!searchShowMoreBool"></i>
							</div>
							<el-button type="primary" @click="onSearch" size="small" class="iconfont iconchaxun">查询</el-button>
							<el-button
								type="primary"
								@click="
									formInline = {}
									onSearch()
								"
								size="small"
								class="iconfont iconzhongzhi"
							>重置</el-button>
						</div>
					</el-form-item>
				</el-row>
				<el-row v-show="searchShowMoreBool">
					<el-form-item label="地址:">
						<el-input v-model="formInline.dz" style="width:170px;" placeholder="请输入" clearable></el-input>
						<!-- <el-select clearable v-model="formInline.lspzbm" placeholder="请选择">
							<el-option v-for="item in option2" :key="item.value" :label="item.label" :value="item.value"></el-option>
						</el-select>-->
					</el-form-item>
					<el-form-item label="状态:">
						<el-select clearable v-model="formInline.zt" placeholder="请选择">
							<el-option v-for="(item, index) in sfbas" :key="index" :label="item" :value="index"></el-option>
						</el-select>
					</el-form-item>
				</el-row>
			</el-form>
		</el-row>
		<el-row>
			<el-table
				:data="tableData"
				stripe
				v-loading="listLoading"
				border
				fit
				highlight-current-row
				style="width: 100%"
			>
				<el-table-column align="center" label="序号" width="70">
					<template slot-scope="scope">
						<span>{{ scope.$index + 1 }}</span>
					</template>
				</el-table-column>
				<el-table-column align="center" prop="qymc" label="单位名称" show-overflow-tooltip>
					<template slot-scope="scope">{{ scope.row.qymc }}</template>
				</el-table-column>
				<el-table-column align="center" prop="kdyxcr" label="有效仓容">
					<template slot-scope="scope">{{ scope.row.yxcr }}</template>
				</el-table-column>
				<el-table-column align="center" prop="yxgr" label="有效罐容">
					<template slot-scope="scope">{{ scope.row.yxgr }}</template>
				</el-table-column>
				<el-table-column align="center" prop="dwdm" label="企业代码" show-overflow-tooltip>
					<template slot-scope="scope">{{ scope.row.dwdm }}</template>
				</el-table-column>
				<el-table-column align="center" prop="dwlx" label="企业性质">
					<template slot-scope="scope">{{ scope.row.qyxz }}</template>
				</el-table-column>
				<el-table-column align="center" prop="zczb" label="注册资本（万元）">
					<template slot-scope="scope">{{ scope.row.zczb }}</template>
				</el-table-column>
				<el-table-column align="center" prop="fddbr" label="法人代表">
					<template slot-scope="scope">
						{{
						scope.row.fddbr
						}}
					</template>
				</el-table-column>
				<el-table-column align="center" prop="jyfw" label="经营范围" show-overflow-tooltip>
					<template slot-scope="scope">{{ scope.row.jyfw }}</template>
				</el-table-column>
				<el-table-column align="center" prop="qytxdz" label="地址" show-overflow-tooltip>
					<template slot-scope="scope">
						{{
						scope.row.qytxdz
						}}
					</template>
				</el-table-column>
				<el-table-column align="center" prop="sfba" label="是否变更">
					<template slot-scope="scope">{{ scope.row.sfbg }}</template>
				</el-table-column>
				<el-table-column align="center" prop="sfznhsjgz" label="是否停（歇）业">
					<template slot-scope="scope">
						{{
						scope.row.sftxy
						}}
					</template>
				</el-table-column>
				<el-table-column align="center" prop="qyzt" label="状态">
					<template slot-scope="scope">
						{{
						scope.row.sfbamc
						}}
					</template>
				</el-table-column>
				<el-table-column align="center" label="操作" width="200">
					<template slot-scope="scope">
						<el-tooltip class="item" effect="light" content="查看" placement="top">
							<el-button
								@click="addApply('detail', scope.row.qybabh,scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_show_btn iconfont iconchakan2"
							></el-button>
						</el-tooltip>
						<!-- 自治区审核 -->
						<el-tooltip
							class="item"
							effect="light"
							content="备案审核"
							placement="top"
							v-if="scope.row.sfbamc == '待自治区审核' && orgLength == 5"
						>
							<el-button
								@click="addApply('audit', scope.row.qybabh, scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_edit_btn iconfont iconshenhe"
							></el-button>
						</el-tooltip>
						<!-- 盟市审核 -->
						<el-tooltip
							class="item"
							effect="light"
							content="备案审核"
							placement="top"
							v-if="scope.row.sfbamc == '待盟市审核' && orgLength == 8"
						>
							<el-button
								@click="addApply('audit', scope.row.qybabh, scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_edit_btn iconfont iconshenhe"
							></el-button>
						</el-tooltip>
						<!-- 旗县审核 -->
						<el-tooltip
							class="item"
							effect="light"
							content="备案审核"
							placement="top"
							v-if="scope.row.sfbamc == '待旗县审核' && orgLength == 11"
						>
							<el-button
								@click="addApply('audit', scope.row.qybabh, scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_edit_btn iconfont iconshenhe"
							></el-button>
						</el-tooltip>
						<!-- <el-tooltip class="item" effect="light" content="删除" placement="top">
							<el-button
								@click="deleteData(scope.row)"
								type="primary"
								size="small"
								class="operate_delete_btn iconfont iconshanchu"
							></el-button>
						</el-tooltip>-->
						<el-tooltip
							class="item"
							effect="light"
							content="变更审核"
							placement="top"
							v-if="
								scope.row.sfbamc == '备案变更待审核' &&
									scope.row.isModify
							"
						>
							<el-button
								@click="addApply('change', scope.row.qybabh,scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_edit_btn iconfont iconzhuangtaixiugai"
							></el-button>
						</el-tooltip>
						<el-tooltip
							class="item"
							effect="light"
							content="停（歇）业登记审核"
							placement="top"
							v-if="
								scope.row.sfbamc == '停歇业待审核' &&
									scope.row.isStopIndustry
							"
						>
							<el-button
								@click="addApply('shutreg', scope.row.qybabh,scope.row.sfba)"
								type="primary"
								size="small"
								class="operate_edit_btn iconfont iconqianzhang"
							></el-button>
						</el-tooltip>
					</template>
				</el-table-column>
			</el-table>
		</el-row>
		<el-row>
			<el-pagination
				@size-change="handleSizeChange"
				@current-change="handleCurrentChange"
				:current-page.sync="pageForm.page"
				:page-sizes="[10, 20, 30, 40]"
				:page-size="pageForm.size"
				layout="total, sizes, prev, pager, next, jumper"
				:total="pageForm.total"
			></el-pagination>
		</el-row>
		<el-dialog title="验收申请选择" :visible.sync="centerDialogVisible" width="30%" center>
			<el-select clearable style="width: 100%;" v-model="yslx" placeholder="请选择">
				<el-option
					v-for="item in yslxList"
					:key="item.dictCode"
					:label="item.dictName"
					:value="item.dictCode"
				></el-option>
			</el-select>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="addDetail">确 认</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
// import { selectPageByEntity, deleteByEntity } from '@/api/grainReserves/outInManagement/outInAccApply/index'
import { list } from '@/api/grainCoManage/warehousingLogistics/dynamicFiling/index.js'
// import { getPzOptions } from '@/api/grainReserves/rotationPlanImple/rotationPrice'
const sfbas = [
	'未备案',
	'待提交',
	'待旗县审核',
	'已驳回',
	'已备案',
	'备案变更未提交',
	'备案变更待审核',
	'备案变更驳回',
	'备案变更审核通过',
	'停歇业未提交',
	'停歇业待审核',
	'停歇业驳回',
	'停歇业审核通过',
	'待盟市审核',
	'待自治区审核'
]
export default {
	data() {
		return {
			orgLength:"",
			searchShowMoreBool: false,
			pzOptions: [],
			yslxList: [
				{ dictCode: '1', dictName: '包干入库' },
				{ dictCode: '2', dictName: '兜底入库' },
				{ dictCode: '3', dictName: '兜底出库' }
			],
			centerDialogVisible: false,
			yslx: '',
			formInline: {
				rkccmc: '',
				htbh: '',
				lspzbm: ''
			},
			listLoading: false,
			tableData: [],
			pageForm: {
				page: 1,
				size: 10,
				total: 0
			},
			qybm: '',
			sfbas: [
				'未备案',
				'待提交',
				'待旗县审核',
				'已驳回',
				'已备案',
				'备案变更未提交',
				'备案变更待审核',
				'备案变更驳回',
				'备案变更审核通过',
				'停歇业未提交',
				'停歇业待审核',
				'停歇业驳回',
				'停歇业审核通过',
				'待盟市审核',
				'待自治区审核'
			]
		}
	},
	created() {
		if(sessionStorage.getItem("orgCode").length == 5){
			this.orgLength = 5
		}else if(sessionStorage.getItem("orgCode").length == 8){
			this.orgLength = 8
		}else if(sessionStorage.getItem("orgCode").length == 11){
			this.orgLength = 11
		}
		// alert(this.orgLength)
		var codelen = String(sessionStorage.orgCode).length
		if (codelen == 5) this.qybm = 3
		if (codelen == 8) this.qybm = 2
		if (codelen == 11) this.qybm = 1
		// this.qybm = 3
		this.getList()
	},
	methods: {
		onSearch() {
			this.pageForm.page = 1
			this.getList()
		},
		getList() {
			let data = {
				...this.formInline,
				pageSize: this.pageForm.size,
				pageNum: this.pageForm.page,
				qybm: this.qybm
			}
			list(data).then((res) => {
				if (res.infoCode == 200) {
					this.pageForm.total = res.data.total
					var list = res.data.items
					list.forEach((d) => {
						d.sfbamc = sfbas[d.sfba]
					})
					this.tableData = list
				} else {
					this.$message.error(res.msg)
				}
			})
		},
		addApply(pages, id, state) {
			this.$router.push({
				path: pages,
				query: { page: pages, id: id, state: state }
			})
		},
		addDetail() {
			this.centerDialogVisible = false
			this.$router.push({
				name: 'outInAccApplyDetail',
				query: { yslx: this.yslx, detail: 0 }
			})
		},
		handleClick(row, state) {
			this.$router.push({
				path: '/basq/qybasq-detail',
				query: { page: pages }
			})
			// this.centerDialogVisible = false;
			// if(state == 0){
			//   this.$router.push({name:'outInAccApplyDetail',query: {yslx: row.yslx,detail:1,ysid:row.ysid,shzt: row.shzt}})
			// }else if(state == 1){
			//   this.$router.push({name:'outInAccApplyDetail',query: {yslx: row.yslx,detail:0,ysid:row.ysid,shzt: row.shzt}})
			// }else{
			//   this.$router.push({name:'outInAccApplyDetail',query: {yslx: row.yslx,detail:1,ysid:row.ysid,signFlag: 1,shzt: row.shzt}})
			// }
		},
		deleteData(row) {
			deleteByEntity(row.ysid).then((res) => {
				if (res.infoCode == 200) {
					this.$message({
						message: '删除成功',
						type: 'success'
					})
					this.getList()
				} else {
					this.$message.error(res.msg)
				}
			})
		},
		handleSizeChange(val) {
			this.pageForm.size = val
			this.getList()
		},
		handleCurrentChange(val) {
			this.pageForm.page = val
			this.getList()
		}
	}
	// beforeCreate() {
	// 	getPzOptions(11).then((res) => {
	// 		this.pzOptions = res.data
	// 	})
	// }
}
</script>
