...
|
...
|
@@ -25,22 +25,23 @@ var tableGird = new common.grid({ |
|
|
},
|
|
|
columns: [
|
|
|
{display: "属性名称", name: "attributeName"},
|
|
|
{display: "属性类型",
|
|
|
{
|
|
|
display: "属性类型",
|
|
|
|
|
|
//name: "attributeValues"
|
|
|
render: function (item) {
|
|
|
var propType = item.attributeValues;
|
|
|
|
|
|
var propsStr="";
|
|
|
var propsStr = "";
|
|
|
if (common.util.__isJsonString(propType)) {
|
|
|
var props = JSON.parse(propType);
|
|
|
[].slice.call(props,0).forEach(function(prop){
|
|
|
[].slice.call(props, 0).forEach(function (prop) {
|
|
|
propsStr += prop.name + ",";
|
|
|
});
|
|
|
} else {
|
|
|
propsStr = propType;
|
|
|
}
|
|
|
return '<p> '+propsStr+'</p>';
|
|
|
return '<p> ' + propsStr + '</p>';
|
|
|
}
|
|
|
|
|
|
},
|
...
|
...
|
@@ -63,7 +64,7 @@ var tableGird = new common.grid({ |
|
|
render: function (items) {
|
|
|
|
|
|
if (items.categoryId == window.sortid)
|
|
|
return ('<button data-index="' + items.__index + '" class="btn btn-success btn-xs edit-class-btn">编辑</button>');
|
|
|
return ('<button data-index="' + items.__index + '" class="btn btn-success btn-xs edit-class-btn">编辑</button>');
|
|
|
}
|
|
|
}
|
|
|
]
|
...
|
...
|
@@ -74,16 +75,18 @@ var propValueGrid = new common.grid({ |
|
|
|
|
|
el: "#prop-value-table",
|
|
|
columns: [
|
|
|
{display: "ID", name: "id",
|
|
|
{
|
|
|
display: "ID", name: "id",
|
|
|
render: function (items) {
|
|
|
|
|
|
//items.id=items.__index+1;
|
|
|
return('<input id="id" disabled="true" class="form-control width110 propValueID" value="'+items.id+'" required="required" data-index="'+items.__index+'" type="text">');
|
|
|
return ('<input id="id" disabled="true" class="form-control width110 propValueID" value="' + items.id + '" required="required" data-index="' + items.__index + '" type="text">');
|
|
|
}
|
|
|
},
|
|
|
{display: "属性值", name: "name",
|
|
|
{
|
|
|
display: "属性值", name: "name",
|
|
|
render: function (items) {
|
|
|
return('<input id="name" class="form-control width110 propValue" value="'+items.name+'" data-index="'+items.__index+'" required="required" type="text" placeholder="属性值">');
|
|
|
return ('<input id="name" class="form-control width110 propValue" value="' + items.name + '" data-index="' + items.__index + '" required="required" type="text" placeholder="属性值">');
|
|
|
}
|
|
|
|
|
|
},
|
...
|
...
|
@@ -93,10 +96,10 @@ var propValueGrid = new common.grid({ |
|
|
render: function (items) {
|
|
|
|
|
|
var html = [];
|
|
|
if (items.__index == propValueGrid.__rows.length-1) {
|
|
|
if (items.__index == propValueGrid.__rows.length - 1) {
|
|
|
html.push('<button data-index="' + items.__index + '" class="btn btn-success btn-xs prop-add-btn">添加</button>');
|
|
|
}
|
|
|
if (items.__index == 0 ) {
|
|
|
if (items.__index == 0) {
|
|
|
|
|
|
if (propValueGrid.__rows.length != 1) {
|
|
|
html.push('<button data-index="' + items.__index + '" class="btn btn-success btn-xs prop-del-btn">删除</button>');
|
...
|
...
|
@@ -112,9 +115,8 @@ var propValueGrid = new common.grid({ |
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on("change",".propValueID",function(){
|
|
|
var item=propValueGrid.__rows[$(this).data("index")];
|
|
|
$(document).on("change", ".propValueID", function () {
|
|
|
var item = propValueGrid.__rows[$(this).data("index")];
|
|
|
|
|
|
if (item) {
|
|
|
item.id = $(this).val();
|
...
|
...
|
@@ -122,8 +124,8 @@ $(document).on("change",".propValueID",function(){ |
|
|
|
|
|
});
|
|
|
|
|
|
$(document).on("change",".propValue",function(){
|
|
|
var item=propValueGrid.__rows[$(this).data("index")];
|
|
|
$(document).on("change", ".propValue", function () {
|
|
|
var item = propValueGrid.__rows[$(this).data("index")];
|
|
|
|
|
|
if (item) {
|
|
|
item.name = $(this).val();
|
...
|
...
|
@@ -133,7 +135,7 @@ $(document).on("change",".propValue",function(){ |
|
|
|
|
|
//增加属性值
|
|
|
$(document).on('click', '.prop-add-btn', function () {
|
|
|
propValueGrid.__rows.push({name:"",id:parseInt(propValueGrid.__rows[propValueGrid.__rows.length-1].id) + 1});
|
|
|
propValueGrid.__rows.push({name: "", id: parseInt(propValueGrid.__rows[propValueGrid.__rows.length - 1].id) + 1});
|
|
|
propValueGrid.reload();
|
|
|
});
|
|
|
|
...
|
...
|
@@ -141,15 +143,15 @@ $(document).on('click', '.prop-add-btn', function () { |
|
|
$(document).on('click', '.prop-del-btn', function () {
|
|
|
|
|
|
var item = propValueGrid.__rows[$(this).data('index')];
|
|
|
propValueGrid.__rows.splice($(this).data('index'),1);
|
|
|
propValueGrid.__rows.splice($(this).data('index'), 1);
|
|
|
propValueGrid.reload();
|
|
|
});
|
|
|
var timeid;
|
|
|
sortmenu.init(function () {
|
|
|
clearTimeout(timeid);
|
|
|
timeid=setTimeout(function(){
|
|
|
timeid = setTimeout(function () {
|
|
|
tableGird.init('/product/attr/queryProductAttributeList');
|
|
|
},2000);
|
|
|
}, 2000);
|
|
|
});
|
|
|
|
|
|
$('#add-attri').click(function () {
|
...
|
...
|
@@ -173,65 +175,119 @@ function attributeOp(prefix, url, item) { |
|
|
|
|
|
var a = new common.edit(".confirm");
|
|
|
|
|
|
if(item.attributeValues) {
|
|
|
if (item.attributeValues) {
|
|
|
|
|
|
|
|
|
if (common.util.__isJsonString(item.attributeValues)) {
|
|
|
propValueGrid.__rows = JSON.parse(item.attributeValues);
|
|
|
} else {
|
|
|
propValueGrid.__rows=[{ 'name':"", 'id':"1"}];
|
|
|
propValueGrid.__rows = [{'name': "", 'id': "1"}];
|
|
|
}
|
|
|
} else {
|
|
|
propValueGrid.__rows=[{ 'name':"", 'id':"1"}];
|
|
|
propValueGrid.__rows = [{'name': "", 'id': "1"}];
|
|
|
}
|
|
|
|
|
|
common.dialog.confirm(prefix + "属性", common.util.__template($("#template").html(), item), function () {
|
|
|
return a.submit(url, function (option) {
|
|
|
option.data.categoryId = item.categoryId;
|
|
|
option.data.attributeId = item.attributeId;
|
|
|
|
|
|
// 检查所有属性值是否为空
|
|
|
//if (!checkPropName()) {
|
|
|
// alert()
|
|
|
//}
|
|
|
var inputType = $('#inputType').val();
|
|
|
var propVlaueArr = propValueGrid.__rows.splice(0).map(function (v, index) {
|
|
|
return {
|
|
|
id: v.id,
|
|
|
name: v.name
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType == "") {
|
|
|
// 不显示属性列表
|
|
|
return a.submit(url, function (option) {
|
|
|
option.data.categoryId = item.categoryId;
|
|
|
option.data.attributeId = item.attributeId;
|
|
|
|
|
|
var inputType = $('#inputType').val();
|
|
|
// 检查所有属性值是否为空
|
|
|
|
|
|
console.log(inputType);
|
|
|
// 单行文本 或者 多行文本 时不显示表格
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType =="") {
|
|
|
console.log(inputType);
|
|
|
// 单行文本 或者 多行文本 时不显示表格
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType == "") {
|
|
|
|
|
|
} else {
|
|
|
var propVlaueArr = propValueGrid.__rows.splice(0).map(function(item,inex){
|
|
|
return {id:item.id,
|
|
|
name:item.name
|
|
|
} else {
|
|
|
option.data.attributeValues = JSON.stringify(propVlaueArr);
|
|
|
}
|
|
|
|
|
|
console.log(propVlaueArr);
|
|
|
//option.debug = true;
|
|
|
|
|
|
propValueGrid.__rows = [];
|
|
|
option.success = function (res) {
|
|
|
|
|
|
res = res.data;
|
|
|
if (res.code == "200") {
|
|
|
a.$tip("提交成功", function () {
|
|
|
tableGird.reload();
|
|
|
}, 'growl-success');
|
|
|
} else {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
option.data.attributeValues = JSON.stringify(propVlaueArr);
|
|
|
return false;
|
|
|
},
|
|
|
option.error = function (res) {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
// 显示属性列表
|
|
|
if (propVlaueArr) {
|
|
|
propVlaueArr.forEach(function (pv) {
|
|
|
if (!pv.name) {
|
|
|
a.$tip('属性值不能为空');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return a.submit(url, function (option) {
|
|
|
option.data.categoryId = item.categoryId;
|
|
|
option.data.attributeId = item.attributeId;
|
|
|
|
|
|
// 检查所有属性值是否为空
|
|
|
|
|
|
console.log(inputType);
|
|
|
// 单行文本 或者 多行文本 时不显示表格
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType == "") {
|
|
|
|
|
|
} else {
|
|
|
option.data.attributeValues = JSON.stringify(propVlaueArr);
|
|
|
}
|
|
|
|
|
|
console.log(propVlaueArr);
|
|
|
//option.debug = true;
|
|
|
|
|
|
propValueGrid.__rows = [];
|
|
|
option.success = function (res) {
|
|
|
|
|
|
res = res.data;
|
|
|
if (res.code == "200") {
|
|
|
a.$tip("提交成功", function () {
|
|
|
tableGird.reload();
|
|
|
}, 'growl-success');
|
|
|
} else {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
option.error = function (res) {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
} else {
|
|
|
a.$tip('属性值不能为空');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
console.log(propVlaueArr);
|
|
|
//option.debug = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
propValueGrid.__rows = [];
|
|
|
option.success = function (res) {
|
|
|
|
|
|
res = res.data;
|
|
|
if (res.code == "200") {
|
|
|
a.$tip("提交成功", function () {
|
|
|
tableGird.reload();
|
|
|
}, 'growl-success');
|
|
|
} else {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
option.error = function (res) {
|
|
|
a.$tip(res.message);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
...
|
...
|
@@ -249,10 +305,10 @@ function attributeOp(prefix, url, item) { |
|
|
}
|
|
|
|
|
|
|
|
|
function showORHidePropValue () {
|
|
|
function showORHidePropValue() {
|
|
|
var inputType = $('#inputType').val();
|
|
|
// 单行文本 或者 多行文本 时不显示表格
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType =="") {
|
|
|
if (inputType == 'textarea' || inputType == 'text' || inputType == "") {
|
|
|
$('#attributeValues').show();
|
|
|
$('#prop-value-table').hide();
|
|
|
$('.propValue').removeAttr("required");
|
...
|
...
|
|