createGoods.html 7.09 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>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
    <script>
        document.write(addHead('品牌管理', ''));
    </script>

        <input id="brandName" type="text">
        <input id="brandSeries" type="text"/>
</div>

<div region="center">
    <div style="margin-left: 30px;margin-top: 20px;height: 660px">
        <table id="SkuTable"></table>
    </div>
</div>

<script type="text/javascript">

    var brandId;
    $(function () {


        $.ajax({
            contentType: "application/json",
            dataType: "json",
            type: "GET",
            url: contextPath + '/brand/getBrandName',
            /*data: JSON.stringify({
             limit: 0
             }),*/
            success: function (data) {
                if (data.code != 200 || !data.data || data.data.length == 0) {
                    return;
                }
                $("#brandName").myCombobox({
                    prompt: "选择名称",
                    width: 200,
                    data: data.data,
                    valueField: "id",
                    textField: "text"
                });
            }
        });

        $.ajax({
            contentType: "application/json",
            dataType: "json",
            type: "GET",
            url: contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + $('#brandName').combobox('getValue'),
            //data: brandId : ,
            success: function (data) {
                if (data.code != 200 || !data.data || data.data.length == 0) {
                    return;
                }
                $("#brandSeries").myCombobox({
                    prompt: "选择名称",
                    width: 200,
                    data: data.data,
                    valueField: "id",
                    textField: "text"
                });
            }
        });


        $("#SkuTable").myDatagrid({
            fit: true,
            fitColumns: true,
            nowrap: false,
            url: contextPath + "/brand/getBrandPageList",
            method: 'POST',
            /*queryParams: {
             'brandName':'',
             'status':''
             },*/
            loadFilter: function (data) {
                var temp = defaultLoadFilter(data);
                temp.rows = temp.list;
                return temp;
            },
            columns: [[{
                title: "ID",
                field: "id",
                width: 40,
                align: "center"
            }, {
                title: "品牌LOGO",
                field: "brandLogo",
                width: 80,
                align: "center",
                formatter: function (value) {
                    if (value == null || value == '' || value == undefined) {
                        return '';
                    }
                    return '<img src="' + value + '"  style="width:98px;height:98px"/></a>';
                }
            }, {
                title: "品牌名称",
                field: "brandName",
                width: 100,
                align: "center"
            }, {
                title: "英文名称",
                field: "brandNameEn",
                width: 80,
                align: "center"
            }, {
                title: "品牌搜索词",
                field: "brandSearch",
                width: 170,
                align: "center"
            }, {
                title: "状态",
                field: "status",
                width: 80,
                align: "center",
                formatter: function (value, rowData) {
                    if (value == 1) {
                        return '开启';
                    }
                    return '关闭';
                }
            }, {
                title: "创建时间",
                field: "createTime",
                width: 170,
                align: "center"
            }, {
                title: "操作",
                field: "operations",
                width: 80,
                align: "center",
                formatter: function (value, rowData) {
                    var str = "<a role='edit' dataId='" + rowData.id + "'  style='margin-left:10px'>编辑</a>";
                    if (1 == rowData.status) {
                        str += "<a role='closeBrand' dataId='" + rowData.id + "' style='margin-left:10px'>关闭品牌</a>";
                    } else {
                        str += "<a role='openBrand' 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 () {
                // 编辑
                $(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
                    iconCls: "icon-edit",
                    onClick: function () {
                        var id = $(this).attr("dataId");
                        editRow(id);
                    }
                });
                // 关闭品牌
                $(this).myDatagrid("getPanel").find("a[role='closeBrand']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        updateBrandStatus($(this).attr("dataId"), 2);
                    }
                });

                // 开启品牌
                $(this).myDatagrid("getPanel").find("a[role='openBrand']").linkbutton({
                    iconCls: "icon-more",
                    onClick: function () {
                        updateBrandStatus($(this).attr("dataId"), 1);
                    }
                });
            }
        });


        // 搜索
        $("#searchLinkButton").linkbutton({
            onClick: function () {
                var param = getParams();
                $("#brandTable").myDatagrid("load", param);
            }
        });

        // 搜索全部
        $("#searchAllLinkButton").linkbutton({
            onClick: function () {
                $('#brandStatus').combobox('clear');
                $('#brandName').combobox('clear');
                var param = {};
                $("#brandTable").myDatagrid("load", param);
            }
        });

        /**
         * 提取出搜索参数
         */
        function getParams() {
            var brandName = $('#brandName').combobox('getText');
            var status = $('#brandStatus').combobox('getValue');
            var param = {};
            if (undefined !== brandName && null !== brandName && "" !== brandName) {
                param.brandName = brandName;
            }
            if (undefined !== status && null !== status && "" !== status) {
                param.status = status;
            }
            return param;
        }



    });


</script>

</body>
</html>