<?php
/**
 * 合集视频
 * $Id: collection_media_list.inc,v 1.1 2020/01/03 11:18:46  Exp $
 * @author lixq
 * @access public
 * @package manager.templates
 */

global $school_list;
global $school_count;
global $school_title;
?>
<style type="text/css">
	.m-l{
		margin-left: 10px;
	}
</style>
<div id="classSetting">
	<div class="list_title">
		合集视频管理<el-button type="primary" style="margin-right: 10px;" @click="addClass()">合集视频添加</el-button>
	</div>
	<br/>
	<form id="search_form" action="collection_media_list.php" method="post">
	合集名称:<input type="text" value="<?=$title?>" name="title" class="el-input__inner input_100 m-l"/>
	<el-button type="primary" @click="search()" class="edit_btn search_btn">检索</el-button>
	</form>
  <br />
  <div class="result_list">
  	<el-table :data="tableData" border>
  		<el-table-column  prop="title" label="合集名称" width=""></el-table-column>
  		<el-table-column  prop="media_count" label="视频数量" width=""></el-table-column>
  		<el-table-column  prop="view_count" label="观看人数" width=""></el-table-column>
  		<el-table-column  prop="upload_date" label="最新上传" width=""></el-table-column>
  		<el-table-column  label="操作"  width="150">
  			<template slot-scope="scope">
  				<el-button @click="handleDetail(scope.row)" type="text" size="small">详情</el-button>
  				<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 ($course_count > 0) {
?>
<!--page begin-->
<?
require_once("page_common.inc");
?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
	foreach ($course_list as $tmp) {
	?>
		var data={
			id:<?=$tmp["id"] ?>,
			title:'<?=$tmp["title"]?>',
			media_count:'<?=$tmp["media_count"]?>',
			upload_date:'<?=!empty($tmp["upload_date"])?$tmp["upload_date"]:"-"?>',
			view_count:'<?=!empty($tmp["view_count"])?$tmp["view_count"]:0?>'
		};
		list.push(data);
	<?
	}
	?>

	new Vue({
		el:'#classSetting',
		data:{
			tableData: list,
		},
		methods:{
			handleChange(row) {
		  	window.location.href='collection_media_edit_input.php?action_type=edit&id='+row.id;
		  },
		  deleteRow(rows) {
      	this.$confirm('是否删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
			window.location.href='collection_media_delete_result.php?id='+rows.id;
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    	},
    	addClass(){
    		window.open('collection_media_edit_input.php?action_type=new','_self');
    	},
    	handleDetail(rows){
    	  window.location.href='course_media_list.php?id='+rows.id;
      },
		  search(){
    	  $("input[name='parent_category_id']").val(this.parent_category_id);
				$("input[name='sub_category_id']").val(this.sub_category_id);
				$("#search_form").submit();
			}
		}
	})
</script>