Main.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /*
  2. 控制层,
  3. 所有逻辑代码都在这里写
  4. */
  5. Ext.QuickTips.init();
  6. Ext.define('erp.controller.common.Main', {
  7. extend: 'Ext.app.Controller',
  8. requires: ['erp.util.FormUtil'],
  9. /* refs:[
  10. {ref: 'erpTreePanel',selector: 'erpTablePanel'},
  11. {ref: 'erpTabPanel',selector:'erpTablePanel'}
  12. ], */
  13. stores: ['TreeStore'],//声明该控制层要用到的store
  14. /* models: ['TreeModel'],//声明该控制层要用到的model
  15. */
  16. views: ['common.main.Header','common.main.Bottom','common.main.TreePanel','common.main.TabPanel','common.main.Viewport','common.main.FlowPanel',
  17. 'common.main.Toolbar','common.main.TreeTabPanel','core.trigger.SearchField', 'core.window.ReLogin'],//声明该控制层要用到的view
  18. init: function(){
  19. var me = this;
  20. me.FormUtil = Ext.create('erp.util.FormUtil');
  21. this.flag = true;//防止双击时tree节点重复加载
  22. //每隔8秒刷新【网络寻呼】
  23. Ext.defer(function(){
  24. me.loadPagingRelease();
  25. }, 1000);
  26. //每隔一分钟刷新[首页待办事宜]
  27. Ext.defer(function(){
  28. me.loadJprocess();
  29. }, 60000);
  30. this.control({
  31. 'erpTreePanel': {
  32. itemmousedown: function(selModel, record){
  33. if(!this.flag){
  34. return;
  35. }
  36. this.flag = false;
  37. setTimeout(function(){
  38. me.flag = true;
  39. me.loadTab(selModel, record);
  40. },20);//防止双击时tree节点重复加载
  41. },
  42. itemclick: function(selModel, record){
  43. if(!this.flag){
  44. return;
  45. }
  46. this.flag = false;
  47. setTimeout(function(){
  48. me.flag = true;
  49. me.loadTab(selModel, record);
  50. },20);
  51. },
  52. itemdbclick: function(selModel, record){
  53. if(!this.flag){
  54. return;
  55. }
  56. this.flag = false;
  57. setTimeout(function(){
  58. me.flag = true;
  59. me.loadTab(selModel, record);
  60. },20);
  61. },
  62. afterrender: function(){
  63. }
  64. },
  65. 'erpTabPanel': {
  66. tabchange: function(tab, newC, oldC, obj){
  67. }
  68. },
  69. 'menuitem[id=lock]': {
  70. click: function(btn){
  71. //锁定屏幕
  72. me.lockPage();
  73. }
  74. },
  75. 'combobox[id=city]': {
  76. afterrender: function(f){
  77. f.store.loadData(me.getCitys());
  78. if(!Ext.isEmpty(f.value)){
  79. me.getWeather(f);
  80. }
  81. },
  82. change: function(f){
  83. if(f.value != null){
  84. me.getWeather(f);
  85. }
  86. }
  87. },
  88. 'combobox[id=day]': {
  89. change: function(f){
  90. if(f.value != null && f.value != ''){
  91. var city = f.ownerCt.down('combobox[id=city]');
  92. if(city != null && city != ''){
  93. me.getWeather(city);
  94. }
  95. }
  96. }
  97. },
  98. 'menuitem[id=addrbook]': {
  99. click: function(){
  100. me.showAddrBook();
  101. }
  102. },
  103. 'treepanel[id=addr-tree]': {
  104. itemmousedown: function(selModel, record){
  105. if(record.data['leaf']){
  106. //开始寻呼
  107. me.showDialogBox(null, Math.abs(record.data['id']), record.data['text']);
  108. } else {
  109. if(!record.isExpanded() && contains(record.data['id'], 'org', true)){//如果是组织
  110. var ch = record.childNodes, bool = false;
  111. Ext.each(ch, function(){
  112. if(this.data['leaf']) {
  113. bool = true;
  114. }
  115. });
  116. if(bool) {
  117. //刷新当前组织下人员在线状态
  118. me.checkOnline(record);
  119. }
  120. }
  121. }
  122. }
  123. },
  124. 'menuitem[id=set-pwd]': {
  125. click: function() {
  126. me.showPwdPanel();
  127. }
  128. }
  129. });
  130. },
  131. loadTab: function(selModel, record){
  132. var me = this;
  133. if (record.get('leaf')) {
  134. switch (record.data['showMode']){
  135. case 0: //0-选项卡模式
  136. me.openCard(record);break;
  137. case 1: //1-弹出框式
  138. me.openBox(record);break;
  139. case 2: //2-空白页
  140. me.openBlank(record);break;
  141. case 3: //3-窗口模式
  142. me.openWin(record);break;
  143. default:
  144. me.openCard(record);break;
  145. }
  146. //***********常用模块++
  147. //工作台所在页面
  148. var w = Ext.getCmp("content-panel").items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow;
  149. //常用模块
  150. var link = w.Ext.getCmp("bench_link");
  151. if(link){
  152. w.workbench._set_bench_link(record.get('id'));
  153. }
  154. me.flag = true;
  155. } else {
  156. if(record.isExpanded() && record.childNodes.length > 0){//是根节点,且已展开
  157. record.collapse(true,true);//收拢
  158. me.flag = true;
  159. } else {//未展开
  160. //看是否加载了其children
  161. if(record.childNodes.length == 0){
  162. //从后台加载
  163. var tree = Ext.getCmp('tree-panel');
  164. var condition = tree.baseCondition;
  165. tree.setLoading(true, tree.body);
  166. Ext.Ajax.request({//拿到tree数据
  167. url : basePath + 'common/lazyTree.action',
  168. params: {
  169. parentId: record.data['id'],
  170. condition: condition
  171. },
  172. callback : function(options,success,response){
  173. tree.setLoading(false);
  174. var res = new Ext.decode(response.responseText);
  175. if(res.tree){
  176. if(!record.get('level')) {
  177. record.set('level', 0);
  178. }
  179. Ext.each(res.tree, function(n){
  180. if(n.showMode == 2){//openBlank
  181. n.text = "<a href='" + basePath + me.parseUrl(n.url) + "' target='_blank'>" + n.text + "</a>";
  182. }
  183. if(!n.leaf) {
  184. n.level = record.get('level') + 1;
  185. n.iconCls = 'x-tree-icon-level-' + n.level;
  186. }
  187. });
  188. record.appendChild(res.tree);
  189. record.expand(false,true);//展开
  190. me.flag = true;
  191. } else if(res.exceptionInfo){
  192. showError(res.exceptionInfo);
  193. me.flag = true;
  194. }
  195. }
  196. });
  197. } else {
  198. record.expand(false,true);//展开
  199. me.flag = true;
  200. }
  201. }
  202. }
  203. },
  204. openTab : function (panel, id, url){
  205. var o = (typeof panel == "string" ? panel : id || panel.id);
  206. var main = Ext.getCmp("content-panel");
  207. var tab = main.getComponent(o);
  208. if (tab) {
  209. main.setActiveTab(tab);
  210. } else if(typeof panel!="string"){
  211. panel.id = o;
  212. var p = main.add(panel);
  213. main.setActiveTab(p);
  214. }
  215. },
  216. getMyNewEmails: function(){
  217. Ext.Ajax.request({
  218. url : basePath + "oa/mail/getNewMail.action",
  219. method : 'post',
  220. callback : function(options, success, response){
  221. var res = new Ext.decode(response.responseText);
  222. if(res.exceptionInfo){
  223. showError(res.exceptionInfo);return;
  224. }
  225. }
  226. });
  227. },
  228. parseUrl: function(url){
  229. var id = url.substring(url.lastIndexOf('?')+1);//将作为新tab的id
  230. if (id == null) {
  231. id = url.substring(0,url.lastIndexOf('.'));
  232. }
  233. if(contains(url, 'session:em_uu', true)){//对url中session值的处理
  234. url = url.replace(/session:em_uu/g,em_uu);
  235. }
  236. if(contains(url, 'session:em_code', true)){//对url中em_code值的处理
  237. url = url.replace(/session:em_code/g, "'" + em_code + "'");
  238. }
  239. if(contains(url, 'sysdate', true)){//对url中系统时间sysdate的处理
  240. url = url.replace(/sysdate/g, "to_date('" + Ext.Date.toString(new Date()) + "','yyyy-mm-dd')");
  241. }
  242. if(contains(url, 'session:em_name', true)){
  243. url = url.replace(/session:em_name/g,"'"+em_name+"'" );
  244. }
  245. return url;
  246. },
  247. openCard: function(record){
  248. var me = this;
  249. var panel = Ext.getCmp(record.get('id'));
  250. if(!panel){
  251. var url = me.parseUrl(record.data['url']);//解析url里的特殊描述
  252. panel = {
  253. title : record.get('qtip').length>5?(record.get('qtip').substring(0,5)+'..'):record.get('qtip'),
  254. tag : 'iframe',
  255. tabConfig: {tooltip:record.get('qtip')},
  256. border : false,
  257. frame: false,
  258. layout : 'fit',
  259. iconCls : record.data.iconCls,
  260. html : '<iframe id="iframe_' + id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  261. closable : true,
  262. listeners : {
  263. close : function(){
  264. var main = Ext.getCmp("content-panel");
  265. main.setActiveTab(Ext.getCmp("HomePage"));
  266. }
  267. }
  268. };
  269. this.openTab(panel, record.get('id'), url);
  270. } else{
  271. var main = Ext.getCmp("content-panel");
  272. main.setActiveTab(panel);
  273. }
  274. },
  275. openBox: function(record){
  276. window.open(basePath + this.parseUrl(record.data['url']), record.get('qtip'), 'width=' + (window.screen.width-10) +
  277. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  278. },
  279. openBlank: function(record){
  280. //window.open(basePath + this.parseUrl(record.data['url']));
  281. },
  282. openWin: function(record){
  283. if(Ext.getCmp('twin_' + record.data['id'])){
  284. Ext.getCmp('twin_' + record.data['id']).show();
  285. } else {
  286. new Ext.window.Window({
  287. id : 'twin_' + record.data['id'],
  288. title: record.get('qtip').length>5?(record.get('qtip').substring(0,5)+'..'):record.get('qtip'),
  289. height: "100%",
  290. width: "80%",
  291. maximizable : true,
  292. layout : 'anchor',
  293. items: [{
  294. tag : 'iframe',
  295. frame : true,
  296. anchor : '100% 100%',
  297. layout : 'fit',
  298. html : '<iframe id="iframe_twin" src="' + basePath + this.parseUrl(record.data['url'])
  299. + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  300. }]
  301. }).show();
  302. }
  303. },
  304. lockPage: function(){
  305. var me = this;
  306. Ext.Ajax.request({
  307. url: basePath + "common/logout.action",
  308. method : 'post',
  309. callback : function(options,success,response){
  310. var res = Ext.decode(response.responseText);
  311. if(res.success){
  312. //弹出解锁框
  313. me.showLock();
  314. }
  315. }
  316. });
  317. },
  318. /**
  319. * 显示锁屏window
  320. */
  321. showLock: function(){
  322. var me = this;
  323. var panel = Ext.create('Ext.window.Window', {
  324. id: 'lock-win',
  325. frame: true,
  326. closable: false,
  327. modal: true,
  328. autoShow: true,
  329. title: '<div style="height:25;padding-top:5px;color:blue;background: #E0EEEE url(' + basePath + 'resource/ext/resources/themes/images/default/grid/grid-blue-hd.gif) repeat center center">&nbsp;!您的屏幕已锁定</div>',
  330. bodyStyle: 'background: #E0EEEE',
  331. width: 360,
  332. height: 260,
  333. renderTo: Ext.getBody(),
  334. items: [{
  335. xtype: 'displayfield',
  336. height: 130,
  337. labelWidth: 128,
  338. labelSeparator: '',
  339. fieldStyle: 'color:#7D9EC0;font-size:15px;font-family:隶书;',
  340. fieldLabel: '<img src="' + basePath + 'resource/images/screens/locked.png" style="background: #E0EEEE;">',
  341. value: '如需解锁,请输入您的密码'
  342. },{
  343. xtype: 'hidden',
  344. name: 'username',
  345. id: 'username',
  346. value: em_code
  347. },{
  348. xtype: 'form',
  349. bodyStyle: 'background: #E0EEEE',
  350. layout: 'column',
  351. items: [{
  352. xtype: 'textfield',
  353. labelSeparator: '',
  354. columnWidth: 0.8,
  355. fieldLabel: '<img src="' + basePath + 'resource/images/screens/key.png" style="background: #E0EEEE;padding-left:15px;">',
  356. labelWidth: 40,
  357. fieldCls: 'x-form-field-cir',
  358. id: 'password',
  359. name: 'password',
  360. inputType: 'password'
  361. },{
  362. xtype: 'button',
  363. columnWidth: 0.2,
  364. cls: 'x-btn-blue',
  365. text: '解锁',
  366. handler: function(){
  367. me.removeLock();
  368. }
  369. }]
  370. }]
  371. });
  372. panel.el.slideIn('b', { duration: 1000 });
  373. },
  374. removeLock: function(){
  375. var win = Ext.getCmp('lock-win');
  376. if(win && win.down('#password').value != null){
  377. Ext.Ajax.request({
  378. url: basePath + "common/login.action",
  379. params: {
  380. username: win.down('#username').value,
  381. password: win.down('#password').value,
  382. language: language
  383. },
  384. method : 'post',
  385. callback : function(options,success,response){
  386. var res = Ext.decode(response.responseText);
  387. if(res.success){
  388. //弹出解锁框
  389. win.close();
  390. } else {
  391. if(res.reason){
  392. alert(res.reason);
  393. win.down('#password').setValue('');
  394. win.down('#password').focus();
  395. }
  396. }
  397. }
  398. });
  399. }
  400. },
  401. /**
  402. * 右下角小消息提示
  403. * @param title 标题
  404. * @param fromId 发送人Id
  405. * @param from 发送人
  406. * @param date 日期
  407. * @param context 正文
  408. * @param url 消息链接
  409. * @param msgId 消息ID
  410. */
  411. showMsgTip: function(title,prId,fromId, from, date, context, url, msgId,master){
  412. var me = this;
  413. var panel = Ext.getCmp('msg-win-' + prId);
  414. if(!panel){
  415. panel = Ext.create('erp.view.core.window.MsgTip', {
  416. title: title,
  417. from: from,
  418. date: date,
  419. url: url,
  420. msgId: msgId,
  421. prId:prId,
  422. height: 120,//提示信息显示不全
  423. context: context,
  424. listeners: {
  425. close: function(){
  426. me.updatePagingStatus(msgId, 1,master);
  427. },
  428. check: function(){
  429. me.showDialogBox(msgId, fromId, from, date, context);
  430. },
  431. reply: function(){
  432. me.showDialogBox(msgId, fromId, from, date, context);
  433. }
  434. }
  435. });
  436. }
  437. },
  438. transImages: function(msg){
  439. msg = msg.toString();
  440. var faces = msg.match(/&f\d+;/g);
  441. Ext.each(faces, function(f){//表情
  442. msg = msg.replace(f, '<img src="' + basePath + 'resource/images/face/' + f.substr(2).replace(';', '') + '.gif">');
  443. });
  444. var images = msg.match(/&img\d+;/g);
  445. Ext.each(images, function(m){//图片
  446. msg = msg.replace(m, '');
  447. });
  448. return msg;
  449. },
  450. /**
  451. * 对话框
  452. * @param id 消息的主键值
  453. * @param otherId 对方人员ID
  454. * @param other 对方人名
  455. * @param date 时间
  456. * @param context 对话内容
  457. */
  458. showDialogBox: function(id, otherId, other, date, context){
  459. var me = this;
  460. var panel = Ext.getCmp('dialog-win-' + otherId);
  461. if(!panel){
  462. panel = Ext.create('erp.view.core.window.DialogBox', {
  463. other: other,
  464. otherId: otherId
  465. });
  466. }
  467. if(!Ext.isEmpty(id)){
  468. panel.insertDialogItem(other, date, context);
  469. if(Ext.getCmp('dialog-min-' + otherId)){
  470. Ext.getCmp('dialog-min-' + otherId).setText("<font color=red>有新消息...</font>" );
  471. } else {
  472. me.updatePagingStatus(id, 1);
  473. }
  474. }
  475. },
  476. /**
  477. * 循环刷新寻呼信息
  478. * @param cycletime 间隔时间 {快速4000(聊天过程中)、中等8000(普通模式)、慢速15000(session中断等异常情况下)}
  479. */
  480. loadPagingRelease: function(){
  481. var me = this;
  482. me.cycletime = me.cycletime || 8000;
  483. if(!Ext.getCmp('lock-win')){
  484. try{
  485. me.getPagingRelease();
  486. Ext.getCmp('process-lazy').setText('');
  487. } catch (e) {
  488. //需要try catch一下,不然,循环会因出现的异常而中断。网络中断后,如果不刷新主页,而是直接重新登录的话,就不会继续循环刷新寻呼
  489. me._showerr(e);
  490. }
  491. }
  492. setTimeout(function(){
  493. if(me.allowMsg)
  494. me.loadPagingRelease();
  495. }, me.cycletime);
  496. },
  497. /**
  498. * 循环刷新流程信息
  499. * */
  500. loadJprocess: function(){
  501. var me = this;
  502. if(!me.bench) me.bench=Ext.getCmp("content-panel").items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.workbench;
  503. if(me.onlyJprocess == undefined) me.onlyJprocess=getSetting("refreshOnlyJprocess");
  504. if(!Ext.getCmp('lock-win') && me.bench){
  505. me.bench.refreshTask(me.onlyJprocess);
  506. }
  507. setTimeout(function(){
  508. me.loadJprocess();
  509. },60000);
  510. },
  511. _showerr: function(e) {
  512. var me = this;
  513. if(e.code == 101 || e.message == 'NETWORK_ERR' || e.message == 'NETWORK_LAZY' || e.message == 'NETWORK_LOCK'){//NETWORK_ERR
  514. me.cycletime = 20000;
  515. if(e.message == 'NETWORK_ERR') {
  516. showLoginDiv(true);
  517. Ext.getCmp('process-lazy').setText('服务器连接中断,服务器可能已关闭或在重启,尝试连接中...');
  518. } else if(e.message == 'NETWORK_LAZY') {
  519. Ext.getCmp('process-lazy').setText('请求超时8000ms,服务器负荷过大或网络延迟,请暂缓操作,尝试恢复中...');
  520. } else if(e.message == 'NETWORK_LOCK') {//账号被强制锁定
  521. Ext.Ajax.request({
  522. url: basePath + "common/logout.action",
  523. method : 'post',
  524. callback : function(options, success, response){
  525. var res = Ext.decode(response.responseText);
  526. if(res.success){
  527. alert('您已被管理员强制注销,请重新登录!');
  528. window.location.reload();
  529. }
  530. }
  531. });
  532. }
  533. }
  534. },
  535. /**
  536. * 获取未读网络寻呼
  537. */
  538. getPagingRelease: function(){
  539. var me = this, t1 = new Date().getTime();
  540. Ext.Ajax.request({
  541. url : basePath + 'oa/info/getPagingRelease.action',
  542. method : 'get',
  543. timeout: 8000,
  544. callback : function(options, success, response){
  545. var e = null;
  546. if(success == false) {
  547. var lazy = new Date().getTime() - t1;
  548. if(lazy > 7500) {// 表示超时引起
  549. e = new Error("NETWORK_LAZY");
  550. } else {// 表示服务器连接中断引起
  551. e = new Error("NETWORK_ERR");
  552. }
  553. } else {
  554. me.cycletime = 8000;
  555. }
  556. var localJson = new Ext.decode(response.responseText, true);
  557. if(localJson.exceptionInfo) {
  558. var info = localJson.exceptionInfo;
  559. if(info == 'ERR_NETWORK_SESSIONOUT'){
  560. e = new Error("NETWORK_ERR");
  561. } else if(info == 'ERR_NETWORK_LOCKED'){
  562. e = new Error("NETWORK_LOCK");
  563. } else {
  564. showMessage('警告', info);
  565. }
  566. }
  567. if(e != null) {
  568. me._showerr(e);return;
  569. }
  570. if(localJson.success){
  571. if (localJson.IsRemind) {
  572. me.allowMsg = true;
  573. var data = Ext.decode(localJson.data);
  574. if(data != null && data.length > 0){
  575. Ext.each(data, function(d){
  576. if(Ext.getCmp('dialog-win-' + d.pr_releaserid)){
  577. me.showDialogBox(d.prd_id, d.pr_releaserid, d.pr_releaser, Ext.Date.format(Ext.Date.parse(d.pr_date, 'Y-m-d H:i:s'), 'Y-m-d H:i:s'), d.pr_context,d.currentMaster);
  578. } else {
  579. me.showMsgTip('您收到了新的寻呼',d.pr_id,d.pr_releaserid, d.pr_releaser, Ext.Date.format(Ext.Date.parse(d.pr_date, 'Y-m-d H:i:s'), 'Y-m-d H:i:s'),
  580. d.pr_context, 'jsps/oa/info/pagingDetail.jsp?formCondition=prd_idIS' + d.prd_id, d.prd_id,d.currentMaster);
  581. }
  582. });
  583. }
  584. } else {
  585. me.allowMsg = false;// 设置为不允许弹消息窗
  586. }
  587. }
  588. }
  589. });
  590. },
  591. /**
  592. * @param id 明细ID
  593. * @param status 待修改状态
  594. */
  595. updatePagingStatus: function(id, status,master){
  596. Ext.Ajax.request({
  597. url : basePath + 'oa/info/updateStatus.action',
  598. params: {
  599. id: id,
  600. status: status,
  601. master:master
  602. },
  603. method : 'post',
  604. callback : function(options,success,response){
  605. var localJson = new Ext.decode(response.responseText);
  606. if(localJson.exceptionInfo){
  607. showError(localJson.exceptionInfo);return null;
  608. }
  609. }
  610. });
  611. },
  612. /**
  613. * 抓取天气
  614. */
  615. getWeather: function(f){
  616. Ext.Ajax.request({
  617. url: basePath + 'common/getWeather.action',
  618. params: {
  619. city: f.value,
  620. day: f.ownerCt.down('combobox[id=day]').value
  621. },
  622. method: 'POST',
  623. callback : function(options,success,response){
  624. var res = Ext.decode(response.responseText);
  625. var w = res.weather;
  626. if(w){
  627. var container = f.ownerCt.ownerCt;
  628. Ext.each(container.items.items, function(item, index){
  629. if(index > 0){
  630. item.destroy();
  631. }
  632. });
  633. f.ownerCt.ownerCt.insert(1, {
  634. xtype: 'displayfield',
  635. width: 120,
  636. html: "<div style='color:blue;font-size:12px;'>&nbsp;" + w.low + "℃ ~ " + w.high + "℃ " + w.weather + "</div>" +
  637. '<img src="' + basePath + 'resource/images/weather/' + w.code + '.png">'
  638. });
  639. }
  640. }
  641. });
  642. },
  643. getCitys: function(){
  644. var citys = ["深圳","北京","天津","上海","重庆","石家庄","太原","沈阳","长春","哈尔滨","南京","杭州","合肥","福州","南昌","济南","郑州","武汉","长沙","广州","海口","成都","贵阳","昆明","西安","兰州","西宁","拉萨","南宁","呼和浩特","银川","乌鲁木齐","香港","台北","澳门"];
  645. var datas = new Array();
  646. Ext.each(citys, function(){
  647. datas.push({
  648. display: this,
  649. value: this
  650. });
  651. });
  652. return datas;
  653. },
  654. /**
  655. * 通讯录
  656. */
  657. showAddrBook: function(){
  658. if(!Ext.getCmp('addrbook-win')){
  659. Ext.create('Ext.window.Window', {
  660. id: 'addrbook-win',
  661. title: '我的通讯录',
  662. height: screen.height*0.8,
  663. width: screen.width*0.2,
  664. renderTo: Ext.getBody(),
  665. animCollapse: false,
  666. constrainHeader: true,
  667. bodyBorder: true,
  668. layout: 'accordion',
  669. border: false,
  670. autoShow: true,
  671. collapsible : true,
  672. x: screen.width*0.8,
  673. items: [
  674. Ext.create('erp.view.oa.addrBook.AddrBookTree', {
  675. id: 'addr-tree',
  676. title: '联系人'
  677. }),
  678. {
  679. title: '设置',
  680. html:'<p>...</p>',
  681. autoScroll:true
  682. },
  683. {
  684. title: '我的应用',
  685. html : '<p>...</p>'
  686. }
  687. ]
  688. });
  689. } else {
  690. Ext.getCmp('addrbook-win').show();
  691. }
  692. },
  693. checkOnline: function(record){
  694. Ext.Ajax.request({
  695. url: 'oa/info/checkOnline.action',
  696. params: {
  697. orgid: Number(record.data.data ? record.data.data.or_id : record.raw.data.or_id)
  698. },
  699. method: 'POST',
  700. callback : function(options,success,response){
  701. var res = Ext.decode(response.responseText);
  702. var data = res.data;
  703. if(data){
  704. var count = 0;
  705. var ems = Ext.Array.pluck(data, 'em_id');
  706. Ext.each(record.childNodes, function(node){
  707. if(Ext.Array.contains(ems, Math.abs(node.data['id']))){
  708. node.set('iconCls', 'x-tree-icon-happy');
  709. node.set('cls', 'x-tree-cls-node-on');
  710. var d = Ext.Array.filter(data, function(dd){
  711. return dd.em_id == Math.abs(node.get('id'));
  712. })[0];
  713. node.set('qtip', '<table>' +
  714. '<tr><td>编号:</td><td>' + d.em_code + '</td></tr>' +
  715. '<tr><td>姓名:</td><td>' + d.em_name + '</td></tr>' +
  716. '<tr><td>IP:</td><td>' + d.ip + '</td></tr>' +
  717. '<tr><td>时间:</td><td>' + Ext.Date.format(new Date(d.date), 'Y-m-d H:i:s') + '</td></tr>' +
  718. '</table>');
  719. count++;
  720. } else {
  721. node.set('iconCls', 'x-tree-icon-sad');
  722. node.set('cls', 'x-tree-cls-node-off');
  723. }
  724. });
  725. if(count > 0){
  726. if(!record.data.oriText){
  727. record.data.oriText = record.data.text;
  728. }
  729. record.expand(false,true);
  730. }
  731. }
  732. }
  733. });
  734. },
  735. showPwdPanel: function() {
  736. Ext.create('erp.view.core.window.PwdWindow');
  737. }
  738. });