goods.yohoCoin.Audit.js 12.3 KB
webpackJsonp([57],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	//yoho币
	'use strict';
	var $ = __webpack_require__(1),
	    common=__webpack_require__(2);

	var ENUM = {
	    gender: {
	        1: '男',
	        2: '女',
	        3: '通用'
	    },
	    status: {
	        0: '未设置',
	        1: '<b style="color:#428bca">待审核</b>',
	        2: '<b style="color:#5cb85c">通过</b>',
	        3: '<b style="color:#ff0000">驳回</b>'
	    },
	    auditor: {
	        2965: 'Tracy',
	        10235: 'David Wong'
	    }
	}
	var gridParams = function() {
	    var select = tabTree.getAddress();
	    return {
	        auditStatus: $("#yohoCoinNav .active").data('status'),
	        productSkn: common.util.__input("skn"),
	        shopId: common.util.__input("shop"),
	        brandId: common.util.__input("brand"),
	        supplierId: common.util.__input("supplier"),
	        gender: common.util.__input("gender"),
	        auditorId: common.util.__input("auditor"),
	        maxSortId: select[0] ? select[0].id : "",
	        middleSortId: select[1] ? select[1].id : "",
	        smallSortId: select[2] ? select[2].id : "",
	        sortId: select[3] ? select[3].id : ""
	    };
	}
	var COLUMNS = {
	    c1: [   //待审核列表
	            {display: '', type: 'checkbox'},
	            {display: 'SKN', name: 'productSkn'},
	            {display: '商品信息', name: 'info', render: function(item) {
	                var html = ""
	                html +=  "<p>名称:" + item.productName + "</p>" + "<p>品牌:" + item.brandName + "</p>" + "<div>类目:";
	                if(item.maxSortName) {html += item.maxSortName;}
	                if(item.middleSortName) {html += "&nbsp;>&nbsp;" + item.middleSortName;}
	                if(item.smallSortName) {html += "&nbsp;>&nbsp;" + item.smallSortName;}
	                html += "</div>";
	                return html;
	            }},
	            {display: '供应商 / 店铺', name: 'supplier_name', render: function(item) {
	                var html = '';
	                if (item.supplierName) {html += item.supplierName;}
	                if (item.shopName) {html += '&nbsp;/&nbsp;' + item.shopName;}
	                return html;
	            }},
	            {display: '性别', name: 'gender', render: function(item) {
	                return ENUM.gender[item.gender];
	            }},
	            {display: '吊牌价', name: 'retailPrice'},
	            {display: '销售价', name: 'salesPrice'},
	            {display: '执行返币金额', name: 'returnCoin', render: function(item) {
	                return item.productPrice.returnCoinMoney;
	            }},
	            {display: '审核返币金额', name: 'needAuditCoin', render: function(item) {
	                return item.productPrice.needAuditCoin;
	            }},
	            {display: '状态', name: 'status', render: function(item) {
	                return ENUM.status[item.productPrice.coinStatus];
	            }},
	            {display: '操作信息', name: 'operateInfo', render: function(item) {
	                var html = '';
	                if (item.productPrice.founderName) {html += '<p>操作人:' + item.productPrice.founderName + '</p>';}
	                if (item.productPrice.auditDt) {html += '<div style="color: #999; font-size: 12px;">' + getTime(item.productPrice.auditDt) + '</div>';}
	                return html;
	            }},
	            {display: '操作', render: function(item) {
	                return '<a href="javascript:;" class="btn btn-success btn-xs btn-checkOk" data-skn="' + item.productSkn + '">审核通过</a>' +
	                    '<a href="javascript:;" class="btn btn-danger btn-xs btn-checkNo" data-skn="' + item.productSkn + '">驳回</a>';
	            }}
	        ],
	    c2: [   //通过,驳回,全部列表展示
	            {display: 'SKN', name: 'productSkn'},
	            {display: '商品信息', name: 'info', render: function(item) {
	                var html = ""
	                html +=  "<p>名称:" + item.productName + "</p>" + "<p>品牌:" + item.brandName + "</p>" + "<div>类目:";
	                if(item.maxSortName) {html += item.maxSortName;}
	                if(item.middleSortName) {html += "&nbsp;>&nbsp;" + item.middleSortName;}
	                if(item.smallSortName) {html += "&nbsp;>&nbsp;" + item.smallSortName;}
	                html += "</div>";
	                return html;
	            }},
	            {display: '供应商 / 店铺', name: 'supplier_name', render: function(item) {
	                var html = '';
	                if (item.supplierName) {html += item.supplierName;}
	                if (item.shopName) {html += '&nbsp;/&nbsp;' + item.shopName;}
	                return html;
	            }},
	            {display: '性别', name: 'gender', render: function(item) {
	                return ENUM.gender[item.gender];
	            }},
	            {display: '吊牌价', name: 'retailPrice'},
	            {display: '销售价', name: 'salesPrice'},
	            {display: '执行返币金额', name: 'returnCoin', render: function(item) {
	                return item.productPrice.returnCoinMoney;
	            }},
	            {display: '审核返币金额', name: 'needAuditCoin', render: function(item) {
	                return item.productPrice.needAuditCoin;
	            }},
	            {display: '状态', name: 'status', render: function(item) {
	                var html = "<div>" + ENUM.status[item.productPrice.coinStatus] + "</div>";
	                if(item.productPrice.coinStatus == 3){
	                    html += '<a class="noCheckReason" href="javascript:" data-text="'+ item.productPrice.comment +'" style="color: #ec971f;text-decoration: underline;margin:0">驳回理由</a>';
	                }
	                return html;
	            }},
	            {display: '审批人', name: 'auditor', render: function(item) {
	                return ENUM.auditor[item.productPrice.auditorId];
	            }},
	            {display: '操作信息', name: 'operateInfo', render: function(item) {
	                var html = '';
	                if (item.productPrice.founderName) {html += '<p>操作人:' + item.productPrice.founderName + '</p>';}
	                if (item.productPrice.auditDt) {html += '<div style="color: #999; font-size: 12px;">' + getTime(item.productPrice.auditDt) + '</div>';}
	                return html;
	            }}
	        ]
	}

	new common.dropDown({
	    el: '#shop',
	    ajax: 'shopsRest'
	});
	new common.dropDown({
	    el: '#brand',
	    ajax: 'brand'
	});
	new common.dropDown({
	    el: '#supplier',
	    ajax: 'querySupplier'
	});

	//多级菜单
	var tabTree = new common.tabTree("#sortTree", {status: 1, sortLevel: 1});
	tabTree.init();

	var g1 = new common.grid({
	    el: "#yohoCoinAudit_table",
	    parms: gridParams,
	    columns: COLUMNS.c1
	}),
	    g2 = new common.grid({
	    el: "#yohoCoinAudit_table",
	    parms: gridParams,
	    columns: COLUMNS.c2
	}),
	    g = null;

	//审批通过
	function ajaxCheckOk(productSkn){
	    common.util.__ajax({
	        url:'/good/yohoCoin/pass',
	        data: {
	            "productSkn": productSkn
	        }
	    },function(rs){
	        g.reload();
	    });
	}

	//批量审核通过
	function ajaxCheckOkBatch(productSkns){
	    common.util.__ajax({
	        url:'/good/yohoCoin/passBatch',
	        data: {
	            "productSkns": JSON.stringify(productSkns)
	        }
	    },function(rs){
	        g.reload();
	    });
	}

	//驳回
	function ajaxCheckNo(productSkn, comment){
	    common.util.__ajax({
	        url:'/good/yohoCoin/reject',
	        data: {
	            "productSkn": productSkn,
	            "comment": comment
	        }
	    },function(rs){
	        g.reload();
	    });
	}

	//批量驳回
	function ajaxCheckNoBatch(productSkns, comment){
	    common.util.__ajax({
	        url:'/good/yohoCoin/rejectBatch',
	        data: {
	            "productSkns": JSON.stringify(productSkns),
	            "comment": comment
	        }
	    },function(rs){
	        g.reload();
	    });
	}

	//找到以选中的商品的SKN
	function findCheckedSknList(){
	    var sknList = new Array();
	    var checkedItems = $("#yohoCoinAudit_table").find(".wqt_checkbox:checked");
	    $.each(checkedItems, function(index,value){
	        var skn = $(value).parent().next().text();
	        sknList.push(skn);
	    });
	    return sknList;
	}

	//时间转换
	function getTime(time){
	    var t = new Date(time);
	    var formattedTime = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
	    return formattedTime;
	}

	//批量审批通过
	$(document).on('click', '#all-checkOk', function() {
	    var checkOkList = findCheckedSknList();
	    if(checkOkList.length > 0){
	        common.dialog.confirm(
	            "批量审核通过确认",
	            "你确认<strong style='color:#5cb85c'>&nbsp;&nbsp;批量审核通过&nbsp;&nbsp;</strong>么?",
	            function(){
	                ajaxCheckOkBatch(checkOkList);
	            },
	            function(){}
	        );
	    }else{
	        common.util.__tip("没有选择任何商品!");
	    }
	});

	//批量驳回
	$(document).on('click', '#all-checkNo', function() {
	    var checkNoList = findCheckedSknList();
	    if(checkNoList.length > 0){
	        common.dialog.confirm(
	            "批量审核驳回确认",
	            "你确认<strong style='color:#d9534f'>&nbsp;&nbsp;批量审核驳回&nbsp;&nbsp;</strong>么?如果确认,<strong style='color: #f0ad4e'>请填写驳回理由!</strong> \
	            <textarea id='checkComment' class='form-control' rows='3' style='margin: 10px 0'></textarea> \
	            <div class='checkTip' style='display: none; color: #ff0000; font-weight: bold'><span>提示:请填写驳回理由!</span></div>",
	            function(){
	                var comment = $("#checkComment").val();
	                if(comment){
	                    ajaxCheckNoBatch(checkNoList, comment);
	                }else{
	                    $("#checkComment").focus();
	                    $(".checkTip").show();
	                    return false;
	                }
	            },
	            function(){}
	        );
	    }else{
	        common.util.__tip("没有选择任何商品!");
	    }
	});

	//选择分类
	$(document).on('click', '#yohoCoinNav li', function() {
	    $(this).addClass("active").siblings().removeClass("active");
	    if($(this).data("status") == "1"){
	        $("#checkOperation").show();
	        g1.init("/good/yohoCoin/queryPageList4Audit");
	        g = g1;
	    }else{
	        $("#checkOperation").hide();
	        g2.init("/good/yohoCoin/queryPageList4Audit");
	        g = g2;
	    }
	});

	//审核通过
	$(document).on('click', '.btn-checkOk', function() {
	    var productSkn = $(this).data("skn");
	    common.dialog.confirm(
	        "审核通过确认",
	        "你确认<strong style='color:#5cb85c'>&nbsp;&nbsp;审核通过&nbsp;&nbsp;</strong>么?",
	        function(){
	            ajaxCheckOk(productSkn);
	        },
	        function(){}
	    );
	});

	//驳回
	$(document).on('click', '.btn-checkNo', function() {
	    var productSkn = $(this).data("skn");
	    common.dialog.confirm(
	        "审核驳回确认",
	        "你确认<strong style='color:#d9534f'>&nbsp;&nbsp;审核驳回&nbsp;&nbsp;</strong>么?如果确认,<strong style='color: #f0ad4e'>请填写驳回理由!</strong> \
	        <textarea id='checkComment' class='form-control' rows='3' style='margin: 10px 0'></textarea> \
	        <div class='checkTip' style='display: none; color: #ff0000; font-weight: bold'><span>提示:请填写驳回理由!</span></div>",
	        function(){
	            var comment = $("#checkComment").val();
	            if(comment){
	                ajaxCheckNo(productSkn, comment);
	            }else{
	                $("#checkComment").focus();
	                $(".checkTip").show();
	                return false;
	            }
	        },
	        function(){}
	    );
	});

	//查看驳回理由
	$(document).on('click', '.noCheckReason', function() {
	    var reason = $(this).data("text");
	    common.dialog.confirm("查看驳回理由", reason, function(){}, function(){});
	});

	//筛选
	$(document).on('click', '#filter-btn', function() {
	    g.reload(1);
	});

	//全部
	$(document).on('click', '#all-btn', function() {
	    $("#yohoCoinNav li").eq(3).click();
	});

	//禁页面默认在待审核列表
	$("#yohoCoinNav li").eq(0).click();



/***/ }
]);