Beispiel #1
0
 /// <summary>
 /// OnAfterRenderAsync 方法
 /// </summary>
 /// <param name="firstRender"></param>
 /// <returns></returns>
 protected override async Task OnAfterRenderAsync(bool firstRender)
 {
     if (firstRender && JSRuntime != null)
     {
         Interop = new JSInterop <BarcodeReader>(JSRuntime);
         await Interop.Invoke(this, ScannerElement, "bb_barcode", "init");
     }
 }
Beispiel #2
0
        /// <summary>
        /// OnAfterRender 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && Message != null)
            {
                _interop = new JSInterop <MessageBase>(JSRuntime);
                await _interop.Invoke(Message, MessageItemElement, "showMessage", nameof(MessageBase.Clear));
            }
        }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <MultiSelect <TValue> >(JSRuntime);
                await Interop.Invoke(this, SelectElement, "bb_multi_select", nameof(Close));
            }
        }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender && JSRuntime != null)
            {
                Interop = new JSInterop <Camera>(JSRuntime);
                await Interop.Invoke(this, CameraElement, "bb_camera", "init");
            }
        }
Beispiel #5
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <Layout>(JSRuntime);
                await Interop.Invoke(this, null, "bb_layout", nameof(SetCollapsed));
            }
        }
Beispiel #6
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <TableFilter>(JSRuntime);
                await Interop.Invoke(this, FilterElement, "bb_filter", nameof(Close));
            }
        }
Beispiel #7
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <ModalDialog>(JSRuntime);
                await Interop.Invoke(this, DialogElement, "bb_dialog", "init");
            }
        }
Beispiel #8
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interop = new JSInterop <SliderBase>(JSRuntime);
                await Interop.Invoke(this, Slider, "slider", nameof(SliderBase.SetValue));
            }
        }
Beispiel #9
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRender(firstRender);

            if (firstRender && JSRuntime != null)
            {
                Interop = new JSInterop <SliderBase>(JSRuntime);
                Interop.Invoke(this, Slider, "slider", nameof(SliderBase.SetValue));
            }
        }
Beispiel #10
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            // 执行客户端动画
            if (firstRender)
            {
                if (Toast != null)
                {
                    Interop = new JSInterop <Toast>(JSRuntime);
                    await Interop.Invoke(Toast, ToastBoxElement, "showToast", nameof(Toast.Clear));
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            // 执行客户端动画
            if (firstRender && JSRuntime != null)
            {
                if (Toast != null && !string.IsNullOrEmpty(Id))
                {
                    _interop = new JSInterop <Toast>(JSRuntime);
                    await _interop.Invoke(Toast, Id, "showToast", nameof(ToastBase.Clear));
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interope = new JSInterop <Editor>(JSRuntime);
                await Interope.Invoke(this, EditorElement, "editor", nameof(Update), Height, Value ?? "");
            }
            if (_renderValue)
            {
                _renderValue = false;
                await JSRuntime.InvokeVoidAsync(EditorElement, "editor", "code", "", "", Value ?? "");
            }
        }
Beispiel #13
0
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        /// <returns></returns>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                Interope = new JSInterop <Editor>(JSRuntime);
                var methodGetPluginAttrs  = "";
                var methodClickPluginItem = "";
                if (CustomerToolbarButtons.Any())
                {
                    methodGetPluginAttrs  = nameof(GetPluginAttrs);
                    methodClickPluginItem = nameof(ClickPluginItem);
                }
                await Interope.Invoke(this, EditorElement, "bb_editor", methodGetPluginAttrs, methodClickPluginItem, nameof(Update), Height, Value ?? "");
            }
            if (_renderValue)
            {
                _renderValue = false;
                await JSRuntime.InvokeVoidAsync(EditorElement, "bb_editor", "code", "", "", "", "", Value ?? "");
            }
        }
        /// <summary>
        /// OnAfterRenderAsync 方法
        /// </summary>
        /// <param name="firstRender"></param>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            if (firstRender)
            {
                if (ShowSearch)
                {
                    // 注册 SeachBox 回调事件
                    Interop = new JSInterop <Table <TItem> >(JSRuntime);
                    await Interop.Invoke(this, TableElement, "bb_table_search", nameof(OnSearch), nameof(OnClearSearch));
                }

                FirstRender = false;
                methodName  = Height.HasValue ? "fixTableHeader" : "init";

                ScreenSize = await RetrieveWidth();

                // 初始化列
                if (AutoGenerateColumns)
                {
                    var cols = InternalTableColumn.GetProperties <TItem>(Columns);
                    Columns.Clear();
                    Columns.AddRange(cols);
                }

                ColumnVisibles = Columns.Select(i => new ColumnVisibleItem {
                    FieldName = i.GetFieldName(), Visible = i.Visible
                }).ToList();

                // set default sortName
                var col = Columns.FirstOrDefault(i => i.Sortable && i.DefaultSort);
                if (col != null)
                {
                    SortName  = col.GetFieldName();
                    SortOrder = col.DefaultSortOrder;
                }
                await QueryAsync();
            }

            if (!firstRender)
            {
                IsRendered = true;
            }

            if (IsRendered)
            {
                if (IsLoading)
                {
                    IsLoading = false;
                    var _ = JSRuntime.InvokeVoidAsync(TableElement, "bb_table_load", "hide");
                }

                // fix: https://gitee.com/LongbowEnterprise/BootstrapBlazor/issues/I2AYEH
                // PR: https://gitee.com/LongbowEnterprise/BootstrapBlazor/pulls/818
                if (Columns.Any(col => col.ShowTips) && string.IsNullOrEmpty(methodName))
                {
                    methodName = "tooltip";
                }

                if (!string.IsNullOrEmpty(methodName))
                {
                    await JSRuntime.InvokeVoidAsync(TableElement, "bb_table", methodName);

                    methodName = null;
                }

                if (IsAutoRefresh && AutoRefreshInterval > 500 && AutoRefreshCancelTokenSource == null)
                {
                    AutoRefreshCancelTokenSource = new CancellationTokenSource();

                    // 自动刷新功能
                    _ = Task.Run(async() =>
                    {
                        try
                        {
                            while (!(AutoRefreshCancelTokenSource?.IsCancellationRequested ?? true))
                            {
                                await InvokeAsync(QueryAsync);
                                await Task.Delay(AutoRefreshInterval, AutoRefreshCancelTokenSource?.Token ?? new CancellationToken(true));
                            }
                        }
                        catch (TaskCanceledException) { }
                    });
                }
            }
        }