Authored by liuyue

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

... ... @@ -2,7 +2,9 @@
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var e = new common.edit("#activityForm");
var e = new common.edit("#activityForm", {
"bucket" : "activity"
});
e.on("render", function() {
... ...
... ... @@ -26,7 +26,8 @@ var g=new common.grid({
var html=[];
html.push("<div class='form-group'><div class='col-sm-11 red'><input type=text value='"+item.factoryCode+"' data-index="+item.__index+" class='factoryCode form-control' placeholder='款型编码' required/></div></div>");
html.push('<div class="rows" id="rows__'+item.__index+'">');
html.push(common.util.__template($("#template").html(),{index:item.__index}));
item.goodsSizeList=item.goodsSizeList||[{"factoryCode":"","sizeId":"","salePrice":""}];
html.push(common.util.__template2($("#template").html(),{index:item.__index,goodsSizeList:item.goodsSizeList}));
html.push('</div>');
return html.join('');
}
... ... @@ -55,7 +56,7 @@ $(document).on("click",".sortadd",function(){
"goodsColorImage": "",
goodsName: $(this).text(),
colorId: (+$(this).data("id")),
goodsSizeList: [ENUM.goodsSizeList]
goodsSizeList: [{"factoryCode":"","sizeId":"","salePrice":""}]
});
g.reload();
g.__e.init();
... ... @@ -73,19 +74,29 @@ $(document).on("change",".factoryCode",function(){
});
$(document).on("click",".btn-sort-add",function(){
var item=g.__rows[$(this).data("index")];
item.goodsSizeList.push(ENUM.goodsSizeList);
var __index=item.goodsSizeList.length;
$("#rows__"+$(this).data("index")).append(common.util.__template($("#template").html(),{index:item.__index,__index:__index}));
item.goodsSizeList.push({"factoryCode":"","sizeId":"","salePrice":""});
g.reload();
g.__e.init();
});
$(document).on("click",".btn-sort-remove",function(){
var item=g.__rows[$(this).data("index")];
var __index=$(this).data("eq");
[].splice.call(item.goodsSizeList,__index,1);
$(this).parent("div").parent(".form-group").remove();
alert($(this).data("index"));
$(".btn-sort-remove","#rows__"+$(this).data("index")).each(function(index){
console.log(index);
$(this).data("eq",''+index);
});
console.log(item.goodsSizeList);
g.reload();
g.__e.init();
});
$(document).on("change",".btn-sort-chima",function(){
var _index=$(this).data("index");
var _eq=$(this).data("eq");
var item=g.__rows[_index].goodsSizeList[_eq];
item.factoryCode=$(this).val();
});
$(document).on("change",".btn-sort-xiaoshou",function(){
});
$(document).on("change",".btn-sort-tiaoma",function(){
});
$(document).on("change",".btn-sort-kebu",function(){
});
\ No newline at end of file
... ...
var $=require('jquery');
var edit=require('../common/edit');
var e=new edit("#basicForm");
var e=new edit("#basicForm",{
bucket:"brandLogo"
});
//brandTonality
e.on("validate",function(){
var num=$.trim($("#brandTonality").val());
... ...
... ... @@ -24,14 +24,16 @@ require('../util/datepicker');
require('../util/jquery.gritter');
var edit=function(option){
var edit=function(el,option){
this.registerEvent={
validate:[],
bind:[],
render:[],
callback:[]
};
this.el= typeof option==="string"?option:option.el;
this.el=el;
this.option=option||{};
//typeof option==="string"?option:option.el;
// new edit.prototype.init(this);
}
edit.prototype={
... ... @@ -161,7 +163,7 @@ edit.prototype={
// });
$('input[type="file"]',that.el).ajaxfileupload({
'action': '/ajax/upload',
'params':{"userId":543883,"bucket":'smart',__type:"upload"},
'params':{"userId":543883,"bucket":that.option.bucket||'smart',__type:"upload"},
'onComplete': function(response) {
if(response.status){
var _w=$(this).next().find('.fileinput-button-icon');
... ...
... ... @@ -94,6 +94,31 @@ var util={
},
__template2:function(str,source){
// console.log(str);
var result="";
var script=[];
script.push('var each=function(obj,fn){');
script.push(' var that=this;');
script.push(' if({}.toString.call(obj)=="[object Array]"){');
script.push(' for(var i=0;i<obj.length;i++){');
script.push(' fn.call(i,i,obj[i]);');
script.push(' }');
script.push(' return;');
script.push(' }');
script.push(' if(typeof obj=="function"||typeof obj=="object"&&!!obj){');
script.push(' for(var i in obj){');
script.push(' fn.call(i,i,obj[i]);');
script.push(' }');
script.push(' return;');
script.push(' }');
script.push('}');
result=script.join('')+";\n";
var formstr=function (code) {
return "'" + code
.replace(/('|\\)/g, '\\$1')
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n') + "'";
}
//获取参数
var keys=[];
for(var key in source){
... ... @@ -105,38 +130,38 @@ var util={
}
var result="var "+keys.join(',')+";";
result+="var "+keys.join(',')+";";
var html="";
html=str.replace(/\{\{(.*?)\}\}/igm,function(name,$1){
html=str.replace(/\[\[(.*?)\]\]/igm,function(name,$1){
var trim=$1.replace(/^\s+|\s+$/,'');
if(/^each/.test(trim))
{
trim=trim.replace(/^each\s+(\w+)\s+as\s+(\w+)\s+(\w+)/,'Util.Fun.each\( $1,function($3,$2){');
return "{{"+trim+"}}";
trim=trim.replace(/^each\s+(\w+)\s+as\s+(\w+)\s+(\w+)/,'each\( $1,function($3,$2){');
return "[["+trim+"]]";
}else
if(/^\/each/.test(trim)){
trim=trim.replace(/^\/each/,'});')
return "{{"+trim+"}}";
return "[["+trim+"]]";
}
else if(/^if/.test(trim)){
trim=trim.replace(/^if(.+)/,'if($1){');
return "{{"+trim+"}}";
return "[["+trim+"]]";
}
else if(/^\/if/.test(trim)){
trim=trim.replace(/^\/if/,'};')
return "{{"+trim+"}}";
return "[["+trim+"]]";
}
else if(/^else$/.test(trim)){
trim=trim.replace(/else/,'}else{');
return "{{"+trim+"}}";
return "[["+trim+"]]";
}
else{
return "{{+"+trim+"+}}";
return "[[+"+trim+"+]]";
}
});
html=html.replace(/(^|\}\})(.*?)(\{\{|$)/igm,function(name,$1,$2){
html=html.replace(/(^|\]\])(.*?)(\[\[|$)/igm,function(name,$1,$2){
var trim=$2.replace(/^\s+|\s+$/,'');
return trim?Util.String.formstr($2):'';
return trim?formstr($2):'';
});
// var result="var result='';result+=";
var arr=html.split(/\n+/igm);
... ...
... ... @@ -9,6 +9,14 @@ var ENMA = {
1: "图片",
2: "视频",
3: "文本"
},
dia:{
1:"img",
2:"video",
3:"wenZi"
},
bucket:{
bucket:"goodsimg"
}
}
... ... @@ -27,7 +35,7 @@ var g = new common.grid({
}, {
display: "内容",
render: function(item) {
item.orderBy == item.__index;
item.orderBy = (item.__index+1);
if (item.isDefault == 1) {
return '<input type="file" name="coverImg" id="coverImg" value="' + item.attachUrl + '" placeholder="封面图" required/>';
} else {
... ... @@ -36,7 +44,7 @@ var g = new common.grid({
} else if (item.attachType == 2) {
return "<video src='" + item.attachUrl + "' controls></video>";
} else {
return item.attachUrl;
return item.intro;
}
}
}
... ... @@ -61,7 +69,7 @@ g.__rows = __ac ? JSON.parse(__ac) : [{
}];
g.init(g.__rows);
var e1 = new common.edit('#baseTable');
var e1 = new common.edit('#baseTable',ENMA.bucket);
e1.on("callback", function(obj) {
if (obj.key == "file_onComplete_coverImg") {
g.__rows[0].attachUrl = obj.data;
... ... @@ -76,7 +84,7 @@ $(window).on('beforeunload', function() {
}
});
//初始化form表单
var e = new common.edit('#editor-group');
var e = new common.edit('#editor-group',ENMA.bucket);
e.on("validate", function() {
... ... @@ -84,12 +92,42 @@ e.on("validate", function() {
batchNo: $('#batchNo').val(),
id: $("#id").val()
};
return common.util.__ajax({
url: '/limit/checkBatch',
async: true,
var _m="批次号接口接口异常";
common.util.__ajax({
url: '/limit/getLimitCodeByBatchNo',
async: false,
data: param
}, null, true);
}, function(res){
console.log(res);
if(res.data){
_m="";
}else{
_m="批次号不存在";
}
}, true);
if(_m){
return _m;
}else{
common.util.__ajax({
url: '/limit/checkBatch',
async: false,
data: param
}, function(res){
console.log(res);
if(res.data){
_m="";
}else{
_m=res.message;
}
}, true);
if(_m){
return _m;
}
}
});
///limit/getLimitCodeByBatchNo
e.on("validate", function() {
if (!g.__rows[0].attachUrl) {
... ... @@ -102,27 +140,41 @@ e.on("validate", function() {
if (limitProductType == 2) {
if (activityId == "") {
return "请填写排队限购ID";
} else {
var exists = false;
common.util.__ajax2({
url: '/limit/DrawlineActivityRest/checkActivityIdExists',
async: false,
data: {
activityId: activityId
}else{
var _m="排队限购ID接口异常";
common.util.__ajax({
url:'/limit/DrawlineActivityRest/checkActivityIdExists',
async:false,
data:{activityId:activityId}
},function(res){
if(res.data.exists){//true
_m="";
}else{
_m="排队限购ID不存在";
}
}, function(res) {
if (res.code == 200) {
if (res.data.exists) {
exists = true;
},true);
if(_m){
return _m;
}else{
///limit/checkActivityIdNoExist
common.util.__ajax({
url:'/limit/checkActivityIdNoExist',
async:false,
data:{activityId:activityId,id: $("#id").val()}
},function(res){
console.log("checkActivityIdNoExist",res);
if(res.data){//true
_m="";
}else{
_m="排队限购ID"+activityId+"已被关联";
}
},true);
if(_m){
return _m;
}
return true;
});
if (!exists) {
return "排队限购ID不存在";
}
}
}
}
});
e.on("validate", function() {
... ... @@ -132,13 +184,6 @@ e.on("validate", function() {
}
});
e.on("validate", function() {
var limitProductType = $("#limitProductType").val();
var activityId = $.trim($("#activityId").val());
if (limitProductType == 2 && activityId == "") {
return "请填写排队限购ID";
}
});
function orderByIsRequired(val) {
if (val == 1) {
... ... @@ -195,12 +240,9 @@ $('.limit-add-btn').click(function(option) {
// type = $('#limit-add-form').attr('type');
var Bll = {
imgVideo: function(title, item, index) {
if (item.attachType == 2 || item.__attachType == 2) {
item.extend = "mp4"
};
img: function(title, item, index) {
common.dialog.confirm(title, common.util.__template($("#picDialogTemp").html(), item), function() {
var _html = $.trim($("#imgVideoText").val());
var _html = $.trim($("#imgText").val());
if (_html) {
if (item.attachType) {
... ... @@ -209,7 +251,7 @@ var Bll = {
} else {
//添加
g.__rows.push({
"attachType": item.__attachType,
"attachType":1,
"attachUrl": _html,
"isDefault": 0,
"attachName": $("#attachName").val()
... ... @@ -220,27 +262,67 @@ var Bll = {
e1.init();
}
});
var a = new common.edit("#upload-wrapper");
var a = new common.edit("#upload-wrapper",ENMA.bucket);
a.on("callback", function(obj) {
if (obj.key == "file_onComplete_imgVideo") {
$("#imgVideoText").val(obj.data);
if (obj.key == "file_onComplete_imgfile") {
$("#imgText").val(obj.data);
}
});
a.init();
},
video:function(title, item, index){
common.dialog.confirm(title, common.util.__template($("#vidioDialogTemp").html(), item), function() {
var _html = $.trim($("#videoText").val());
var _html1 = $.trim($("#imgText").val());
if (_html&&_html1) {
if (item.attachType) {
//修改
g.__rows[index].attachUrl = _html;
g.__rows[index].intro = _html1;
} else {
//添加
g.__rows.push({
"attachType": 2,
"attachUrl": _html,
"intro":_html1,
"isDefault": 0,
"attachName": $("#attachName").val()
});
}
g.reload();
e1.init();
}
});
var a1 = new common.edit("#upload-wrapper1",ENMA.bucket);
a1.on("callback", function(obj) {
if (obj.key == "file_onComplete_videofile") {
$("#videoText").val(obj.data);
}
});
a1.init();
var a2 = new common.edit("#upload-wrapper2",ENMA.bucket);
a2.on("callback", function(obj) {
console.log(obj);
if (obj.key == "file_onComplete_imgfile") {
$("#imgText").val(obj.data);
}
});
a2.init();
},
wenZi: function(title, item, index) {
common.dialog.confirm(title, common.util.__template('<textarea id="text-editor">{attachUrl}</textarea>', item), function() {
common.dialog.confirm(title, common.util.__template('<textarea id="text-editor">{intro}</textarea>', item), function() {
var _html = $.trim($("#text-editor").val());
if (_html) {
if (item.attachType) {
//修改
g.__rows[index].attachUrl = _html;
g.__rows[index].intro = _html;
} else {
//添加
g.__rows.push({
"attachType": 3,
"attachUrl": _html,
"intro": _html,
"isDefault": 0
});
}
... ... @@ -259,17 +341,11 @@ $('body').on('click', '#textDialog', function() {
return false;
});
$('body').on('click', '#picDialog', function() {
Bll.imgVideo("添加图片", {
name: "图片",
__attachType: 1
});
Bll.img("添加图片",{});
return false;
});
$('body').on('click', '#videoDialog', function() {
Bll.imgVideo("添加视频", {
name: "视频",
__attachType: 2
});
Bll.video("添加视频",{});
return false;
});
//删除
... ... @@ -282,5 +358,5 @@ $('body').on('click', ".delete", function() {
//修改
$('body').on('click', ".edit", function() {
var item = g.rows[$(this).data("index")];
Bll[item.attachType == 3 ? "wenZi" : "imgVideo"]("修改" + ENMA.attachType[item.attachType], item, $(this).data("index"));
Bll[ENMA.dia[item.attachType]]("修改" + ENMA.attachType[item.attachType], item, $(this).data("index"));
});
\ No newline at end of file
... ...
... ... @@ -89,38 +89,27 @@ var tableGird = new common.grid({
render: function(item) {
return ('<input class="order-input width50" data-id="' + item.id + '" data-type="orderBy" type="text" value="' + item.orderBy + '"/>');
}
},
// {
// display: "未发售排序",
// name: "notSaleSort",
// render: function(item) {
// if (item.saleFlag == 1) {
// return '-';
// } else {
// return ('<input class="order-input width50" data-id="' + item.id + '" data-type="notSaleOrderBy" type="text" value="' + item.notSaleOrderBy + '"/>');
// }
// }
// },
{
display: "封面图",
render: function(item) {
return ('<img class="cover-img" src="' + item.attachUrl + '" />');
}
}, {
display: "SKN",
name: "productSkn"
}, {
display: "发售日期",
name: "saleTimeStr",
render: function(item) {
if (item.dayFlag == 1) {
return item.saleTimeStr;
} else {
return item.saleTimeStr.slice(0, 7);
}
},{
display: "封面图",
render: function(item) {
return ('<img class="cover-img" src="' + item.attachUrl + '" />');
}
}, {
display: "SKN",
name: "productSkn",render:function(item){
return item.SKN||'待定';
}
}, {
display: "发售日期",
name: "saleTimeStr",
render: function(item) {
if (item.dayFlag == 1) {
return item.saleTimeStr;
} else {
return item.saleTimeStr.slice(0, 7);
}
}, {
}
},{
display: "是否发售",
name: "saleFlag",
render: function(item) {
... ... @@ -216,8 +205,7 @@ $('#export-btn').on('click', function() {
queryConf += '|';
}
});
queryConf = "2016030711350185";
window.open("/ajax/down?queryConf=" + queryConf + "&type=limitProductReminder");
window.open("/ajax/down?queryConf="+queryConf+"&type=limitProductReminder");
// common.util.__ajax({
// url: '/ajax/down',
// type:'GET',
... ...
... ... @@ -233,7 +233,9 @@
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var e=new common.edit("#storeForm");
var e=new common.edit("#storeForm",{
bucket:"shops"
});
var Bll={
toast:function(content,url,id){
... ...
var $=require('jquery');
var edit=require('../common/edit');
var e=new edit("#basicForm");
var e=new edit("#basicForm",{
bucket:"supplier"
});
e.on("validate",function(){
... ...
exports.domain = require('../config/common.js').domain;
// exports.domain = 'http://172.16.6.246:8081/platform/';
//exports.domain = 'http://172.16.6.240:8088/platform/';//王书生
//exports.domain = 'http://172.16.6.182:8080/yohobuy-platform-web'; //曹燕
//路由配置
... ... @@ -136,6 +136,12 @@ exports.res = [{
}, {
name: 'status',
type: 'Number'
}, {
name: 'limitProductType',
type: 'Number'
}, {
name: 'activityId',
type: 'Number'
}]
}, {
route: '/limit/ajax/getCodeCount',
... ... @@ -196,6 +202,14 @@ exports.res = [{
name: 'id',
type: 'Number'
}]
},{
route:'/limit/getLimitCodeByBatchNo',
method:'POST',
url:'/limitCode/checkLimitCodeByBatchNo',
params:[
{name:"batchNo",type:'Number'},
{name:"id",type:"Number"}
]
}, {
route: '/limit/batch/export',
method: 'POST',
... ... @@ -221,4 +235,12 @@ exports.res = [{
params:[
{name:"activityId",type:"Number"}
]
},{
route:'/limit/checkActivityIdNoExist',
method:'POST',
url:'/limitProduct/checkActivityIdNoExist',
params:[
{name:"activityId",type:"Number"},
{name:"id",type:"Number"}
]
}];
\ No newline at end of file
... ...
... ... @@ -232,10 +232,11 @@
</div>
<script type="text/template" id="template">
[[each goodsSizeList as item __index]]
<div class="form-group">
<!-- <label class="col-sm-1 red">*</label> -->
<div class="col-sm-2">
<select class="form-control" data-index={#index#} class="btn-sort-chima">
<select class="form-control btn-sort-chima" data-index=[[index]] data-eq=[[__index]] value=[[item.factoryCode]]>
<option value="-1">选择尺码</option>
<option value="XS">XS</option>
<option value="S">S</option>
... ... @@ -245,21 +246,22 @@
</select>
</div>
<div class="col-sm-2">
<input class="form-control" class="btn-sort-xiaoshou" placeholder="默认销售价" data-index={#index#}></input>
<input class="form-control btn-sort-xiaoshou" placeholder="默认销售价" data-index=[[index]] data-eq=[[__index]]></input>
</div>
<div class="col-sm-2">
<input class="form-control" class="btn-sort-tiaoma" placeholder="条码" data-index={#index#}></input>
<input class="form-control btn-sort-tiaoma" placeholder="条码" data-index=[[index]] data-eq=[[__index]]></input>
</div>
<div class="col-sm-2">
<select class="form-control" class="btn-sort-kebu">
<select class="form-control btn-sort-kebu" data-index=[[index]] data-eq=[[__index]]>
<option value="-1">能否补货</option>
<option value="1">可补货</option>
<option value="2">不可补货</option>
</select>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-info btn-xs btn-sort-add" data-index={#index#}>+</button>
<button type="button" class="btn btn-info btn-xs btn-sort-remove" data-index={#index#} data-eq={#__index#}>-</button>
<button type="button" class="btn btn-info btn-xs btn-sort-add" data-index=[[index]]>+</button>
<button type="button" class="btn btn-info btn-xs btn-sort-remove" data-index=[[index]] data-eq=[[__index]]>-</button>
</div>
</div>
[[/each]]
</script>
\ No newline at end of file
... ...
... ... @@ -35,7 +35,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">品牌logo <span class="red">*</span></label>
<div class="col-sm-8">
<input type="file" id="brandIco" name="brandIco" value="{{brandIco}}" required placeholder="品牌logo" />
<input type="file" id="brandIco" name="brandIco" value="{{brandIco}}" required placeholder="品牌logo"/>
</div>
</div>
<div class="form-group">
... ...
... ... @@ -49,7 +49,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">排队限购ID:</label>
<div class="col-sm-8">
<input id="activityId" type="{{activityId}}" class="form-control" />
<input id="activityId" type="text" class="form-control" value="{{activityId}}" />
</div>
</div>
<div class="form-group">
... ... @@ -86,8 +86,9 @@
<label class="radio-inline"><input type="radio" name="hotFlag" value="0"></label>
<input type="hidden" value="{{hotFlag}}" id="hotFlag" for="radio">
</div>
<div class="col-md-3 height60 order-by">
<label>排序<span class="red">*</span></label>
<label>排序</label>
<label><input id="orderBy" value="{{orderBy}}" type="text" class="form-control" placeholder="排序" required></label>
<p>(提示:数字越大越靠前)</p>
</div>
... ... @@ -127,21 +128,60 @@
<script type="text/template" id="picDialogTemp">
<div class="row">
<div id="upload-wrapper" class="col-md-3">
<input id="imgVideo" name="imgVideo" type="file" extend="{extend}" class="btn btn-primary ml10" value="{attachUrl}">
<input id="imgfile" name="imgfile" type="file" class="btn btn-primary ml10" value="{attachUrl}">
</div>
<div class="col-md-9">
<div class="row">
<label class="pull-left control-label height40">图片链接</label>
<div class="pull-left ml10">
<input class="form-control" id="imgText" type="text" placeholder="图片链接" value="{attachUrl}">
</div>
</div>
<div class="row">
<label class="pull-left control-label height40">图片描述</label>
<div class="pull-left ml10">
<input class="form-control" type="text" id="attachName" value="{attachName}" placeholder="图片描述">
</div>
</div>
</div>
</div>
</script>
<script type="text/template" id="vidioDialogTemp">
<div class="row">
<div id="upload-wrapper1" class="col-md-3">
<input id="videofile" name="videofile" type="file" extend="mp4" class="btn btn-primary ml10" value="{attachUrl}">
</div>
<div class="col-md-9">
<div class="row">
<label class="pull-left control-label height40">{name}链接</label>
<label class="pull-left control-label height40">视频链接</label>
<div class="pull-left ml10">
<input class="form-control" id="imgVideoText" type="text" placeholder="{name}链接" value="{attachUrl}">
<input class="form-control" id="videoText" type="text" placeholder="视频链接" value="{attachUrl}">
</div>
</div>
<div class="row">
<label class="pull-left control-label height40">{name}描述</label>
<label class="pull-left control-label height40">视频描述</label>
<div class="pull-left ml10">
<input class="form-control" type="text" id="attachName" value="{attachName}" placeholder="视频描述">
</div>
</div>
</div>
</div>
<div class="row">
<div id="upload-wrapper2" class="col-md-3">
<input id="imgfile" name="imgfile" type="file" class="btn btn-primary ml10" value="{intro}">
</div>
<div class="col-md-9">
<div class="row">
<label class="pull-left control-label height40">图片链接</label>
<div class="pull-left ml10">
<input class="form-control" type="text" id="attachName" value="{attachName}" placeholder="{name}描述">
<input class="form-control" id="imgText" type="text" placeholder="图片链接" value="{intro}">
</div>
</div>
</div>
</div>
... ...