Main.js 29 KB

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