let param=$M.param()
let dom=$M.find(param.id)

let up=new $Data.getData('#data')
let  group=new $View.getView
(
    {
        id:'#group',fun:()=>
        {
            $Drag.members('#group [drag_id_data]')
        }
    }
)

$M.dispatch('html','slide-detail-index-update',{type:'show'})


$M.find('#save').listener
(
    'click',async ()=>
    {
        if(!up.usable())
        {
            $M.dispatch('html','com-alert-update',{type:'set',message:'请输入类型用"@"分隔'})
            return
        }
        let data=up.get()
        await $_Db.replace('data',{type:data.type},{type:data.type,value:dom.innerHTML})
        daGet()
    }
)


function makeObj(arr)
{
    let obj={}
    for (let index = 0; index < arr.length; index++) 
    {
        let cur=arr[index]
        let type=cur.type.toString()
        typeArr=type.split('@')

        let tmpObj=obj
        for (let index = 0; index < typeArr.length; index++) 
        {
            let curr=typeArr[index]
            if(!tmpObj[curr])tmpObj[curr]={}

            tmpObj=tmpObj[curr]
        }
        tmpObj.$value=cur.value
        tmpObj.$id=cur.id
    }
    return obj
}



function daGet() 
{
    $_Db.select
    (
        'data',{},async (arr)=>
        {
            let bcak=makeObj(arr)
            group.set(bcak);
        }
    )       
}

daGet()