Authored by weiqingting

update

... ... @@ -297,7 +297,12 @@ var util = {
// 判断是否是有效的json字串
__isJsonString: function (str) {
try {
JSON.parse(str);
var a=JSON.parse(str);
if(typeof a=="object"){
return true;
}else{
return false;
}
} catch (e) {
return false;
}
... ...
... ... @@ -31,8 +31,8 @@ var tableGird = new common.grid({
//name: "attributeValues"
render: function (item) {
var propType = item.attributeValues;
var propsStr = "";
console.log(item);
if (common.util.__isJsonString(propType)) {
var props = JSON.parse(propType);
[].slice.call(props, 0).forEach(function (prop) {
... ... @@ -173,7 +173,7 @@ $(document).on('change', '#inputType', function () {
function attributeOp(prefix, url, item) {
var a = new common.edit(".confirm");
var a = new common.edit(".modal-body");
if (item.attributeValues) {
... ... @@ -187,10 +187,16 @@ function attributeOp(prefix, url, item) {
propValueGrid.__rows = [{'name': "", 'id': "1"}];
}
common.dialog.confirm(prefix + "属性", common.util.__template($("#template").html(), item), function () {
var d=new common.dialog({
title:prefix + "属性",
width:'80%',
content:common.util.__template($("#template").html(), item),
button:[
{
value: "确定",
callback: function(){
var inputType = $('#inputType').val();
var propVlaueArr = propValueGrid.__rows.splice(0).map(function (v, index) {
var propVlaueArr = propValueGrid.__rows.map(function (v, index) {
return {
id: v.id,
name: v.name
... ... @@ -199,7 +205,7 @@ function attributeOp(prefix, url, item) {
if (inputType == 'textarea' || inputType == 'text' || inputType == "") {
// 不显示属性列表
return a.submit(url, function (option) {
a.submit(url, function (option) {
option.data.categoryId = item.categoryId;
option.data.attributeId = item.attributeId;
... ... @@ -223,6 +229,7 @@ function attributeOp(prefix, url, item) {
if (res.code == "200") {
a.$tip("提交成功", function () {
tableGird.reload();
d.close();
}, 'growl-success');
} else {
a.$tip(res.message);
... ... @@ -243,7 +250,7 @@ function attributeOp(prefix, url, item) {
return false;
}
return a.submit(url, function (option) {
a.submit(url+"?_datetime_="+Date.now(), function (option) {
option.data.categoryId = item.categoryId;
option.data.attributeId = item.attributeId;
... ... @@ -265,9 +272,8 @@ function attributeOp(prefix, url, item) {
res = res.data;
if (res.code == "200") {
a.$tip("提交成功", function () {
tableGird.reload();
}, 'growl-success');
d.close();
} else {
a.$tip(res.message);
}
... ... @@ -284,14 +290,13 @@ function attributeOp(prefix, url, item) {
}
}
return false;
},
css: "btn-primary"
}
]
});
a.init();
// 属性值列表的初始化
... ...