var data=new $Data.getData
(
    "#article",true,async (val,dom)=>
    {
        if(dom.type=='file')$Route.call('com@upload')
        $Edit.upload
        (
            '/index/file',val,dom,function(obj)
            {
                $M.dispatch('html','updateUpload',obj)
            }
        )
        return val
    }
) 
var url,upType,parent;

if($Rd && $Rd[0]=='@')
{
    url='/http/article/mrg/update'
    upType='_id'
    $Rd=$Rd.slice(1);

    $Ajax.get
    (
        {
            url:'/http/article/mrg/get',
            param:{_id:$Rd},
            fun:function(d)
            {
                if(d && !d.code)
                {
                    parent=d.data.parent;
                    $M.find('[editPrivateContent]').innerHTML=d.data.content
                    $M.find('[editTitle]').value=d.data.title
                    if(!d.data.private)
                    {
                        $M.find('[editPrivateOk]').checked=true
                    }
                    else
                    {
                        $M.find('[editPrivate]').checked=true
                    }
                }
            }
        }
    )
}
else
{
    url='/http/article/mrg/edit'
    upType='parent'
    parent=$Rd;
}

$M.find('#subimt').listener
(
    'await',
    function(eve,dom)
    {
        if(!data.usable())
        {
            dom.removeAttribute('await')
            $M.dispatch('body','fadeAppend',{content:'请填写完整',time:3});
            return;
        }
        var result=data.get();
        console.log(result)
        result[upType]=$Rd;
        $Ajax.post
        (
            {
                url:url,
                param:result,
                fun:function(d)
                {
                    dom.removeAttribute('await')
                    if(d && d.code==0)
                    {
                        $M.dispatch('body','updateListRight',{id:parent});
                        $M.dispatch('body','fadeAppend',{content:'提交成功',time:3});
                    }
                    else
                    {
                        $M.dispatch('body','fadeAppend',{content:'提交失败',time:3});
                    }
                }
            }
        )  
    }
)
