size-property.js 2.71 KB
/**
 * Created by wangqianjun on 16/2/3.
 */
'use strict';
var $ = require('jquery'),
    Handlebars = require('yoho.handlebars');

var dropDown=require('../common/dropDown');
require('../util/jquery.gritter');
var grid=require('../common/grid');


exports.init=function(){

    function __ajax(options,callback){
        $.ajax({
            type: 'POST',
            url: options.url,
            dataType: 'json',
            data:options.data||{},
            success: function(res) {
                res=res.data;

                $("#input").val("");
                $("#modal-id").modal('hide'); //影藏弹框

                if (res.code === 200) {
                    $.gritter.add({
                        title: options.msg||"提交成功",
                        class_name: 'growl-success',
                        sticky: false,
                        time: '1000',
                        after_open: function() {
                            callback&&callback();
                        }
                    });
                } else {
                    $.gritter.add({
                        title: '提交失败',
                        class_name: 'growl-danger',
                        sticky: false,
                        time: '1000'
                    });
                }
            }
        });
    }
    var g=new grid({
        el:'#size-property',

        // 传递给后台的参数
        parms:function(){

            //var supplierid=!!~$.trim($('#supplier-name').val())?$('#supplier-name').val():"0",
            //    brandId = !!~$.trim($('#brand-name').val())?$('#brand-name').val():"0";
            return {

            };
        },
        columns:[
            {display:"编号",name:"id"},
            {display:"属性名",name:"attributeName"},
            //{display:"包含品牌",name:"",render:function(item){
            //    var str='';
            //    $.each(item.shopRelationList,function (index,a) {
            //        str+='<p>'+a.brandName+'</p>';
            //    })
            //    return str;
            //}},
            {display:"操作",name:"", render:function(item){

                return '<a class="btn btn-info add2" id="'+item.id+'" data-toggle="modal" href="#modal-id">编辑</a>'

            }}
        ]
    });
    console.log($('#url').val());
    g.init($('#url').val());

    // 添加&编辑 尺码属性
   $('#size-property').on('click','.add2',function(){

       var id = $(this).attr('id');
       var options = {};

       if()
       //__ajax({
       //    url: "/erpproduct/sizeattribute/propertyAdd",
       //    data:{
       //        attributeName: $('#input').val()
       //    }
       //},function(){
       //    g.reload();
       //});
   });

}