DialogBox.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /**
  2. * 网络寻呼--聊天框
  3. * (在系统主页工作台下的通讯录,选择任意人员即可打开聊天框)
  4. * 支持在线、离线消息、图片、附件
  5. * 支持查看、清除消息历史
  6. * 需传递参数other、otherId、[date]、[context]
  7. */
  8. Ext.define('erp.view.core.window.DialogBox', {
  9. extend: 'Ext.window.Window',
  10. alias: 'widget.dialogbox',
  11. frame: true,
  12. closable: false,
  13. autoShow: true,
  14. bodyStyle: 'background: #E0EEEE',
  15. width: 550,
  16. height: 460,
  17. renderTo: Ext.getBody(),
  18. layout: 'border',
  19. initComponent: function() {
  20. this.id = 'dialog-win-' + this.otherId;
  21. this.title = '<div style="height:25;padding-top:5px;color:#FF6A6A;background: #E0EEEE url(' +
  22. basePath + 'resource/ext/resources/themes/images/default/grid/grid-blue-hd.gif) repeat center center">&nbsp;您与 【' + this.other + '】 的会话:</div>';
  23. this.items = [{
  24. region: 'center',
  25. items: [{
  26. xtype: 'panel',
  27. id: 'log' + this.otherId,
  28. height: 255,
  29. width: 550,
  30. autoScroll: true,
  31. bodyStyle: 'background: #E0EEEE;'
  32. }, this.createDialogForm()]
  33. },{
  34. xtype: 'panel',
  35. region: 'east',
  36. height: 450,
  37. width: 320,
  38. hidden: true,
  39. id: 'history' + this.otherId,
  40. autoScroll: true,
  41. bodyStyle: 'background: #E0EEEE',
  42. bbar: this.getPagingToolbar(),
  43. tbar: this.getQueryToolbar()
  44. }];
  45. this.callParent(arguments);
  46. this.updatePosition();
  47. this.baseCondition = "(pr_releaserid=" + em_uu + " AND prd_recipientid=" + this.otherId + ") OR (pr_releaserid=" +
  48. this.otherId + " AND prd_recipientid=" + em_uu + ")";
  49. },
  50. tools: [{
  51. type: 'minimize',
  52. handler: function(){//最小化
  53. var win = arguments[2].ownerCt;
  54. var b = Ext.getCmp('bottom') || parent.Ext.getCmp('bottom');
  55. if(b){
  56. b.insert(1, {
  57. id: 'dialog-min-' + win.otherId,
  58. text: win.other,
  59. tooltip: win.context,
  60. tab: win,
  61. width: 150,
  62. style: {
  63. background: '#E0EEEE'
  64. },
  65. handler: function(btn){
  66. btn.tab.show();
  67. btn.destroy();
  68. }
  69. });
  70. win.hide();
  71. }
  72. }
  73. },{
  74. type: 'close',
  75. handler: function(){
  76. var win = arguments[2].ownerCt;
  77. win.close();
  78. }
  79. }],
  80. /**
  81. * 聊天输入框
  82. */
  83. createDialogForm: function(){
  84. var me = this;
  85. me.dialogForm = Ext.create('Ext.form.Panel', {
  86. width: 550,
  87. items: [{
  88. xtype: 'htmleditor',
  89. enableColors: false,
  90. enableAlignments: false,
  91. enableFont: false,
  92. enableFontSize: false,
  93. enableFormat: false,
  94. enableLinks: false,
  95. enableLists: false,
  96. enableSourceEdit: false,
  97. name: 'msg',
  98. frame: false,
  99. height: 115,
  100. width: 550,
  101. fieldStyle: 'border-bottom: none;',
  102. fixKeys: function() { // load time branching for fastest keydown performance
  103. if (Ext.isIE) {
  104. return function(e){
  105. var me = this,
  106. k = e.getKey(),
  107. doc = me.getDoc(),
  108. range, target;
  109. if (k === e.TAB) {
  110. e.stopEvent();
  111. range = doc.selection.createRange();
  112. if(range){
  113. range.collapse(true);
  114. range.pasteHTML('&nbsp;&nbsp;&nbsp;&nbsp;');
  115. me.deferFocus();
  116. }
  117. }
  118. else if (k === e.ENTER) {
  119. range = doc.selection.createRange();
  120. if (range) {
  121. target = range.parentElement();
  122. if(!target || target.tagName.toLowerCase() !== 'li'){
  123. e.stopEvent();
  124. range.pasteHTML('<br />');
  125. range.collapse(false);
  126. range.select();
  127. }
  128. }
  129. }
  130. };
  131. }
  132. if (Ext.isOpera) {
  133. return function(e){
  134. var me = this;
  135. if (e.getKey() === e.TAB) {
  136. e.stopEvent();
  137. me.win.focus();
  138. me.execCmd('InsertHTML','&nbsp;&nbsp;&nbsp;&nbsp;');
  139. me.deferFocus();
  140. }
  141. };
  142. }
  143. if (Ext.isWebKit) {
  144. return function(e){
  145. var me = this,
  146. k = e.getKey();
  147. if (k === e.TAB) {
  148. e.stopEvent();
  149. me.execCmd('InsertText','\t');
  150. me.deferFocus();
  151. }
  152. else if (k === e.ENTER) {
  153. e.stopEvent();
  154. me.execCmd('InsertHtml','<br /><br />');
  155. me.deferFocus();
  156. }
  157. };
  158. }
  159. return null; // not needed, so null
  160. }(),
  161. initEditor : function(){
  162. //Destroying the component during/before initEditor can cause issues.
  163. try {
  164. var me = this,
  165. dbody = me.getEditorBody(),
  166. ss = me.textareaEl.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),
  167. doc,
  168. fn;
  169. ss['background-attachment'] = 'fixed'; // w3c
  170. dbody.bgProperties = 'fixed'; // ie
  171. Ext.DomHelper.applyStyles(dbody, ss);
  172. doc = me.getDoc();
  173. if (doc) {
  174. try {
  175. Ext.EventManager.removeAll(doc);
  176. } catch(e) {}
  177. }
  178. /*
  179. * We need to use createDelegate here, because when using buffer, the delayed task is added
  180. * as a property to the function. When the listener is removed, the task is deleted from the function.
  181. * Since onEditorEvent is shared on the prototype, if we have multiple html editors, the first time one of the editors
  182. * is destroyed, it causes the fn to be deleted from the prototype, which causes errors. Essentially, we're just anonymizing the function.
  183. */
  184. fn = Ext.Function.bind(me.onEditorEvent, me);
  185. Ext.EventManager.on(doc, {
  186. mousedown: fn,
  187. dblclick: fn,
  188. click: fn,
  189. keyup: fn,
  190. buffer:100
  191. });
  192. // These events need to be relayed from the inner document (where they stop
  193. // bubbling) up to the outer document. This has to be done at the DOM level so
  194. // the event reaches listeners on elements like the document body. The effected
  195. // mechanisms that depend on this bubbling behavior are listed to the right
  196. // of the event.
  197. fn = me.onRelayedEvent;
  198. Ext.EventManager.on(doc, {
  199. mousedown: fn, // menu dismisal (MenuManager) and Window onMouseDown (toFront)
  200. mousemove: fn, // window resize drag detection
  201. mouseup: fn, // window resize termination
  202. click: fn, // not sure, but just to be safe
  203. dblclick: fn, // not sure again
  204. keydown:this.onEditorKeyDownEvent,
  205. scope: me
  206. });
  207. if (Ext.isGecko) {
  208. Ext.EventManager.on(doc, 'keypress', me.applyCommand, me);
  209. }
  210. if (me.fixKeys) {
  211. Ext.EventManager.on(doc, 'keydown', me.fixKeys, me);
  212. }
  213. Ext.EventManager.on(window, 'unload', me.beforeDestroy, me);
  214. doc.editorInitialized = true;
  215. me.initialized = true;
  216. me.pushValue();
  217. me.setReadOnly(me.readOnly);
  218. me.fireEvent('initialize', me);
  219. } catch(ex) {
  220. // ignore (why?)
  221. }
  222. },
  223. onEditorKeyDownEvent : function(e){
  224. //this.updateToolbar();
  225. this.fireEvent("keydown", this, e);
  226. },
  227. initComponent : function(){
  228. var me = this;
  229. me.addEvents(
  230. 'initialize',
  231. 'activate',
  232. 'beforesync',
  233. 'beforepush',
  234. 'sync',
  235. 'push',
  236. 'editmodechange',
  237. 'keydown'
  238. );
  239. me.callParent(arguments);
  240. me.initLabelable();
  241. me.initField();
  242. },
  243. listeners: {
  244. keydown:function(component,event){
  245. if(event.keyCode==13||event.ctrlKey&&event.keyCode==13){
  246. Ext.getCmp('msg-post').handler();
  247. }
  248. }
  249. },
  250. }],
  251. buttonAlign: 'right',
  252. buttons: [{
  253. text: '寻呼记录',
  254. cls: 'x-btn-blue',
  255. height: 23,
  256. width: 80,
  257. handler: function(){
  258. if(Ext.getCmp('history' + me.otherId).hidden){
  259. me.setWidth(870);
  260. Ext.getCmp('history' + me.otherId).show();
  261. me.getCount();
  262. } else {
  263. me.setWidth(550);
  264. Ext.getCmp('history' + me.otherId).hide();
  265. }
  266. }
  267. },{
  268. text: '关&nbsp;闭',
  269. cls: 'x-btn-blue',
  270. height: 23,
  271. width: 80,
  272. handler: function(btn){
  273. me.close();
  274. }
  275. },{
  276. text: '发&nbsp;送',
  277. cls: 'x-btn-blue',
  278. height: 23,
  279. width: 80,
  280. id:'msg-post',
  281. handler: function(btn){
  282. me.post();
  283. }
  284. }],
  285. tbar: {
  286. xtype: 'toolbar',
  287. height: 25,
  288. items: [{
  289. iconCls: 'x-tree-icon-happy',
  290. cls: 'x-btn-blue',
  291. text: '选择表情',
  292. handler: function(btn){
  293. me.showFace(btn);
  294. }
  295. },me.picture(),{
  296. iconCls: 'x-button-icon-up',
  297. text: '发送附件',
  298. cls: 'x-btn-blue'
  299. },'->',{
  300. text: '常用语',
  301. cls: 'x-btn-blue',
  302. menu: [{
  303. text: '谢谢!'
  304. },{
  305. text: '哦,好的。'
  306. },{
  307. text: '嗯,知道了。'
  308. },{
  309. text: '您好!我现在正忙,一会儿回复您。'
  310. }]
  311. }]
  312. }
  313. });
  314. return me.dialogForm;
  315. },
  316. /**
  317. * 插入聊天记录
  318. */
  319. insertDialogItem: function(name, date, context, cmp){
  320. context = this.transImages(context);
  321. cmp = cmp || this.down('#log' + this.otherId);
  322. cmp.add({
  323. xtype: 'displayfield',
  324. height: 'auto',
  325. fieldLabel: (name == null || name == em_name) ? '<font color=green style="font-weight:bold;font-family:宋体;">我:</font>' +
  326. "<font color=green style='margin-left:5px;'>(" + date + ")</font>" :
  327. '<font color=blue style="font-weight:bold;font-family:宋体;">' + name + ':</font>' +
  328. "<font color=blue style='margin-left:5px;'>(" + date + ")</font>",
  329. labelWidth: 300,
  330. labelSeparator: '',
  331. fieldStyle: 'color:green'
  332. });
  333. cmp.add({
  334. xtype: 'displayfield',
  335. labelSeparator: '',
  336. height: 'auto',
  337. fieldStyle: 'padding-left:30px;color:black;',
  338. value: context
  339. });
  340. cmp.setActive( true,cmp.items.items[cmp.items.items.length-1]);
  341. },
  342. /**
  343. * 显示表情picker
  344. */
  345. showFace: function(btn){
  346. var picker = Ext.getCmp(btn.id + '-picker');
  347. if(picker){
  348. if(picker.hidden){
  349. picker.show();
  350. } else {
  351. picker.hide();
  352. }
  353. } else {
  354. picker = Ext.create('erp.view.core.picker.Face', {
  355. id: btn.id + '-picker',
  356. floating: true,
  357. ownerCt: btn,
  358. hidden: true,
  359. renderTo: Ext.getBody(),
  360. listeners: {
  361. scope:this,
  362. select: function(picker, face) {
  363. var msg = btn.ownerCt.ownerCt.down('htmleditor[name=msg]');
  364. var element = document.createElement("img");
  365. element.src = picker.facepath + face.substr(2).replace(';', '') + picker.format;
  366. element.title = face;
  367. msg.getEl().dom.getElementsByTagName('iframe')[0].contentWindow.document.body.appendChild(element);
  368. picker.hide();
  369. }
  370. }
  371. });
  372. picker.alignTo(btn.getEl(), 'tl-bl?');
  373. picker.show(btn.getEl());
  374. }
  375. },
  376. post: function(){
  377. var me = this;
  378. var form = me.dialogForm;
  379. var area = form.down('htmleditor[name=msg]');
  380. if(area.getValue() != null && area.getValue() != ''){
  381. var imgs = area.getEl().dom.getElementsByTagName('iframe')[0].contentWindow.document.body.getElementsByTagName('img');
  382. var value = area.value;
  383. me.insertDialogItem(null, Ext.Date.format(new Date(), 'Y-m-d H:i:s'), me.transImages(value));
  384. Ext.each(imgs, function(i){
  385. value = value.replace(i.outerHTML, i.title);
  386. });
  387. me.sendDialog(value);
  388. area.setValue('');
  389. }
  390. },
  391. /**
  392. * 图片信息转化
  393. * (纯html格式会加大数据量。这里将图片、附件等转化成特殊的描述,可以简化信息量)
  394. * 分为表情&f;,用户上传图片&img;
  395. */
  396. transImages: function(msg){
  397. msg = msg.toString();
  398. var faces = msg.match(/&f\d+;/g);
  399. Ext.each(faces, function(f){//表情
  400. msg = msg.replace(f, '<img src="' + basePath + 'resource/images/face/' + f.substr(2).replace(';', '') + '.gif">');
  401. });
  402. var images = msg.match(/&img\d+;/g);
  403. Ext.each(images, function(m){//图片
  404. var id = m.substr(4).replace(';', '');
  405. Ext.Ajax.request({
  406. url : basePath + 'common/getFilePaths.action',
  407. async: false,
  408. params: {
  409. id: id
  410. },
  411. method : 'post',
  412. callback : function(options,success,response){
  413. var res = new Ext.decode(response.responseText);
  414. if(res.files && res.files.length > 0){
  415. msg = msg.replace("&img" + id + ";", '<img src="' + res.files[0].fp_path + '">');
  416. }
  417. }
  418. });
  419. });
  420. return msg;
  421. },
  422. /**
  423. * 发送寻呼
  424. */
  425. sendDialog: function(context){
  426. var me = this;
  427. Ext.Ajax.request({
  428. url : basePath + 'oa/info/sendPagingRelease.action',
  429. async: false,
  430. params: {
  431. formStore: Ext.encode({
  432. prd_recipient: me.other,
  433. prd_recipientid: me.otherId,
  434. pr_context: context
  435. })
  436. },
  437. method : 'post',
  438. callback : function(options,success,response){
  439. var localJson = new Ext.decode(response.responseText);
  440. if(localJson.success){
  441. }
  442. }
  443. });
  444. },
  445. /**
  446. * window显示位置
  447. */
  448. updatePosition: function(){
  449. var count = Ext.ComponentQuery.query('dialogbox').length;//多个聊天框时,错位显示
  450. var x = (screen.width - 500)/2;
  451. var y = (screen.height - 500)/2;
  452. this.setPosition(x - count*30, y - count*30);
  453. this.show();
  454. },
  455. page: 1,
  456. pageSize: 10,
  457. getPagingToolbar: function(){
  458. var box = this,
  459. pageSize = box.pageSize,
  460. dataCount = box.dataCount;
  461. var bar = Ext.create('Ext.toolbar.Paging', {
  462. id: 'pagingtoolbar' + box.otherId,
  463. updateInfo : function(){
  464. var page=this.child('#inputItem').getValue();
  465. var me = this,
  466. displayItem = me.child('#displayItem'),
  467. pageData = me.getPageData();
  468. pageData.fromRecord = (page-1)*pageSize+1;
  469. pageData.toRecord = page*pageSize > dataCount ? dataCount : page*pageSize;
  470. pageData.total = dataCount;
  471. var msg;
  472. if (displayItem) {
  473. if (box.dataCount === 0) {
  474. msg = me.emptyMsg;
  475. } else {
  476. msg = Ext.String.format(
  477. me.displayMsg,
  478. pageData.fromRecord,
  479. pageData.toRecord,
  480. pageData.total
  481. );
  482. }
  483. displayItem.setText(msg);
  484. me.doComponentLayout();
  485. }
  486. },
  487. getPageData : function(){
  488. var totalCount = box.dataCount;
  489. return {
  490. total : totalCount,
  491. currentPage : box.page,
  492. pageCount: Math.ceil(box.dataCount / box.pageSize),
  493. fromRecord: ((box.page - 1) * box.pageSize) + 1,
  494. toRecord: Math.min(box.page * box.pageSize, totalCount)
  495. };
  496. },
  497. doRefresh:function(){
  498. this.moveFirst();
  499. },
  500. onPagingKeyDown : function(field, e){
  501. var me = this,
  502. k = e.getKey(),
  503. pageData = me.getPageData(),
  504. increment = e.shiftKey ? 10 : 1,
  505. pageNum = 0;
  506. if (k == e.RETURN) {
  507. e.stopEvent();
  508. pageNum = me.readPageFromInput(pageData);
  509. if (pageNum !== false) {
  510. pageNum = Math.min(Math.max(1, pageNum), pageData.pageCount);
  511. me.child('#inputItem').setValue(pageNum);
  512. if(me.fireEvent('beforechange', me, pageNum) !== false){
  513. box.page = pageNum;
  514. box.getHistoryStore(box.page, box.pageSize);
  515. }
  516. }
  517. } else if (k == e.HOME || k == e.END) {
  518. e.stopEvent();
  519. pageNum = k == e.HOME ? 1 : pageData.pageCount;
  520. field.setValue(pageNum);
  521. } else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN) {
  522. e.stopEvent();
  523. pageNum = me.readPageFromInput(pageData);
  524. if (pageNum) {
  525. if (k == e.DOWN || k == e.PAGEDOWN) {
  526. increment *= -1;
  527. }
  528. pageNum += increment;
  529. if (pageNum >= 1 && pageNum <= pageData.pages) {
  530. field.setValue(pageNum);
  531. }
  532. }
  533. }
  534. me.updateInfo();
  535. me.resetTool(value);
  536. },
  537. moveFirst : function(){
  538. var me = this;
  539. me.child('#inputItem').setValue(1);
  540. value = 1;
  541. box.page = value;
  542. box.getHistoryStore(value, pageSize);
  543. me.updateInfo();
  544. me.resetTool(value);
  545. },
  546. movePrevious : function(){
  547. var me = this;
  548. me.child('#inputItem').setValue(me.child('#inputItem').getValue() - 1);
  549. value = me.child('#inputItem').getValue();
  550. box.page = value;
  551. box.getHistoryStore(value, pageSize);
  552. me.updateInfo();
  553. me.resetTool(value);
  554. },
  555. moveNext : function(){
  556. var me = this,
  557. last = me.getPageData().pageCount;
  558. total = last;
  559. me.child('#inputItem').setValue(me.child('#inputItem').getValue() + 1);
  560. value = me.child('#inputItem').getValue();
  561. box.page = value;
  562. box.getHistoryStore(value, pageSize);
  563. me.updateInfo();
  564. me.resetTool(value);
  565. },
  566. moveLast : function(){
  567. var me = this,
  568. last = me.getPageData().pageCount;
  569. total = last;
  570. me.child('#inputItem').setValue(last);
  571. value = me.child('#inputItem').getValue();
  572. box.page = value;
  573. box.getHistoryStore(value, pageSize);
  574. me.updateInfo();
  575. me.resetTool(value);
  576. },
  577. onLoad : function() {
  578. var e = this, d, b, c, a;
  579. if (!e.rendered) {
  580. return
  581. }
  582. d = e.getPageData();
  583. b = d.currentPage;
  584. c = Math.ceil(box.dataCount / pageSize);
  585. a = Ext.String.format(e.afterPageText, isNaN(c) ? 1 : c);
  586. e.child("#afterTextItem").setText(a);
  587. e.child("#inputItem").setValue(b);
  588. e.child("#first").setDisabled(b === 1);
  589. e.child("#prev").setDisabled(b === 1);
  590. e.child("#next").setDisabled(b === c || c===1);//
  591. e.child("#last").setDisabled(b === c || c===1);
  592. e.child("#refresh").enable();
  593. e.updateInfo();
  594. e.fireEvent("change", e, d);
  595. },
  596. resetTool: function(value){
  597. this.child('#last').setDisabled(value == box.dataCount);
  598. this.child('#next').setDisabled(value == total || value == 1);
  599. this.child('#first').setDisabled(value <= 1);
  600. this.child('#prev').setDisabled(value <= 1);
  601. }
  602. });
  603. return bar;
  604. },
  605. getQueryToolbar: function(){
  606. var me = this;
  607. return {
  608. xtype: 'toolbar',
  609. items: [{
  610. iconCls: 'x-button-icon-query',
  611. width: 18,
  612. style: {
  613. marginBottom: '5px',
  614. border: 'none'
  615. },
  616. tooltip: '查询',
  617. handler: function(){
  618. var value = me.down('condatefield[name=pr_date]').value;
  619. if(!Ext.isEmpty(value)){
  620. me.page = 1;
  621. me.filterCondition = "(pr_date " + value + ")";
  622. me.getCount();
  623. }
  624. }
  625. }, Ext.create('erp.view.core.form.ConDateField', {
  626. name: 'pr_date',
  627. width: 295
  628. })]
  629. };
  630. },
  631. getHistoryStore: function(page, pageSize){
  632. var me = this;
  633. me.down('#history' + me.otherId).removeAll();
  634. Ext.Ajax.request({//拿到grid的columns
  635. url : basePath + 'common/datalist.action',
  636. params: {
  637. caller: 'PagingRelease',
  638. condition: me.filterCondition ? me.filterCondition + ' AND (' + me.baseCondition + ')': me.baseCondition,
  639. page: page,
  640. pageSize: pageSize
  641. },
  642. method : 'post',
  643. callback : function(options,success,response){
  644. var res = new Ext.decode(response.responseText);
  645. if(res.exception || res.exceptionInfo){
  646. showError(res.exceptionInfo);
  647. return;
  648. }
  649. var data = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];//一定要去掉多余逗号,ie对此很敏感
  650. data = Ext.Array.sort(data, function(a, b){//按时间升序排序
  651. return a.pr_date > b.pr_date;
  652. });
  653. Ext.each(data, function(d){
  654. me.insertDialogItem(d.pr_releaser, Ext.Date.format(Ext.Date.parse(d.pr_date, 'Y-m-d H:i:s'), 'Y-m-d H:i:s'),
  655. d.pr_context, me.down('#history' + me.otherId));
  656. });
  657. //修改pagingtoolbar信息
  658. Ext.getCmp('pagingtoolbar' + me.otherId).onLoad();
  659. }
  660. });
  661. },
  662. getCount: function(){
  663. var me = this;
  664. Ext.Ajax.request({
  665. url : basePath + '/common/datalistCount.action',
  666. params: {
  667. caller: 'PagingRelease',
  668. condition: me.filterCondition ? me.filterCondition + ' AND (' + me.baseCondition + ")": me.baseCondition
  669. },
  670. method : 'post',
  671. callback : function(options,success,response){
  672. var res = new Ext.decode(response.responseText);
  673. if(res.exception || res.exceptionInfo){
  674. showError(res.exceptionInfo);
  675. return;
  676. }
  677. me.dataCount = res.count;
  678. me.getHistoryStore(me.page, me.pageSize);
  679. }
  680. });
  681. },
  682. /**
  683. * 插入图片组件
  684. */
  685. picture: function(){
  686. var form = Ext.create('Ext.form.Panel', {
  687. bodyStyle: 'background: transparent no-repeat 0 0;border: none;',
  688. items: [{
  689. xtype: 'filefield',
  690. name: 'file',
  691. buttonOnly: true,
  692. hideLabel: true,
  693. width: 86,
  694. height: 17,
  695. buttonConfig: {
  696. iconCls: 'x-button-icon-pic',
  697. text: '插入图片',
  698. baseCls: 'x-btn',
  699. cls: 'x-btn-blue'
  700. },
  701. listeners: {
  702. change: function(field){
  703. field.ownerCt.getForm().submit({
  704. url: basePath + 'common/uploadPic.action?em_code=' + em_code,
  705. waitMsg: "正在解析图片信息",
  706. success: function(fp, o){
  707. if(o.result.error){
  708. showError(o.result.error);
  709. } else {
  710. var msg = form.ownerCt.ownerCt.down('htmleditor[name=msg]');
  711. var element = document.createElement("img");
  712. element.src = o.result.path;
  713. element.title = '&img' + o.result.filepath + ";";
  714. msg.getEl().dom.getElementsByTagName('iframe')[0].contentWindow.document.body.appendChild(element);
  715. }
  716. }
  717. });
  718. }
  719. }
  720. }]
  721. });
  722. return form;
  723. },
  724. /**
  725. * 插入附件组件
  726. */
  727. attach: function(){
  728. var form = Ext.create('Ext.form.Panel', {
  729. bodyStyle: 'background: transparent no-repeat 0 0;border: none;',
  730. items: [{
  731. xtype: 'filefield',
  732. name: 'file',
  733. buttonOnly: true,
  734. hideLabel: true,
  735. width: 82,
  736. height: 17,
  737. buttonConfig: {
  738. iconCls: 'x-button-icon-up',
  739. text: '发送附件',
  740. cls: 'x-btn-blue'
  741. },
  742. listeners: {
  743. change: function(field){
  744. field.ownerCt.getForm().submit({
  745. url: basePath + 'common/upload.action?em_code=' + em_code,
  746. waitMsg: "正在解析附件信息",
  747. success: function(fp, o){
  748. if(o.result.error){
  749. showError(o.result.error);
  750. } else {
  751. var msg = form.ownerCt.ownerCt.down('htmleditor[name=msg]');
  752. var element = document.createElement("img");
  753. element.src = o.result.path;
  754. element.title = '&img' + o.result.filepath + ";";
  755. msg.getEl().dom.getElementsByTagName('iframe')[0].contentWindow.document.body.appendChild(element);
  756. }
  757. }
  758. });
  759. }
  760. }
  761. }]
  762. });
  763. return form;
  764. },
  765. download: function(id, msg){
  766. Ext.Ajax.request({
  767. url : basePath + 'common/getFilePaths.action',
  768. async: false,
  769. params: {
  770. id: id
  771. },
  772. method : 'post',
  773. callback : function(options,success,response){
  774. var res = new Ext.decode(response.responseText);
  775. if(res.exception || res.exceptionInfo){
  776. showError(res.exceptionInfo);
  777. return;
  778. }
  779. if(res.files.length > 0){
  780. msg = msg.replace("&img" + id + ";", '<img src="' + res.files[0].fp_path + '">');
  781. }
  782. }
  783. });
  784. }
  785. });