Ejemplo n.º 1
0
        async void OnSelectedTabChanged(object sender, SelectedChangedEventArgs e)
        {
            Tab tab = e.SelectItem as Tab;

            if (tab.Content != null)
            {
                return;
            }

            RptInfo info = tab.Tag as RptInfo;

            if (!await info.Init())
            {
                return;
            }

            // 加载查询面板内容,脚本优先
            IRptSearchForm searchForm = null;

            if (info.ScriptObj != null)
            {
                searchForm = info.ScriptObj.GetSearchForm(info);
            }
            if (searchForm == null && info.Root.Params.ExistXaml)
            {
                searchForm = new RptSearchForm(info);
            }
            if (searchForm != null)
            {
                tab.Content       = searchForm;
                tab.Menu          = searchForm.Menu;
                searchForm.Query += OnQuery;
            }

            // 初次加载自动执行查询
            if (info.Root.ViewSetting.AutoQuery || searchForm == null)
            {
                _view.LoadReport(info);
            }
        }
Ejemplo n.º 2
0
        public RptViewWin(RptInfo p_info)
        {
            // 确保RptInfo已初始化,因含异步!

            IRptSearchForm searchForm = null;

            if (p_info.ScriptObj != null)
            {
                p_info.ScriptObj.View = _view;
                searchForm            = p_info.ScriptObj.GetSearchForm(p_info);
            }

            Main wc   = new Main();
            var  tabs = new Tabs();
            var  tab  = new Tab {
                Title = "内容"
            };

            tab.Content = _view;
            tabs.Items.Add(tab);
            wc.Items.Add(tabs);
            Items.Add(wc);

            var setting = p_info.Root.ViewSetting;

            if (setting.ShowMenu)
            {
                var menu = new Menu();
                if (!setting.ShowSearchForm &&
                    (searchForm != null || p_info.Root.Params.ExistXaml))
                {
                    menu.Items.Add(new Mi {
                        ID = "查询", Icon = Icons.搜索, Cmd = _view.CmdSearch
                    });
                }
                menu.Items.Add(new Mi {
                    ID = "导出", Icon = Icons.导出, Cmd = _view.CmdExport
                });
                menu.Items.Add(new Mi {
                    ID = "打印", Icon = Icons.打印, Cmd = _view.CmdPrint
                });
                p_info.ScriptObj?.InitMenu(menu);
                tab.Menu = menu;
            }

            if (setting.ShowSearchForm &&
                (searchForm != null || p_info.Root.Params.ExistXaml))
            {
                Pane wi = new Pane();
                tabs = new Tabs();
                tab  = new Tab {
                    Title = "查询"
                };

                // 加载查询面板内容
                if (searchForm == null)
                {
                    searchForm = new RptSearchForm(p_info);
                }
                tab.Menu          = searchForm.Menu;
                searchForm.Query += (s, e) => _view.LoadReport(e);
                tab.Content       = searchForm;

                tabs.Items.Add(tab);
                wi.Items.Add(tabs);
                Items.Add(wi);
            }

            // 初次加载自动执行查询
            if (setting.AutoQuery || p_info.Root.Params.Data.Count == 0)
            {
                _view.LoadReport(p_info);
            }
        }