configList.html 3.93 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>Yoho!Buy运营平台</title>
    <script src="/ufoPlatform/js/include.js"></script>
    <script src="/ufoPlatform/js/ajaxfileupload.js"></script>
    <style>
        .btn-download span {
            line-height: 40px;
            color: #87CEFA;
        }
    </style>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 160px">
    <script>
        document.write(addHead('配置管理', ''));
    </script>
</div>
<div region="center">
    <div style="margin-left: 30px;margin-top: 20px;height: 660px">
        <table id="configTable"></table>
    </div>
</div>

<script type="text/javascript">
    var param = {};
    $(function () {

        $("#configTable").myDatagrid({
            fit: true,
            fitColumns: true,
            nowrap: false,
            url: contextPath + "/ResourcesGoodsPool/selectAll",
            method: 'POST',
            loadFilter: function (data) {
                var temp = defaultLoadFilter(data);
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "配置说明",
                field: "poolName",
                width: 40,
                align: "center"
            }, {
                title: "配置值",
                field: "poolId",
                width: 80,
                align: "center",
                formatter: function (value, rowData) {
                    var v = value==null?"":value;
                    var str = "<input id='pool_id_"+rowData.id+"' type='text' value='"+v+"'>";
                    return str;
                }
            }, {
                title: "操作",
                field: "operations",
                width: 80,
                align: "center",
                formatter: function (value, rowData) {
                    var str = "<a role='edit' dataId='" + rowData.id + "'  style='margin-left:10px;background-color: #5bc0de'>提交</a>";
                    return str;
                }
            }]],
            cache: false,
            pagination: true,
            pageSize: 10,
            pageList: [10],
            idField: "id",
            singleSelect: false,
            checkOnSelect: false,
            onLoadSuccess: function () {
                $.parser.parse($("#configTable").parent());
                // 编辑
                $(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
                    iconCls: "icon-edit",
                    onClick: function () {
                        var id = $(this).attr("dataId");
                        editRow(id);
                    }
                });
            }
        });


        function editRow(id) {
            debugger
            var pool_id = document.getElementById("pool_id_"+id).value;
            var ajaxData = {};
            ajaxData.poolId = pool_id;
            ajaxData.id = id;

            $.ajax({
                url: contextPath + '/ResourcesGoodsPool/updatePoolIdById',
                contentType: "application/json",
                dataType: "json",
                type: "POST",
                data: JSON.stringify(ajaxData),
                success: function(ret) {
                    $.messager.progress("close");
                    if (ret && ret.code == 200 && ret.data == 1) {
                        $.messager.show({
                            title:'操作提示',
                            msg:'提交成功'
                        });
                        $("#configTable").myDatagrid("load", param);
                    } else {
                        $.messager.alert('操作提示', '提交失败');
                    }
                },
                error: function(err) {
                    $.messager.progress("close");
                    $.messager.alert('操作提示', err.message || '提交失败');
                }
            });

        }
    });
</script>

</body>
</html>