<?php
/**
 * 系统常量定义
 * $Id: system_const_list.inc,v 1.1 2020/01/12 11:18:46  Exp $
 * @author lixq
 * @access public
 * @package manager.templates
 */

global $system_const_list;

?>

<div id="classSetting">
	<div class="list_title">
		系统常量定义
		 <div style="float: right;">
			<el-button type="primary" style="margin-right: 10px;" @click="addSysConst()">添加</el-button>
		</div>
	</div>

  <br />
  <div class="result_list">
  	<el-table :data="tableData" border>
  		<el-table-column  prop="id" label="编号"  width="50px"></el-table-column>
  		<el-table-column  prop="name" label="常量定义名" width=""></el-table-column>
  		<el-table-column  prop="title" label="文字描述" width=""></el-table-column>
  		<el-table-column  prop="constant_value" label="常量的值" width=""></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 ($system_const_list as $system_const_mst) {
	?>
		var data={
			id:<?=$system_const_mst->id ?>,
			name:'<?=$system_const_mst->name?>',
			title:'<?=$system_const_mst->title?>',
			constant_value:'<?=$system_const_mst->constant_value?>'
		};
		list.push(data);
	<?
	}
	?>

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