<?php
/**
 * 领导机构
 * $Id: government_list.inc,v 1.1 2020/01/03 11:18:46  Exp $
 * @author lixq
 * @access public
 * @package manager.templates
 */

global $government_list;

?>

<div id="classSetting">
	<div class="list_title">
		领导机构
		 <div style="float: right;">
			<el-button type="primary" style="margin-right: 10px;" @click="addGovernment()">领导机构添加</el-button>
			<el-button type="primary" style="margin-right: 10px;" @click="csvDownload()">领导机构下载</el-button>
		</div>
	</div>

  <br />
  <div class="result_list">
  	<el-table :data="tableData" border>
  		<el-table-column width="50" prop="id" label="编号" ></el-table-column>
  		<el-table-column  prop="province" label="省级名称" width=""></el-table-column>
  		<el-table-column  prop="city" label="市级名称" width=""></el-table-column>
  		<el-table-column  prop="district" label="区县名称" width=""></el-table-column>
  		<el-table-column  prop="title" label="教育管局名称" width=""></el-table-column>
  		<el-table-column  label="操作"  width="180">
  			<template slot-scope="scope">
  				<el-button @click="handleChange(scope.row)" type="text" size="small">编辑</el-button>
  				<el-button type="text" size="small" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
  				<el-button type="text" size="small" @click="toQR(scope.row)">二维码管理</el-button>
  			</template>
  			</el-table-column>
  	</el-table>
  </div>
</div>
<?
if ($government_count > 0) {
?>
<!--page begin-->
<?
require_once("page_common.inc");
?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
	foreach ($government_list as $government_mst) {
	?>
		var data={
			id:<?=$government_mst->id ?>,
			province:'<?=$government_mst->province?>',
			city:'<?=$government_mst->city?>',
			district:'<?=$government_mst->district?>',
			title:'<?=$government_mst->title ?>'
		};
		list.push(data);
	<?
	}
	?>

	new Vue({
		el:'#classSetting',
		data:{
			tableData: list
		},
		methods:{
			handleChange(row) {
		  	console.log(row);
		  	window.location.href='government_edit_input.php?id='+row.id;
		  },
		  deleteRow(rows) {
	    	this.$confirm('是否删除?', '提示', {
		    	confirmButtonText: '确定',
		    	cancelButtonText: '取消',
		    	type: 'warning'
		 		}).then(() => {
		    	this.$message({
		      	type: 'success',
		      	message: '删除成功!'
		     	});
//	        		rows.splice(index, 1);
					window.location.href='government_delete_result.php?id='+rows.id;
		   	}).catch(() => {
		    	this.$message({
		      	type: 'info',
		      	message: '已取消删除'
		    	});          
		    });
	    },
	    addGovernment(){
	    	window.open('government_new.php','_self')
	    },
	    toQR(row){
	      window.location.href='government_qr_list.php?id='+row.id;
	    },
	    csvDownload(){
	      window.location.href='government_list_csv_download.php';
		}
		}
	})
</script>