Authored by 王钱钧

【产品管理】->【尺码属性管理】功能添加

/**
* 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();
//});
});
}
... ...
/**
* Created by wangqianjun on 16/2/3.
*/
//接口主域
var env = process.env.NODE_ENV || 'development';
// exports.domain = 'http://192.168.102.205:18025';
var domain = {
//development:'http://localhost:30012',
//development:'http://172.16.6.227:8083/yohobuy-platform-web',
development: 'http://192.168.102.215:8080/platform',
test:'http://192.168.102.205:18025/yoho-adminportal-web',
preview:'http://192.168.81.13:8189/yoho-admin-portal',
production:'http://192.168.81.6:8189/yoho-admin-portal'
};
exports.domain = domain[env];
//路由配置
exports.res = [
{
//产品管理【品类列表】页面渲染
route: '/erpproduct/sizeattribute/index',
method: 'GET',
view: 'pages/product/size-property',
src: '/product/size-property',
isJsonRaw:true
}, {
route: '/erpproduct/sizeattribute/propertyList',
method: 'POST',
url: '/product/querySizeAttributeList', //接口的url
isJsonRaw:true,
params:[
{name: 'page', type: 'Number', def: '1'}, //页码
{name: 'size', type: 'Number', def : '10'} //每页条数
]
}, {
route: '/erpproduct/sizeattribute/propertyAdd', // 添加尺码属性
method: 'POST',
url: '/product/addSizeAttribute', //接口的url
isJsonRaw:true,
params:[
{name: 'attributeName', type: 'String'} //名称
]
}, {
route: '/erpproduct/sizeattribute/propertyModify', // 修改尺码属性
method: 'POST',
url: '/product/updateSizeAttribute', //接口的url
isJsonRaw:true,
params:[
{name: 'id', type: 'Number'}, //id
{name: 'attributeName', type: 'String'} //名称
]
}
];
\ No newline at end of file
... ...
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">尺码属性管理</a></li>
<li>尺码属性管理</li>
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>尺码属性列表</h4>
</div>
</div>
</div>
</div>
</div>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-body">
<div class="row">
<a class="btn btn-info" data-toggle="modal" href='#modal-id'>添加尺码属性</a>
</div>
</div>
<input type="hidden" id="url" value="/erpproduct/sizeattribute/propertyList"/>
<div id="size-property">
</div>
</div>
</div>
<div class="modal fade" id="modal-id">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">添加尺码属性</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="input" class="col-sm-2 control-label">尺码名:</label>
<div class="col-sm-10">
<input type="text" name="" id="input" class="form-control" value="" required="required" pattern="" title="">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary add">保存</button>
</div>
</div>
</div>
</div>
... ...