Ext.define('erp.view.common.main.Header', {
extend: 'Ext.panel.Panel',
alias: 'widget.erpHeader',
initComponent: function() {
var me = this;
Ext.applyIf(this, {
region: 'north',
bodyStyle: "background-image: url('" + basePath + "resource/images/header_gray.png')",
layout: 'hbox',
layoutConfig: {
padding: '5',
align: 'middle'
},
defaults: {margins:'3 5 0 0'},
items: [{
xtype: 'image',
width: 85,
height: 30,
margins: '0 5 0 0',
src : basePath + 'resource/images/uas.png'
},{
xtype: 'tbtext',
align: 'stretch',
text: ''+$I18N.common.main.sysTitle+''
},{
xtype: 'tbtext',
flex: 10,
text: ''
},{
xtype: 'button',
text: '选项',
height: 24,
align: 'stretch',
pack: 'end',
cls: 'main-btn-underline',
overCls: 'main-btn-underline-over',
menu: [{
iconCls: 'menuitem-lock',
text: '锁定屏幕',
id: 'lock'
},{
xtype: 'menuseparator'
},{
iconCls: 'main-msg',
text: '系统设置',
menu: [{
iconCls: 'main-msg',
text: '修改密码',
id: 'set-pwd'
},{
iconCls:'main-msg',
text:'弹出消息',
checked: true,
xtype: 'menucheckitem',
overflow: 'visible',
labelAlign:'left',
id:'set-msg',
listeners:{
afterrender:function(com){
Ext.Ajax.request({
method:'post',
url:basePath+'common/getMsgSet.action?_noc=1',
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo != null){
showError(res.exceptionInfo);return;
}else if(res.success){
com.setChecked(res.IsRemaind);
}
}
});
},
click:function(item,e){
var msg=item.checked?'确认启用消息提醒吗?':'确认取消消息提醒吗?';
var remind=item.checked?1:0;
Ext.MessageBox.show({
title:'消息设置?',
msg: msg,
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.WARNING,
fn: function(btn){
if(btn == 'yes'){
Ext.Ajax.request({
url:basePath+'common/setMsgRemaind.action?_noc=1',
params: {
remind:remind
},
method : 'post',
callback : function(options,success,response){
var local=Ext.decode(response.responseText);
if(local.success) {
Ext.Msg.alert('提示','设置成功!');
}else {
showError(local.exceptionInfo);
}
}
});
} else if(btn == 'no'){
//不保存
e.record.reject();
} else {
return;
}
}
});
}
}
}]
},{
iconCls: 'main-msg',
text: '开发者工具',
menu: [{
xtype: 'menucheckitem',
text: '显示栈轨迹',
listeners: {
afterrender: function(item) {
Ext.Ajax.request({
url: basePath + 'common/usersetting/develop.action',
method: 'GET',
callback: function(opt, s, res) {
var r = Ext.decode(res.responseText);
item.setChecked(r.debug);
}
});
},
click: function(item) {
Ext.Ajax.request({
url: basePath + 'common/usersetting/develop.action',
method: 'POST',
params: {
debug: item.checked
},
callback: function(opt, s) {
if (s) {
Ext.Msg.alert('提示', '系统错误提示内容将' + (item.checked ? '' : '不再') + '显示栈轨迹!');
}
}
});
}
}
}]
},{
iconCls: 'main-msg',
text: '关于优软',
handler: function(){
window.open('http://www.usoftchina.com');
}
}]
},{
xtype: 'tbtext',
align: 'end',
text: '|'
},{
xtype: 'button',
text: '任务',
height: 24,
align: 'stretch',
pack: 'end',
cls: 'main-btn-underline',
overCls: 'main-btn-underline-over',
menu: [{
iconCls: 'main-task',
text: '发起任务',
handler: function(b){
var win = b.taskwin;
if(!win) {
b.taskwin = win = Ext.create('erp.view.core.window.Task');
}
win.show();
}
},{
iconCls: 'main-task',
text: '我的待办任务',
handler:function(){
openTable("我的待办任务",'jsps/common/datalist.jsp?whoami=ResourceAssignment!Bill&_noc=1&urlcondition=ra_emid=' + em_uu + ' AND ra_taskpercentdone<100 ','Task');
}
},{
iconCls: 'main-task',
text: '我的超时任务',
handler:function(){
openTable("我的超时任务",'jsps/common/datalist.jsp?whoami=ResourceAssignment!Bill&_noc=1&urlcondition=ra_emid=' + em_uu + ' AND ra_taskpercentdone<100 AND ra_enddate\'待审批\' ', 'MyProcess');
}
},{
iconCls:'main-msg',
text:'我发起的待办流程',
handler:function(){
openTable("我发起的待办流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_do=1&_noc=1&urlcondition=jp_launcherid=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
}
},{
iconCls:'main-msg',
text:'我发起的超时流程',
handler:function(){
openTable("我发起的超时流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_do=1&_noc=1&urlcondition=jp_launcherid=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
}
},{
iconCls:'main-msg',
text:'我发起已结束流程',
handler:function(){
openTable("我发起已结束流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_noc=1&_do=1&&urlcondition=(jp_launcherid=\'' + em_code + '\' AND jp_status=\'已审批'+'\') or (jp_launcherid=\'' + em_code + '\' AND jp_status=\'已结束'+'\') ','MyProcess');
}
}]
},{
xtype: 'tbtext',
align: 'end',
text: '|',
margins: '3 5 0 0'
},{
xtype: 'button',
align: 'end',
height: 24,
text: $I18N.common.main.changeMaster,
cls: 'main-btn-underline',
overCls: 'main-btn-underline-over',
menu: me.getMasterMenu(),
margins: '3 5 0 0'
},{
xtype: 'tbtext',
align: 'end',
text: '|'
},{
xtype: 'button',
align: 'end',
height: 24,
text: $I18N.common.main.relogin,
cls: 'main-btn-underline',
overCls: 'main-btn-underline-over',
handler: function(){
main_relogin();
}
},{
xtype: 'tbtext',
align: 'end',
text: '|'
},{
xtype: 'button',
height: 24,
align: 'end',
text: $I18N.common.main.logout,
cls: 'main-btn-underline',
overCls: 'main-btn-underline-over',
handler: function(){
logout();
}
}],
height: 35
});
this.callParent(arguments);
},
prefix: 'uu-',
addUU: function(p, f, u) {
if(!Ext.isEmpty(f.value)) {
var me = this, enval = escape(f.value);
var tx = '' + f.value + '';
var bt = this.down('button[uumsg=' + enval + ']');
if(!bt) {
this.insert(3, {
text: tx,
name: this.prefix + u.uu_field,
xtype: 'button',
height: 24,
isuu: true,
uumsg: enval,
relative: {
panel: p,
field: f,
uu: u
},
cls: 'x-btn-bw',
iconCls: 'x-btn-uu-medium',
margins: '3 5 0 0',
handler: function(btn) {
var u = btn.relative.uu;
if(u) {
me.openUUClient(u, unescape(btn.uumsg));
}
}
});
}
}
},
clearUU: function() {
var me = this,
uu = me.query('button[isuu=true]');
Ext.each(uu, function(u){
me.remove(u);
});
},
removeUU: function(p) {
var me = this,
uu = me.query('button[isuu=true]');
Ext.each(uu, function(u){
var pl = u.relative.panel;
if(pl.id == p.id)
me.remove(u);
});
},
refreshUU: function(panel, form, uu) {
var me = this;
this.clearUU();
Ext.each(uu, function(u){
var f = form.down('#' + u.uu_field);
if(f) {
if(!(u.uu_ftype == 1 && f.value == em_code) && !(u.uu_ftype == 2 && f.value == em_name)) {//排除自己
me.addUU(panel, f, u);
}
}
});
},
openUUClient: function(u, val) {
var ef = 'em_name', tab = 'Employee', uuf = 'em_uu';
switch(u.uu_ftype) {
case 0:
ef = 'em_id';break;
case 1:
ef = 'em_code';break;
case 2:
ef = 'em_name';break;
case 3:
ef = 'em_uu';break;
case 4:
ef = 've_id';tab = "Vendor";uuf = "ve_uu";break;
case 5:
ef = 've_code';tab = "Vendor";uuf = "ve_uu";break;
case 6:
ef = 've_name';tab = "Vendor";uuf = "ve_uu";break;
case 7:
ef = 've_uu';tab = "Vendor";uuf = "ve_uu";break;
case 8:
ef = 'cu_id';tab = "Customer";uuf = "cu_uu";break;
case 9:
ef = 'cu_code';tab = "Customer";uuf = "cu_uu";break;
case 10:
ef = 'cu_name';tab = "Customer";uuf = "cu_uu";break;
case 11:
ef = 'cu_uu';tab = "Customer";uuf = "cu_uu";break;
}
if(ef == uuf) {
window.location = 'uas:' + val + '@58.61.153.82';
} else {
Ext.Ajax.request({
url : basePath + 'common/getFieldData.action',
params: {
caller: tab,
field: uuf,
condition: ef + '=\'' + val + '\''
},
method : 'post',
callback : function(options,success,response){
var rs = new Ext.decode(response.responseText);
if(rs.exceptionInfo){
showError(rs.exceptionInfo);
} else if(rs.success){
var uu = rs.data;
if(Ext.isEmpty(uu)){
showError(val + ' 的关联UU号为空!');
} else {
window.location = 'uas:' + uu + '@58.61.153.82';
}
}
}
});
}
},
getMasterMenu : function() {
var me = this;
var menu = Ext.create('Ext.menu.Menu', {
listeners: {
buffer: 100,
beforeshow: function(m) {
me.getMasters(m);
},
afterrender: function( menu ) {
menu.tip = new Ext.ToolTip({
target: menu.getEl().getAttribute("id"),
delegate: ".x-menu-item",
trackMouse: true,
renderTo: document.body,
text: "text",
title: "",
width: 160,
height: 50,
listeners: {
beforeshow: function updateTip( tip ) {
var menuItem = menu.down('#' + tip.triggerElement.id );
if( !menuItem.initialConfig.qtip ) return false;
tip.body.dom.innerHTML = menuItem.initialConfig.qtip;
}
}
});
}
}
});
return menu;
},
getMasters : function(m) {
var me = this;
if (m.items.items.length == 0 && !m.loaded) {
// 取账套配置,以及账套权限配置
Ext.Ajax.request({
url: basePath + 'common/getMasters.action',
method: 'GET',
callback: function(opt, s, r) {
if (s) {
var rs = Ext.decode(r.responseText),
c = rs.currentMaster,
g = rs.group,
_t = rs._type,
_m = rs._master,
_ma = new Array(),
items = new Array();
if(_m != null) {
_ma = _m.split(',');
}
for(var i in rs.masters) {
var s = rs.masters[i];
if("true" === g && "admin" !== _t) {
if(!Ext.Array.contains(_ma, s.ma_name)) {
if(s.ma_type == 2) {
if(!s.ma_soncode)
continue;
var h = s.ma_soncode.split(','), _b = false;
for (j in h ) {
if(Ext.Array.contains(_ma, h[j])) {
_b = true;break;
}
};
if(!_b) continue;
} else
continue;
}
}
var o = {text: s.ma_function, master: s, qtip: s.ma_name,
listeners: {
click: function(b) {
me.changeMaster(b);
}
}};
if (s.ma_name == c) {
o.iconCls = 'main-todo';
o.disabled = true;
}
items.push(o);
}
m.add(items);
m.show();
m.loaded = true;
}
}
});
}
},
changeMaster : function(b) {
var me = this, tab = me.ownerCt.down('tabpanel'), bt = me.ownerCt.down('erpBottom'),tree=me.ownerCt.down('erpTreePanel');
warnMsg('确定切换到' + b.text + '?', function(t){
if(t == 'yes' || t == 'ok') {
Ext.Ajax.request({
url: basePath + 'common/changeMaster.action',
params: {
to: b.qtip
},
callback: function(opt, s, r) {
var rs = Ext.decode(r.responseText);
if(rs.success) {
if (tab) {
var p = tab.plugins[0];
if (p) {
p.doClose(true);
}
bt.update({sob: b.text});
window.sob = b.qtip;
var m = b.ownerCt, items = m.items.items;
Ext.each(items, function(){
if(this.id == b.id) {
this.setIconCls('main-todo');
this.setDisabled(true);
} else {
this.setIconCls(' ');
this.setDisabled(false);
}
});
var home = tab.down('#HomePage');
if (home) {
home.getEl().down('iframe').dom.contentWindow.location.reload();
}
} else {
window.location.reload();
}
} else {
alert('切换失败,请检查您在(' + b.qtip + ')的账号和密码.');
}
}
});
}
});
}
});