Header.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. Ext.define('erp.view.common.main.Header', {
  2. extend: 'Ext.panel.Panel',
  3. alias: 'widget.erpHeader',
  4. initComponent: function() {
  5. var me = this;
  6. Ext.applyIf(this, {
  7. region: 'north',
  8. bodyStyle: "background-image: url('" + basePath + "resource/images/header_gray.png')",
  9. layout: 'hbox',
  10. layoutConfig: {
  11. padding: '5',
  12. align: 'middle'
  13. },
  14. defaults: {margins:'3 5 0 0'},
  15. items: [{
  16. xtype: 'image',
  17. width: 85,
  18. height: 30,
  19. margins: '0 5 0 0',
  20. src : basePath + 'resource/images/uas.png'
  21. },{
  22. xtype: 'tbtext',
  23. align: 'stretch',
  24. text: '<font size="4" color="black">'+$I18N.common.main.sysTitle+'</font>'
  25. },{
  26. xtype: 'tbtext',
  27. flex: 10,
  28. text: ''
  29. },{
  30. xtype: 'button',
  31. align: 'end',
  32. text: '工作台',
  33. height: 24,
  34. cls: 'main-btn-underline',
  35. overCls: 'main-btn-underline-over',
  36. menu: [{
  37. iconCls: 'main-msg',
  38. text: '我的工作台',
  39. handler: function(){
  40. Ext.getCmp("content-panel").setActiveTab(0);
  41. }
  42. },{
  43. iconCls: 'main-msg',
  44. text: '工作台设置',
  45. handler: function(){
  46. Ext.getCmp("content-panel").setActiveTab(0);
  47. if(!Ext.getCmp('win')){
  48. Ext.create('erp.view.core.window.WorkBenchSet');
  49. }
  50. }
  51. },{
  52. iconCls: 'main-msg',
  53. text: '系统设置',
  54. handler: function(){
  55. }
  56. },{
  57. iconCls: 'main-msg',
  58. text: '文档管理',
  59. handler: function(){
  60. window.open(basePath + 'jsps/oa/doc/documentmanage.jsp');
  61. }
  62. },{
  63. iconCls: 'main-email',
  64. text: '企业邮箱',
  65. handler: function(){
  66. if(en_email!=null){
  67. window.open(en_email);
  68. }
  69. }
  70. },{
  71. iconCls: 'main-schedule',
  72. text: '工作日历',
  73. handler: function(){
  74. window.open(basePath + 'jsps/oa/persontask/myAgenda/PersonCalendar.jsp');
  75. }
  76. }]
  77. },{
  78. xtype: 'tbtext',
  79. align: 'end',
  80. text: '|'
  81. },{
  82. xtype: 'button',
  83. text: '选项',
  84. height: 24,
  85. align: 'stretch',
  86. pack: 'end',
  87. cls: 'main-btn-underline',
  88. overCls: 'main-btn-underline-over',
  89. menu: [{
  90. iconCls: 'menuitem-lock',
  91. text: '锁定屏幕',
  92. id: 'lock'
  93. },{
  94. iconCls: 'main-msg',
  95. text: '操作指南'
  96. },{
  97. xtype: 'menuseparator'
  98. },{
  99. text: '语言',
  100. iconCls: 'main-msg',
  101. cls: 'main-btn-underline',
  102. overCls: 'main-btn-underline-over',
  103. menu: [{
  104. iconCls: 'main-todo',
  105. text: '简体'
  106. },{
  107. text: '繁體'
  108. },{
  109. text: 'English'
  110. },{
  111. text: '其它'
  112. }]
  113. },{
  114. iconCls: 'main-msg',
  115. text: '系统设置',
  116. menu: [{
  117. iconCls: 'main-msg',
  118. text: '我的信息'
  119. },{
  120. iconCls: 'main-msg',
  121. text: '我的权限'
  122. },{
  123. iconCls: 'main-msg',
  124. text: '修改密码',
  125. id: 'set-pwd'
  126. },{
  127. iconCls:'main-msg',
  128. text:'弹出消息',
  129. checked: true,
  130. xtype: 'menucheckitem',
  131. overflow: 'visible',
  132. labelAlign:'left',
  133. id:'set-msg',
  134. listeners:{
  135. afterrender:function(com){
  136. Ext.Ajax.request({
  137. method:'post',
  138. url:basePath+'common/getMsgSet.action?_noc=1',
  139. callback : function(options,success,response){
  140. var res = new Ext.decode(response.responseText);
  141. if(res.exceptionInfo != null){
  142. showError(res.exceptionInfo);return;
  143. }else if(res.success){
  144. com.setChecked(res.IsRemaind);
  145. }
  146. }
  147. });
  148. },
  149. click:function(item,e){
  150. var msg=item.checked?'确认启用消息提醒吗?':'确认取消消息提醒吗?';
  151. var remind=item.checked?1:0;
  152. Ext.MessageBox.show({
  153. title:'消息设置?',
  154. msg: msg,
  155. buttons: Ext.Msg.YESNO,
  156. icon: Ext.Msg.WARNING,
  157. fn: function(btn){
  158. if(btn == 'yes'){
  159. Ext.Ajax.request({
  160. url:basePath+'common/setMsgRemaind.action?_noc=1',
  161. params: {
  162. remind:remind
  163. },
  164. method : 'post',
  165. callback : function(options,success,response){
  166. var local=Ext.decode(response.responseText);
  167. if(local.success) {
  168. Ext.Msg.alert('提示','设置成功!');
  169. }else {
  170. showError(local.exceptionInfo);
  171. }
  172. }
  173. });
  174. } else if(btn == 'no'){
  175. //不保存
  176. e.record.reject();
  177. } else {
  178. return;
  179. }
  180. }
  181. });
  182. }
  183. }
  184. },{
  185. iconCls: 'main-msg',
  186. text: '工作台',
  187. menu: [{
  188. iconCls: 'main-msg',
  189. text: '我的工作台',
  190. handler: function(){
  191. Ext.getCmp("content-panel").setActiveTab(0);
  192. }
  193. },{
  194. iconCls: 'main-msg',
  195. text: '工作台设置'
  196. },{
  197. iconCls: 'main-msg',
  198. text: '快捷栏设置'
  199. }]
  200. }]
  201. },{
  202. iconCls: 'main-msg',
  203. text: '清除浏览器缓存',
  204. handler: function(){
  205. window.open('chrome://settings');
  206. }
  207. },{
  208. iconCls: 'main-msg',
  209. text: '关于优软',
  210. handler: function(){
  211. window.open('http://www.usoftchina.com');
  212. }
  213. }]
  214. },{
  215. xtype: 'tbtext',
  216. align: 'end',
  217. text: '|'
  218. },{
  219. xtype: 'button',
  220. text: '任务',
  221. height: 24,
  222. align: 'stretch',
  223. pack: 'end',
  224. cls: 'main-btn-underline',
  225. overCls: 'main-btn-underline-over',
  226. menu: [{
  227. iconCls: 'main-task',
  228. text: '发起任务',
  229. handler: function(b){
  230. var win = Ext.create('erp.view.core.window.Task');
  231. win.show();
  232. }
  233. },{
  234. iconCls: 'main-task',
  235. text: '我待办的任务',
  236. handler:function(){
  237. openTable("我待办的任务",'jsps/common/datalist.jsp?whoami=ResourceAssignment!Bill&_noc=1&urlcondition=ra_emid=' + em_uu,'Task');
  238. }
  239. },{
  240. iconCls: 'main-task',
  241. text: '我发起的任务',
  242. handler:function(){
  243. openTable("我发起的任务",'jsps/common/datalist.jsp?whoami=ProjectTask!Bill&_noc=1&urlcondition=recorder=\'' + em_name + '\'','ProjectTask');
  244. }
  245. }]
  246. },{
  247. xtype: 'button',
  248. text: '流程',
  249. height: 24,
  250. align: 'stretch',
  251. pack: 'end',
  252. cls: 'main-btn-underline',
  253. overCls: 'main-btn-underline-over',
  254. menu: [{
  255. iconCls: 'main-msg',
  256. text: '发起流程',
  257. handler: function(){
  258. openTable("发起流程","jsps/common/LaunchProcess.jsp?canAdd=1&_noc=1","LaunchProcess");
  259. }
  260. },{
  261. iconCls: 'main-msg',
  262. text: '流程催办',
  263. handler: function(){
  264. openTable("流程催办","jsps/common/batchDeal.jsp?whoami=Process!Remind&_noc=1","Process!Remind");
  265. }
  266. },{
  267. iconCls: 'main-msg',
  268. text: '我的待办流程',
  269. handler:function(){
  270. openTable("我的待办流程",'jsps/common/datalist.jsp?whoami=JProcess&_noc=1&urlcondition=jp_nodedealman=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
  271. }
  272. },{
  273. iconCls: 'main-msg',
  274. text: '我的超时流程',
  275. handler:function(){
  276. openTable("我的超时流程",'jsps/common/datalist.jsp?whoami=JProcess&_noc=1&urlcondition=jp_nodedealman=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
  277. }
  278. },{
  279. iconCls: 'main-msg',
  280. text: '我的待办转移流程',
  281. handler:function(){
  282. openTable("我的待办转移流程",'jsps/common/datalist.jsp?whoami=TransferProcess&_noc=1&urlcondition=jt_acceptercode=\'' + em_code + '\' and jp_flag = 1 and jp_status=\'待审批\' ', 'MyProcess');
  283. }
  284. },{
  285. iconCls:'main-msg',
  286. text:'我的已处理流程',
  287. handler:function(){
  288. openTable("我的已处理流程",'jsps/common/datalist.jsp?whoami=JProcess&_noc=1&_do=1&urlcondition=jp_nodedealman=\'' + em_code + '\' and jp_status<>\'待审批\' ', 'MyProcess');
  289. }
  290. },{
  291. iconCls:'main-msg',
  292. text:'我发起的待办流程',
  293. handler:function(){
  294. openTable("我发起的待办流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_noc=1&urlcondition=jp_launcherid=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
  295. }
  296. },{
  297. iconCls:'main-msg',
  298. text:'我发起的超时流程',
  299. handler:function(){
  300. openTable("我发起的超时流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_noc=1&urlcondition=jp_launcherid=\'' + em_code + '\' AND jp_status=\'待审批'+'\' ','MyProcess');
  301. }
  302. },{
  303. iconCls:'main-msg',
  304. text:'我发起已结束流程',
  305. handler:function(){
  306. openTable("我发起已结束流程",'jsps/common/datalist.jsp?whoami=JProcess!Header&_noc=1&urlcondition=(jp_launcherid=\'' + em_code + '\' AND jp_status=\'已审批'+'\') or (jp_launcherid=\'' + em_code + '\' AND jp_status=\'已结束'+'\') ','MyProcess');
  307. }
  308. }]
  309. },{
  310. xtype: 'tbtext',
  311. align: 'end',
  312. text: '|'
  313. },{
  314. xtype: 'button',
  315. align: 'end',
  316. height: 24,
  317. text: $I18N.common.main.changeMaster,
  318. cls: 'main-btn-underline',
  319. overCls: 'main-btn-underline-over',
  320. menu: me.getMasterMenu()
  321. },{
  322. xtype: 'tbtext',
  323. align: 'end',
  324. text: '|'
  325. },{
  326. xtype: 'button',
  327. align: 'end',
  328. height: 24,
  329. text: $I18N.common.main.relogin,
  330. cls: 'main-btn-underline',
  331. overCls: 'main-btn-underline-over',
  332. handler: function(){
  333. main_relogin();
  334. }
  335. },{
  336. xtype: 'tbtext',
  337. align: 'end',
  338. text: '|'
  339. },{
  340. xtype: 'button',
  341. height: 24,
  342. align: 'end',
  343. text: $I18N.common.main.logout,
  344. cls: 'main-btn-underline',
  345. overCls: 'main-btn-underline-over',
  346. handler: function(){
  347. logout();
  348. }
  349. }],
  350. height: 35
  351. });
  352. this.callParent(arguments);
  353. },
  354. prefix: 'uu-',
  355. addUU: function(p, f, u) {
  356. if(!Ext.isEmpty(f.value)) {
  357. var me = this, enval = escape(f.value);
  358. var tx = '<font size=2 color=blue>' + f.value + '</font>';
  359. var bt = this.down('button[uumsg=' + enval + ']');
  360. if(!bt) {
  361. this.insert(3, {
  362. text: tx,
  363. name: this.prefix + u.uu_field,
  364. xtype: 'button',
  365. height: 24,
  366. isuu: true,
  367. uumsg: enval,
  368. relative: {
  369. panel: p,
  370. field: f,
  371. uu: u
  372. },
  373. cls: 'x-btn-bw',
  374. iconCls: 'x-btn-uu-medium',
  375. margins: '3 5 0 0',
  376. handler: function(btn) {
  377. var u = btn.relative.uu;
  378. if(u) {
  379. me.openUUClient(u, unescape(btn.uumsg));
  380. }
  381. }
  382. });
  383. }
  384. }
  385. },
  386. clearUU: function() {
  387. var me = this,
  388. uu = me.query('button[isuu=true]');
  389. Ext.each(uu, function(u){
  390. me.remove(u);
  391. });
  392. },
  393. removeUU: function(p) {
  394. var me = this,
  395. uu = me.query('button[isuu=true]');
  396. Ext.each(uu, function(u){
  397. var pl = u.relative.panel;
  398. if(pl.id == p.id)
  399. me.remove(u);
  400. });
  401. },
  402. refreshUU: function(panel, form, uu) {
  403. var me = this;
  404. this.clearUU();
  405. Ext.each(uu, function(u){
  406. var f = form.down('#' + u.uu_field);
  407. if(f) {
  408. if(!(u.uu_ftype == 1 && f.value == em_code) && !(u.uu_ftype == 2 && f.value == em_name)) {//排除自己
  409. me.addUU(panel, f, u);
  410. }
  411. }
  412. });
  413. },
  414. openUUClient: function(u, val) {
  415. var ef = 'em_name', tab = 'Employee', uuf = 'em_uu';
  416. switch(u.uu_ftype) {
  417. case 0:
  418. ef = 'em_id';break;
  419. case 1:
  420. ef = 'em_code';break;
  421. case 2:
  422. ef = 'em_name';break;
  423. case 3:
  424. ef = 'em_uu';break;
  425. case 4:
  426. ef = 've_id';tab = "Vendor";uuf = "ve_uu";break;
  427. case 5:
  428. ef = 've_code';tab = "Vendor";uuf = "ve_uu";break;
  429. case 6:
  430. ef = 've_name';tab = "Vendor";uuf = "ve_uu";break;
  431. case 7:
  432. ef = 've_uu';tab = "Vendor";uuf = "ve_uu";break;
  433. case 8:
  434. ef = 'cu_id';tab = "Customer";uuf = "cu_uu";break;
  435. case 9:
  436. ef = 'cu_code';tab = "Customer";uuf = "cu_uu";break;
  437. case 10:
  438. ef = 'cu_name';tab = "Customer";uuf = "cu_uu";break;
  439. case 11:
  440. ef = 'cu_uu';tab = "Customer";uuf = "cu_uu";break;
  441. }
  442. if(ef == uuf) {
  443. window.location = 'uas:' + val + '@58.61.153.82';
  444. } else {
  445. Ext.Ajax.request({
  446. url : basePath + 'common/getFieldData.action',
  447. params: {
  448. caller: tab,
  449. field: uuf,
  450. condition: ef + '=\'' + val + '\''
  451. },
  452. method : 'post',
  453. callback : function(options,success,response){
  454. var rs = new Ext.decode(response.responseText);
  455. if(rs.exceptionInfo){
  456. showError(rs.exceptionInfo);
  457. } else if(rs.success){
  458. var uu = rs.data;
  459. if(Ext.isEmpty(uu)){
  460. showError(val + ' 的关联UU号为空!');
  461. } else {
  462. window.location = 'uas:' + uu + '@58.61.153.82';
  463. }
  464. }
  465. }
  466. });
  467. }
  468. },
  469. getMasterMenu : function() {
  470. var me = this;
  471. var menu = Ext.create('Ext.menu.Menu', {
  472. listeners: {
  473. buffer: 100,
  474. beforeshow: function(m) {
  475. me.getMasters(m);
  476. },
  477. afterrender: function( menu ) {
  478. menu.tip = new Ext.ToolTip({
  479. target: menu.getEl().getAttribute("id"),
  480. delegate: ".x-menu-item",
  481. trackMouse: true,
  482. renderTo: document.body,
  483. text: "text",
  484. title: "",
  485. width: 160,
  486. height: 50,
  487. listeners: {
  488. beforeshow: function updateTip( tip ) {
  489. var menuItem = menu.down('#' + tip.triggerElement.id );
  490. if( !menuItem.initialConfig.qtip ) return false;
  491. tip.body.dom.innerHTML = menuItem.initialConfig.qtip;
  492. }
  493. }
  494. });
  495. }
  496. }
  497. });
  498. return menu;
  499. },
  500. getMasters : function(m) {
  501. var me = this;
  502. if (m.items.items.length == 0 && !m.loaded) {
  503. // 取帐套配置,以及帐套权限配置
  504. Ext.Ajax.request({
  505. url: basePath + 'common/getMasters.action',
  506. method: 'GET',
  507. callback: function(opt, s, r) {
  508. if (s) {
  509. var rs = Ext.decode(r.responseText),
  510. c = rs.currentMaster,
  511. g = rs.group,
  512. _t = rs._type,
  513. _m = rs._master,
  514. _ma = new Array(),
  515. items = new Array();
  516. if(_m != null) {
  517. _ma = _m.split(',');
  518. }
  519. for(var i in rs.masters) {
  520. var s = rs.masters[i];
  521. if("true" === g && "admin" !== _t) {
  522. if(!Ext.Array.contains(_ma, s.ma_name)) {
  523. if(s.ma_type == 2) {
  524. if(!s.ma_soncode)
  525. continue;
  526. var h = s.ma_soncode.split(','), _b = false;
  527. for (j in h ) {
  528. if(Ext.Array.contains(_ma, h[j])) {
  529. _b = true;break;
  530. }
  531. };
  532. if(!_b) continue;
  533. } else
  534. continue;
  535. }
  536. }
  537. var o = {text: s.ma_function, master: s, qtip: s.ma_name,
  538. listeners: {
  539. click: function(b) {
  540. me.changeMaster(b);
  541. }
  542. }};
  543. if (s.ma_name == c) {
  544. o.iconCls = 'main-todo';
  545. o.disabled = true;
  546. }
  547. items.push(o);
  548. }
  549. m.add(items);
  550. m.show();
  551. m.loaded = true;
  552. }
  553. }
  554. });
  555. }
  556. },
  557. changeMaster : function(b) {
  558. var me = this, tab = me.ownerCt.down('tabpanel'), bt = me.ownerCt.down('erpBottom');
  559. warnMsg('确定切换到' + b.text + '?', function(t){
  560. if(t == 'yes' || t == 'ok') {
  561. Ext.Ajax.request({
  562. url: basePath + 'common/changeMaster.action',
  563. params: {
  564. to: b.qtip
  565. },
  566. callback: function(opt, s, r) {
  567. if (s) {
  568. var rs = Ext.decode(r.responseText);
  569. if(rs.success) {
  570. if (tab) {
  571. var p = tab.plugins[0];
  572. if (p) {
  573. p.doClose(true);
  574. }
  575. bt.update({sob: b.text});
  576. window.sob = b.qtip;
  577. var m = b.ownerCt, items = m.items.items;
  578. Ext.each(items, function(){
  579. if(this.id == b.id) {
  580. this.setIconCls('main-todo');
  581. this.setDisabled(true);
  582. } else {
  583. this.setIconCls(' ');
  584. this.setDisabled(false);
  585. }
  586. });
  587. var home = tab.down('#HomePage');
  588. if (home) {
  589. home.getEl().down('iframe').dom.contentWindow.location.reload();
  590. }
  591. } else {
  592. window.location.reload();
  593. }
  594. } else {
  595. alert('切换失败,请检查您在(' + b.qtip + ')的账号和密码.');
  596. }
  597. }
  598. }
  599. });
  600. }
  601. });
  602. }
  603. });