| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /**
- * 打开/切换到新页签
- * @param xtype: view xtype
- * @param title: 标题
- * @param id: id
- * @param config: 绑定到view的其他配置
- */
- function openTab(xtype, title, id, config) {
- var mainTab = Ext.getCmp('main-tab-panel');
- var panel = mainTab.query('[tabId="' + id + '"]')[0];
- if(!panel) {
- panel = Ext.create('saas.view.core.tab.Panel', {
- tabId: id,
- title: title,
- viewType: xtype,
- viewConfig: config
- });
- Ext.suspendLayouts();
- mainTab.setActiveTab(mainTab.add(panel));
- Ext.resumeLayouts(true);
- }else {
- panel.viewConfig = config;
- mainTab.setActiveTab(panel);
- }
- }
- /**
- * 重设tab标题
- */
- function refreshTabTitle(id, title) {
- var currentTab = getCurrentTab();
- currentTab.tabId = id;
- currentTab.setTitle(title);
- }
- /**
- * 获得当前Tab
- */
- function getCurrentTab() {
- var mainTab = Ext.getCmp('main-tab-panel');
- var currentTab = mainTab.getActiveTab();
- return currentTab;
- }
- /**
- * 显示toast提示(无需用户操作)
- * @param content: 内容
- * @param title: 标题
- *
- */
- function showToast(content, title) {
- Ext.toast({
- html: content,
- title: title,
- closable: false,
- align: 't',
- slideDUration: 400,
- maxWidth: 400
- });
- }
- /**
- * 显示警告(需要选择是、否)
- * @param title: 标题
- * @param message: 内容
- * @return : Promise
- */
- function showConfirm(title, message) {
- return new Ext.Promise(function (resolve, reject) {
- Ext.MessageBox.confirm(title, message, function(buttonId) {
- return resolve(buttonId);
- });
- })
- }
- function warnMsg(msg, fn){
- Ext.MessageBox.show({
- title: '提示',
- msg: msg,
- buttons: Ext.Msg.YESNO,
- icon: Ext.Msg.WARNING,
- fn: fn
- });
- }
- function deleteWarn(msg, fn){
- Ext.MessageBox.show({
- title: '提示',
- msg: msg || '确定要删除当前表单?',
- buttons: Ext.Msg.YESNO,
- icon: Ext.Msg.WARNING,
- fn: fn,
- renderTo: Ext.getCmp('main-tab-panel').getActiveTab().getEl()
- });
- }
- /**
- * 判断字符串是否日期字符串
- * 需要满足格式 yyyy-MM-dd hh:mm:ss
- * 或者yyyy-M-d h:m:s
- * @param str: 字符串
- * @returns Boolean
- */
- function isDateString(str) {
- return (/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/).test(str);
- }
|