Index.js 5.42 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: "操作",
            align: "center",
            render: function (item) {
                var html = [];
                if (item.isRefundExchange == 0) {
                    html.push('&nbsp;&nbsp;<lable for="btn-item-close"><input type="radio" data-index="' + item.__index + '" checked href="JavaScript:;" id="btn-item-close" name="isRefundExchange' + item.__index + '" data-type="close">不允许退换货</lable>');
                    html.push('<lable for="btn-item-open"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-open" name="isRefundExchange' + item.__index + '" data-type="open">允许退换货</lable>');
                    html.push('&nbsp;&nbsp;<lable for="btn-item-open2"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-open2" name="isRefundExchange' + item.__index + '" data-type="open2">超过7天不允许退换货</lable>');
                } else if (item.isRefundExchange == 1) {
                    html.push('&nbsp;&nbsp;<lable for="btn-item-close"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-close" name="isRefundExchange' + item.__index + '" data-type="close">不允许退换货</lable>');
                    html.push('<lable for="btn-item-open"><input type="radio" data-index="' + item.__index + '" checked  href="JavaScript:;" id="btn-item-open" name="isRefundExchange' + item.__index + '" data-type="open">允许退换货</lable>');
                    html.push('&nbsp;&nbsp;<lable for="btn-item-open2"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-open2" name="isRefundExchange' + item.__index + '" data-type="open2">超过7天不允许退换货</lable>');
                } else {
                    html.push('&nbsp;&nbsp;<lable for="btn-item-close"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-close" name="isRefundExchange' + item.__index + '" data-type="close">不允许退换货</lable>');
                    html.push('<lable for="btn-item-open"><input type="radio" data-index="' + item.__index + '" href="JavaScript:;" id="btn-item-open" name="isRefundExchange' + item.__index + '" data-type="open">允许退换货</lable>');
                    html.push('&nbsp;&nbsp;<lable for="btn-item-open2"><input type="radio" data-index="' + item.__index + '" checked href="JavaScript:;" id="btn-item-open2" name="isRefundExchange' + item.__index + '" data-type="open2">超过7天不允许退换货</lable>');
                }
                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: 1
    };
    Bll.toast("确认允许退换货吗?", "/refundExchangeAttribute/modifyRefundExchangeStatus", item);

});

$(document).on('click', "#btn-item-open2", function () {
    var item = g.rows[$(this).data("index")];
    item = {
        productSkn: item.productSkn,
        isRefundExchange: 2
    };
    Bll.toast("确认超过7天不允许退换货吗?", "/refundExchangeAttribute/modifyRefundExchangeStatus", item);

});

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

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