<script>
    layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
        let admin = layui.admin;
        let form = layui.form;
        let table = layui.table
        let element = layui.element;

        form.on('submit(cancel)', function (data) {
            admin.closeThisDialog();
        });
        form.on('submit(transferSupplier)', function (data) {
            admin.showLoading({
                type: 3,
            });
            let url = '/api/supplier_contact/TransferSupplierContact?supplier_id=' + getQueryVariable('supplier_id');
            let res = $.get(url, data.field, function (res) {
                if (!res) {
                    admin.removeLoading();
                    layer.msg('网络错误,请重试', {icon: 6});
                } else {
                    admin.removeLoading();
                    res = JSON.parse(res);
                    if (res.err_code === 0) {
                        layer.msg(res.err_msg, {icon: 6});
                        setTimeout(function () {
                            admin.closeThisDialog();
                        },500);
                    } else {
                        admin.removeLoading();
                        layer.msg(res.err_msg, {icon: 5});
                        return false;
                    }
                }
            });

            return false;
        });
    });
</script>