unionShareUserBanks.html 9.74 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">
            </input>
            <label>持卡人姓名:</label>
            <input class="easyui-textbox" id="name" name="name">
            </input>
            <label>身份证号:</label>
            <input class="easyui-textbox" id="idCardNo" name="idCardNo" style="width:300px">
            </input>
            <label>银行卡号:</label>
            <input class="easyui-textbox" id="bankCardNo" name="bankCardNo" style="width:300px">
            </input>
            <label>银行:</label>
            <input class="easyui-combobox" id="bankCode" name="bankCode">
            </input>
            <label>状态:</label>
            <input class="easyui-combobox" id="status" name="status"
                   data-options="valueField: 'value',
		                        textField: 'label',
		                        data: [{
			                      label: '正常',
			                      value: '1'
		                          },{
			                      label: '作废',
			                      value: '0'
		                          }]">
            </input>

            <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="userOrdersTable"></table>
    </div>
</div>
<script type="text/javascript">
    var checkedItems = [];
    $(function () {
        var _bankCodeSelector = $("#bankCode");
        $.ajax({
            type: 'POST',
            url: contextPath + "/UnionShareRest/getBankList",
            //data: JSON.stringify(formData),
            async: true,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            success: function(res) {
                //$.messager.progress("close");
                debugger;
                if (res.code == 200) {
                    if(res.data){
                        _bankCodeSelector.combobox({valueField: 'bankCode',
                            textField: 'bankName',
                            data:res.data});
                    }
                } else {
                    $.messager.alert("失败", res.message, "error");
                }
            },
            error:function(res){
                $.messager.alert("失败", "加载所属业务,请刷新页面重试", "error");
                return false;
            }
        });

        $("#userOrdersTable").myDatagrid({
            fit: true,
            fitColumns: true,
            <!-- idField: "id",-->
            view: fileview,
            nowrap: false,
            onCheckAll: addcheckItem,
            onCheck: addcheckItem,
            onUncheckAll: removeAllItem,
            onUncheck: removeSingleItem,
            url: contextPath + "/UnionShareRest/queryUnionShareUserBanks",
            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: "idCardNo",
                width: 200,
                align: "center"
            }, {
                title: "持卡人姓名",
                field: "name",
                width: 200,
                align: "center"
            }, {
                title: "银行卡号",
                field: "bankCardNo",
                width: 200,
                align: "center"
            }, {
                title: "银行",
                field: "bankName",
                width: 200,
                align: "center"
            }, {
                title: "状态",
                field: "status",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
                    if(rowData.status == 1) {
                        return "正常";
                    }else if(rowData.status == 0) {
                        return "作废";
                    }
                }
            }, {
                title: "创建时间",
                field: "createTime",
                width: 200,
                align: "center"
            }, {
                title: "修改时间",
                field: "updateTime",
                width: 200,
                align: "center"
            }, {
                title: "操作",
                field: "asdf",
                width: 200,
                align: "center",
                formatter: function (value, rowData, rowIndex) {
                    if(rowData.status == 1) {
                        var str = "<a role='cancel' 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='cancel']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        var cancleId=$(this).attr("dataId");
                        $.post(contextPath + "/UnionShareRest/cancelUserBanks", {id: cancleId}, 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 = {
                    uid:$("#uid").val(),
                    name:$("#name").val(),
                    idCardNo:$("#idCardNo").val(),
                    bankCardNo:$("#bankCardNo").val(),
                    status:$("#status").combobox('getValue'),
                    bankCode:$("#bankCode").combobox('getValue')
                };
                $("#userOrdersTable").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());
                }
            });
        }

        var fileview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: function (target) { isCheckItem(); } });

        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>