import ListCategory from '../listCategory/ListCategory';
import {Message} from '@hot/pc-es-cn-shop-ui';
const CategoryType = {
    TYPE_SYS: 1,    
    TYPE_CUSTOM:2   
}
class NavCategoryLeft extends ListCategory{
    constructor(config) {
        config = config || {};
        config.className = 'cd-nav-category-left';
        super(config);
    }
    render() {
        super.render();
        this.$subLayer.hide();
        this.$addbtn.hide();
    }
    renderItem(data){
        if(data){
            data.hasSubList = true;
            super.renderItem(data);
        }
    }
    validateData() {
        let itemData = this._getData();
        if(!itemData.cateName){
            Message.error('一级类目文案不能为空。');
            return false;
        }
        return true;
    }
    _getData(){
        let itemData = {
            type: this.type,
            cateId: this.$categoryWrapper.find('.J_item').attr('cate-id')
        }
        if(this.type == CategoryType.TYPE_SYS){
            itemData.cateName = this.$categoryWrapper.find('.J_cateName').text();
        }
        else{
            itemData.cateName = this.$categoryWrapper.find('.J_cateInput').val();
            let showData = this.displayUI.getData();
            itemData = $.extend(true, itemData, showData);
        }
        const {extConfig} = this.config.moduleData || {};
        itemData.extConfig = extConfig;
        return itemData;
    }
}
export default NavCategoryLeft;