unionShareUserApplys.html 12.9 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>
    <form id="searchForm" method="post" accept-charset="utf-8">
        <div style="margin-left: 10px;margin-top: 10px">
            <label>用户ID:</label>
            <input class="easyui-textbox" id="uid" name="uid"/>
            <label>姓名:</label>
            <input class="easyui-textbox" id="name" name="name"/>
            <label>手机:</label>
            <input class="easyui-textbox" id="mobile" name="mobile"/>
            <label>社交媒体:</label>
            <input class="easyui-combobox" id="socialMediaType" name="socialMediaType">
            </input>
            <label>社交媒体账号:</label>
            <input class="easyui-textbox" id="socialMediaAccount" name="socialMediaAccount">
            </input>
            <label>状态:</label>
            <input class="easyui-combobox" id="status" name="status"
                   data-options="valueField: 'value',
		                        textField: 'label',
		                        data: [{
			                      label: '申请中',
			                      value: '1'
		                          },{
			                      label: '通过',
			                      value: '2'
		                          },{
			                      label: '拒绝',
			                      value: '3'
		                          }]">
            </input>

        </div>
        <div style="margin-left: 10px;margin-top: 10px">
            <label>开始时间:</label>
            <input class="easyui-datetimebox" id="beginTime" name="beginTime">
            </input>
            <label>结束时间:</label>
            <input class="easyui-datetimebox" id="endTime" name="endTime">
            </input>
            <a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
            <a id="passButton" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">批量通过</a>
            <a id="exportButton" 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="userApplyTable"></table>
    </div>
</div>
<script type="text/javascript">
    var checkedItems = [];
    $(function () {

        var _socialMediaTypeSelector = $("#socialMediaType");
        $.ajax({
            type: 'POST',
            url: contextPath + "/UnionShareRest/getSocialMediaBasicParams",
            //data: JSON.stringify(formData),
            async: true,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            success: function(res) {
                //$.messager.progress("close");
                if (res.code == 200) {
                    if(res.data){
                        _socialMediaTypeSelector.combobox({valueField: 'type',
                            textField: 'name',
                            data:res.data.mediaType});
                    }
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            },
            error:function(res){
                $.messager.alert("失败", "加载所属业务,请刷新页面重试", "error");
                return false;
            }
        });

        $("#userApplyTable").myDatagrid({
            fit: true,
            fitColumns: true,
            <!-- idField: "id",-->
            view: fileview,
            nowrap: false,
            onCheckAll: addcheckItem,
            onCheck: addcheckItem,
            onUncheckAll: removeAllItem,
            onUncheck: removeSingleItem,
            url: contextPath + "/UnionShareRest/queryUnionShareUserApplys",
            method: 'POST',
            loadFilter: function (data) {
                var temp = defaultLoadFilter(data);
                temp=null==temp?[]:temp;
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "ID",
                field: "id",
                idField:"id",
                width: 200,
                align: "center",
                checkbox: true
            }, {
                title: "用户ID",
                field: "uid",
                width: 200,
                align: "center"
            }, {
                title: "姓名",
                field: "name",
                width: 200,
                align: "center"
            }, {
                title: "手机号",
                field: "mobile",
                width: 200,
                align: "center"
            }, {
                title: "社交媒体",
                field: "socialMediaType",
                width: 200,
                align: "center"
            }, {
                title: "社交媒体账号",
                field: "socialMediaAccount",
                width: 200,
                align: "center"
            }, {
                title: "社交媒体粉丝数",
                field: "socialMediaFans",
                width: 200,
                align: "center"
            }, {
                title: "状态",
                field: "statusStr",
                width: 200,
                align: "center"
            }, {
                title: "申请时间",
                field: "createTime",
                width: 200,
                align: "center"
            }, {
                title: "审核时间",
                field: "checkTime",
                width: 200,
                align: "center"
            }, {
                title: "操作",
                field: "asdf",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
                    //状态:1-申请中,2-通过,3-拒绝
                    if(rowData.status == 1) {
                        var str = "<a role='pass' dataId='" + rowData.id + "' style='margin-left:10px'>通过</a>";
                        str += "<a role='refuse' dataId='" + rowData.id + "' style='margin-left:10px'>拒绝</a>";
                        return str;
                    }
                }
            }
            ]],
            cache: false,
            pagination: true,
            pageSize: 10,
            pageList: [10],
            idField: "id",
            singleSelect: false,
            checkOnSelect: false,
            onLoadSuccess: function (data) {
                resetSelectedCheckBox(data);

                $(this).myDatagrid("getPanel").find("a[role='pass']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        var cancleId=$(this).attr("dataId");
                        pass(cancleId);
                    }
                });

                $(this).myDatagrid("getPanel").find("a[role='refuse']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        var cancleId=$(this).attr("dataId");
                        refuse(cancleId);
                    }
                });

            }
        });

        function pass(id) {
            var paramObj={};
            if(id==null) {
                paramObj.ids = checkedItems.toString();
            }else {
                paramObj.id = id;
            }
            $.post(contextPath + "/UnionShareRest/agreeApply", paramObj, function (res) {
                $.messager.progress("close");
                if (res.code == 200) {
                    if(res.data > 0) {
                        $.messager.show({
                            title: "提示",
                            msg: "通过成功!",
                            height: 120
                        });
                    }else {
                        $.messager.alert("失败", "操作失败,请重新操作", "error");
                    }
                    $("#searchBtn").click();
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            }, "json");

        }
        function refuse(id) {
            var paramObj={};
            if(id==null) {
                paramObj.idArray = checkedItems;
            }else {
                paramObj.id = id;
            }
            $.post(contextPath + "/UnionShareRest/refuseApply", paramObj, function (res) {
                $.messager.progress("close");
                if (res.code == 200) {
                    if(res.data > 0) {
                        $.messager.show({
                            title: "提示",
                            msg: "拒绝成功!",
                            height: 120
                        });
                    }else {
                        $.messager.alert("失败", "操作失败,请重新操作", "error");
                    }
                    $("#searchBtn").click();
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            }, "json");

        }

        function resetSelectedCheckBox(data){
            $("input[type='checkbox'][name='id']").each(function () {
                var cb=$(this);
                $.each(checkedItems,function(index,value){
                    if(value==cb.val()){
                        cb.attr("checked",true);
                        return false;
                    }
                });
            });
        }

        $("#searchBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
                checkedItems=[];
                var param = getParams();
                $("#userApplyTable").myDatagrid("load", param);
            }
        });

        function addcheckItem() {
            $("input[type='checkbox'][name='id']:checked").each(function () {
                var k = findCheckedItem($(this).val());
                if (k == -1) {
                    checkedItems.push($(this).val());
                }
            });
        }
        $("#passButton").linkbutton({
            onClick : function() {
                if (checkedItems.length == 0) {
                    $.messager.alert('提示','请选择要审核通过的数据');
                    return;
                }
                pass(null);
            }
        });

        $("#exportButton").linkbutton({
            onClick : function() {
                window.open(contextPath + "/batch/export.do?type=unionShareApplyExportImpl&queryConf=" + escape(JSON.stringify(getParams())));
//                window.open(contextPath + "/batch/export.do?type=unionShareApplyExportImpl&queryConf=" + getParams());
            }
        });
        var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });
        function getParams() {
            var param = {
                uid:$("#uid").val(),
                name:$("#name").val(),
                socialMediaType:$("#socialMediaType").combobox('getValue'),
                socialMediaAccount:$("#socialMediaAccount").val(),
                status:$("#status").combobox('getValue'),
                mobile:$("#mobile").val()
            };
            if ($("#beginTime").datetimebox('getValue')!='')
            {
                param.beginTime = parseInt(new Date($("#beginTime").datetimebox('getValue')).getTime() / 1000)
            }
            if ($("#endTime").datetimebox('getValue') != ''){
                param.endTime = parseInt(new Date($("#endTime").datetimebox('getValue')).getTime() / 1000)
            }
            return param;
        }

        function isCheckItem() {
            for (var i = 0; i < checkedItems.length; i++) {
                $("input[type='checkbox'][name='id'][value='"+checkedItems[i]+"']").attr("checked", "checked");
            }
        }

        function findCheckedItem(ID) {
            for (var i = 0; i < checkedItems.length; i++) {
                if (checkedItems[i] == ID) return i;
            }
            return -1;
        }

        function removeAllItem(rows) {
            $("input[type='checkbox'][name='id']").each(function () {
                if (!this.checked) {
                    var k = findCheckedItem($(this).val());
                    if (k != -1) {
                        checkedItems.splice(k, 1);
                    }
                }
            });
        }

        function removeSingleItem(rowIndex, rowData) {
            var k = findCheckedItem(rowData.id);
            if (k != -1) {
                checkedItems.splice(k, 1);
            }
        }

    });
</script>
</body>
</html>