<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('磁贴列表')" />
	<style>
		.tableImage_s{
			border-radius:2px;
			width: 24px;
			height: 22px;
		}
		.tableImage_m{
			border-radius:2px;
			width: 36px;
			height: 30px;
		}
		.tableImage_l{
			border-radius:2px;
			width: 73px;
			height: 32px;
		}
	</style>
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="magnet-form">
				<div class="select-list">
					<ul>
						<li>
							磁贴名称：<input type="text" name="magnetName"/>
						</li>
						<li>
							磁贴状态：<select name="visible" th:with="type=${@dict.getType('sys_show_hide')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
						<li>
							磁贴类型：<select name="magnetType" th:with="type=${@dict.getType('sys_magnet_type')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
						<li>
							磁贴入口：<select name="userType" th:with="type=${@dict.getType('sys_system_name')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-success" onclick="addNew()" shiro:hasPermission="wxportal:magnet:add">
				<i class="fa fa-plus"></i> 新增
			</a>
			<a class="btn btn-success" onclick="setTheme()" shiro:hasPermission="wxportal:magnet:themeAdd">
				主题设置
			</a>
			<!--<a class="btn btn-primary" onclick="$.operate.editFull()" shiro:hasPermission="wxportal:magnet:edit">-->
			<!--<i class="fa fa-edit"></i> 修改-->
			<!--</a>-->
		</div>
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
		</div>
	</div>
</div>

<th:block th:include="include :: footer" />
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('wxportal:magnet:edit')}]];
	var removeFlag = [[${@permission.hasPermi('wxportal:magnet:remove')}]];
	var datas = [[${@dict.getType('sys_show_hide')}]];
	var magnetSizeList = [[${@dict.getType('wx_magnet_size')}]];
	var magnetTypeDatas = [[${@dict.getType('sys_magnet_type')}]];
    var userTypeDatas = [[${@dict.getType('sys_system_name')}]];

	var prefix = ctx + "wxportal/magnet";

	$(function() {
		var options = {
			url: prefix + "/list",
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove/{id}",
			showColumns: false,
			showToggle: false,
			modalName: "磁贴管理",
			columns: [{
				checkbox: true
			},
				{
					field : 'id',
					title : 'id',
					visible: false
				},
				{
					field: 'magnetName',
					title: '磁贴名称',
					width: '15%'
				},
				{
					field: 'bgUrl',
					title: '背景图片',
					width: '10%',
					formatter: function(value, row, index) {
						var str="";
						if(ctx=="/"){
							str = value;
						}else{
							str = ctx+value;
						}
						if(row.magnetSize=="S"){
							return $.table.imageView(str,218,237,"tableImage_s img-view");
						}else if(row.magnetSize=="M"){
							return $.table.imageView(str,300,360,"tableImage_m img-view");
						}else if(row.magnetSize=="L"){
							return $.table.imageView(str,320,730,"tableImage_l img-view");
						}
					}
				},
				{
					field: 'url',
					title: '请求地址',
					width: '30%',
					align: "left",
					formatter: function(value, item, index) {
						if(item.magnetType =="1"){
							return item.appletQrUrl;
						}else {
							return item.url;
						}
					}
				},
				{
					title: '磁贴类型',
					field: 'magnetType',
					width: '10%',
					align: "left",
					formatter: function(value, item, index) {
						return $.table.selectDictLabel(magnetTypeDatas, item.magnetType);
					}
				},
                {
                    title: '磁贴入口',
                    field: 'userType',
                    width: '10%',
                    align: "left",
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(userTypeDatas, item.userType);
                    }
                },
				{
					title: '磁贴尺寸',
					field: 'magnetType',
					width: '10%',
					align: "left",
					formatter: function(value, item, index) {
						return $.table.selectDictLabel(magnetSizeList, item.magnetSize);
					}
				},
				{
					field: 'visible',
					title: '可见',
					width: '10%',
					align: "left",
					formatter: function(value, row, index) {
						if (row.magnetType == 'F') {
							return '-';
						}
						return $.table.selectDictLabel(datas, row.visible);
					}
				},
				{
					field: 'orderNum',
					title: '排序',
					width: '10%',
					align: "left"
				},
				{
					title: '操作',
					width: '15%',
					align: "left",
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editMagnet(\'' + row.magnetId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.magnetId + '\')"><i class="fa fa-trash"></i>删除</a>');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});


	function addNew(){
		$.modal.openFull("添加" + $.table._option.modalName, $.operate.addUrl(0));
	}

	function editMagnet(id){
		$.modal.openFull("修改" + $.table._option.modalName, $.operate.editUrl(id));
	}

    function setTheme(){
        $.modal.openFull("主题设置", prefix + '/themeAdd');
    }
</script>
</body>
</html>