...
|
...
|
@@ -61,27 +61,50 @@ var g = new common.grid({ |
|
|
]
|
|
|
});
|
|
|
g.init("/shotManage/proPhoto/index2");
|
|
|
var pictureBoList = [];
|
|
|
|
|
|
|
|
|
var Bll = {
|
|
|
toast: function (url, item, hint) {
|
|
|
var a = common.dialog.confirm(hint,
|
|
|
common.util.__template2($("#template1").html(), item),
|
|
|
function () {
|
|
|
common.util.__ajax({
|
|
|
url: url,
|
|
|
data: {
|
|
|
productSku: parseInt($("#Sku").val()),
|
|
|
productPhotoAddStrList: JSON.stringify(pictureBoList)
|
|
|
}
|
|
|
}, function (res) {
|
|
|
if (res.code == '200') {
|
|
|
g.reload();
|
|
|
a.close();
|
|
|
pictureBoList = [];
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
pictureBoList: [],
|
|
|
selectedBoId: [],
|
|
|
//重新渲染图片列表
|
|
|
rendBoList: function (pictureBoList) {
|
|
|
$(".image-list").html('');
|
|
|
$("#addPic").append(common.util.__template2($("#template2").html(),
|
|
|
{
|
|
|
pictureBoList: pictureBoList
|
|
|
}
|
|
|
));
|
|
|
},
|
|
|
toast: function (url, item, datacall) {
|
|
|
Bll.pictureBoList = item.pictureBoList || [];
|
|
|
Bll.selectedBoId = [];
|
|
|
var a = new common.dialog({
|
|
|
title: "图片",
|
|
|
width: '80%',
|
|
|
content: common.util.__template2($("#template1").html(), item),
|
|
|
button: [
|
|
|
{
|
|
|
value: "提交", callback: function () {
|
|
|
var data = datacall && datacall(Bll.pictureBoList, Bll.selectedBoId);
|
|
|
common.util.__ajax({
|
|
|
url: url,
|
|
|
data: data
|
|
|
}, function (res) {
|
|
|
if (res.code == '200') {
|
|
|
g.reload();
|
|
|
a.close();
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
}, css: "btn-primary"
|
|
|
},
|
|
|
{
|
|
|
"value":"取消",
|
|
|
css: "btn-info"
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
Bll.rendBoList(Bll.pictureBoList);
|
|
|
common.edit.ajaxfileupload(".picfile", {
|
|
|
params: {
|
|
|
__type: "upload",
|
...
|
...
|
@@ -90,17 +113,13 @@ var Bll = { |
|
|
valid_extensions: ['png', 'jpg', 'jpeg'],
|
|
|
onComplete: function (response) {
|
|
|
if (response.status && response.code == 200) {
|
|
|
//console.log("response",response);
|
|
|
console.log("response", response);
|
|
|
var data = {
|
|
|
"fileName": response.data,
|
|
|
"originalName": "1035027.jpg"
|
|
|
};
|
|
|
pictureBoList.push(data);
|
|
|
$("#addPic").html(common.util.__template2($("#template2").html(),
|
|
|
{
|
|
|
pictureBoList: pictureBoList
|
|
|
}
|
|
|
));
|
|
|
Bll.pictureBoList.push(data);
|
|
|
Bll.rendBoList(Bll.pictureBoList);
|
|
|
}
|
|
|
else {
|
|
|
common.util.__tip(response.message, 'warning');
|
...
|
...
|
@@ -112,55 +131,39 @@ var Bll = { |
|
|
};
|
|
|
//上传图片--点击事件
|
|
|
$('#upload-btn').on('click', function () {
|
|
|
var item = {};
|
|
|
Bll.toast('/shotManage/proPhoto/add', item, "上传图片");
|
|
|
var item = {
|
|
|
__state: "add"
|
|
|
};
|
|
|
Bll.toast('/shotManage/proPhoto/add', item, function (pictureBoList, selectedBoId) {
|
|
|
return {
|
|
|
productSku: parseInt($("#Sku").val()),
|
|
|
productPhotoAddStrList: JSON.stringify(pictureBoList)
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
//上传图片时 删除单张图片
|
|
|
//删除单张图片
|
|
|
$(document).on('click', '.remove1', function () {
|
|
|
var index = $(this).parents(".cover-image-item").index();
|
|
|
//界面删除
|
|
|
$(this).parents('.cover-image-item').remove();
|
|
|
//数组中删除
|
|
|
pictureBoList.splice(index, 1);
|
|
|
//console.log("pictureBoList", pictureBoList);
|
|
|
var index = $(this).data("index");
|
|
|
Bll.selectedBoId.push(Bll.pictureBoList[index].id);
|
|
|
Bll.pictureBoList.splice(index, 1);
|
|
|
Bll.rendBoList(Bll.pictureBoList);
|
|
|
});
|
|
|
|
|
|
//查询按钮--点击事件
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
var ids = [];
|
|
|
//编辑
|
|
|
$(document).on('click', '.update', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var pics = item.pictureBoList || [];
|
|
|
console.log("pics",pics);
|
|
|
$(document).on('click', '.remove2', function () {
|
|
|
var index = $(this).parents(".cover-image-item").index();
|
|
|
//界面删除
|
|
|
$(this).parents('.cover-image-item').remove();
|
|
|
console.log(pics[index]);
|
|
|
console.log("pics[index].id",pics[index].id);
|
|
|
ids.push(pics[index].id);
|
|
|
pics.splice(index, 1);
|
|
|
item.__state = "update";
|
|
|
Bll.toast('/shotManage/proPhoto/update', item, function (pictureBoList, selectedBoId) {
|
|
|
return {
|
|
|
productSkn: item.productSkn,
|
|
|
ids: JSON.stringify(selectedBoId)
|
|
|
}
|
|
|
});
|
|
|
var b = common.dialog.confirm("编辑", common.util.__template2($("#template3").html(), item),
|
|
|
function () {
|
|
|
common.util.__ajax({
|
|
|
url: "/shotManage/proPhoto/update",
|
|
|
data: {
|
|
|
productSkn: item.productSkn,
|
|
|
ids: JSON.stringify(ids)
|
|
|
}
|
|
|
}, function (res) {
|
|
|
//console.log("res",res);
|
|
|
if (res.code == '200') {
|
|
|
g.reload();
|
|
|
ids = [];
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
});
|
|
|
|
|
|
//查询按钮--点击事件
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|