auditing.js 6.85 KB
/**
 * Created by wangqianjun on 16/5/4.
 */
var $ = require('jquery');
common = require('../common/common');
datepicker = require('../util/datepicker');

var ENUM = {
    AuditEnum: {
        '0': '待审核',
        '1': '审核通过',
        '2': '审核失败',
    },

    RecommendEnum: {
        true: '已推荐',
        false: '未推荐'
    },

    RewardEnum: {
        false: '未发送奖励',
        true: '奖励已发放'
    },
}


//下拉框
new common.dropDown({
    el: "#status"
});

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

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

//日期插件
$('.hasDatepicker').fdatepicker({
    format: 'yyyy-mm-dd'
});


/**
 * 获取商品图片url
 * @param item
 */

function goodsImg(item) {

    var goods = item.goods;
    var goodsImgUrl = "";
    if (goods != null && goods.goodsImg != null && goods.goodsImg.length > 0) {
        goodsImgUrl = goods.goodsImg[0].imageUrl;
    }

    return goodsImgUrl;


}

var g = new common.grid({
    el: '#basicTable',
    size: 10,

    complete: function () {
        $('#basicTable').poptrox({
            usePopupCaption: true
        });
    },

    parms: function () {

        return {
            status: $('#status').val(),
            recomReward: $('#recomReward').val(),
            hasImage: $('#hasImage').val(),
            beginTime: common.util.__input('beginTime'),
            endTime: common.util.__input('endTime'),
            uid: common.util.__input('uid'),
            productName: common.util.__input('productName'),
            productSkn: common.util.__input('productSkn'),
            orderCode: common.util.__input('orderCode')
        };
    },
    columns: [{
        display: '订单号',
        name: "orderId"
    }, {
        display: '商品名称',
        render: function (item) {
            var goods = item.goods;
            if (goods != null) {
                productHref = "http://item.yohobuy.com/product/pro_" + item.productId + "_" + goods.goodsId + "/" + goods.cnAlphabet + ".html";
            }
            return '<a href="' + productHref + '">' + item.productName + '</a>';
        }
    }, {
        display: '用户id',
        name: "uid"
    }, {
        display: '商品图片',
        render: function (item) {
            var imgurl = goodsImg(item);

            if (imgurl && imgurl != "") {
                return ' <a class="pop" href="' + goodsImg(item) + '"> <img src="' + goodsImg(item) + '" title="' + item.productName + '"  width="100" height="60"/> </a>';

            }
        }
    }, {
        display: "评价图片",
        render: function (item) {
            if (item.url && item.url != "") {
                return '<a class="pop" href="' + item.url + '"><img src="' + item.url + '" " title="' + item.orderId + '" width="100" height="60"/> </a>'
            }
        }
    }, {
        display: '评价内容',
        name: "content",
        //width:'15%',
        style: "width:15%; word-break:break-all;"
    }
        , {
            display: '评价星级',
            name: "satisfied"
        }, {
            display: '审核状态',
            render: function (item) {

                return "<p>" + ENUM.AuditEnum[item.status]?ENUM.AuditEnum[item.status]:"" + "</p>";
            }
        },
        {
            display: '审核返币',
            render: function (item) {
                return "<p>" + ENUM.RewardEnum[item.shareReward]?ENUM.RewardEnum[item.shareReward]:"" + "</p>";
            }
        },
        {
            display: '推荐状态',
            render: function (item) {
                return "<p>" + ENUM.RecommendEnum[item.recomReward]? ENUM.RecommendEnum[item.recomReward]:"" + "</p>";
            }
        }, {
            display: "创建时间",

            render: function (item) {
                var t = new Date(item.createTime * 1000);
                var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
                return "<p>" + formatted + "</p>";
            }
        }, {
            display: '备注',
            name: "remark"
        }, {
            display: '审核操作',
            //}
            render: function (items) {
                var HtmArr = [];

                if (items.status == 0) {
                    HtmArr.push('<a style="margin-bottom:10px;" data-index="' + items.__index + '" data-type="pass" href="JavaScript:;" class="btn btn-success btn-xs aud">审核通过</a>');
                    HtmArr.push('<a data-index="' + items.__index + '" data-type="fail" href="JavaScript:;" class="btn btn-danger btn-xs aud">审核不通过</a>');
                } else if (items.status == 1) {
                    HtmArr.push('<a  data-index="' + items.__index + '" data-type="cancelpass" href="JavaScript:;" class="btn btn-warning btn-xs aud">取消审核通过</a>');
                } else if (items.status == 2) {
                    HtmArr.push('<a data-index="' + items.__index + '" data-type="cancelpass" href="JavaScript:;" class="btn btn-warning btn-xs aud">取消审核不通过</a>');
                }

                return HtmArr.join('');
            }
        }, {
            display: '推荐操作',
            //}
            render: function (items) {
                var HtmArr = [];

                if (items.recomReward == 0) {
                    HtmArr.push('<a  data-index="' + items.__index + '" data-type="pass" href="JavaScript:;" class="btn btn-success btn-xs recomment">推荐</a>');
                } else {
                    HtmArr.push('<a data-index="' + items.__index + '" data-type="fail" href="JavaScript:;" class="btn btn-danger btn-xs recomment">取消推荐</a>');
                }

                return HtmArr.join('');
            }
        }
    ]
});
g.init('/shareOrder/shareOrderList');


// 审核
$(document).on('click', '.aud', function () {
    var item = g.rows[$(this).data("index")];

    var type = $(this).data('type');
    common.util.__ajax({
        url: '/shareOrder/aud',
        data: {
            commentId: item.id,
            result: type,
            uid: item.uid
        }
    }, function (res) {
        if (res.code == 200) {
            common.util.__tip('操作成功', 'success');
            g.reload();
        } else {
            common.util.__tip(res.message);
        }
    }, true);

});


// 推荐
$(document).on('click', '.recomment', function () {
    var item = g.rows[$(this).data("index")];

    var type = $(this).data('type');
    common.util.__ajax({
        url: '/shareOrder/recommend',
        data: {
            commentId: item.id,
            recomReward: type,
            uid: item.uid
        }
    }, function (res) {
        if (res.code == 200) {
            common.util.__tip('操作成功', 'success');
            g.reload();
        } else {
            common.util.__tip(res.message);
        }
    }, true);

});

$(document).on('click', '#filter', function () {
    g.reload();
});