resourceContentManage.js 25.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
var $ = require('jquery'),
    common = require('../common/common');
var Button = require('./partials/Button1');
var resourceObj = require('./partials/resourceObj');
var Validate = require('./partials/Validate1');
var addObj = require('./partials/addObj');

/*获取数据*/
var resources = [];
var times = [];
var currIndex = 0;
//资源id
var param = location.href.substring(location.href.lastIndexOf("/") + 1);
common.util.__ajax({
    url: "/resources/resContentIndex",
    data: {id: param},
    async: false
}, function (res) {
    resources = res.data;
    console.log(resources);
}, true);

/*配置模块*/
var edit = new common.edit2(".modal-body", {
    bucket: "yhb-img01"
});

var Bll = {
    Brands: [],
    Brands1: {},
    Brdata: [],
    contentDatas: [],
    module: null,
    __render: function (selecter, templater, data) {
        $(selecter).html(common.util.__template2($("#" + templater).html(), data));
    },
    toast: function (index, module) {
        var btn = Button.filter(function (item) {
            return item.template_name == module.contentData.template_name;
        });
        //console.log("打开的数据module",module);
        var d = new common.dialog({
            title: (!!~index ? "修改" : "添加") + btn[0].button_name,
            //content: common.util.__template2($("#" + module.contentData.dialog).html(), module),
            content: common.util.__template2($("#" + btn[0].dialog).html(), module),
            width: '70%',
            button: [{
                value: "保存",
                callback: function () {
                    var couponFlag = true;
                    if (Validate[module.contentData.template_name]) {
                        Validate[module.contentData.template_name].forEach(function (item) {
                            couponFlag = item.fn(module.contentData);
                        })
                    }
                    if (edit.validate() && couponFlag) {
                        //TODO
                        if (resourceObj[module.contentData.template_name]) {
                            resourceObj[module.contentData.template_name](module.contentData.data);
                        }
                        !!~index ? Bll.contentDatas[currIndex][index] = module : Bll.contentDatas[currIndex].push(module);
                        Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
                        d.close();
                    }
                    return false;
                },
                css: "btn-primary"
            }]
        });
        Bll.__editRender();
    },
    renderDialog: function (templater) {
        Bll.__render(".modal-body", templater, Bll.module);
        Bll.__editRender();
    },
    __editRender: function () {
        $('.draggable').each(function () {
            if ($(this).children().length) {
                $(this).sortable().bind('sortupdate', function () {
                    var fn = new Function("Bll", "return Bll.module.contentData." + $(this).data("array"));
                    var arr = fn(Bll);
                    var arr2 = [];//拖拽后顺序
                    var itemsUpdate = $(this).children();
                    if (itemsUpdate.length == arr.length) {
                        for (var i = 0; i < itemsUpdate.length; i++) {
                            arr2.push($(itemsUpdate[i]).attr("drag-index"));
                        }
                        for (var i = 0; i < arr.length; i++) {
                            arr2[i] = arr[arr2[i]];
                        }
                        arr = arr2;
                    }
                })
            }
        });
        edit.init();
        edit.on("file_onComplete", function (obj) {
            var names = obj.field;
            Bll.module.contentData.data = common.util.__buildobj(names, '.', Bll.module.contentData.data, function (o, name) {
                o[name] = obj.data;
            });
        });
    },
    //获取品牌
    getBrands: function () {
        var Brand = {};
        $.get("/ajax/yohosearch", function (res) {
            res.data.forEach(function (item, index) {
                var brandAlif = (item.brand_alif || "").toUpperCase();
                if (/^[0-9]$/.test(item.brand_alif)) {
                    brandAlif = "0-9";
                }
                if (/^\W$/.test(item.brand_alif)) {
                    brandAlif = "#";
                }
                Brand[brandAlif] = Brand[brandAlif] || [];
                Brand[brandAlif].push(item);
                Bll.Brands1[item.id] = item;
            });
            for (var i in Brand) {
                Brand[i].sort(function (a, b) {
                    if (a.brand_name && b.brand_name) {
                        var aName = a.brand_name.toLowerCase(),
                            bName = b.brand_name.toLowerCase();
                        if (aName < bName) return -1;
                        if (aName > bName) return 1;
                    }
                    return 0;
                });
                Bll.Brands.push({
                    name: i,
                    items: Brand[i]
                });
            }
        });
    },
    renderBrandPic: function (Brdata) {
        var Brands2 = [];
        Brdata.forEach(function (item, index) {
            if (!item.brandIco) {
                var a = Bll.Brands1[item];
                a.brandIco = common.util.__joinImg("brandLogo", a.brand_ico);
                Brands2.push(a);
            } else {
                item.brandIco = common.util.__template(item.brandIco, {width: 110, height: 150});
                Brands2.push(item);
            }

        });
        Bll.module = Bll.module || {};
        Bll.module.contentData = Bll.module.contentData || {};
        Bll.module.contentData.data = Bll.module.contentData.data || {};
        Bll.module.contentData.data.list = Bll.module.contentData.data.list || [];
        for (var i = 0; i < Brands2.length; i++) {
            var pic = {};
            if (Bll.module.contentData.template_name == "kidsBrands") {
                pic = {
                    "src": Brands2[i].brandIco,
                    "id": Brands2[i].id,
                    "title": Brands2[i].brand_name
                };
            } else {
                pic = {
                    "src": Brands2[i].brandIco,
                    "id": Brands2[i].id,
                    "name": Brands2[i].brand_name
                };
            }
            Bll.module.contentData.data.list.push(pic);
        }
        Bll.renderDialog("brands-template");
    },
    getLocalTime:function(nS) {
        var date = new Date(parseInt(nS) * 1000);
        var mm = date.getMonth() + 1;
        var dd = date.getDate();
        var h = date.getHours();
        var min = date.getMinutes();
        var second = date.getSeconds();
        return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd) + " " + (h < 10 ? "0" + h : h) + ":"
            + (min < 10 ? "0" + min : min) + ":" + (second < 10 ? "0" + second : second);
    }
};

//初始化时间
var statusArr = ["已过期", "进行中", "未发布"];
for(var i = 0; i < resources.length; i++) {
    //status 0:已过期;1:进行中;2:未发布
    var time = resources[i].resource.publishTime==0?"":Bll.getLocalTime(resources[i].resource.publishTime);
    times[i] = {
        time:time,
        status:statusArr[resources[i].status]
    }
}

/*第一步,基础模板*/
Bll.__render("#content-list", "content-template", resources[currIndex]);
Bll.__render(".contents", "template_content_btns", {btns: Button});
Bll.__render("#times-list", "times-template", {times:times, selected:0});

/*第二部,把楼层数据转化成数组*/
for(var i = 0; i < resources.length; i++) {
    Bll.contentDatas[i] = [];
    resources[i].contentData.forEach(function (item, index) {
        item.contentData = JSON.parse(item.contentData);
        var temp;
        if (item.contentData.template_name == "kidsBrands") {
            temp = item.contentData.data.params.more_url;
            item.contentData.data.params.more_url = {};
            item.contentData.data.params.more_url.action = JSON.parse(temp).action || "";
            item.contentData.data.params.more_url.url = JSON.parse(temp).url || "";
        }
        if (item.contentData.template_name == 'title') {
            temp = item.contentData.data.more_link;
            item.contentData.data.more_link = {};
            item.contentData.data.more_link.action = JSON.parse(temp).action || "";
            item.contentData.data.more_link.url = JSON.parse(temp).url || "";
        }
        item.contentData = JSON.stringify(item.contentData);
        item.contentData = item.contentData.replace(/(gif|png|jpg|jpeg)\?[^"]*/g, '$1');
        item.contentData = common.util.__ObjToArray(JSON.parse(item.contentData));
        Bll.contentDatas[i].push(item);
    });
}

/*第三部解析楼层*/
Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});

/*第四部 操作按钮  添加 删除 修改*/
$(document).on("click", ".add_btn", function () {
    var item = Button[$(this).data("index")];
    Bll.module = {};
    Bll.module.contentData = $.extend(true, {}, item);
    Bll.toast(-1, Bll.module);
});

/*第五步 绑定监听事件*/
$(document).on("change", ".observe", function () {
    var $this = $(this);
    var name = $this.data("field");
    Bll.module.contentData.data = common.util.__buildobj(name, '.', Bll.module.contentData.data, function (obj, name) {
        obj[name] = $this.val();
        if (name == "image_style") {
            delete obj["default"];
            delete obj["T1F2"];
            delete obj["L1R2"];
            delete obj["imageList"];
            obj[obj[name]] = true;
        }
    });
});

/*删除*/
$(document).on("click", ".del", function () {//删除
    var index = $(this).data("index");
    common.dialog.confirm("警告",
        common.util.__template2("是否确认删除?", {}),
        function () {
            if (Bll.contentDatas[currIndex][index].id) {
                common.util.__ajax({
                    url: "/resources/delResContent",
                    data: {id: Bll.contentDatas[currIndex][index].id}
                });
            }
            Bll.contentDatas[currIndex].splice(index, 1);
            Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
        });
});

/*编辑*/
$(document).on("click", ".edit", function () {
    var index = $(this).data("index");
    var item = Bll.contentDatas[currIndex][index];
    Bll.module = $.extend(true, {}, item);
    Bll.toast(index, Bll.module);
});

/*根据limit判断最多添加条数, 根据event判断添加的类型, data-event:template_name + "-template"*/
$(document).on("click", ".addBtn", function () {
    var length = $(this).data("limit");
    var arr = $(this).data("event").split(".");
    if (arr[1] == "data") {
        if (Bll.module.contentData.data.length >= length) {
            common.util.__tip("最多" + length + "条!", "warning");
            return;
        }
        Bll.module.contentData.data.push(addObj[arr.join("_")]);
    } else {
        if (Bll.module.contentData.data[arr[1]].length >= length) {
            common.util.__tip("最多" + length + "条!", "warning");
            return;
        }
        Bll.module.contentData.data[arr[1]].push(addObj[arr.join("_")]);
    }
    Bll.renderDialog(arr[0] + "-template");
});

/*删除行*/
$(document).on("click", ".delBtn", function () {
    var arr = $(this).data("event").split(".");
    var index = $(this).data("index");
    if (arr[1] == "data") {
        Bll.module.contentData.data.splice(index, 1);
    } else {
        Bll.module.contentData.data[arr[1]].splice(index, 1);
    }
    Bll.renderDialog(arr[0] + "-template");
});

//输入领券码验证
$(document).on("change", "#couponID", function () {
    var couponID = $(this).val();
    common.util.__ajax({
        url: "/coupon/batchCheckCoupons",
        async: false,
        data: {
            params: couponID
        }
    }, function () {
    });
});

//获取品牌
Bll.getBrands();
//打开品牌选择模态
$(document).on("click", "#addBrands", function () {
    var e = new common.edit("#brandForm");
    new common.dialog({
        title: "选择品牌",
        width: "70%",
        content: common.util.__template2($("#template5").html(), {
            Brands: Bll.Brands,//所有品牌数据
            Brdata: []
        }),
        button: [
            {
                value: "确定",
                callback: function () {
                    Bll.Brdata = $("#brandCheckBox").val().split('|');
                    Bll.renderBrandPic(Bll.Brdata);
                },
                css: "btn-primary"
            },
            {
                value: "取消"
            }
        ]
    });
    e.init();
});
//品牌筛选
$(document).on('click', '.brand-index', function () {
    var brandIndex = $(this).text();
    $('.brand-wrap').find('[name="' + brandIndex + '"]').show().siblings().hide();
});

//*****************************************************************//
/*图片列表*/
$(document).on("click", '.is_show_name', function () {
    Bll.module.contentData.data.title.is_show_name = $(this).val();
    Bll.renderDialog("imageList-template");
});
//*****************************************************************//
/*推荐(标题 + 12张图)*/
$(document).on("change", '#recommendContentFive-is_show', function () {
    var fn = new Function("console.log(111)");
    fn();
    Bll.module.contentData.data.title.is_show = 1 - Bll.module.contentData.data.title.is_show;
    Bll.renderDialog("recommendContent-template");
});
//*****************************************************************//
/*焦点图*/
$(document).on("change", '#focus-select', function () {
    Bll.module.contentData.focus_type = $(this).val();
    Bll.renderDialog("focus-template");
});
//*****************************************************************//
/*编辑推荐*/
$(document).on("change", '#editorTalk-is_show', function () {
    Bll.module.contentData.data.title.is_show = 1 - Bll.module.contentData.data.title.is_show;
    Bll.renderDialog("editorTalk-template");
});
//推荐品牌 是否显示名称
$(document).on("click", '.is_show_name_brand', function () {
    Bll.module.contentData.data.is_show_name = $(this).val();
    Bll.renderDialog("brands-template");
});
//**********************************************************************************/
//复制
$(document).on("click", "#copyTab", function() {
    common.util.__ajax({
        url: "/resources/copyResContent",
        data: {rId:resources[currIndex].resource.id}
    }, function (res) {
        //setTimeout(function() {
        window.location.href = window.location.href;
        //}, 2000);
    });
});
//保存时间
$(document).on("click", "#saveTime", function() {
    if(times[currIndex].status == "进行中") {
        common.util.__tip("进行中的页面不能更改时间");
        return false;
    }
    if(!times[currIndex].time) {
        common.util.__tip("该页面不能更改时间");
        return;
    }
    common.util.__ajax({
        url: "/resources/updateResPublishTime",
        data: {
            id:resources[currIndex].resource.id,
            time:times[currIndex].time
        }
    }, function (res) {
        //setTimeout(function() {
        window.location.href = window.location.href;
        //}, 2000);
    });
});
new common.edit2("#times-list").init();
//切换预发布tab
$(document).on("click", ".timesLi", function() {
    if(!$(this).hasClass("active")) {
        $(this).addClass("active").siblings().removeClass("active");
        currIndex = $(this).data("index");
        Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas[currIndex]});
        Bll.__render("#times-list", "times-template", {times: times, selected: currIndex});
        new common.edit2("#times-list").init();
    }
});
$(document).on("change", ".preTimes", function() {
    times[$(this).data("index")].time = $(this).val();
});
//删除tab
$(document).on("click", "#delTab", function() {
    if(times[currIndex].status == "进行中") {
        common.util.__tip("进行中的页面不能删除");
        return false;
    }
    if(!times[currIndex].time) {
        common.util.__tip("该页面不能删除");
        return false;
    }
    common.dialog.confirm("警告", "确定取消" + times[currIndex].time + "发布的页面吗?",function() {
        common.util.__ajax({
            url: "/resources/deleteResourceById",
            data: {
                id: resources[currIndex].resource.id
            }
        }, function (res) {
            //setTimeout(function() {
            window.location.href = window.location.href;
            //}, 2000);

        });
    });
});

/*保存事件*/
$(document).on("click", "#sub_btn", function () {
    var data = {
        "content": {},
        "data_id": {},
        "rId": ""
    };
    for (var i = 0; i < Bll.contentDatas[currIndex].length; i++) {
        var contentData = Bll.contentDatas[currIndex][i].contentData;
        var action;
        var url;
        var goodsSrc = "imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/90";
        addSuffix(contentData);
        delete contentData.button_name;
        delete contentData.dialog;
        //kids推荐品牌
        if (contentData.template_name == "kidsBrands") {
            action = contentData.data.params.more_url.action || "";
            url = contentData.data.params.more_url.url || "";
            contentData.data.params.more_url = "{\"action\":\"" + action + "\",\"url\":\"" + url + "\"}";
        }
        //标题标签
        if (contentData.template_name == "title") {
            action = contentData.data.more_link.action || "";
            url = contentData.data.more_link.url || "";
            contentData.data.more_link = "{\"action\":\"" + action + "\",\"url\":\"" + url + "\"}";
        }
        //商品
        if (contentData.template_name == "goods") {
            for (var j = 0; j < contentData.data.length; j++) {
                if (contentData.data[j].src) {
                    var a = contentData.data[j].src.split("?");
                    a[1] = goodsSrc;
                    contentData.data[j].src = a.join("?");
                }
            }
        }
        //商品组
        if (contentData.template_name == "goodsGroup") {
            for (var m = 0; m < contentData.data.length; m++) {
                if (contentData.data[m].list) {
                    for (var n = 0; n < contentData.data[m].list.length; n++) {
                        var b = contentData.data[m].list[n].src.split("?");
                        b[1] = goodsSrc;
                        contentData.data[m].list[n].src = b.join("?");
                    }

                }
            }
        }
        data.content[i] = JSON.stringify(common.util.__ArrayToObj(contentData));
        data.content[i] = JSON.stringify(common.util.__ArrayToObj(Bll.contentDatas[currIndex][i].contentData));
        if (Bll.contentDatas[currIndex][i].id) {
            data.data_id[i] = "id_" + Bll.contentDatas[currIndex][i].id;
        }
    }
    data.rId = resources[currIndex].resource.id;
    data.content = JSON.stringify(data.content);
    data.data_id = JSON.stringify(data.data_id);
    common.util.__ajax({
        url: "/resources/addResContent",
        data: data
    }, function (res) {
        //setTimeout(function() {
        window.location.href = window.location.href;
        //},1000)

    });
});

var addSuffix = function (contentData) {
    if (typeof  contentData == "object") {
        for (var i in contentData) {
            if (i == "src" && contentData[i].indexOf("?") == -1) {
                contentData[i] = contentData[i] + "?imageView2/{mode}/w/{width}/h/{height}";
            } else {
                addSuffix(contentData[i]);
            }
        }
    }
    return contentData;
};
/****************************************************************************************************/
/*商品,商品组*/

/*选择商品表格*/
var goodsgird = new common.grid({
    el: '#goodsgird',
    parms: function () {
        var beginPrice = 0, endPrice = 1000000;
        if (common.util.__input('beginPrice')) {
            beginPrice = common.util.__input('beginPrice');
        }
        if (common.util.__input('endPrice')) {
            endPrice = common.util.__input('endPrice')
        }
        return {
            query: common.util.__input('skns'),
            price: beginPrice + "," + endPrice
        };
    },
    columns: [
        {
            display: "选择",
            type: "checkbox"
        }, {
            display: "产品图片",
            render: function (item) {
                if (item.images_url) {
                    item.images_url = common.util.__joinImg("goodsimg", item.images_url);
                }
                else {
                    if(item.default_images){
                        item.images_url = common.util.__joinImg("goodsimg", item.default_images);
                    }
                    else{
                        item.images_url=""
                    }
                }
                return "<img width=120 height=60 src='" + item.images_url + "?imageView/2/w/100/h/100'/>";
            }
        }, {
            display: "产品名称",
            name: "product_name"
        }, {
            display: "品牌",
            name: "brand_name"
        }, {
            display: "现价",
            name: "sales_price"
        }, {
            display: "牌价",
            name: "market_price"
        }, {
            display: "预售",
            name: "stock_number"
        }, {
            display: "库存",
            name: "storage_num"
        }]
});
//搜索按钮
$(document).on("click", "#search", function () {
    if($.trim($("#skns").val()).length<5){
        common.util.__tip("请输入超过5个字符后再搜索","warning");
        return;
    }
    if(goodsgird.grid){
        goodsgird.reload(1);
    }else{
        goodsgird.init('/yohosearch/search');
    }
});
//点击“选择标签”按钮(添加商品)
$(document).on("click", "#goodsSelectBtn", function () {
    new common.dialog({
        title: "选择商品",
        content: $("#template_dialog_goodsgird").html(),
        width: '80%',
        button: [{
            value: "确定",
            callback: function () {
                Bll.module.contentData.data = goodsgird.selected.map(function (item, index) {
                    return {
                        src: item.images_url,
                        id: item.product_skn
                    }
                });
                // Bll.module.data=goodsgird.selected;
                Bll.__render("#goodspic", "template_dialog_goodsimgs", {
                    datas: Bll.module.contentData.data
                });
            },
            css: "btn-primary"
        }]
    });
    goodsgird.grid=null;
    //goodsgird.init('/yohosearch/search');
});
//点击“添加组”按钮(添加商品组)
$(document).on("click", "#goodsaddBtn", function () {
    var item = $.extend(true, {}, Button[5].data[0]);
    if (Bll.module.contentData.data[0].list.length) {
        Bll.module.contentData.data.push(item);
    }
    Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
});
//点击“选择标签”按钮(添加商品组)
$(document).on("click", ".goodsSelectBtn", function () {
    var index = $(this).data("index");
    new common.dialog({
        title: "选择商品",
        content: $("#template_dialog_goodsgird").html(),
        width: '80%',
        button: [{
            value: "确定",
            callback: function () {
                goodsgird.selected.forEach(function (item, i) {
                    Bll.module.contentData.data[index].list[i] = {
                        src: item.images_url,
                        id: item.product_skn,
                        maxSortId: item.max_sort_id
                    };
                    if (!i) {
                        Bll.module.contentData.data[index].cover = {
                            cover: item.images_url,
                            maxSortId: item.max_sort_id
                        };
                    }
                });
                Bll.__render("#groupsgoods", "template_dialog_remgoodsgroup", Bll.module);
            },
            css: "btn-primary"
        }]
    });
    goodsgird.grid=null;
});
//删除图片按钮
$(document).on("click", ".removepic", function () {
    var $parent = $(this).parents("ul.imagegroup");
    var i = $parent.data("i");//组标志
    var isg = typeof(i) === "number" ? true : false;
    //推荐商品组
    if (isg) {
        Bll.module.contentData.data[i].list.splice($(this).data("index"), 1);
        Bll.module.contentData.data[i].cover = {};
        if (Bll.module.contentData.data[i].list.length == 0) {
            Bll.module.contentData.data[i].cover.cover = "";
            Bll.module.contentData.data[i].cover.maxSortId = "";
        }
        else {
            Bll.module.contentData.data[i].cover.cover = Bll.module.contentData.data[i].list[0].src;
            Bll.module.contentData.data[i].cover.maxSortId = Bll.module.contentData.data[i].list[0].maxSortId;
        }
    }
    //商品
    else {
        Bll.module.contentData.data.splice($(this).data("index"), 1);
    }
    $parent.html(common.util.__template2($("#template_dialog_goodsimgs").html(), {
        datas: isg ? Bll.module.contentData.data[i].list : Bll.module.contentData.data
    }));
});
$(document).on("mouseover", "#add-content .dragItem", function () {
    var drag = new common.drag("#add-content", Bll.contentDatas, function (data) {
        Bll.contentDatas = data;
        Bll.__render("#add-content", "template_content", {modules: Bll.contentDatas});
    })
    drag.Initialize();
});
$(document).on("mouseleave", "#add-content .dragItem", function () {
    new common.drag("#add-content").destroy();
});