<template>
	<div class="content-main">
		<el-form :inline="true" :model="searchForm" class="search-bm-boder">
			<el-form-item label="注册地点:">
				<el-select v-model="searchForm.zt" 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 label="隶属于:">
				<el-select v-model="searchForm.zt" 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-row v-show="searchShowMoreBool">
				<el-form-item label="隶属于:">
					<el-select v-model="searchForm.zt" 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 label="注册地:">
					<el-select v-model="searchForm.zt" 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-row>
		</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="qymc" label="单位名称" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="ssqymc" label="单位类型" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="qyxz" label="单位性质" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="qyszqybhs" label="隶属于" align="center" show-overflow-tooltip>
				<template slot-scope="scope">
					<span>{{scope.row.qyszqybhs&&scope.row.qyszqybhs.join(',')}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="jhsl" 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="ztmc" label="注册时间" align="center" show-overflow-tooltip></el-table-column>
			<el-table-column prop="qyzt" 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="text"
								size="small"
								class="operate_show_btn iconfont iconshenhe"
								@click="onDetail(scope.row,1)"
								v-if="scope.row.ztmc=='待审核'"
							></el-button>
						</el-tooltip>
						<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 iconchaxun 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 { selectList, getStatus } from '@/api/grainReserves/alternationPlanManage/alternationApproval/index.js';
import { list } from '@/api/grainReserves/grainCoManage/coInfo/index.js';
export default {
	data() {
		return {
			searchShowMoreBool: false,
			loading: true,
			pageForm: {
				pageNum: 1,
				total: 0,
				pageSize: 10
			},
			statusOpt: [],
			status: [
				// { code: '91000013', name: '已通过' }, { code: '91000046', name: '自治区驳回' }, { code: '91000043', name: '盟市已通过' }, { code: '91000044', name: '盟市已驳回' }, { code: '91000041', name: '旗县已通过' }, { code: '91000042', name: '旗县已驳回' }, { code: '91000004', name: '待审核' // 已提交 }
			], // 状态
			searchForm: {
				zt: null, // 状态
				sqrq: null // 申请日期
			},
			tableData: []
		}
	},
	created() {
		this.getList();
		// this.getStatus();
	},
	methods: {
		getStatus() {
			var userRoles = sessionStorage.getItem('userRole');
			getStatus(userRoles ? userRoles.split(',') : []).then(res => {
				if (res.infoCode === 200) {
					var status = res.data;
					this.status = res.data;
					var _status = [];
					for (var k in status) {
						_status.push({
							code: k,
							name: status[k]
						})
					}
					this.statusOpt = _status;
				}
			})
		},
		onSearch() {
			this.pageForm.pageNum = 1;
			this.getList();
		},
		getList() {
			this.loading = true;
			let { pageNum, pageSize } = this.pageForm;
			let { zt } = this.searchForm;
			list({
				...this.searchForm,
				pageNum,
				pageSize
				// zt: zt || null
			})
				.then(res => {
					this.loading = false
					if (res.infoCode === 200) {
						this.pageForm.total = res.data.total;
						this.tableData = res.data.list;
						return
					} else {
						this.tableData = [];
						this.pageForm.total = 0;
					}
				})
				.catch(err => {
					this.loading = false;
				})
		},
		onDetail(row, state) {
			this.$router.push({
				path: 'detail',
				query: {
					state: state,
					jhbm: row.jhbm,
					taskId: row.rwid,
					lcid: row.lcid,
					sszz: row.sszz
				}
			})
		},
		handleSizeChange(val) {
			this.pageForm.pageSize = val;
			this.getList();
		},
		handleCurPageChange(val) {
			this.pageForm.pageNum = val;
			this.getList();
		}
	}
}
</script>
