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

<style type="text/css">
	.result_list{
		width: 701px;
	}
</style>
<div id="classSetting">
	<div class="list_title">
		证书管理 <el-button type="primary" style="margin-right: 10px;" @click="addCertificate()">证书添加</el-button>
	</div>
	<br/>
	<div class="result_list">
		<el-table :data="tableData" border style="width: 100%">
		    <el-table-column
		      prop="title"
		      label="证书名称"
		      width="400">
		    </el-table-column>
		    <el-table-column  label="封面图" min-width="20%" >
		    	<template   slot-scope="scope">       
          	<el-image style="height: 50px" :src="scope.row.front_image" :preview-src-list="scope.row.srcList"></el-image>     
          </template>         
      	</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>
<?
if ($certificate_count > 0) {
?>
<!--page begin-->
<?
require_once("page_common.inc");
?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
	foreach ($certificate_list as $tmp) {
	?>
		var data={
			id:<?=$tmp->id ?>,
			title:'<?=$tmp->title ?>',
			front_image:'<?=$tmp->front_image?>',
			srcList: ['<?=$tmp->front_image?>']
		};
		list.push(data);
	<?
	 }
	?>

	new Vue({
		el:'#classSetting',
		data:{
			tableData: list,
		},
		methods:{
			handleChange(row) {
		        console.log(row);
		        window.location.href='certificate_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='certificate_delete_result.php?id='+rows.id;
		        }).catch(() => {
		          this.$message({
		            type: 'info',
		            message: '已取消删除'
		          });          
		        });
	      	},
	      	addCertificate(){
	      		window.open('certificate_edit_input.php?action_type=new','_self')
	      	}
		}
	})
</script>
