Authored by liuyue

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

/**
* Created by wangqianjun on 16/2/18.
*/
var $ = require('jquery');
var edit = require('../common/edit');
// 上传图片
var e = new edit('#form-base');
e.init();
$('#save').on('click', function () {
var colorName = $('#colorName').val();
var colorCode = $('#colorCode').val();
var colorId = $('#id').val();
var url = $('#route-url').val();
// 判断是否是16进制颜色值(3位或者6位)
colorCode = colorCode.replace(/\s/g, '');
var isHexColor = /^[0-9a-fA-F]{3,6}$/.test(colorCode);
if (isHexColor) {
e.submit(url, function (option) {
option.success = function (res) {
res = res.data;
if(res.code=="200"){
e.$tip('提交成功',function(){
location.href="/erpproduct/color/index";
},'growl-success');
}else{
e.$tip(res.message);
}
return false;
}
option.error=function(res){
e.$tip("提交失败");
}
//callback&&callback(option.data);
});
} else {
alert('颜色代码不合法');
}
});
... ...
// 尺码管理
var $ = require('jquery');
var edit = require('../common/edit');
var dropDown = require('../common/dropDown');
var dropDown = require('../common/dropDown');
var Handlebars = require('yoho.handlebars')
// 【产品管理】->[颜色管理]
new edit('#colorUrlBox').init();
$('#save').on('click',function(){
var id =$('#id').val();
var colorName = $('#colorName').val();
var colorCode = $('#colorCode').val();
var colorValue = $('#colorValue').attr('value');
if(!id){
__ajax({
url:'/erpproduct/product/saveColor',
data:{
colorName: colorName,
colorCode: colorCode,
colorValue: colorValue
}
})
}else{
__ajax({
url:'/erpproduct/size/updatColor',
data:{
id:id,
colorName: colorName,
colorCode: colorCode,
colorValue: colorValue
'use strict';
var $ = require('jquery'),
common = require('../common/common');
var g = new common.grid({
el: '#color-list',
columns: [
{display: "编号", name: "id"},
{display: "颜色名称", name: "colorName"},
{display: "颜色代码", name: "colorCode"},
{display: "颜色值", name: "colorValue", render: function (item) {
return '<img src="'+item.colorValue+'"/>';
}},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info save" href="/erpproduct/product/addColor/'+item.id+'" data-index="' + item.__index + '">编辑</a>';
}
})
}
})
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(){
window.location.href='/erpproduct/color/index';
},1000)
} else {
$.gritter.add({
title: '提交失败',
class_name: 'growl-danger',
sticky: false,
time: '1000'
});
setInterval(function(){
window.location.href='/erpproduct/color/index';
},1000)
}
}
});
}
}
]
});
g.init($('#url').val());
... ...
... ... @@ -5,66 +5,64 @@
var $ = require('jquery'),
common = require('../common/common');
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>';
}
}
]
});
g.init($('#url').val());
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>';
}
}
]
});
$('#size-property').on('click', '.add2', function () {
g.init($('#url').val());
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: (function () {
var input = $('#input').val();
if (input === '' || $.trim(input) === '') return "尺码名不能为空";
return {
id: item.id,
attributeName: $("#input").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: (function(){
var input = $('#input').val();
if (input === '' || $.trim(input) === '') return "尺码名不能为空";
return {
id: item.id,
attributeName: $("#input").val()
};
})()
}, function () {
g.reload();
});
}, function () {
g.reload();
});
});
});
});
// 添加&编辑 尺码属性
$('#add').on('click', function () {
// 添加&编辑 尺码属性
$('#add').on('click', function () {
common.dialog.confirm("添加尺码属性",
common.util.__template($("#template").html(), {id: "", input: ""})
, function () {
common.util.__ajax({
url: '/erpproduct/sizeattribute/propertyAdd',
data: (function(){
var input = $('#input').val();
if (input === '' || $.trim(input) === '') return "尺码名不能为空";
return {
attributeName: input
};
})()
}, function () {
g.reload();
});
common.dialog.confirm("添加尺码属性",
common.util.__template($("#template").html(), {id: "", input: ""})
, function () {
common.util.__ajax({
url: '/erpproduct/sizeattribute/propertyAdd',
data: (function () {
var input = $('#input').val();
if (input === '' || $.trim(input) === '') return "尺码名不能为空";
return {
attributeName: input
};
})()
}, function () {
g.reload();
});
});
});
});
... ...
... ... @@ -51,16 +51,16 @@ readfile('./js',function(src){
index.push(src);
});
// var index=["./js/index","./js/main1",'./js/coupon/edit','./js/coupon/index','./js/supplier/index','./js/supplier/edit'
// ,'./js/supplier/info','./js/brand/edit','./js/brand/index','./js/product/add','./js/product/index','./js/store/adminedit','./js/store/adminindex'
// ,'./js/store/examine','./js/store/indexlist','./js/store/info','./js/store/check','./js/store/index'
// ,'./js/limitcode/edit','./js/limitcode/index','./js/product/attr'];
//区分不同系统环境
var __reg=/(js\\)|\\|(\.js)/g;
if(path.sep=="/"){
__reg=/(js\/)|\/|(\.js)/g;
}
for(var i in index){
var __name=index[i].replace(/(js\\)|\\|(\.js)/g,'');
entry[__name]=".\\"+index[i];
var __name=index[i].replace(__reg,'');
entry[__name]='.'+path.sep+index[i];
}
console.log(entry);
var plugins=[
//获取公共js
... ...
... ... @@ -6,7 +6,15 @@ exports.res = [{
route: '/erpproduct/color/index',
method: 'GET',
view: 'pages/product/color',
url:'/productColor/queryProductColors'
//url:'/productColor/queryProductColors'
src: '/product/color',
isJsonRaw:true
},{
// 获取颜色列表
route: '/erpproduct/product/colorList',
method: 'POST',
url: '/productColor/queryProductColors', //接口的url
isJsonRaw:true
},{
// 获取单个颜色
route: '/erpproduct/product/getColor',
... ... @@ -21,7 +29,10 @@ exports.res = [{
route: '/erpproduct/product/addColor',
method: 'GET',
view:'pages/product/addColor',
src:'/product/color'
src:'/product/color-add',
data:{
url:'/erpproduct/product/saveColor'
}
},{
// 新增颜色
route: '/erpproduct/product/saveColor',
... ... @@ -34,7 +45,7 @@ exports.res = [{
{name: 'colorValue', type: 'String'}
]
},{
// 新增颜色
// 打开修改颜色页面
route: '/erpproduct/product/addColor/:param',
method: 'GET',
url:"/productColor/queryProductColor",
... ... @@ -43,10 +54,13 @@ exports.res = [{
params:[
{name:'param',type:'Number'}
],
src:'/product/color'
data:{
url:'/erpproduct/product/updatColor'
},
src:'/product/color-add'
},{
// 新增尺码
route: '/erpproduct/size/updatColor',
// 修改颜色
route: '/erpproduct/product/updatColor',
method: 'POST',
url:"/productColor/updateProductColor",
isJsonRaw:true,
... ...
... ... @@ -12,13 +12,13 @@
<div>
<div style="width: 30%;float: left;">
<h4>添加颜色</h4>
<h4>{{pageTitle}}</h4>
</div>
</div>
</div>
</div>
</div>
<div class="contentpanel">
<div class="contentpanel" id="form-base">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="container" style="margin-top:10px;">
<div class="row form-horizontal" style="margin-bottom:10px;">
... ... @@ -27,14 +27,13 @@
<div class="form-group">
<label for="input" class="col-sm-2 control-label">颜色名称:</label>
<div class="col-sm-8">
<input type="text" name="" id="colorName" class="form-control" value="
{{data.colorCode}}" required="required" pattern="" title="">
<input type="text" name="" id="colorName" class="form-control" value="{{data.colorName}}" required="required" pattern="" title="">
</div>
</div>
<div class="form-group">
<label for="input" class="col-sm-2 control-label">颜色代码:</label>
<div class="col-sm-8">
<input type="text" name="" id="colorCode" class="form-control" value=" {{data.colorName}}" required="required" pattern="" title="">
<input type="text" name="" id="colorCode" class="form-control" value="{{data.colorCode}}" required="required" pattern="" title="">
</div>
</div>
<div class="form-group">
... ... @@ -48,4 +47,7 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
<input hidden="true" id="route-url" value="{{url}}"/>
\ No newline at end of file
... ...
... ... @@ -23,32 +23,12 @@
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-body">
<div class="row">
<a href="/erpproduct/product/addColor" class="btn btn-info" >添加颜色</a>
<a class="btn btn-info" href="/erpproduct/product/addColor">添加颜色</a>
</div>
</div>
<table class="table table-striped table-bordered responsive dataTable no-footer">
<thead>
<tr>
<th>编号</th>
<th>颜色名称</th>
<th>颜色代码</th>
<th>颜色值</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<input type="hidden" id="url" value="/erpproduct/product/colorList"/>
<div id="color-list" class="color">
{{#data.list}}
<tr>
<td>{{id}}</td>
<td>{{colorName}}</td>
<td>{{colorCode}}</td>
<td><img src="{{colorValue}}"></td>
<td><a href="/erpproduct/product/addColor/{{id}}" class="btn btn-info getsize" >操作</a></td>
</tr>
{{/data.list}}
</tbody>
</table>
</div>
</div>
\ No newline at end of file
</div>
</div>
... ...