<?php
/**
 * 管理员管理
 * $Id: account_list.inc,v 1.1 2015/10/08 11:18:50 wanggb Exp $
 * @author netvillage
 * @access public
 * @package manager.templates
 */

global $account_list;

?>
<!--<div class="page_title">年级设定</div>

<div class="page_buttons">
	<a class="flatbutton" href="grade_edit_input.php?action_type=new">年级添加</a>
</div>


<br />
<div id="result_list" style="width:50%;">
<table >
<tr>
<th class="contents_title" width="75%">年级名称</th>
<th class="contents_title" width="25%">操作</th>
<?
	foreach ($grade_list as $grade_mst) {
?>
<tr>
	<td align="center"><?=htmlspecialchars($grade_mst->title) ?></td>

	<td align="center">
		<a class="flatbutton" href="grade_edit_input.php?action_type=edit&id=<?=$grade_mst->id ?>">编辑</a>
		<a class="flatbutton" href="javascript:void(0);if (confirm('确定要删除吗?')) location.href='grade_delete_result.php?id=<?=$grade_mst->id ?>';">删除</a>
	</td>
</tr>
<?
}
?>
</table>
</div>-->
<style type="text/css">
	.conClasstable{
		width: 701px;
		overflow-x: hidden;
		margin-top: 20px;
	}
	.conClasstable .cell{
		text-align: center;
	}
</style>
<div id="classSetting">
	<div style="display: flex;justify-content: space-between;align-items: center;padding-left: 10px;">
		年级设定<el-button type="primary" style="margin-right: 10px;" @click="addClass()">年级添加</el-button>
	</div>
	<div class="conClasstable">
		<el-table
		    :data="tableData"
		    border
		    style="width: 100%">
		    <el-table-column
		      prop="name"
		      label="年级名称"
		      width="600">
		    </el-table-column>
		    <el-table-column
		      label="操作"
		      width="100">
		      <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>
		      </template>
		    </el-table-column>
		</el-table>
	</div>
</div>

<script type="text/javascript">
	var list=[];
	<?
		foreach ($grade_list as $grade_mst) {
	?>
		var data={
			id:<?=$grade_mst->id ?>,
			name:'<?=$grade_mst->title ?>'
		};
		list.push(data);
	<?
	}
	?>

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