/* * @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 [ `
`, '
', '', '
', `
${id || ''}
`, `${_collapseHandleHtml(level)}`, `${_columnHtml(level)}`, `${_picHtml()}`, `${_modelHtml(selectList)}`, `${_stateHtml()}`, `
-
`, `${_handleHtml()}`, '
', ].join(''); }else{ return [ `
`, '
', '', '
', `
${id || ''}
`, `${_collapseHandleHtml(level)}`, `${_columnHtml(level)}`, `${_modelHtml(selectList)}`, `${_stateHtml()}`, `
-
>`, `${_handleHtml()}`, '
', ].join(''); } } function _collapseHandleHtml(level) { let html = ''; if (level < 3) { html = ['
', '', '
'].join(''); } return html; } function _columnHtml(level) { let levelArr = ['一级', '二级', '三级'], html = ''; let nowLevel = $('input[name="level"]').val(); if (level < 3 && nowLevel > level) { html = [ '
', `
${levelArr[level - 1]}
`, '
', '
', '', '
', '
', '', '
', ].join(''); } else { html = [ '
', `
${levelArr[level - 1]}
`, '
', '
', '', '
', '
', '
', ].join(''); } return html; } function _picHtml(imgList) { return [ '
', '
', '
', '
    ', '
    ', '
    ', '', '添加图片', '
    ', '
    ', '
', '
', '
', '
', ].join(''); } function _modelHtml(selectList) { let htmlArr = []; let firstItem = {"id":"", "title":"","sid":""}; if(selectList.length > 0){ firstItem = selectList[0]; } selectList.forEach(item => { htmlArr.push(`
  • ${item.title}
  • `); }); return [ '
    ', '
    ', '', '', '
    ', '
    ', '', '
    ', '
    ', ].join(''); } function _stateHtml() { return [ '
    ', '
    ', '', '', '
    ', '
    ', ].join(''); } function _handleHtml() { return [ '
    ', '', '', '', '', '
    ', ].join(''); }