index.js 3.02 KB
'use strict';
var $ = require('jquery'),
    common=require('../common/common');

var ENUM={
    status:{0:'待审核',1:'审核通过',2:'驳回',3:'过期',4:'作废'},//全部
    tips:{"0":0,"1":0,"2":0,"3":0,"4":0,"all":0}
}

/*下拉选择*/
new common.dropDown({el:"#store",ajax:"queryShop"});
new common.dropDown({el:"#brand",ajax:"queryBrand"});
new common.dropDown({el:"#createor",ajax:"querySupplier"});

var t = new common.tab({
    el:"#basicTab",
    click:function(){
        g.reload(1);
    },
    columns:[
        {name:"0",display:"待审核({0})"},
        {name:"1",display:"审核通过({1})"},
        {name:"2",display:"驳回({2})"},
        {name:"3",display:"过期({3})"},
        {name:"4",display:"作废({4})"},
        {name:"all",display:"全部({all})"}
    ]
}).init(ENUM.tips);


var g = new common.grid({
    el: '#basicTable',
    parms:function(){
    	return {
            brandId:common.util.__input("brandId"),
            name:common.util.__input("filter-name"),
            reqDepartment:common.util.__input("filter-dep"),
            status: t.active
        };
    },
    columns:[
    	{display:"SKN",name:"skn"},
    	{display:"商品信息",render:function(item){
    		var html=[];
    		html.push("<p>名称:"+item.productName+"</p>");
    		html.push("<p>品牌:"+item.productName+"</p>");
    		html.push("<p>品类:"+item.productName+"</p>");
    		return html.join('');
    	}},
    	{display:"售价",name:"salesPrice"},
    	{display:"年龄层/性别",name:"skn"},
    	{display:"是否预售",name:"skn"},
    	{display:"奥莱",name:"skn"},
    	{display:"商品类别",name:"skn"},
    	{display:"其他",name:"skn"},
    	{display:"创建时间",name:"skn"},
    	{display:"创建人",name:"skn"},
    	{display:"操作",render:function(item){
    		var HtmArr=[];
    		HtmArr.push('<a class="btn btn-info btn-xs apply-update" href="/base/goods/update/:productSkn">修改</a>');
    		HtmArr.push('<a class="btn btn-primary btn-xs apply-success" data-index="'+ item.__index+'" href="javascript:;">通过</a>');
            HtmArr.push('<a class="btn btn-warning btn-xs apply-back" data-index="'+ item.__index+'" href="javascript:;">驳回</a>');
            return HtmArr.join('');
    	}}
    ]
});
g.init('/base/goods/ajax/index');


var Bll={
	toast:function(content,fn){
        common.dialog.confirm("温馨提示",content,function(){
            common.util.__ajax({
                url:'/supplier/index/status',
                data:fn()
            },function(){
                g.reload();
            });
        });
    }
}
//通过
$(document).on("click",".apply-success",function(){
	var item=g.rows[$(this).data("index")];
    var data=function(){
        return {
                id:item.id
            };
    }
    Bll.toast("你确定审核通过吗?",data);
});
//驳回
$(document).on("click",".apply-back",function(){
	var item=g.rows[$(this).data("index")];
    var data=function(){
        return {
                id:item.id
            };
    }
    Bll.toast($("#template").html(),data);
});