window.clickSubmit = async function(e)
{
    let confirmParentRelation = false;
    if($('[name=parent]').length && $('[name=parent]').val() && $('[name=parent]').val() != task.parent)
    {
        await $.get($.createLink('task', 'ajaxGetRelation', 'taskIdList=' + $('[name=parent]').val()), function(data)
        {
            if(data) confirmParentRelation = true;
        })
    }

    let confirmSelfRelation = false;
    if($('[name=status]').length && $('[name=status]').val() == 'cancel' && task.status != 'cancel')
    {
        await $.get($.createLink('task', 'ajaxGetRelation', 'taskIdList=' + task.id), function(data)
        {
            if(data) confirmSelfRelation = true;
        })
    }

    if(confirmParentRelation || confirmSelfRelation)
    {
        let unlinkRelationTip = (!confirmSelfRelation && confirmParentRelation) ? unlinkParentRelationTip : unlinkSelfRelationTip;
        zui.Modal.confirm({message: unlinkRelationTip, actions: [{key: 'confirm', text: unlinkLang, btnType: 'primary', class: 'btn-wide'}, {key: 'cancel'}]}).then((res) =>
        {
            if(res)
            {
                const link     = $('#editForm').attr('action');
                const formData = new FormData($('#editForm')[0]);

                $.ajaxSubmit({url: link, data: formData});
            }
            else
            {
                return false;
            }
        })

        return false;
    }

    return true;
}
