Index.js 3.76 KB
/**
 * Created by yoho on 2016/6/28.
 */
/**
 * Created by wangqianjun on 16/4/12.
 */
'use strict';
var $ = require('jquery');
var common = require('../../../common/common');
var Bll = {
    Status: ["是", "否"],
    toast: function (hint, url, data) {
        common.dialog.confirm("警告",
            hint,
            function () {
                common.util.__ajax({
                    url: url,
                    data: data
                }, function () {
                    g.reload();
                }, true);
            });
    }
};
/*下拉选择*/
new common.dropDown({
    el: "#brandId",
    ajax: "brand",
    hash: true,
    params:function(){
        return {userLimitFlag:true};
    }
});

new common.dropDown({
    el: "#productSkn",
    ajax: "queryRefundExchangeProductSkn"
});

new common.dropDown({
    el: "#isPayDelivery"
});

var g = new common.grid({
    el: '#basicTable',
    parms: function () {
        return {
            brandId: common.util.__input("brandId"),
            isRefundExchange: common.util.__input("isRefundExchange"),
            productSkn: common.util.__input("productSkn")
        };
    },
    columns: [
        {
            display: 'SKN',
            name: 'productSkn'
        }, {
            display: '品牌',
            name: 'brandName'
        },
        {
            display: "是否特殊商品",
            render: function (item) {
                var html = [];
                html.push("<p>" + Bll.Status[item.isRefundExchange] + "</p>");
                return html.join('');
            }
        },
        {
            display: "操作",
            render: function (item) {
                var html = [];
                if (item.sortIsRefundExchange == 0) {
                    if (item.isRefundExchange == 0) {//普通商品
                        html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn" id="btn-item-close" data-type="close">关闭</a>');
                    } else {//特殊商品
                        html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-open" data-type="open">开启</a>');
                    }
                } else {
                    if (item.isRefundExchange == 0) {//普通商品
                        html.push('<a data-index="' + item.__index + '" disabled href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn" id="btn-item-close" data-type="close">关闭</a>');
                    } else {//特殊商品
                        html.push('<a data-index="' + item.__index + '" disabled href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-open" data-type="open">开启</a>');
                    }
                }
                return html.join('');
            }
        }
    ]
});
g.init('/refundExchangeAttribute/queryRefundExchangeList');

// 筛选
$(document).on('click', "#filter-btn", function () {
    g.reload(1);
});
//开启
$(document).on('click', "#btn-item-open", function () {
    var item = g.rows[$(this).data("index")];
    item = {
        productSkn: item.productSkn,
        isRefundExchange: 0
    };
    Bll.toast("确认开启吗?", "/refundExchangeAttribute/modifyRefundExchangeStatus", item);

});
//关闭
$(document).on('click', "#btn-item-close", function () {
    var item = g.rows[$(this).data("index")];
    item = {
        productSkn: item.productSkn,
        isRefundExchange: 1
    };
    Bll.toast("确认关闭吗?", "/refundExchangeAttribute/modifyRefundExchangeStatus", item);
});

$('#export-btn').on('click', function () {
    window.open("/ajax/down?queryConf=" + JSON.stringify(g.options.parms()) + "&type=productRefundExchangeExport");
});