import { _decorator, Component, Label, Node, Sprite, Toggle, UITransform } from 'cc';
import { event_item, event_item_change_one_item_status } from '../../../data/data';
import { tools } from '../../tools';
import { config } from '../../config';
const { ccclass, property } = _decorator;

@ccclass('event_item_view')
export class event_item_view extends Component {
    @property(Node) lab_event_id:Node = null;
    @property(Node) lab_event_name:Node = null;
    @property(Node) btn_edit_event:Node = null;
    private m_type:number = 0;
    private m_data:event_item = null;
    private m_delete_call = null;
    public initView(type:number,data:event_item,delete_call){
        this.m_data = data;
        this.m_type = type;
        this.m_delete_call = delete_call;
       
        this.lab_event_id.getComponent(Label).string = `当前-${ config.event_type_map.get(this.m_type)}-事件id：${this.m_data.event_id}`
        this.lab_event_name.getComponent(Label).string = `当前事件名字：${this.m_data.event_name}`
        this.btn_edit_event.on(Node.EventType.TOUCH_END,()=>{
            tools.show_edit_event( this.m_type ,this.m_data,(data)=>{
                if(this.m_delete_call!=null){
                    this.node.removeFromParent()
                    this.m_delete_call(data)
                }
            })
        })
      
    }
}


