Header.js 17 KB

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