import { util } from '../../util/util.js'
import {verify} from '../../util/verify.js'
import {base} from "./base.js";
import {fullMap} from "../../fullMap.js";
class vCutCharFold  extends base{

    constructor(data) {
        super(data);
        this.title = data.label_name;
        this.eleID=util.getUUID();
        this.objID=this.eleID+'div';
        this.type='cutCharFold';
        this.isValue=false;
    }
    getObjID(){
        return this.objID;
    }
    render(renderParentID) {
        let data=this.data
        if(data.kind==undefined||data.kind=='default'){
            this.renderDefault(renderParentID);
        }
        if(data.kind=='custom'){
            this.renderCustom(renderParentID);
        }
    }
    renderDefault(renderParentID){
        let that=this;
        let htmlTemplate=`
        <div class="card mb-4"  id="${that.objID}div" style="display: none">
        <div class="card-header" title="点击折叠 或 展开">
        <a class="d-flex justify-content-between text-dark" data-toggle="collapse" aria-expanded="true" id="${that.objID}a" href="#${that.objID}fold">
        <font _mstmutation="1">${that.title}</font><div class="collapse-icon"></div></a></div>
        <div id="${that.objID}fold" class="collapse show" data-parent="#${that.objID}div" style="">
        <div class="card-body">
        <div forrows style="margin-bottom: -0.5rem;" class="form-group row col-sm-12" id="${that.objID}"></div>
        </div></div></div>
        `;
        document.getElementById(renderParentID).insertAdjacentHTML("beforeEnd", htmlTemplate);
    }
    //折叠状态
    activeHide(){
        document.getElementById(this.objID+'a').className='d-flex justify-content-between text-dark collapsed';
        document.getElementById(this.objID+'fold').className='collapse';
    }
    //展开状态
    activeShow(){
        document.getElementById(this.objID+'a').className='d-flex justify-content-between text-dark';
        document.getElementById(this.objID+'fold').className='collapse show';
    }
    renderCustom(renderParentID){
        //虚拟字段 不需要任何操作
    }
    hide(){
        document.getElementById(this.objID+'div').setAttribute('style', 'display:none');//隐藏
    }
    show(){
        document.getElementById(this.objID+'div').setAttribute('style', '');//展示
    }
    setDisabled(){

    }
    removeDisabled(){

    }
    getValue(){

    }
    setValue(){

    }
    hideDiv(){
        let eleObj = document.getElementById(this.getObjID());
        eleObj.style.display='none';
        let eleObjDiv = document.getElementById(this.getObjID()+'div');
        eleObjDiv.style.display='none';
    }
    showDiv(){
        let eleObj = document.getElementById(this.getObjID());
        eleObj.style.display='';
        let eleObjDiv = document.getElementById(this.getObjID()+'div');
        eleObjDiv.style.display='';
    }
    refreshCanNull(){

    }
    init(){
        let that=this;
        that.activeShow();//初始化时默认全部展开
    }
}
export { vCutCharFold }