index.js 2.14 KB
/**
 * 商品管理列表
 */
'use strict';
var $ = require('jquery'),
    Handlebars = require('yoho.handlebars'),
    grid = require('../common/grid'),
    dropDown = require('../common/dropDown');

require('../util/jquery.simplePagination');
require('../util/jquery.gritter');

exports.init = function() {
	//下拉框
    $('.select2-offscreen').select2();
    new dropDown({
        el:'#brand-id',
        ajax:'brand'
    });

    var btnAuthority = JSON.parse($('#btnAuthority').val());

    var g = new grid({
        el: '#basicTable',
        size: 10,
        parms: function() {
            return {
                skn: $.trim($('#skn').val()) || '',
                brandName: $.trim($('#brand-name').val()) || '',
                storeName: $.trim($('#store-name').val()) || '',
                status: $.trim($('#status').val()) || '',
                jit: $.trim($('#jit').val()) || ''
            };
        },
        columns: [
            {display: 'SKN', name: 'skn'},
            {display: '图片', name: "goodsIcon", render: function(item) {
            	return '<img src="' + item.goodsIcon + '">';
            }},
            {display: '商品名称', name: "goodsName"},
            {display: '品牌', name: "brandName"},
            {display: '吊牌价', name: "price"},
            {display: '更新时间', name: "updateTime"},
            {display: '操作', name:"status", render: function(items) {
                var HtmArr = [];

                if (btnAuthority.detail) {
                    HtmArr.push('<a href="supplier/baseaudit/info?product_skn='+ items.skn+'"" class="btn btn-info btn-xs">详情</a>');
                }
                if (items.status === 0) {
                    HtmArr.push('<a data-id="' + items.id + '" href="JavaScript:;" class="btn btn-warning btn-xs open-brand">开启品牌</a>');
                }
                if (items.status === 1) {
                    HtmArr.push('<a data-id="' + items.id + '" href="JavaScript:;" class="btn btn-danger btn-xs close-brand">关闭品牌</a>');
                }
                return HtmArr.join('');
            }}
        ]
    })
    
    g.init($("#gridurl").val());

}