"use strict";
layui.extend({
    common    :   'js/common'
}).use(['jquery','layer','common','form'],function(){
    var $ = layui.jquery;

    var $node = {
        idInput     :   $('input[name="id"]'),
        resetBtn    :  $('button[type="reset"]')
    };

    $.ajax({
        url     :    '/device/mq/get/' + $node.idInput.val(),
        success :   function (result) {
            layui.form.val('entity_form',result.data);
        }
    });


    //  绑定表单提交事件
    layui.form.on("submit(entity_submit_event)",function(data){
        $.ajax({
            url     :   '/device/mq/edit',
            data    :   data.field,
            type    :   'POST',
            success :   function(){
                $node.resetBtn.click();
                parent.location.reload();
            }
        });
    });

    //  绑定取消事件
    $node.resetBtn.on('click',function(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });


});