<template>
	<div class="content-main">
		<el-form :inline="true" :model="searchForm" class="search-bm-boder">
			<el-form-item label="企业名称">
				<el-input v-model="searchForm.qymc" clearable></el-input>
			</el-form-item>
			<el-form-item label="审核状态">
				<el-select v-model="searchForm.shzt" clearable>
					<el-option
						v-for="item in statusOpt"
						:key="item.code"
						:value="item.code"
						:label="item.name"
					></el-option>
				</el-select>
			</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="searchForm = {}" size="small" class="iconfont iconzhongzhi"
						>重置</el-button
					>
				</div>
			</el-form-item>
		</el-form>
		<el-table border :data="tableData" stripe style="width:100%" v-loading="loading">
			<el-table-column type="index" label="序号" align="center" width="60"></el-table-column>
			<!-- <el-table-column prop="sqbm" label="申请编码" align="center" show-overflow-tooltip></el-table-column> -->
			<el-table-column prop="qymc" label="企业名称" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column
				prop="tyshxydm"
				label="社会信用代码"
				align="center"
				show-overflow-tooltip
			></el-table-column>
			<el-table-column prop="fddbr" label="法定代表人" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="qylxr" label="联系人" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="bgdh" label="联系电话" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="qyztmc" label="审核状态" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="index" label="操作" align="center" width="150">
				<template slot-scope="scope">
					<span>
						<el-tooltip class="item" effect="light" content="审核" placement="top">
							<el-button
								type="primary"
								size="small"
								class="operate_show_btn iconfont iconshenhe"
								@click="onDetail(scope.row, 1)"
								v-if="scope.row.shzt == 0"
							></el-button>
						</el-tooltip>
						<!-- <el-button v-if="scope.row.ztmc=='待审核'" type="text" class="iconfont iconxiugai" size="small" @click="onDetail(scope.row,1)">审核</el-button>
						<el-button type="text" class="iconfont iconchaxun" size="small" @click="onDetail(scope.row,2)">查看</el-button>-->
						<el-tooltip class="item" effect="light" content="查看" placement="top">
							<el-button
								type="primary"
								size="small"
								class="iconfont iconchakan2 operate_show_btn"
								@click="onDetail(scope.row, 2)"
							></el-button>
						</el-tooltip>
					</span>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			@size-change="handleSizeChange"
			@current-change="handleCurPageChange"
			:current-page="pageForm.pageNum"
			:page-sizes="[10, 20, 30, 40]"
			:page-size="100"
			layout="total, sizes, prev, pager, next, jumper"
			:total="pageForm.total"
		></el-pagination>
	</div>
</template>

<script>
import { list } from '@/api/grainCoManage/coInfoAudit/index.js'

const qyzts = {
	// 0: '注销',
	// 1: '正常',
	// 2: '待审核',
	// 3: '已驳回'
		2: '待审核',
		3: '已驳回',
		4: '已备案',
		5: '已通过'
}
const shzts = {
	0: '待审核',
	1: '已通过',
	2: '已驳回',
}
export default {
	data() {
		return {
			loading: true,
			pageForm: {
				pageNum: 1,
				total: 0,
				pageSize: 10
			},
			statusOpt: [
				// { name: '待审核', code: 2 },
				// { name: '已驳回', code: 3 },
				// // { name: '已备案', code: 4 },
				// { name: '已通过', code: 5 }
				{ name: '待审核', code: 0 },
				{ name: '已通过', code: 1 },
				{ name: '已驳回', code: 2 },
			],
			searchForm: {
				sfba: null, // 状态
				qymc: null // 企业名称
			},
			tableData: []
		}
	},
	created() {
		this.getList()
	},
	methods: {
		onSearch() {
			this.pageForm.pageNum = 1
			this.getList()
		},
		getList() {
			this.loading = true
			let { pageNum, pageSize } = this.pageForm
			let { zt, sqsj } = this.searchForm
			let orgCode = null
			if(sessionStorage.orgCode.length==5){
				orgCode = null
			}else{
				orgCode = sessionStorage.orgCode
			}
			list({
				...this.searchForm,
				...this.pageForm,
				sslsxzglbm: orgCode,
				// sfbas: [0,1]
			})
				.then((res) => {
					this.loading = false
					if (res.infoCode === 200) {
						var list = res.data.list
						list.forEach((d) => {
							// d.qyztmc = qyzts[d.sfba]
							d.qyztmc = shzts[d.shzt]
						})
						this.tableData = list
						this.pageForm.total = res.data.total
						console.log(res.data.total)
					} else {
						this.tableData = []
						this.pageForm.total = 0
					}
				})
				.catch((err) => {
					this.loading = false
					this.$message.error(err.msg)
				})
		},
		onDetail(row, state) {
			this.$router.push({
				path: 'detail',
				query: {
					state: state,
					tyshxydm: row.tyshxydm
				}
			})
		},
		handleSizeChange(val) {
			this.pageForm.pageSize = val
			this.getList()
		},
		handleCurPageChange(val) {
			this.pageForm.pageNum = val
			this.getList()
		}
	}
}
</script>
