Authored by weiqingting

类目

... ... @@ -2,6 +2,11 @@
var $ = require('jquery'),
common=require('../common/common');
// require('../common/tree');
// var sorttree=$("#tree").SnAddress().data("tree.sort");
// console.log(sorttree);
var tabTree=new common.tabTree("#tree");
tabTree.init();
var ENUM={
goodsSizeList:{"factoryCode":"","sizeId":"","salePrice":""}
... ... @@ -117,22 +122,23 @@ e.on("validate",function(){
});
e.init();
$(document).on("click","#btnReview",function(){
console.log(g.__e.validate());
// e.submit($("#basicForm").attr("action"),function(option){
// option.debug=true;
// option.success=function(res){
// res = res.data;
// if(res.code == "200") {
// e.$tip("提交成功", function() {
// location.href="/activity/drawline/index"
// }, 'growl-success');
// }else{
// e.$tip(res.message);
// }
// },
// option.error=function(res){
// e.$tip(res.message);
// }
// });
// return false;
var sortid=tabTree.selected.length>0?tabTree.selected[tabTree.selected.length-1].id:"";
console.log(sortid);
e.submit($("#basicForm").attr("action"),function(option){
option.debug=true;
option.success=function(res){
res = res.data;
if(res.code == "200") {
e.$tip("提交成功", function() {
location.href="/activity/drawline/index"
}, 'growl-success');
}else{
e.$tip(res.message);
}
},
option.error=function(res){
e.$tip(res.message);
}
});
return false;
});
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ edit = require('./edit'),
dropDown = require('./dropDown'),
dialog=require('./dialog');
tab=require('./tab'),
tabTree=require('./tabTree');
util=require('./util');
var common={
... ... @@ -14,7 +15,8 @@ var common={
tab:tab,
dropDown:dropDown,
edit:edit,
util:util
util:util,
tabTree:tabTree
}
module.exports=common;
\ No newline at end of file
... ...
var $=require('jquery');
function tabTree(ele,options){
var defaults = {
innerHtml: ' <a href="javascript:void(0);" class="cityboxbtn" ></a>' + '<div class="citybox">' + '<div class="chooseArea">' + "</div>" + '<div class="arriveBox">' + '<div class="cityshow"></div>' + "</div>" + '<div class="closeSelector"></div>' + "</div>",
level: 1,
columns: [{
state: "prov",
text: "一级分类",
hide: false,
addclass: ""
}, {
state: "city",
text: "二级分类",
hide: false,
addclass: ""
}, {
state: "area",
text: "三级分类",
hide: false,
addclass: ""
}, {
state: "town",
text: "四级分类",
hide: false,
addclass: ""
}],
datas: [{
sortName: "",
code: "",
id: ""
}, {
sortName: "",
code: "",
id: ""
}, {
sortName: "",
code: "",
id: ""
}, {
sortName: "",
code: "",
id: ""
}],
otherParam: null,
stepMet: null,
complete: null
};
this.options = $.extend({}, defaults, options);
this.element = $(ele);
}
tabTree.prototype= {
init: function(datas) {
var g = this,
p = this.options;
g.element.addClass("citySelect");
g.dom = g.dom || g._dom();
g.selected = [], g.records = [], g.rows = [];
p.datas = datas || p.datas;
if (p.columns.length < p.datas.length) {
return
}
g.renderHeader();
g.setEvent()
},
setEvent: function() {
var g = this,
p = this.options;
g.dom["cityboxbtn"].click(function(event) {
g.dom["cityboxbtn"].addClass("select");
g.dom["citybox"].show().css("top", g.inputHeight + "px");
if ($("iframe", g.element).length > 0) {
$("iframe", g.element).css({
top: g.inputHeight + "px",
height: g.dom["citybox"].height()
})
}
g.dom["chooseArea"].children("p").each(function() {
if ($(this).hasClass("disable") && $(this).hasClass("cur")) {
g.active_count = 0;
g.getData(g._getParam(0))
}
});
return event.stopPropagation()
});
g.dom["closeSelector"].click(function(event) {
g.reset();
return event.stopPropagation()
});
g.dom["chooseArea"].children("p").click(function(event) {
if ($(this).hasClass("disable")) {
return event.stopPropagation()
} else {
g.active_count = $(this).index();
g.getData(g._getParam(g.active_count));
return event.stopPropagation()
}
});
g.dom["cityshow"].on("click", "span>a", function(event) {
var rowid = $(this).attr("data").split("_")[1];
g.select(g.records[rowid]);
if (p.stepMet != null && g.selected.length != p.datas.length) {
p.stepMet(g.selected, g.active_count)
}
g.changeVolume();
return event.stopPropagation()
});
$(document).click(function() {
if (g.dom["citybox"].css("display") == "block") {
g.reset()
}
})
},
changeVolume: function() {
var g = this,
p = this.options;
var _data = g.selected[g.active_count];
$("span", g.dom["chooseArea"]).eq(g.active_count).html(_data.sortName);
g.selected[g.active_count].isdirect = _data.item ? true : false;
var _cur = g.active_count;
for (var i = g.active_count + 1; i < p.datas.length; i++) {
$("span", g.dom["chooseArea"]).eq(i).html(p.columns[i].text)
}
if (g.active_count + 1 <= p.datas.length - 1) {
g.active_count++;
var _next = g.active_count;
if (_data.item) {
_cur = g.active_count;
$("p", g.dom["chooseArea"]).eq(g.active_count).addClass("disable");
$("span", g.dom["chooseArea"]).eq(g.active_count).html(_data.item[0].sortName);
g.selected[g.selected.length] = _data.item[0];
g.active_count++;
_next = g.active_count
}
if (g.active_count <= p.datas.length - 1) {
g.getData(g._getParam(_next))
} else {
g.active_count = 0;
g.setHeadVal();
g.reset()
}
} else {
g.setHeadVal();
g.reset()
}
},
getData: function(_param) {
var g = this,
p = this.options;
$("p", g.dom["chooseArea"]).eq(g.active_count).removeClass("disable").addClass("cur").siblings("p").removeClass("cur");
for (var i = g.active_count + 1; i < p.datas.length; i++) {
if ($("span", g.dom["chooseArea"]).eq(i).html() == p.columns[i].text) {
$("p", g.dom["chooseArea"]).eq(i).addClass("disable")
}
}
_param.param=_param.selectId;
g.getAjax(_param)
},
getAjax: function(param) {
var g = this,
p = this.options;
var ajaxOptions = {
type: "POST",
url: param.state=="prov"?" /product/class/queryAllProductSortList":"/product/class/queryProductSortList",
data: param,
dataType: 'json',
beforeSend: function(msg) {
g.dom["cityshow"].html("加载中...")
},
success: function(items) {
items=items.data;
g.dom["cityshow"].html("");
g.records.length = 0;
g.rows.length = 0;
if (items.data.length == 0) {
g.active_count = 0;
g.setHeadVal();
g.reset();
}else{
$.each(items.data, function(count, item) {
var b = $("<span/>");
var a = $("<a/>");
if (item.ishot == "true") {
a.addClass("imp")
}
a.attr("data", "Sns_" + count).html(item.sortName);
b.append(a);
g.dom["cityshow"].append(b);
g.records.push(count);
g.rows.push(item)
});
if ($("iframe", g.dom["citybox"]).length > 0) {
$("iframe", g.dom["citybox"]).height(g.element[0].offsetHeight)
}
}
},
error: function(e1, e2) {}
};
$.ajax(ajaxOptions)
},
setHeadVal: function() {
var g = this,
p = this.options;
$.each(g.selected, function(count, item) {
$("span", g.dom["cityboxbtn"]).eq(count).show().html(item.sortName);
if (item.isdirect || p.columns[count].hide) {
if (p.datas.length != 1) {
$("span", g.dom["cityboxbtn"]).eq(count).hide()
}
}
});
p.datas.length = 0;
$.each(g.selected, function(count, item) {
p.datas.push(item)
});
if (p.complete != null) {
p.complete(p.datas, false)
}
},
renderHeader: function() {
var g = this,
p = this.options;
function _buildHtml(_count, items, isdisable) {
var _tempfun1 = function(_count, item, isdisable) {
var _html = "";
var _txt = $.trim(item.sortName) == "" ? p.columns[_count].text : item.sortName;
_html += "<span ";
if (item.isdirect || p.columns[_count].hide) {
_html += 'style="display: none"'
}
if (p.columns[_count].addclass) {
_html += ' class="' + p.columns[_count].addclass + '"'
}
_html += ">" + _txt + "</span>";
_html += "<em></em>";
return _html
};
var _tempfun2 = function(count, item, isdisable) {
var _txt = $.trim(item.sortName) == "" ? p.columns[_count].text : item.sortName;
var _html = '<p eq="' + count + '"><span>' + _txt + "</span><b></b></p>";
if (isdisable || item.id == "") {
_html = '<p class="disable"><span>' + _txt + "</span><b></b></p>"
}
return _html
};
g.dom["cityboxbtn"].append(_tempfun1(_count, items, isdisable));
g.dom["chooseArea"].append(_tempfun2(_count, items, isdisable))
}
if (p.datas && p.columns && p.datas.length > 0) {
var _isdirect = false;
$.each(p.datas, function(count, item) {
if (item.id) {
g.selected[count] = item
}
_buildHtml(count, item, _isdirect);
_isdirect = p.datas[count].isdirect
});
if (g.selected.length > 0 && !g.selected[g.selected.length - 1].isdirect) {
if (g.selected.length != p.datas.length) {
g.active_count = g.selected.length;
g.getData(g._getParam(g.active_count))
} else {
g.active_count = g.selected.length - 1;
g.getData(g._getParam(g.active_count))
}
} else {
g.active_count = 0;
g.getData(g._getParam(g.active_count))
}
_isdirect = false;
if (p.complete != null) {
p.complete(p.datas, true)
}
}
g.dom.chooseArea["append"]('<div class="clear"></div>');
g.dom.cityboxbtn["append"]("<b></b>");
g.inputHeight = g.dom.cityboxbtn["height"]();
g.dom["chooseArea"].addClass("fix");
var _isIE6 = window.VBArray && !window.XMLHttpRequest;
if (_isIE6 && $("iframe", g.dom["citybox"]).length < 1) {
var iframe = document.createElement("iframe");
g.dom["citybox"].after(iframe);
var httpType = ("https:" == document.location.protocol) ? "https" : "http";
if (httpType == "https") {
$(iframe).attr("src", "https://imgssl.suning.com/images/ShoppingArea/Common/blankbg.gif")
}
$(iframe).css({
width: g.dom["citybox"].width(),
height: 0,
position: "absolute",
"z-index": 10,
opacity: 0,
top: 0,
left: 0
})
}
},
reset: function() {
var g = this,
p = this.options;
g.dom["cityboxbtn"].removeClass("select");
g.dom["citybox"].hide();
if ($("iframe", g.element).length > 0) {
$("iframe", g.element).css({
height: 0 + "px"
})
}
},
select: function(rp) {
var g = this,
p = this.options;
var row = g.rows[parseInt(rp)];
g.selected.length = g.active_count;
g.selected[g.selected.length] = row
},
_getParam: function(rp) {
var g = this,
p = this.options;
var defaults = {
state: p.columns[rp].state,
selectId: rp - 1 > -1 ? g.selected[rp - 1].id : 0
};
var setting = {};
if (p.otherParam) {
var obj = p.otherParam(rp, p.columns, g.selected);
if (obj && typeof(obj) == "object") {
setting = obj
}
}
var params = $.extend(defaults, setting);
return params
},
_dom: function() {
var g = this,
p = this.options;
g.element.html(p.innerHtml);
var wrap = g.element;
var name, DOM = {
wrap: $(wrap)
},
els = wrap[0].getElementsByTagName("*"),
elsLen = els.length;
for (var i = 0; i < elsLen; i++) {
name = els[i].className;
if (name) {
DOM[name] = $(els[i], wrap)
}
}
return DOM
},
getAddress: function() {
var g = this,
p = this.options;
return p.datas
},
getRows: function() {
var g = this,
p = this.options;
return g.selected
},
setCurrent: function(rp) {
var g = this,
p = this.options;
g.dom["cityboxbtn"].addClass("select");
g.dom["citybox"].show().css("top", g.inputHeight + "px");
if (g.selected.length - parseInt(rp) >= 0) {
g.active_count = parseInt(rp);
g.getData(g._getParam(g.active_count))
} else {
g.active_count = 0;
g.getData(g._getParam(g.active_count))
}
return event.stopPropagation()
}
};
module.exports = tabTree;
\ No newline at end of file
... ...
var $ = require('jquery'),
common = require('../common/common');
require('../common/bootstrap-wysihtml5');
require('../util/datepicker');
// require('../common/bootstrap-wysihtml5');
// require('../util/datepicker');
var ENMA = {
attachType: {
... ... @@ -362,7 +362,7 @@ var Bll = {
e1.init();
}
});
$('#text-editor').wysihtml5();
// $('#text-editor').wysihtml5();
}
}
... ...
... ... @@ -372,3 +372,214 @@ ul {
border: 1px solid #ddd;
border-bottom-color: transparent;
}
.fix:after {
content: ".";
display: block;
clear: both;
height: 0;
visibility: hidden
}
.fix {
_height: 1%;
*zoom:1}
.citySelect {
position: relative;
z-index: 99;
height: 30px;
line-height: 30px
}
.citySelect b {
position: absolute;
display: block;
height: 12px;
width: 12px;
overflow: hidden;
right: 5px
}
.citySelect span.attr {
float: left;
width: 75px;
height: 26px;
line-height: 26px;
color: #666
}
.citySelect .cityboxbtn {
position: relative;
float: left;
border: 1px solid #ccc;
height: 27px;
line-height: 27px;
padding: 0 38px 0 5px;
color: #333;
z-index: 99;
white-space: nowrap
}
.citySelect .cityboxbtn:hover {
text-decoration: none;
color: #333
}
.citySelect .cityboxbtn b {
// background: url(images/jiantou.png) no-repeat;
top: 8px
}
.citySelect .select {
border: 1px solid #ccc;
border-bottom: 0;
height: 27px;
z-index: 100;
background: #fff;
box-shadow: 0 -1px 2px #ddd
}
.citySelect .cityboxbtn em {
color: #999;
padding: 0 2px
}
.citybox {
display: none;
position: absolute;
left: 0;
top: 0;
width: 600px;
padding: 0 5px 5px 5px;
background: #fff;
border: 1px solid #ccc;
line-height: 1;
z-index: 98;
box-shadow: 0 0 6px #ddd
}
.chooseArea {
padding: 10px;
padding-bottom: 0
}
.chooseArea p {
position: relative;
float: left;
display: inline;
height: 24px;
border: 1px solid #ccc;
line-height: 25px;
margin-right: 5px;
padding: 0 25px 0 8px;
cursor: pointer;
white-space: nowrap;
z-index: 8;
margin: 0 2px;
}
.chooseArea p b {
// background: url(images/jiantou.png) no-repeat;
top: 6px
}
.chooseArea p.cur {
height: 25px;
background: #fff;
line-height: 24px;
border: 2px solid #ffb786;
border-bottom: 0;
z-index: 10
}
.chooseArea p span {
display: block;
max-width: 60px;
_width: expression(this.offsetWidth>60 ? '60px':'auto');
height: 26px;
overflow: hidden;
white-space: normal
}
.chooseArea p.cur b {
background-position: 0 -11px;
top: 4px
}
.chooseArea p.disable {
color: #999
}
.citybox .arriveBox {
position: relative;
background: #fff;
border-top: 2px solid #ffb786;
margin: -2px 5px 0 5px;
padding: 8px 0;
z-index: 9;
*margin-top: -3px;
_margin-top: -2px
}
.cityshow {
width: 600px;
margin: 0 auto
}
.citybox a,.cityshow a:visited {
color: #333
}
.citybox div.cityshow span {
display: inline-block;
float: left;
height: 26px;
width: 85px;
line-height: 26px;
text-align: left;
overflow: hidden
}
.citybox div.cityshow span a {
padding: 5px 7px;
text-decoration: none;
cursor: pointer;
}
.citybox div.cityshow span a:hover {
color: #fff;
background: #f60;
text-decoration: none
}
.citybox div.cityshow span a.imp {
color: #f70
}
.citybox div.cityshow span a.imp:hover {
color: #fff
}
.citybox div.cityshow span {
width: 65px;
padding-right: 15px;
display: inline-block;
float: left;
height: 26px;
line-height: 26px;
text-align: left;
overflow: hidden
}
.closeSelector {
position: absolute;
top: 5px;
right: 5px;
height: 16px;
width: 16px;
// background: url(images/closeSelector.png) no-repeat;
cursor: pointer;
z-index: 9999
}
\ No newline at end of file
... ...
... ... @@ -33,29 +33,35 @@
<div class="form-group">
<label class="col-sm-2 control-label">店铺 <span class="red">*</span></label>
<div class="col-sm-2">
<select id="shopId" class="form-control">
<select id="shopId" class="form-control" required>
<option value="-1">店铺</option>
</select>
</div>
<label class="col-sm-1 control-label">品牌 <span class="red">*</span></label>
<div class="col-sm-2">
<select id="brandId" class="form-control">
<select id="brandId" class="form-control" required>
<option value="-1">品牌</option>
</select>
</div>
<label class="col-sm-1 control-label">供应商 <span class="red">*</span></label>
<div class="col-sm-2">
<select id="supplierId" class="form-control">
<select id="supplierId" class="form-control" required>
<option value="-1">供应商</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">分类<span class="red">*</span></label>
<div class="col-sm-10">
<div id="tree"></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">商品名称<span class="red">*</span></label>
<div class="col-sm-3">
<input type="text" id="productName" class="form-control" />
<input type="text" id="productName" class="form-control" required/>
</div>
<label class="col-sm-1 control-label">厂家编号</label>
<div class="col-sm-1">
... ... @@ -65,13 +71,13 @@
<div class="form-group">
<label class="col-sm-2 control-label">货品年<span class="red">*</span></label>
<div class="col-sm-1">
<select id="goodsYears" class="form-control">
<select id="goodsYears" class="form-control" required>
<option value="2015">2015</option>
</select>
</div>
<label class="col-sm-1 control-label">货品季<span class="red">*</span></label>
<div class="col-sm-1">
<select id="goodsSeason" class="form-control">
<select id="goodsSeason" class="form-control" required>
<option value="春"></option>
<option value="夏"></option>
<option value="秋"></option>
... ... @@ -82,7 +88,7 @@
</div>
<label class="col-sm-1 control-label">商品属性<span class="red">*</span></label>
<div class="col-sm-1">
<select id="attribute" class="form-control">
<select id="attribute" class="form-control" required>
<option value="1">普通商品</option>
<option value="2">赠品</option>
<option value="3">虚拟商品</option>
... ... @@ -105,7 +111,7 @@
<input type="checkbox" name="brandLevel" value="2">大童</label>
<label class="radio-inline">
<input type="checkbox" name="brandLevel" value="3">小童</label>
<input type="hidden" id="ageLevel" name="ageLevel" value="{{ageLevel}}" for="checkbox" />
<input type="hidden" id="ageLevel" name="ageLevel" value="{{ageLevel}}" for="checkbox" required />
</div>
<label class="col-sm-1 control-label">性别<span class="red">*</span></label>
<div class="col-sm-2">
... ... @@ -115,7 +121,7 @@
<input type="radio" name="gender" value="2"></label>
<label class="radio-inline">
<input type="radio" name="gender" value="3">通用</label>
<input type="hidden" id="gender" name="gender" value="{{gender}}" for="radio" />
<input type="hidden" id="gender" name="gender" value="{{gender}}" for="radio" required />
</div>
</div>
<div class="form-group">
... ... @@ -127,7 +133,7 @@
<label class="radio-inline">
<input type="radio" name="brandLevel" value="0"></label>
</div>
<input type="hidden" id="grade" value="{{grade}}" for="radio" />
<input type="hidden" id="grade" value="{{grade}}" for="radio" required/>
</div>
<div class="form-group">
... ...