fastadmin中ajax弹窗修改文字为英文

发布于:2025-07-17 ⋅ 阅读:(20) ⋅ 点赞:(0)

需要把上图的中文改为  切换语言自动切换成英文

找到这个文件

public/assets/js/backend.js

找到如下图部分  

      // //点击包含.btn-ajax的元素时发送Ajax请求   原页面
            // $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
            //     var that = this;
            //     var options = $.extend({}, $(that).data() || {});
            //     if (typeof options.url === 'undefined' && $(that).attr("href")) {
            //         options.url = $(that).attr("href");
            //     }
            //     options.url = Backend.api.replaceids(this, options.url);
            //     var success = typeof options.success === 'function' ? options.success : null;
            //     var error = typeof options.error === 'function' ? options.error : null;
            //     delete options.success;
            //     delete options.error;
            //     var button = Backend.api.gettablecolumnbutton(options);
            //     if (button) {
            //         if (typeof button.success === 'function') {
            //             success = button.success;
            //         }
            //         if (typeof button.error === 'function') {
            //             error = button.error;
            //         }
            //     }
            //     //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
            //     if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
            //         success = function () {
            //             $("#" + options.tableId).bootstrapTable('refresh');
            //         }
            //     }
            //     if (typeof options.confirm !== 'undefined') {
            //         Layer.confirm(options.confirm, function (index) {
            //             Backend.api.ajax(options, success, error);
            //             Layer.close(index);
            //         });
            //     } else {
            //         Backend.api.ajax(options, success, error);
            //     }
            //     return false;
            // });

修改为

   $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
                var that = this;
                var options = $.extend({}, $(that).data() || {});
                if (typeof options.url === 'undefined' && $(that).attr("href")) {
                    options.url = $(that).attr("href");
                }
                options.url = Backend.api.replaceids(this, options.url);
                var success = typeof options.success === 'function' ? options.success : null;
                var error = typeof options.error === 'function' ? options.error : null;
                delete options.success;
                delete options.error;
                var button = Backend.api.gettablecolumnbutton(options);
                if (button) {
                    if (typeof button.success === 'function') {
                        success = button.success;
                    }
                    if (typeof button.error === 'function') {
                        error = button.error;
                    }
                }
                //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
                if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
                    success = function () {
                        $("#" + options.tableId).bootstrapTable('refresh');
                    }
                }
                if (typeof options.confirm !== 'undefined') {
                    // 添加自定义确认按钮文本
                    var confirmOptions = {
                        title: options.confirmTitle || __('Confirm'), // 标题,默认为"Confirm"
                        btn: [
                            {
                                text: options.confirmBtn || __('OK'), // 确认按钮文本
                                callback: function(index) {
                                    Backend.api.ajax(options, success, error);
                                    Layer.close(index);
                                }
                            },
                            {
                                text: options.cancelBtn || __('Cancel'), // 取消按钮文本
                                callback: function(index) {
                                    Layer.close(index);
                                }
                            }
                        ]
                    };
                    Layer.confirm(options.confirm, {
                        title: options.confirmTitle || __('Confirm'),
                        btn: [
                            options.confirmBtn || __('OK'),
                            options.cancelBtn || __('Cancel')
                        ]
                    }, function(index){
                        Backend.api.ajax(options, success, error);
                        Layer.close(index);
                    });
                } else {
                    Backend.api.ajax(options, success, error);
                }
                return false;
            });

按钮使用时添加

   confirmBtn: 'OK', // Confirm button text in English
     cancelBtn: 'Cancel', // Cancel button text in English  即可

  buttons: [
   {
     name: 'check',
     text: __('check'), // 按钮文字,语言在对应的lang文件设置
     title: __('check'), // 提示
     classname: 'btn btn-xs btn-magic btn-ajax',
 
     confirm: __('Are you sure the review has been approved?'),
     confirmBtn: 'OK', // Confirm button text in English
     cancelBtn: 'Cancel', // Cancel button text in English
     icon: 'fa fa-pencil', // 更换图标
     url:'order/check',
                                 
 },
                             


网站公告

今日签到

点亮在社区的每一天
去签到