<html xmlns:th="http://www.thymeleaf.org">
<head>
	<title>私塾家</title>
	<script th:include="sys/common/metaCSS" th:remove="tag"></script>
	<script th:include="sys/common/metaJS" th:remove="tag"></script>
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
		color: red;
	}
	.select_width{
		width: 70px;
	}
	.date_width{
		width: 100px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">系统管理</a></li>
		<li><a th:href="@{/sys/photoscroll/photoscrollList.html}">首页轮播图列表</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/photoscroll/photoscrollList.html}" method="post">
		<ul class="seachform">
			<!--<li>
				<label>标题</label>
				<input name="LIKE_captions" type="text" class="scinput" th:value="${search.get('LIKE_captions')}"/>
			</li>
			-->
			<li>
				<label>&nbsp;</label>
				<input type="button" class="scbtn" value="刷新" />
			</li>
			<li>
				<ul class="toolbar">
					<a th:href="@{/sys/photoscroll/photoscrollAdd.html}"><li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增</li></a>
				</ul>
			</li>
		</ul>
	</form>
	<table class="tablelist">
		<thead>
		<tr>
			<th>图片</th>
			<th>机型</th>
			<th>序号</th>
			<th>创建时间</th>
			<th>是否有效</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<tr th:each="item:${list}" >
			<td  class="imgtd">
				<img th:if="${not #lists.isEmpty(item.url)}" th:src="${imgUrl}+''+${item.url}" style="width: 50px;height: 50px;" />
			</td>
			<td th:text="${item.phoneType}" ></td>
			<td style="text-align: center;" >
				<input type="number" th:value="${item.photoOrder}" th:onBlur="'updatePhotoOrder(\''+${item.id}+'\',\''+${item.photoOrder}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;"  >
			</td>
			<td style="width: 141px;" th:text="${#calendars.format(item.created,'yyyy-MM-dd HH:mm:ss')}" ></td>
			<td th:text="${item.isValid}" ></td>
			<td>
				<a th:href="@{/sys/photoscroll/photoscrollAdd.html(id=${item.id})}" class="tablelink" >修改</a>
				<a href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\')'"  class="tablelink" >删除</a>
			</td>
		</tr>
		</tbody>
	</table>
	<!--分页-->
	<div class="pagin">
		<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
		<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
	</div>
</div>
</body>
<script type="text/javascript">
    //修改排序号
    function updatePhotoOrder(id,oldOrder,_this){
        var photoOrder = $(_this).val();
        if(photoOrder == oldOrder){
            return false;
        }
        if(photoOrder ==''|| photoOrder ==null){
            return false;
        }
        $(_this).removeAttr("onBlur");
        $.ajax({
            url : "[[${sysUrl}]]/sys/photoscroll/updatePhotoOrder",
            type : "post",
            data : {
                id : id,
                photoOrder : photoOrder
            },
            dataType : "json",
            success : function(data) {
                if(data.meta.success){
                    parent.layer.msg('操作成功',{icon:1});
                    $(_this).attr("onBlur","updatePhotoOrder("+id+","+photoOrder+",this)");
                }else{
                    parent.layer.msg('操作失败',{icon: 9})

                }
            }
        });
    }
    function deleteById(id){
        parent.layer.confirm("确定删除吗？",
            {icon: 4, btn: ['确定','取消']
            }, function(){
                $.ajax({
                    url: '[[${sysUrl}]]/sys/photoscroll/photoscrollDelete',
                    type: "post",
                    data:{
                        'id': id
                    },
                    dataType: "json",
                    success:function(data){
                        if(data.meta.success){
                            parent.layer.msg("删除成功",{icon:1});
                            setTimeout(function(){
                                location.reload();
                            },1000);
                        }else{
                            parent.layer.msg(data.meta.message,{icon:11});
                        }
                    }
                });
            });
    }
</script>
</html>