unionShareMessageList.html 6.17 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Yoho!Buy运营平台</title>
    <script src="/union/js/include.js"></script>
    <script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
    <script>
        document.write(addHead('CPS联盟管理', 'CPS消息管理'));
    </script>
    <div style="margin-left: 15px;margin-top: 10px">
            <a id="addBtn" class="easyui-linkbutton btn-primary" style="background-color: #5CB85C;">+创建消息</a>
        </div>
    <form id="searchForm" method="post" accept-charset="utf-8">
        <div style="margin-left: 10px;margin-top: 10px">
            <label>查询时间:</label>
            <input class="easyui-datetimebox" id="startTime" name="beginTime" style="width:180px;"/>~&nbsp;&nbsp;
            <input class="easyui-datetimebox" id="endTime" name="endTime" style="width:180px;"/>
            <a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
        </div>
            
    </form>
</div>
<div region="center">
    <div style="margin-left: 30px;margin-top: 20px; height: 500px;">
        <table id="messageListTable"></table>
    </div>
</div>
<script type="text/javascript">
    $("#addBtn").click(function () {
       window.location.href = contextPath + "/html/unionshare/unionShareMessageAdd.html";
    });

    $(function () {

        $("#messageListTable").myDatagrid({
            fit: true,
            fitColumns: true,
            nowrap: false,
            url: contextPath + "/UnionShareRest/queryUnionShareMessageList",
            method: 'POST',
            loadFilter: function (data) {
            	var temp = defaultLoadFilter(data);
                temp=null==temp?[]:temp;
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "ID",
                field: "id",
                width: 100,
                align: "center",
            }, {
                title: "内容",
                field: "content",
                width: 200,
                align: "center"
            }, {
                title: "图片",
                field: "image",
                width: 200,
                align: "center",
                formatter : function(value, rowData, rowIndex) {
                    var newData = JSON.stringify(rowData);
                    var imgstr="<a href='"+rowData.image+"'><img src='"+rowData.image+"' height='78px;' width='59px;' /></a>";
                    return imgstr;
                }
            }, {
                title: "url",
                field: "url",
                width: 200,
                align: "center"
            }, {
                title: "优先级",
                field: "priority",
                width: 200,
                align: "center",
            }, {
                title: "开始时间",
                field: "startTimeStr",
                width: 200,
                align: "center"
            }, {
                title: "结束时间",
                field: "endTimeStr",
                width: 200,
                align: "center"
            },{
                title: "操作",
                field: "asdf",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
                    var str = "<a role='edit' dataId='"+ rowData.id +"' style='width:100px;'>编辑</a> ";
                    str = str + "<a role='delete' dataId='"+ rowData.id +"' style='width:100px;'>删除</a> ";
                	return str;
                }
            }
            ]],
            cache: false,
            pagination: true,
            pageSize: 10,
            idField: "id",
            singleSelect: false,
            onLoadSuccess: function (data) {
            	$(this).datagrid("getPanel").find("a[role='edit']").linkbutton({
                    onClick: function () {
                    	var id = $(this).attr("dataId");
                        window.location.href = contextPath + "/html/unionshare/unionShareMessageEdit.html?id=" + id;
                    }
                });
            	
            	$(this).datagrid("getPanel").find("a[role='delete']").linkbutton({
                    onClick: function () {
                    	var id = $(this).attr("dataId");
                    	$.messager.confirm("确认", "是否确认删除?", function(flag) {
                            if (flag) {
                                $.post(contextPath + "/UnionShareRest/deleteMessage", {
                                    id : id
                                }, function(data) {
                                    if (data.code == 200) {
                                        $("#messageListTable").datagrid("reload");
                                        window.self.$.messager.show({
                                            title : "提示",
                                            msg : "成功删除!"
                                        });
                                    }else {
                                    	window.self.$.messager.alert("失败", "删除失败!", "error");
                                    }
                                });
                            }
                        });
                    }
                });
            }
        });


        $("#searchBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
            	var startTime;
            	var endTime;
            	if ($("#startTime").datetimebox('getValue')!='')
                {
            		startTime = parseInt(new Date($("#startTime").datetimebox('getValue')).getTime() / 1000)
                }
            	if ($("#endTime").datetimebox('getValue')!='')
                {
            		endTime = parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
                }
            	$("#messageListTable").datagrid("load", {
            		startTime: startTime,
            		endTime: endTime                
                });
            }
        });
    });
</script>
</body>
</html>