Authored by weiqingting

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop

... ... @@ -7,7 +7,9 @@ var urlObj={
'brand':'/brand/getBrandNames',
'managerName':'/supplier/storeadmin/managerName',
'sortattribute':'/erpproduct/sortattribute/ajax/automatic',
'sortsize':'/erpproduct/sortsize/ajax/automatic'
'sortsize':'/erpproduct/sortsize/ajax/automatic',
'shopsRest':'/ShopsRest/getShopsByName'
};
var dropDown=function(option){
... ...
... ... @@ -3,96 +3,64 @@
*/
'use strict';
var $ = require('jquery'),
Handlebars = require('yoho.handlebars');
common = require('../common/common');
var dropDown=require('../common/dropDown');
require('../util/jquery.gritter');
var grid=require('../common/grid');
exports.init = function () {
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 common.grid({
el: '#size-property',
columns: [
{display: "编号", name: "id"},
{display: "属性名", name: "attributeName"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info add2" data-index="' + item.__index + '">编辑</a>';
}
}
});
}
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 item = g.rows[$(this).data("index")];
common.dialog.confirm("修改尺码属性",
common.util.__template($("#template").html(), {id: item.id, input: item.attributeName})
, function () {
common.util.__ajax({
url: '/erpproduct/sizeattribute/propertyModify',
data: {
id: item.id,
attributeName: $("#input").val()
}
}, function () {
g.reload();
});
});
});
// 添加&编辑 尺码属性
$('#size-property').on('click','.add2',function(){
$('#add').on('click', function () {
common.dialog.confirm("添加尺码属性",
common.util.__template($("#template").html(), {id: "", input: ""})
, function () {
common.util.__ajax({
url: '/erpproduct/sizeattribute/propertyAdd',
data: {
attributeName: $("#input").val()
}
}, function () {
g.reload();
});
});
});
}
var id = $(this).attr('id');
var options = {};
if()
//__ajax({
// url: "/erpproduct/sizeattribute/propertyAdd",
// data:{
// attributeName: $('#input').val()
// }
//},function(){
// g.reload();
//});
});
}
... ...
// 尺码管理
var $ = require('jquery');
var edit = require('../common/edit');
var dropDown = require('../common/dropDown');
var dropDown = require('../common/dropDown');
var Handlebars = require('yoho.handlebars')
common = require('../common/common');
exports.init = function() {
$('.getsize').on('click', function() {
$.ajax({
url: '/erpproduct/size/getSize',
type: 'POST',
dataType: "json",
data: {
id: $(this).data('id')
},
success: function(data) {
console.log(data.data.data);
var siezNameBox = [];
siezNameBox.push('<input type="hidden" id="id" value="'+data.data.data.id+'" />');
siezNameBox.push('<input class="form-control"id="siezName" type="text" value="'+data.data.data.sizeName+'" />');
$('#siezNameBox').html(siezNameBox);
var g = new common.grid({
el: '#size-list',
columns: [
{display: "编号", name: "id"},
{display: "尺码名", name: "sizeName"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info add2" data-index="' + item.__index + '">编辑</a>';
}
})
});
$('#addSize').on('click',function(){
$('#siezNameBox').html('<input id="siezName" class="form-control" type="text" value="" />');
$('#modal-id').modal('show');
})
$('.add').on('click', function() {
var id= $('#id').val();
var siezName= $('#siezName').val();
console.log(siezName);
if(!id){
__ajax({
url:'/erpproduct/size/addSize',
data:{
sizeName: siezName
}
})
}else{
__ajax({
url:'/erpproduct/size/updateSize',
data:{
id:id,
sizeName: siezName
}
})
}
})
function __ajax(options,callback){
$.ajax({
type: 'POST',
url: options.url,
dataType: 'json',
data:options.data||{},
success: function(res) {
res=res.data;
if (res.code === 200) {
$.gritter.add({
title: options.msg||"提交成功",
class_name: 'growl-success',
sticky: false,
time: '1000',
after_open: function() {
callback&&callback();
}
});
setInterval(function(){
history.go(0);
},1000)
} else {
$.gritter.add({
title: '提交失败',
class_name: 'growl-danger',
sticky: false,
time: '1000'
});
setInterval(function(){
history.go(0);
},1000)
}
}
]
});
}
function getArr(curPage, pageCount) {
var arr = [];
//改变标签数,最好是奇数.......
var paginitionLength = 5;
var middle = Math.ceil(paginitionLength / 2);
g.init($('#url').val());
$('#size-list').on('click', '.add2', function () {
if (curPage - 1 >= pageCount) {
console.log('err data');
return false;
}
var item = g.rows[$(this).data("index")];
for (var i = 0; i < pageCount && i < paginitionLength; i++) {
arr[i] = i + 1;
}
console.log(item);
// 修改尺码
common.dialog.confirm("修改尺码属性",
common.util.__template($("#template").html(), {id: item.id, input: item.sizeName})
, function () {
common.util.__ajax({
url: '/erpproduct/size/updateSize',
data: function () {
if (curPage <= middle) {
return arr;
}
if (curPage > middle && curPage < pageCount + 1 - middle) {
for (var p = 0; p < arr.length; p++) {
arr[p] = curPage - (paginitionLength - middle - p);
}
if($("#input").val()==""){
return "尺码名不能为空";
}
} else {
for (var k = 0; k < arr.length; k++) {
arr[k] = pageCount - paginitionLength + k + 1;
}
}
return {
id: item.id,
sizeName: $("#input").val()
}
}
}, function () {
g.reload();
});
});
});
return arr;
}
Handlebars.registerHelper("page", function(value) {
var html = [];
var all = getArr(this.number,this.totalPages);
html.push('<li><a href="/erpproduct/size/index/1" aria-label="Previous">&laquo;</a></li>')
$.each(all, function(index) {
html.push('<li><a href="/erpproduct/size/index/' + all[index] + '" aria-label="Previous">' + all[index] + '</a></li>');
})
html.push('<li><a href="/erpproduct/size/index/'+this.totalPages+'" aria-label="Previous">&raquo;</a></li>')
return html.join('');
// 添加尺码
$('#add').on('click', function () {
common.dialog.confirm("添加尺码属性",
common.util.__template($("#template").html(), {id: "", input: ""})
, function () {
common.util.__ajax({
url: '/erpproduct/size/addSize',
data: {
sizeName: $("#input").val()
}
}, function () {
g.reload();
});
});
});
var pagecm = Handlebars.compile($("#pagenation-template").html().replace(/\\/g, ''));
$('#pagewrapper').html(pagecm({
totalPages: $('#totalPages').text(),
number:$('#number').text()
}));
};
\ No newline at end of file
... ...
... ... @@ -7,8 +7,7 @@ var grid=require('../common/grid');
require('../util/jquery.gritter');
exports.init=function(){
new dropDown({el:"#store-name",ajax:"brand"});
new dropDown({el:"#identity-type"});
new dropDown({el:"#store-name",ajax:"shopsRest"});
function __ajax(options,callback){
$.ajax({
... ... @@ -57,6 +56,7 @@ exports.init=function(){
identity: $('#identity-type option:selected').val()
},
success: function(data) {
$('#manager-name').html('');
$.each(data.data.data,function(index){
console.log(data.data.data[index].truename);
$('#manager-name').append("<option value='"+data.data.data[index].pid+"'>"+data.data.data[index].truename+"</option>");
... ...
... ... @@ -91,7 +91,7 @@ exports.init = function() {
function(option) {
option.success = function(res) {
if (res.data.code == "200") {
location.href="/supplier/store/index";
history.go(-1);
} else {
e.$tip("提交失败");
}
... ... @@ -110,7 +110,7 @@ exports.init = function() {
function(option) {
option.success = function(res) {
if (res.data.code == "200") {
location.href="/supplier/store/index";
history.go(-1);
} else {
e.$tip("提交失败");
}
... ... @@ -132,11 +132,13 @@ exports.init = function() {
homepage.each(function(index) {
hplist.push(homepage[index].value);
});
console.log('hplist:'+hplist);
var homeurl = $("input[name='homeurl']");
var homeurlist = [];
homeurl.each(function(index) {
homeurlist.push(homepage[index].value);
homeurlist.push(homeurl[index].value);
});
console.log('homeurlist:'+homeurlist);
var homeaddress = $("input[name='homeaddresslist']");
var homeaddresslist = [];
homeaddress.each(function(index) {
... ... @@ -150,7 +152,6 @@ exports.init = function() {
shopRelation.push('"agreementEndTime":'+$('#updateBrand tbody tr').eq(index).find('td').eq(1).find('.agreementendtime').val()+',');
shopRelation.push('"brandId":'+$('#updateBrand tbody tr').eq(index).find('td').eq(1).find('.brandid').val()+',');
shopRelation.push('"supplierId":'+$('#updateBrand tbody tr').eq(index).find('td').eq(1).find('.supplierid').val());
console.log(index,updateBrand.length-1);
if(index==updateBrand.length-1){
shopRelation.push('}')
}else{
... ... @@ -158,10 +159,9 @@ exports.init = function() {
}
});
shopRelation.push(']')
console.log(shopRelation.join(''));
submit(function(data) {
data.websiteUrl = hplist.toString();
data.otherUrl = homeurlist.toString();
data.otherUrl= hplist.toString();
data.websiteUrl = homeurlist.toString();
data.shopAddress = homeaddresslist.toString();
data.onCheck = onCheck;
data.shopsId = shopsId;
... ... @@ -174,30 +174,30 @@ exports.init = function() {
var homepage = $('#otherUrl').val().split(',');
$.each(homepage,
function() {
$('#homepage').append('<input value="' + this + '" type="text" name="homepage" class="form-control" style="margin-buttom:15px;">')
$('#homepage').append('<input value="' + this + '" type="text" name="homepage" class="form-control" style="margin-bottom:15px;">')
})
}else{
$('#homepage').append('<input type="text" name="homepage" class="form-control" style="margin-buttom:15px;">')
$('#homepage').append('<input type="text" value="'+$('#otherUrl').val()+'" name="homepage" class="form-control" style="margin-bottom:15px;">')
}
if ($('#websiteUrl').val().split(',').length > 1) {
var websiteUrl = $('#websiteUrl').val().split(',');
$.each(websiteUrl,
function() {
$('#homeurl').append('<input value="' + this + '" type="text" name="homeurl" class="form-control" style="margin-buttom:15px;">')
$('#homeurl').append('<input value="' + this + '" type="text" name="homeurl" class="form-control" style="margin-bottom:15px;">')
})
}else{
$('#homeurl').append('<input type="text" name="homeurl" class="form-control" style="margin-buttom:15px;">')
$('#homeurl').append('<input type="text" value="'+$('#websiteUrl').val()+'" name="homeurl" class="form-control" style="margin-bottom:15px;">')
}
if ($('#shopAddress').val().split(',').length > 1) {
var shopAddress = $('#shopAddress').val().split(',');
$.each(shopAddress,
function() {
$('#homeaddress').append('<input value="' + this + '" type="text" name="homeaddresslist" class="form-control" style="margin-buttom:15px;">')
$('#homeaddress').append('<input value="' + this + '" type="text" name="homeaddresslist" class="form-control" style="margin-bottom:15px;">')
})
}else{
$('#homeaddress').append('<input type="text" name="homeaddresslist" class="form-control" style="margin-buttom:15px;">')
$('#homeaddress').append('<input type="text" value="'+$('#shopAddress').val()+'" name="homeaddresslist" class="form-control" style="margin-bottom:15px;">')
}
});
$('#brand-name').on('change',function() {
... ...
... ... @@ -6,18 +6,17 @@ exports.res = [{
route: '/erpproduct/size/index',
method: 'GET',
view: 'pages/product/siezChart',
url:'/product/querySizeList',
//url:'/product/querySizeList',
isJsonRaw:true,
params: [
{name: 'page', type: 'Number',def:1},
{name: 'size', type: 'Number',def:10}
],
//params: [
// {name: 'page', type: 'Number',def:1},
// {name: 'size', type: 'Number',def:10}
//],
src: '/product/sizeChart'
},{
// 产品管理【尺寸】页面分页渲染
route: '/erpproduct/size/index/:page',
method: 'GET',
view: 'pages/product/siezChart',
route: '/erpproduct/sizeattribute/sizeList',
method: 'POST',
url:'/product/querySizeList',
isJsonRaw:true,
params: [
... ... @@ -44,7 +43,7 @@ exports.res = [{
{name: 'sizeName', type: 'String'}
]
},{
// 新增尺码
// 修改尺码
route: '/erpproduct/size/updateSize',
method: 'POST',
url:"/product/updateSize",
... ...
/**
* Created by wangqianjun on 16/2/3.
*/
exports.domain = require('../config/common.js').domain;
exports.domain = require('../config/common.js').domain;
//路由配置
exports.res = [
{
... ...
... ... @@ -248,4 +248,15 @@ exports.res = [{
params:[
{name:"brandId",type:"Number"}
]
}]
\ No newline at end of file
},{
// 店铺列表
route: '/ShopsRest/getShopsByName',
method: 'POST',
url:"/ShopsRest/selectCheckPassShopsByName",
isJsonRaw:true,
params:[
{name:"shopName",type:"String"}
]
}]
\ No newline at end of file
... ...
... ... @@ -18,59 +18,27 @@
</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" id="addSize">添加尺码</a>
<a class="btn btn-info" id="add">添加尺码</a>
</div>
</div>
<table class="table table-striped table-bordered responsive dataTable no-footer">
<thead>
<tr>
<th>编号</th>
<th>尺码名</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{#data.list}}
<tr>
<td>{{id}}</td>
<td>{{sizeName}}</td>
<td><a class="btn btn-info getsize" data-id="{{id}}" data-toggle="modal" href='#modal-id'>操作</a></td>
</tr>
{{/data.list}}
</tbody>
</table>
</div>
<input type="hidden" id="url" value="/erpproduct/sizeattribute/sizeList"/>
<div id="size-list">
{{#data}}
<div style="display: none;" id="totalPages">{{totalPage}}</div>
<div style="display: none;" id="number">{{page}}</div>
<nav ><ul class="pagination" id="pagewrapper"></ul></nav>
{{/data}}
</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" id="siezNameBox"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary add">保存</button>
</div>
</div>
</div>
</div>
<script id="pagenation-template" type="text/x-handlebars-template">
\{\{#page\}\}
\{\{/page\}\}
</script>
\ No newline at end of file
<script type="text/template" id="template">
<div class="form-group">
<label for="input" class="col-sm-2 control-label">尺码名:</label>
<div class="col-sm-10">
<input type="hidden" name="" value="{id}" id="id" class="form-control" value="" required="required" pattern="" title="">
<input type="text" name="" value="{input}" id="input" class="form-control" value="" required="required" pattern="" title="">
</div>
</div>
</script>
\ No newline at end of file
... ...
... ... @@ -23,7 +23,7 @@
<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>
<a class="btn btn-info" id="add">添加尺码属性</a>
</div>
</div>
<input type="hidden" id="url" value="/erpproduct/sizeattribute/propertyList"/>
... ... @@ -33,25 +33,15 @@
</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>
<script type="text/template" id="template">
<div class="form-group">
<label for="input" class="col-sm-2 control-label">尺码属性名:</label>
<div class="col-sm-10">
<input type="hidden" name="" value="{id}" id="id" class="form-control" value="" required="required" pattern="" title="">
<input type="text" name="" value="{input}" id="input" class="form-control" value="" required="required" pattern="" title="">
</div>
</div>
</div>
</script>
... ...
... ... @@ -33,13 +33,16 @@
</div>
<div class="panel-body">
<div class="row">
<span class="col-sm-1 control-label">店铺列表 *</span>
<select name="supplier-name" id="store-name" style="width: 280px;" tabindex="-1" title="" class="select2-offscreen brandBtn-group brandBtn-group-lg">
<option value="-1">店铺列表</option>
</select>
<div style="margin-top: 20px;">
<span class="col-sm-1 control-label">管理员筛选 *</span>
<select name="store-type" id="identity-type" style="width: 280px;" tabindex="-1" title="" class="select2-offscreen brandBtn-group brandBtn-group-lg"><option value="-1" selected="selected">请选择身份</option>
<div class="container-fluid">
<span class="col-sm-1 control-label">店铺列表</span>
<select name="supplier-name" id="store-name" style="width: 280px;" tabindex="-1" title="" class="select2-offscreen brandBtn-group brandBtn-group-lg">
<option value="-1">店铺列表</option>
</select>
</div>
<div class="contentpanel" style="margin-top: 20px;">
<span class="col-sm-1 control-label">管理员筛选</span>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<select name="store-type" id="identity-type" style="width: 280px;" tabindex="-1" title="" class="form-control"><option value="-1" selected="selected">请选择身份</option>
<option value="1" data-valid="">品牌公司</option>
<option value="2" data-valid="">品牌经销商</option>
<option value="3" data-valid="">品牌代运营商</option>
... ... @@ -48,9 +51,12 @@
<option value="6" data-valid="">有货商品运营</option>
<option value="7" data-valid="">有货平台运营</option>
</select>
<select name="time-sort" id="manager-name" tabindex="-1" title="" class="select2-offscreen brandBtn-group">
<option value="-1">选择管理员</option>
</select>
</div>
<div class="col-sm-2">
<select name="time-sort" id="manager-name" tabindex="-1" title="" class="form-control">
<option value="-1">选择管理员</option>
</select>
</div>
</div>
... ...