...
|
...
|
@@ -79,9 +79,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
},
|
|
|
api: {
|
|
|
bindevent: function () {
|
|
|
$(document).on("change", "#c-spec_template_id", function () {
|
|
|
var goods_spec = Config.goods_spec;
|
|
|
var goods_spec = Config.goods_spec;
|
|
|
goods_spec = goods_spec == undefined ? [] : goods_spec.goods_spec;
|
|
|
$(document).on("change", "#c-spec_template_id", function () {
|
|
|
Fast.api.ajax({
|
|
|
url:'goods/specList',
|
|
|
data:{
|
...
|
...
|
@@ -95,81 +95,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
$.each(list,function(index,spec){
|
|
|
html += '<div class="form-group">'+
|
|
|
'<label class="control-label col-xs-12 col-sm-2">'+spec.spec_name+':</label>'+
|
|
|
'<div class="col-xs-12 col-sm-8">';
|
|
|
// 一级规格下规格值
|
|
|
if(spec.options.length > 0){
|
|
|
html += '<div class="radio">';
|
|
|
$.each(spec.options,function(index,spec_v){
|
|
|
var img = spec_v.spec_value_image == '' ? '/assets/img/qrcode.png' : spec_v.spec_value_image;
|
|
|
html += '<label for="'+spec_v.id+'" style="border:1px solid #f1f4f6">'+
|
|
|
'<input id="'+spec_v.id+'" name="row[goods_spec]['+spec_v.spec_id+']" type="radio" value="'+spec_v.id+'">'+
|
|
|
'<img width="100px" src="'+img+'">'+
|
|
|
'<p style="text-align:center">'+spec_v.spec_value+'</p>'+
|
|
|
'</label>';
|
|
|
})
|
|
|
html += '</div>';
|
|
|
}
|
|
|
'<div class="col-xs-12 col-sm-8">'+
|
|
|
commonhHtml(index,spec);
|
|
|
// 一级规格下二级规格
|
|
|
if(spec.two_spec_list.length > 0){
|
|
|
$.each(spec.two_spec_list,function(index,spec_s){
|
|
|
html += '<div class="form-group">'+
|
|
|
'<label class="control-label col-xs-12 col-sm-2">'+spec_s.spec_name+':</label>'+
|
|
|
'<div class="col-xs-12 col-sm-8">';
|
|
|
// 二级规格下规格值
|
|
|
if(spec_s.options.length > 0){
|
|
|
html += '<div class="radio">';
|
|
|
$.each(spec_s.options,function(index,spec_s_v){
|
|
|
var img = spec_s_v.spec_value_image == '' ? '/assets/img/qrcode.png' : spec_s_v.spec_value_image;
|
|
|
html += '<label for="'+spec_s_v.id+'" style="border:1px solid #f1f4f6">'+
|
|
|
'<input id="'+spec_s_v.id+'" name="row[goods_spec]['+spec_s_v.spec_id+']" type="radio" value="'+spec_s_v.id+'">'+
|
|
|
'<img width="100px" src="'+img+'">'+
|
|
|
'<p style="text-align:center">'+spec_s_v.spec_value+'</p>'+
|
|
|
'</label>';
|
|
|
})
|
|
|
html += '</div>';
|
|
|
}
|
|
|
// 二级规格下文本框
|
|
|
if(spec_s.spec_type == '2'){
|
|
|
html += '<input id="c-'+spec_s.id+'" data-rule="required" class="form-control" name="row[goods_spec]['+spec_s.id+']" type="text" value="">';
|
|
|
}
|
|
|
// 二级规格下上传图片
|
|
|
if(spec.spec_type == '3'){
|
|
|
html += '<div class="input-group">'+
|
|
|
'<input id="c-'+spec_s.id+'" data-rule="" class="form-control" size="50" name="row[goods_spec]['+spec_s.id+']" type="text" value="">'+
|
|
|
'<div class="input-group-addon no-border no-padding">'+
|
|
|
'<span><button type="button" id="plupload-'+spec_s.id+'" class="btn btn-danger plupload" data-input-id="c-'+spec_s.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+spec_s.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
|
|
|
'<span><button type="button" id="fachoose-'+spec_s.id+'" class="btn btn-primary fachoose" data-input-id="c-'+spec_s.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
|
|
|
'</div>'+
|
|
|
'<span class="msg-box n-right" for="c-'+spec_s.id+'"></span>'+
|
|
|
'</div>'+
|
|
|
'<ul class="row list-inline plupload-preview" id="p-'+spec_s.id+'"></ul>';
|
|
|
}
|
|
|
html += '</div>'+
|
|
|
'<div class="col-xs-12 col-sm-8">'+
|
|
|
commonhHtml(index,spec_s)+
|
|
|
'</div>'+
|
|
|
'</div>';
|
|
|
})
|
|
|
}
|
|
|
// 一级规格下文本框
|
|
|
if(spec.spec_type == '2'){
|
|
|
html += '<input id="c-'+spec.id+'" data-rule="required" class="form-control" name="row[goods_spec]['+spec.id+']" type="text" value="">';
|
|
|
}
|
|
|
// 一级规格下上传图片
|
|
|
if(spec.spec_type == '3'){
|
|
|
html += '<div class="input-group">'+
|
|
|
'<input id="c-'+spec.id+'" data-rule="" class="form-control" size="50" name="row[goods_spec]['+spec.id+']" type="text" value="">'+
|
|
|
'<div class="input-group-addon no-border no-padding">'+
|
|
|
'<span><button type="button" id="plupload-'+spec.id+'" class="btn btn-danger plupload" data-input-id="c-'+spec.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+spec.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
|
|
|
'<span><button type="button" id="fachoose-'+spec.id+'" class="btn btn-primary fachoose" data-input-id="c-'+spec.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
|
|
|
'</div>'+
|
|
|
'<span class="msg-box n-right" for="c-'+spec.id+'"></span>'+
|
|
|
'</div>'+
|
|
|
'<ul class="row list-inline plupload-preview" id="p-'+spec.id+'"></ul>';
|
|
|
}
|
|
|
html += '</div>'+
|
|
|
'</div>';
|
|
|
})
|
|
|
html += '<div>';
|
|
|
$('.display_mode_1').remove();
|
|
|
$('.layer-footer').before(html);
|
|
|
// 绑定上传事件
|
|
|
Form.events.plupload("#spec-form");
|
|
|
Form.events.faselect("#spec-form");
|
|
|
// 显示隐藏规格
|
|
|
$("input:checked[type=radio]").trigger("change");
|
|
|
}
|
|
|
return false;
|
|
|
}, function(data, ret){
|
...
|
...
|
@@ -181,11 +130,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
|
|
|
// 规格值下规格组
|
|
|
$(document).on("change", "input[type=radio]", function () {
|
|
|
var _this = $(this);
|
|
|
showSpec($(this));
|
|
|
});
|
|
|
|
|
|
// 显示隐藏规格
|
|
|
function showSpec(obj){
|
|
|
Fast.api.ajax({
|
|
|
url:'goods/valueSpecList',
|
|
|
data:{
|
|
|
spec_value_id:$(this).val(),
|
|
|
spec_value_id:obj.val(),
|
|
|
}
|
|
|
}, function(data, ret){
|
|
|
if(ret.code == 1){
|
...
|
...
|
@@ -194,43 +147,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
// 一级规格
|
|
|
$.each(list,function(index,spec){
|
|
|
html += '<div class="form-group">'+
|
|
|
'<label class="control-label col-xs-12 col-sm-2">'+spec.spec_name+':</label>'+
|
|
|
'<div class="col-xs-12 col-sm-8">';
|
|
|
// 一级规格下规格值
|
|
|
if(spec.options.length > 0){
|
|
|
html += '<div class="radio">';
|
|
|
$.each(spec.options,function(index,spec_v){
|
|
|
var img = spec_v.spec_value_image == '' ? '/assets/img/qrcode.png' : spec_v.spec_value_image;
|
|
|
html += '<label for="'+spec_v.id+'" style="border:1px solid #f1f4f6">'+
|
|
|
'<input id="'+spec_v.id+'" name="row[goods_spec]['+spec_v.spec_id+']" type="radio" value="'+spec_v.id+'">'+
|
|
|
'<img width="100px" src="'+img+'">'+
|
|
|
'<p style="text-align:center">'+spec_v.spec_value+'</p>'+
|
|
|
'</label>';
|
|
|
})
|
|
|
html += '</div>';
|
|
|
}
|
|
|
// 一级规格下文本框
|
|
|
if(spec.spec_type == '2'){
|
|
|
html += '<input id="c-'+spec.id+'" data-rule="required" class="form-control" name="row[goods_spec]['+spec.id+']" type="text" value="">';
|
|
|
}
|
|
|
// 一级规格下上传图片
|
|
|
if(spec.spec_type == '3'){
|
|
|
html += '<div class="input-group">'+
|
|
|
'<input id="c-'+spec.id+'" data-rule="" class="form-control" size="50" name="row[goods_spec]['+spec.id+']" type="text" value="">'+
|
|
|
'<div class="input-group-addon no-border no-padding">'+
|
|
|
'<span><button type="button" id="plupload-'+spec.id+'" class="btn btn-danger plupload" data-input-id="c-'+spec.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+spec.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
|
|
|
'<span><button type="button" id="fachoose-'+spec.id+'" class="btn btn-primary fachoose" data-input-id="c-'+spec.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
|
|
|
'</div>'+
|
|
|
'<span class="msg-box n-right" for="c-'+spec.id+'"></span>'+
|
|
|
'</div>'+
|
|
|
'<ul class="row list-inline plupload-preview" id="p-'+spec.id+'"></ul>';
|
|
|
}
|
|
|
html += '</div>'+
|
|
|
'<label class="control-label col-xs-12 col-sm-2" for="c-'+spec.id+'">'+spec.spec_name+':</label>'+
|
|
|
'<div class="col-xs-12 col-sm-8">'+
|
|
|
commonhHtml(index,spec)+
|
|
|
'</div>'+
|
|
|
'</div>';
|
|
|
})
|
|
|
html += '<div>';
|
|
|
_this.parent().parent().parent().parent('.form-group').next('.display_mode_2').remove();
|
|
|
_this.parent().parent().parent().parent('.form-group').after(html);
|
|
|
obj.parent().parent().parent().parent('.form-group').next('.display_mode_2').remove();
|
|
|
obj.parent().parent().parent().parent('.form-group').after(html);
|
|
|
// 绑定上传事件
|
|
|
Form.events.plupload();
|
|
|
Form.events.faselect();
|
|
|
}
|
|
|
return false;
|
|
|
}, function(data, ret){
|
...
|
...
|
@@ -238,7 +166,46 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
alert(ret.msg);
|
|
|
return false;
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 共用html部分
|
|
|
function commonhHtml(index,spec){
|
|
|
var html = '';
|
|
|
// 规格下规格值
|
|
|
if(spec.options.length > 0){
|
|
|
html += '<div class="radio">';
|
|
|
$.each(spec.options,function(index,spec_v){
|
|
|
var img = spec_v.spec_value_image == '' ? '/assets/img/qrcode.png' : spec_v.spec_value_image;
|
|
|
var checked = goods_spec[spec_v.spec_id] == spec_v.id ? 'checked' : index == 0 ? 'checked' : '';
|
|
|
html += '<label for="'+spec_v.id+'" style="border:1px solid #f1f4f6">'+
|
|
|
'<input id="'+spec_v.id+'" '+checked+' name="row[goods_spec]['+spec_v.spec_id+']" type="radio" value="'+spec_v.id+'">'+
|
|
|
'<img width="100px" src="'+img+'">'+
|
|
|
'<p style="text-align:center">'+spec_v.spec_value+'</p>'+
|
|
|
'</label>';
|
|
|
})
|
|
|
html += '</div>';
|
|
|
}
|
|
|
// 规格下文本框
|
|
|
if(spec.spec_type == '2'){
|
|
|
var val = goods_spec[spec.id] == undefined ? '' : goods_spec[spec.id];
|
|
|
html += '<input id="c-'+spec.id+'" data-rule="required" class="form-control" name="row[goods_spec]['+spec.id+']" type="text" value="'+val+'">';
|
|
|
}
|
|
|
// 规格下上传图片
|
|
|
if(spec.spec_type == '3'){
|
|
|
var val = goods_spec[spec.id] == undefined ? '' : goods_spec[spec.id];
|
|
|
html += '<div class="input-group">'+
|
|
|
'<input id="c-'+spec.id+'" data-rule="required" class="form-control" size="50" name="row[goods_spec]['+spec.id+']" type="text" value="'+val+'">'+
|
|
|
'<div class="input-group-addon no-border no-padding">'+
|
|
|
'<span><button type="button" id="plupload-'+spec.id+'" class="btn btn-danger plupload" data-input-id="c-'+spec.id+'" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-'+spec.id+'"><i class="fa fa-upload"></i> 上传</button></span>'+
|
|
|
'<span><button type="button" id="fachoose-'+spec.id+'" class="btn btn-primary fachoose" data-input-id="c-'+spec.id+'" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>'+
|
|
|
'</div>'+
|
|
|
'<span class="msg-box n-right" for="c-'+spec.id+'"></span>'+
|
|
|
'</div>'+
|
|
|
'<ul class="row list-inline plupload-preview" id="p-'+spec.id+'"></ul>';
|
|
|
}
|
|
|
return html;
|
|
|
}
|
|
|
|
|
|
Form.api.bindevent($("form[role=form]"));
|
|
|
}
|
|
|
}
|
...
|
...
|
|