<template>
	<div>
		<div v-if="isSj" class="content-main">
			<el-row class="addBtnBg">
				<el-button
					type="primary"
					class="iconfont iconxiugai1"
					size="small"
					@click="updateSubmit()"
				>
					更新信息</el-button
				>
			</el-row>
			<el-row>
				<el-table
					:data="tableData"
					stripe
					v-loading="listLoading"
					border
					fit
					highlight-current-row
					style="width: 100%; margin-top: 10px"
				>
					<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="orgname"
						label="单位名称"
						show-overflow-tooltip
					>
					</el-table-column>
					<el-table-column
						align="center"
						prop="tyshxydm"
						label="统一社会信用代码"
						min-width="130"
						show-overflow-tooltip
					>
					</el-table-column>
					<!-- <el-table-column align="center" prop="xzjb" label="行政级别" show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column align="center" prop="gjzrs" label="人员数量" show-overflow-tooltip>
                    </el-table-column> -->
					<el-table-column
						align="center"
						prop="dz"
						label="地址"
						show-overflow-tooltip
					>
					</el-table-column>
					<el-table-column
						align="center"
						label="是否执法队"
						min-width="130"
						show-overflow-tooltip
					>
						<template slot-scope="scope">
							<span v-if="scope.row.sfyzfd === 0">是</span>
							<span v-if="scope.row.sfyzfd === 1">否</span>
						</template>
					</el-table-column>
					<el-table-column align="center" label="操作" width="130">
						<template slot-scope="scope">
							<el-button
								@click="detailSubmit(scope.row.orgid)"
								title="查看"
								type="primary"
								size="small"
								class="operate_show_btn iconfont iconchakan2"
							></el-button>
						</template>
					</el-table-column>
				</el-table>
			</el-row>
			<!--        <el-row>-->
			<!--            <el-pagination-->
			<!--                    @size-change="handleSizeChange"-->
			<!--                    @current-change="handleCurrentChange"-->
			<!--                    :current-page.sync="pageForm.pageNum"-->
			<!--                    :page-sizes="[10,20,30,40]"-->
			<!--                    :page-size="pageForm.pageSize"-->
			<!--                    layout="total, sizes, prev, pager, next, jumper"-->
			<!--                    :total="pageForm.total"-->
			<!--            ></el-pagination>-->
			<!--        </el-row>-->
			<updateInformation
				v-if="updateInformationData.dialogVisible"
				:updateInformationData="updateInformationData"
			/>
		</div>
		<div v-else>
			<updateInformation />
		</div>
	</div>
</template>


<script>
import {
	inspectionUnit,
	getList,
} from '@/api/unitBasicInformationMaintenance/index'
import updateInformation from './components/updateInformation'
export default {
	components: {
		updateInformation,
	},
	data() {
		return {
			updateInformationData: {
				dialogVisible: false,
				code: null,
			},
			listLoading: false,
			tableData: [],
			// pageForm: {
			//     pageNum: 1,
			//     pageSize: 10,
			//     total: 17
			// },
			isSj: false,
		}
	},
	created() {
		if (sessionStorage.getItem('orgCode').length > 5) {
			this.isSj = false
		} else {
			this.isSj = true
			// this.getSbdw()
			this.getList('start')
		}
	},
	methods: {
		getSbdw() {
			//组织单位树 --检查单位列表
			inspectionUnit(sessionStorage.getItem('orgCode'))
				.then((res) => {
					if (sessionStorage.getItem('orgCode').length > 5) {
						delete res.data.children
					} else {
						for (let key in res.data) {
							if (key == 'children') {
								for (let k = 0; k < res.data[key].length; k++) {
									delete res.data[key][k].children
								}
							}
						}
						//截取16个区粮办
						let children = res.data.children.slice(0, 16)
						res.data.children = children
					}
					this.tableData.push({
						qymc: res.data.orgName,
					})

					if (res.data.children && res.data.children.length) {
						res.data.children.forEach((item) => {
							this.tableData.push({
								qymc: item.orgName,
							})
						})
					} else {
						this.tableData.push({
							qymc: res.data.orgName,
						})
					}
				})
				.catch()
		},
		//获取列表
		getList(type) {
			getList({}).then((res) => {
				if (res.infoCode == 200) {
					this.tableData = res.data
				} else {
					this.$message({
						type: 'error',
						message: res.msg,
					})
				}
			})
		},
		// //统计图
		// cartogramSubmit(){
		//     this.cartogrameData.dialogVisible = true
		// },
		//查看
		detailSubmit(orgCode) {
			this.$router.push({
				path: '/grainCoManage/basicInformationMaintenance/updateInformation',
				query: {
					type: 'look',
					orgCode: orgCode,
				},
			})
		},
		//更新信息
		updateSubmit() {
			this.$router.push({
				path: '/grainCoManage/basicInformationMaintenance/updateInformation',
				query: {
					type: 'update',
					orgCode: sessionStorage.getItem('orgCode'),
				},
			})
		},
		//
		// handleSizeChange(val) {
		//     this.pageForm.pageSize = val
		//     this.getList()
		// },
		// handleCurrentChange(val) {
		//     this.pageForm.pageNum = val
		//     this.getList()
		// }
	},
}
</script>
