/* * @Descripttion : 栏目列表 * @Author : liuzhifang * @Date : 2022-06-09 14:23:33 * @LastEditors : QianFox Team * @LastEditTime : 2024-08-21 22:29:28 */ let selectList = window.parent.getColumModels(); // 全部折叠 $('#allCollapseBtn').click(function () { let $container = $('#collapseContainer'), $this = $(this), isActive = $this.is('.is-active'); if (isActive) { let $openHandle = $container.find('.foxui-collapse-handle.is-active'); $openHandle.click(); $this.removeClass('is-active'); } else { let $foldHandle = $container.find('.foxui-collapse-handle:not(.is-active)'); $foldHandle.click(); $this.addClass('is-active'); } }); // 根据折叠转换全部折叠按钮状态 $(document).on('click', '.foxui-collapse-handle', function () { let count = $('.foxui-collapse-handle').length, openLen = $('.foxui-collapse-handle.is-active').length; if (count === openLen) { $('#allCollapseBtn').addClass('is-active'); } else { $('#allCollapseBtn').removeClass('is-active'); } }); // 添加一级栏目 $('#addFirstColumnBtn').click(function () { let $container = $('#collapseContainer'); $container.append(_itemHtml({ level: 1, selectList })); $container.children('.foxui-collapse-item:last-child').slideDown('fast'); }); // 添加二级栏目 $(document).on('click', '.column-head-level-1 .add-btn', function () { let $this = $(this), $container = $this.closest('.foxui-collapse-item').children('.foxui-collapse-content').children('.foxui-collapse'), $handle = $this.closest('.foxui-collapse-head').find('.foxui-collapse-handle'), isActive = $handle.is('.is-active'); if (!isActive) $handle.click(); $container.append(_itemHtml({ level: 2, selectList })); $container.children('.foxui-collapse-item:last-child').slideDown('fast'); }); // 添加三级栏目 $(document).on('click', '.column-head-level-2 .add-btn', function () { let $this = $(this), $container = $this.closest('.foxui-collapse-item').children('.foxui-collapse-content').children('.foxui-collapse'), $handle = $this.closest('.foxui-collapse-head').find('.foxui-collapse-handle'), isActive = $handle.is('.is-active'); if (!isActive) $handle.click(); $container.append(_itemHtml({ level: 3, selectList })); $container.children('.foxui-collapse-item:last-child').slideDown('fast'); }); // 删除 // $(document).on('click', '.foxui-collapse .delete-btn', function () { // let $this = $(this), // $item = $this.closest('.foxui-collapse-item'), // len = $item.find('.foxui-collapse-content .foxui-collapse-item').length; // if (len > 0) { // foxui.message({ // text: '此栏目包含子栏目,不可删除!', // type: 'danger', // }); // } // $($item).slideUp('fast', function () { // $(this).remove(); // }); // }); // 设置 $(document).on('click', '.foxui-collapse .set-btn', function () { // let id = $(this).closest('.foxui-collapse-head').children('.column-id').text(); // window.location.href = `column_set.html?columnId=${id}`; }); function _itemHtml({ id, level, selectList }) { let classList = ['column-item-level-1', 'column-item-level-2', 'column-item-level-3']; return [ `
', ].join(''); } function _headHtml({ id, level, selectList }) { let is_thumb = $('input[name="is_thumb"]').val(); if(is_thumb == 1){ return [ `