window.onload = function (ev) {
init();
}
init = function () {
getAttributeInfo();
}
getAttributeInfo = function () {
var parameter = urlEncode(["SelectAllProductAttribute"]);
$.ajax({
type: "post",
url: "/taiwan/php/index.php",
data: {mode: parameter},
dataType: "json",
success: function (data) {
if (data[0].length == 0 || data == -1) {
var th = '
' +
'' + data[i].ProductInfoClassId + ' | ' +
'' + data[i].ProductInfoClassName + ' | ' +
'' + data[i].InfoClassIdAddTime + ' | ' +
'' +
'删除>' +
'修改>' +
' |
'
)
;
warp.append(tr);
}
$("#loading").css({"display": "none"});
$("#warp").css({"display": "table-row-group"});
}
showAddWarp = function () {
$("#modal-demo").modal("show");
}
setAttribute = function (jugde, text, aid) {
var _el = $("#addAttribute");
if (jugde) {
$(_el).bind("click", function () {
addAttribute();
});
}
else {
$(_el).bind("click", function () {
updateAttribute(text, aid);
});
}
}
addAttribute = function () {
var name = $("#AttributeName").val();
if (name == "" || name.trim() == "") {
$.Huimodalalert('请输入属性名!', 2000);
}
else {
var parameter = urlEncode(["InsertAttribute", name]);
$.ajax({
type: "post",
url: "/taiwan/php/index.php",
data: {mode: parameter},
dataType: "json",
success: function (data) {
$("#AttributeName")[0].value = "";
getAttributeInfo();
}
});
$("#warp").css({"display": "none"});
$("#modal-demo").modal("hide");
$("#loading").css({"display": "block"});
}
}
deleteAttribute = function (aid) {
layer.confirm('是否删除属性?', {
btn: ['确定', '取消'] //按钮
}, function (e, a) {
var parameter = urlEncode(["DeleteAttribute", aid]);
$.ajax({
type: "post",
url: "/taiwan/php/index.php",
data: {mode: parameter},
dataType: "json",
success: function (data) {
if (data[0].mode == 1) {
getAttributeInfo();
$.Huimodalalert('删除成功', 2000);
console.log(data);
}
}
});
$(a).prev().remove();
$(a).remove();
$("#warp").css({"display": "none"});
$("#loading").css({"display": "block"});
});
}
showUpdateAttribute = function (text, aid) {
showAddWarp();
$("#AttributeName").val(text);
setAttribute(false, text, aid);
}
updateAttribute = function (text, aid) {
var name = $("#AttributeName").val();
if (name == "" || name.trim() == "") {
$.Huimodalalert('请输入属性名!', 2000);
}
else {
var parameter = urlEncode(["UpdateAttributeName", aid, name]);
$.ajax({
type: "post",
url: "/taiwan/php/index.php",
data: {mode: parameter},
dataType: "json",
success: function (data) {
$("#AttributeName")[0].value = "";
getAttributeInfo();
}
});
$("#warp").css({"display": "none"});
$("#modal-demo").modal("hide");
$("#loading").css({"display": "block"});
}
}
urlEncode = function (arr) {
var i; //循环初始化
for (i = 0; i < arr.length; i++) {
arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
}
return arr.join();
}