workBench.js 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  1. var workbench = {
  2. width: 1/3,
  3. setWidth: function(width){
  4. this.width = width;
  5. },
  6. height: 1/3,
  7. setHeight: function(height){
  8. this.height = height;
  9. },
  10. bench_task: function(){
  11. var me = this.workbench || this;
  12. var notifycount=getNotifyCount();
  13. return Ext.create('Ext.panel.Panel', {
  14. title:'<div class="div-left">待办事宜</div>' +
  15. '<div class="div-right"><a href="javascript:openTable(null,\'JprocessScan\',\'发起流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_launcherid=\\\'' + em_code + '\\\' and jp_status=\\\'待审批\\\' '+'\');">已发起流程</a></div>' +
  16. '<div class="div-right"><a href="javascript:openTable(null,\'JprocessScan\',\'处理流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\\\'' + em_code + '\\\' and jp_status<>\\\'待审批\\\' '+'\' );">已处理流程</a>|</div>'+
  17. '<div class="div-right"><a href="javascript:openTable(null,\'TransferProcess\',\'转移流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jt_acceptercode=\\\'' + em_code + '\\\' and jp_flag = 1 and jp_status=\\\'待审批\\\' '+'\' );">待办转移流程</a>|</div>'+
  18. '<div class="div-right"><a href="javascript:openTable(null,\'JProcess\',\'待办流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\\\'' + em_code + '\\\' and jp_status=\\\'待审批\\\' '+'\' );">更多待办流程</a>|</div>'+
  19. '<div class="div-right"><a href="javascript:openTable(null,\'ResourceAssignment!ALL\',\'提醒任务列表\',\'jsps/common/datalist.jsp\',null,null,\'ra_resourcecode=\\\'' + em_code + '\\\' and ra_statuscode<>\\\'FINISHED\\\' '+'\' );">更多提醒任务</a>|</div>'+
  20. '<div class="div-right"><a href="javascript:openTable(null,\'NotifyJprocess\',\'知会信息\',\'jsps/common/datalist.jsp\',null,null,\'prd_recipientid=session:em_uu\' );"><div id="messagecount">知会('+notifycount+')|</div></a>|</div>'+
  21. '<div class="div-right"><a href="javascript:refreshTask();">刷新</a>|</div>',
  22. id: 'bench_task',
  23. iconCls: 'main-todo',
  24. columnWidth: me.width,
  25. height: me.height,
  26. layout:'anchor',
  27. items:[{
  28. xtype:'gridpanel',
  29. id:'task_grid',
  30. hideHeaders:true,
  31. store: Ext.create('Ext.data.Store', {
  32. fields:['id', 'name','status','type','typecode','CURRENTMASTER','note'],
  33. groupField: 'type'
  34. }),
  35. autoScroll: true,
  36. cls: 'task-grid',
  37. anchor: '100% 100%',
  38. features: [ Ext.create('Ext.grid.feature.Grouping',{
  39. groupHeaderTpl: '{name} (共 {rows.length}项)'
  40. })],
  41. loadNewStore:function(){
  42. me._bench_task();
  43. },
  44. viewConfig :{
  45. stripeRows:false
  46. },
  47. bodyStyle: 'background: #f1f1f1;border: none;',
  48. columns: [{ header: 'ID', dataIndex: 'id', hidden: true},
  49. { header: '事宜名称', dataIndex: 'name', flex:1,renderer:taskItem, id: 'topic'},
  50. { header: '当前状态', dataIndex: 'status',hidden: true},
  51. {header: '事宜类型', dataIndex:'type',hidden: true},
  52. {header:'事宜类型编码', dataIndex:'typecode',hidden: true},
  53. {header:'备注信息', dataIndex:'note',hidden: true},
  54. {header:'Master',dateIndex:'CURRENTMASTER',hidden:true }]
  55. }]
  56. });
  57. },
  58. bench_flow: function(){
  59. var me = this.workbench || this;
  60. return Ext.create('Ext.panel.Panel', {
  61. title:'<div class="div-left">我发起未结束流程</div>' +
  62. '<div class="div-right"><a href="javascript:openTable(null,\'JProcess!Me\',\'流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\'' + em_code + '\');">发布流程</a></div>' +
  63. '<div class="div-right"><a href="javascript:openTable(null,\'JProcess!Me\',\'流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\'' + em_code + '\');">更多流程</a>|</div>',
  64. bodyStyle: 'background: #f1f1f1',
  65. id: 'bench_flow',
  66. contentEl: 'myflow',
  67. iconCls: 'main-todo',
  68. autoScroll: true,
  69. columnWidth: me.width,
  70. height: me.height
  71. });
  72. },
  73. bench_overflow: function(){
  74. var me = this.workbench || this;
  75. return Ext.create('Ext.panel.Panel', {
  76. title:'<div class="div-left">我的超时流程</div>' +
  77. '<div class="div-right"><a href="javascript:openTable(null,\'JProcess!MeOver\',\'流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\'' + em_code + '\');">发布流程</a></div>' +
  78. '<div class="div-right"><a href="javascript:openTable(null,\'JProcess!MeOver\',\'流程列表\',\'jsps/common/datalist.jsp\',null,null,\'jp_nodedealman=\'' + em_code + '\');">更多流程</a>|</div>',
  79. bodyStyle: 'background: #f1f1f1',
  80. id: 'bench_overflow',
  81. contentEl: 'myoverflow',
  82. iconCls: 'main-todo',
  83. autoScroll: true,
  84. columnWidth: me.width,
  85. height: me.height
  86. });
  87. },
  88. bench_schedule: function(){
  89. var me = this.workbench || this;
  90. return Ext.create('Ext.panel.Panel', {
  91. title:'<div class="div-left">我的考勤</div>' +
  92. '<div class="div-right"><a href="javascript:openTable(null,\'Sign\',\'考勤\',\'jsps/common/datalist.jsp\',null,null,\'si_emid=' + em_uu + '\');">我的考勤</a></div>' +
  93. '<div class="div-right"><a href="javascript:alert(\'没有下属\');">下属考勤</a>|</div>',
  94. id: 'bench_schedule',
  95. iconCls: 'main-forget',
  96. layout: 'anchor',
  97. bodyStyle: 'background: #f1f1f1;',
  98. items: [{
  99. xtype: 'button',
  100. id: 'clock',
  101. iconCls: 'x-button-icon-clock',
  102. scale: 'large',
  103. anchor: '100% 33.33%'
  104. },{
  105. xtype: 'button',
  106. iconCls: 'x-button-icon-on',
  107. text: '',
  108. id: 'signin',
  109. signin: false,
  110. intime: null,
  111. tooltip: '',
  112. anchor: '100% 33.33%',
  113. scale: 'large',
  114. handler: function(btn){
  115. if(btn.signin == false){
  116. signin();
  117. }
  118. }
  119. },{
  120. xtype: 'button',
  121. iconCls: 'x-button-icon-off',
  122. hidden: true,
  123. text: '',
  124. signout: false,
  125. outtime: null,
  126. tooltip: '',
  127. id: 'signout',
  128. anchor: '100% 33.33%',
  129. scale: 'large',
  130. handler: function(btn){
  131. if(btn.signout == false){
  132. signout();
  133. }
  134. }
  135. }],
  136. columnWidth: me.width,
  137. height: me.height
  138. });
  139. },
  140. bench_subscription: function(){
  141. var me = this.workbench || this;
  142. return Ext.create('Ext.panel.Panel', {
  143. title: '<div class="div-left">日程安排</div>' +
  144. '<div class="div-right"><a href="' + basePath + 'jsps/plm/calendar/NewMyCalendar.jsp" target="_blank">详细日程</a></div>' +
  145. '<div class="div-right"><a href="' + basePath + 'jsps/plm/calendar/NewMyCalendar.jsp" target="_blank">下属日程</a>|</div>',
  146. id: 'bench_subscription',
  147. layout: 'border',
  148. items: [{
  149. region: 'center',
  150. xtype: 'holidaydatepicker',
  151. autoShow: true
  152. }],
  153. iconCls: 'main-schedule',
  154. columnWidth: me.width,
  155. height: me.height
  156. });
  157. },
  158. bench_notify: function(){
  159. var me = this.workbench || this;
  160. return Ext.create('Ext.panel.Panel', {
  161. title:'<div class="div-left">通知公告</div>' +
  162. '<div class="div-right"><a href="javascript:openTable(0,\'Note\',\'通知\',\'jsps/oa/info/Note.jsp\',\'no_id\',null' + ')">发布通知</a></div>' +
  163. '<div class="div-right"><a href="javascript:openTable(null,\'Note\',\'通知\',\'jsps/common/datalist.jsp\',null,null,null);">更多通知</a>|</div>',
  164. id: 'bench_notify',
  165. iconCls: 'main-msg',
  166. contentEl: 'notify',
  167. columnWidth: me.width,
  168. height: me.height
  169. });
  170. },
  171. bench_news: function(){
  172. var me = this.workbench || this;
  173. return Ext.create('Ext.panel.Panel', {
  174. title:'<div class="div-left">新闻动态</div>' +
  175. '<div class="div-right"><a href="javascript:openTable(0,\'News\',\'新闻\',\'jsps/oa/news/News.jsp\',\'ne_id\',null' + ')">发布新闻</a></div>' +
  176. '<div class="div-right"><a href="javascript:openTable(null,\'News\',\'新闻\',\'jsps/common/datalist.jsp\',null,null,null);">更多新闻</a>|</div>',
  177. id: 'bench_news',
  178. iconCls: 'main-notice',
  179. contentEl: 'news',
  180. columnWidth: me.width,
  181. height: me.height
  182. });
  183. },
  184. bench_link: function(){
  185. var me = this.workbench || this;
  186. return Ext.create('Ext.panel.Panel', {
  187. title: '<div class="div-left">常用模块</div>',
  188. id: 'bench_link',
  189. iconCls: 'main-news',
  190. columnWidth: me.width,
  191. height: me.height,
  192. layout: 'anchor',
  193. items: [{
  194. xtype: 'gridpanel',
  195. id: 'link_grid',
  196. cls: 'custom-grid',
  197. columnLines : true,
  198. autoScroll: true,
  199. anchor: '100% 100%',
  200. store: Ext.create('Ext.data.Store', {
  201. fields:['cu_id', 'cu_description', 'cu_url', 'cu_count'],
  202. data: []
  203. }),
  204. bodyStyle: 'background: #f1f1f1;',
  205. columns: [{
  206. text: 'ID',
  207. dataIndex: 'cu_id',
  208. hidden: true
  209. },{
  210. text: '模块名',
  211. dataIndex: 'cu_description',
  212. flex: 1,
  213. renderer: function(val, meta, record){
  214. var ht = "<a href=\"javascript:openTable("
  215. + record.data['cu_id'] + ",null,\'" + val + "\',\'" + record.data['cu_url'].replace(/\'/g, '\\\'') + "\',null,null,null,null,true)\">" + val + "</a>";
  216. return ht;
  217. }
  218. },{
  219. text: '链接',
  220. dataIndex: 'cu_url',
  221. hidden: true
  222. },{
  223. text: '次数',
  224. dataIndex: 'cu_count',
  225. hidden: true
  226. },{
  227. xtype: 'actioncolumn',
  228. text: '操作',
  229. flex: 0.2,
  230. items: [{
  231. icon: basePath + 'resource/images/16/up.png',
  232. tooltip: '上',
  233. handler: function(view, rowIndex, colIndex) {
  234. var rec = view.getStore().getAt(rowIndex);
  235. view.ownerCt.updateBench(rec.get('cu_id'), 1);
  236. }
  237. },{
  238. icon: basePath + 'resource/images/16/down.png',
  239. tooltip: '下',
  240. handler: function(view, rowIndex, colIndex) {
  241. var rec = view.getStore().getAt(rowIndex);
  242. view.ownerCt.updateBench(rec.get('cu_id'), -1);
  243. }
  244. },{
  245. icon: basePath + 'resource/images/16/delete.png',
  246. tooltip: '删除',
  247. handler: function(view, rowIndex, colIndex) {
  248. var rec = view.getStore().getAt(rowIndex);
  249. _delete_bench_link(rec.get('cu_id'));
  250. }
  251. }]
  252. }],
  253. updateBench : function(id, t) {
  254. var g = this;
  255. g.setLoading(true);
  256. Ext.Ajax.request({
  257. url : basePath + 'common/updateCommonUse.action',
  258. params : {
  259. _noc : 1,
  260. id : id,
  261. type : t
  262. },
  263. callback : function(o, s, r) {
  264. g.setLoading(false);
  265. var rs = Ext.decode(r.responseText);
  266. if (rs.commonuse) {
  267. g.store.loadData(rs.commonuse);
  268. }
  269. }
  270. });
  271. }
  272. }]
  273. });
  274. },
  275. bench_note: function(){
  276. var me = this.workbench || this;
  277. return Ext.create('Ext.panel.Panel', {
  278. title: '<div class="div-left">我的知会</div>',
  279. bodyStyle: 'background: #f1f1f1;',
  280. iconCls: 'main-notice',
  281. id: 'bench_note',
  282. contentEl: 'note2',
  283. columnWidth: me.width,
  284. height: me.height
  285. });
  286. },
  287. bench_mytask: function(){
  288. var me = this.workbench || this;
  289. return Ext.create('Ext.panel.Panel', {
  290. title: '<div class="div-left">我的任务</div>',
  291. bodyStyle: 'background: #f1f1f1',
  292. id: 'bench_mytask',
  293. iconCls: 'main-news',
  294. columnWidth: me.width,
  295. height: me.height
  296. });
  297. },
  298. bench_plan: function(){
  299. var me = this.workbench || this;
  300. return Ext.create('Ext.panel.Panel', {
  301. title:'<div class="div-left">工作计划</div>',
  302. bodyStyle: 'background: #f1f1f1',
  303. id: 'bench_plan',
  304. contentEl: 'plan',
  305. iconCls: 'main-news',
  306. autoScroll: true,
  307. columnWidth: me.width,
  308. height: me.height
  309. });
  310. },
  311. bench_email: function(){
  312. var me = this.workbench || this;
  313. return Ext.create('Ext.panel.Panel', {
  314. title: '<div class="div-left">我的邮箱</div>',
  315. bodyStyle: 'background: #f1f1f1',
  316. id: 'bench_email',
  317. iconCls: 'main-news',
  318. columnWidth: me.width,
  319. height: me.height
  320. });
  321. },
  322. bench_knowledge: function(){
  323. var me = this.workbench || this;
  324. return Ext.create('Ext.panel.Panel', {
  325. title: '<div class="div-left">知识地图</div>',
  326. bodyStyle: 'background: #f1f1f1',
  327. id: 'bench_knowledge',
  328. iconCls: 'main-news',
  329. columnWidth: me.width,
  330. height: me.height
  331. });
  332. },
  333. bench_meeting: function(){
  334. var me = this.workbench || this;
  335. return Ext.create('Ext.panel.Panel', {
  336. title: '<div class="div-left">待开会议</div>',
  337. bodyStyle: 'background: #f1f1f1',
  338. id: 'bench_meeting',
  339. iconCls: 'main-news',
  340. columnWidth: me.width,
  341. height: me.height
  342. });
  343. },
  344. /**
  345. * 我发起的流程
  346. */
  347. _bench_flow: function(){
  348. var me = this.workbench || this;
  349. Ext.Ajax.request({
  350. url : basePath + 'common/datalist.action',
  351. params: {
  352. caller: 'JProcess!Me',
  353. condition: 'jp_launcherid=\'' + em_code + '\'',
  354. page: 1,
  355. pageSize: parseInt(height*0.3/12)
  356. },
  357. method : 'post',
  358. callback : function(options,success,response){
  359. var res = new Ext.decode(response.responseText);
  360. if(res.exception || res.exceptionInfo){
  361. var err = res.exceptionInfo;
  362. if(err.indexOf('ERR_POWER') != -1) {
  363. Ext.get("myflow").insertHtml('afterBegin',
  364. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  365. } else {
  366. showError(err);
  367. }
  368. return;
  369. }
  370. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  371. if(task == [] || task.length == 0){
  372. Ext.get("myflow").insertHtml('afterBegin', '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(暂无任务流程)</div>');
  373. } else {
  374. Ext.create('Ext.grid.Panel', {
  375. autoScroll: true,
  376. store: Ext.create('Ext.data.Store', {
  377. fields:['jp_id', 'jp_form', 'jp_launchTime','enddate', 'jt_duedate','jp_nodeId'],
  378. data: task
  379. }),
  380. height: me.height*0.76,
  381. bodyStyle: 'background: #f1f1f1;border: none;',
  382. columns: [
  383. { header: 'ID', dataIndex: 'jp_id', hidden: true},
  384. { header: '流程单据', dataIndex: 'jp_form', flex: 1.5 , renderer: flowItem},
  385. { header: '限办时间', dataIndex: 'enddate', flex: 1.5, renderer : getDueDate},
  386. { header: 'nodeId', dataIndex: 'jp_nodeId', hidden: true}
  387. ],
  388. renderTo: Ext.get("myflow")
  389. });
  390. }
  391. }
  392. });
  393. },
  394. /**
  395. * 我的超时流程
  396. */
  397. _bench_overflow: function(){
  398. var me = this.workbench || this;
  399. /*Ext.Ajax.request({
  400. url : basePath + 'common/datalist.action',
  401. params: {
  402. caller: 'JProcess!MeOver',
  403. condition: 'jp_nodedealman=\'' + em_code + '\'',
  404. page: 1,
  405. pageSize: parseInt(height*0.3/12)
  406. },
  407. method : 'post',
  408. callback : function(options,success,response){
  409. var res = new Ext.decode(response.responseText);
  410. if(res.exception || res.exceptionInfo){
  411. var err = res.exceptionInfo;
  412. if(err.indexOf('ERR_POWER') != -1) {
  413. Ext.get("myoverflow").insertHtml('afterBegin',
  414. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  415. } else {
  416. showError(err);
  417. }
  418. return;
  419. }
  420. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  421. if(task == [] || task.length == 0){
  422. Ext.get("myoverflow").insertHtml('afterBegin', '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(暂无超时流程)</div>');
  423. } else {
  424. Ext.create('Ext.grid.Panel', {
  425. autoScroll: true,
  426. store: Ext.create('Ext.data.Store', {
  427. fields:['jp_id', 'jp_form', 'jp_launchTime','enddate', 'jt_duedate','jp_nodeId'],
  428. data: task
  429. }),
  430. height: me.height*0.76,
  431. bodyStyle: 'background: #f1f1f1;border: none;',
  432. columns: [
  433. { header: 'ID', dataIndex: 'jp_id', hidden: true},
  434. { header: '流程单据', dataIndex: 'jp_form', flex: 1.5 , renderer: flowOverItem},
  435. { header: '限办时间', dataIndex: 'enddate', flex: 1.5, renderer : getDueDate},
  436. { header: 'nodeId', dataIndex: 'jp_nodeId', hidden: true}
  437. ],
  438. renderTo: Ext.get("myoverflow")
  439. });
  440. }
  441. }
  442. });*/
  443. },
  444. /**
  445. * 待办事宜
  446. */
  447. _bench_task: function(){
  448. var grid = Ext.getCmp('bench_task').down('gridpanel');
  449. grid.store.removeAll();
  450. if(em_code==null) em_code=getCookie('em_code');
  451. Ext.Ajax.request({
  452. url : basePath + 'common/datalist.action',
  453. params: {
  454. caller: 'JProCand',
  455. condition: 'jp_candidate=\'' + em_code + '\' AND jp_status=\'待审批'+'\' AND jp_flag=1',
  456. page: 1,
  457. pageSize: 20,
  458. _noc:1
  459. },
  460. method : 'post',
  461. callback : function(options,success,response){
  462. var res = new Ext.decode(response.responseText);
  463. if(res.exception || res.exceptionInfo){
  464. var err = res.exceptionInfo;
  465. showError(err);
  466. return;
  467. }
  468. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  469. if(task.length > 0){
  470. var items = new Array();
  471. Ext.Array.each(task,function(item){
  472. item.id=item.jp_nodeId;
  473. item.name=item.jp_name+" "+item.jp_codevalue +"("+item.jp_launcherName+")";
  474. item.note=item.jp_processnote;
  475. item.note=item.jp_processnote;
  476. item.status=item.jp_status;
  477. item.type='可选流程';
  478. item.typecode='procand';
  479. items.push(item);
  480. });
  481. grid.store.add(items);
  482. }
  483. }
  484. });
  485. Ext.Ajax.request({
  486. url : basePath + 'common/datalist.action',
  487. params: {
  488. caller: 'JProcess!Me',
  489. condition: '(jp_nodedealman=\'' + em_code + '\' AND jp_status=\'待审批'+'\') or (jp_launcherid=\'' + em_code + '\' AND jp_status=\'未通过'+'\') ',
  490. page: 1,
  491. pageSize:20,
  492. _noc:1
  493. },
  494. method : 'post',
  495. callback : function(options,success,response){
  496. var res = new Ext.decode(response.responseText);
  497. if(res.exception || res.exceptionInfo){
  498. var err = res.exceptionInfo;
  499. showError(err);
  500. return;
  501. }
  502. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  503. if(task.length > 0){
  504. var items = new Array();
  505. Ext.Array.each(task,function(item){
  506. item.id=item.jp_nodeId;
  507. item.name=item.jp_name+" "+item.jp_codevalue +"("+item.jp_launcherName+")";
  508. item.note=item.jp_processnote;
  509. item.status=item.jp_status;
  510. if(!item.source || item.source==0){
  511. if(item.jp_status=='未通过'){
  512. item.type='未同意流程';
  513. item.typecode='unprocess';
  514. }else{
  515. item.type='待审批流程';
  516. item.typecode='process';
  517. }
  518. }else {
  519. item.type='待办转移流程';
  520. item.typecode='transferprocess';
  521. }
  522. items.push(item);
  523. });
  524. grid.store.add(items);
  525. }
  526. }
  527. });
  528. Ext.Ajax.request({
  529. url : basePath + 'common/datalist.action',
  530. params: {
  531. caller: 'ResourceAssignment',
  532. //condition: 'ra_emid=' + em_uu + ' AND ra_taskpercentdone<100',
  533. condition : '(ra_emid=\'' + em_uu + '\' AND ra_statuscode<>\'FINISHED'+'\') or (recorder=\'' + em_name + '\' AND ra_statuscode=\'UNCONFIRMED'+'\') ',
  534. page: 1,
  535. pageSize: 20,
  536. _noc:1
  537. },
  538. method : 'post',
  539. callback : function(options,success,response){
  540. var res = new Ext.decode(response.responseText);
  541. if(res.exception || res.exceptionInfo){
  542. var err = res.exceptionInfo;
  543. showError(err);
  544. return;
  545. }
  546. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  547. if(task.length > 0){
  548. var items = new Array();
  549. Ext.Array.each(task,function(item){
  550. item.id=item.ra_id;
  551. item.name=item.ra_taskname + (item.sourcecode || '');
  552. item.status=item.ra_status;
  553. item.type='待办任务';
  554. item.typecode=(item.ra_type || 'worktask');
  555. item.sourcelink=item.sourcelink;
  556. item.taskId=item.ra_taskid;
  557. items.push(item);
  558. });
  559. grid.store.add(items);
  560. }
  561. }
  562. });
  563. },
  564. _bench_news: function(){
  565. var me = this.workbench || this;
  566. me.getCmpNews();
  567. },
  568. /**
  569. * 内部新闻
  570. */
  571. getCmpNews: function(){
  572. Ext.Ajax.request({
  573. url : basePath + 'common/datalist.action',
  574. params: {
  575. caller: 'News',
  576. condition: '',
  577. page: 1,
  578. pageSize: parseInt(height*0.25/23),
  579. _noc:1
  580. },
  581. method : 'post',
  582. callback : function(options,success,response){
  583. var res = new Ext.decode(response.responseText);
  584. if(res.exception || res.exceptionInfo){
  585. var err = res.exceptionInfo;
  586. if(err.indexOf('ERR_POWER') != -1) {
  587. Ext.get("news").insertHtml('afterBegin',
  588. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  589. } else {
  590. showError(err);
  591. }
  592. return;
  593. }
  594. var news = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];
  595. /*Ext.Array.sort(news, function(a, b){
  596. return b.ne_releasedate > a.ne_releasedate;
  597. });*/
  598. var html = '<ul>';
  599. Ext.each(news, function(n){
  600. var bTime = new Date().getTime();
  601. var eTime = Ext.Date.parse(n.ne_releasedate.substring(0, 10) + ' 23:59:59','Y-m-d H:i:s').getTime();
  602. var allHour = (eTime - bTime)/(60*60*1000);
  603. if(allHour<-72){
  604. html += '<li>' + n.ne_releasedate.substring(0, 10) + '&nbsp;<img src="' + basePath +
  605. 'resource/images/mainpage/new.png"/>&nbsp;<a href="javascript:openTable(null,null,\'新闻\',\'oa/news/view.action?ne_id=' + n.ne_id + '\',\'ne_id\',null' + ')">'
  606. + Ext.String.charEllipsis(n.ne_theme, 32) + '</a></li>';
  607. } else{html += '<li>' + n.ne_releasedate.substring(0, 10) + '&nbsp;<img src="' + basePath +
  608. 'resource/images/mainpage/new.png"/>&nbsp;<a href="javascript:openTable(null,null,\'新闻\',\'oa/news/view.action?ne_id=' + n.ne_id + '\',\'ne_id\',null' + ')">'
  609. + Ext.String.charEllipsis(n.ne_theme, 32) + '</a><img src="' + basePath +
  610. 'resource/images/newitem.gif" /></li>';}
  611. });
  612. html += '</ul>';
  613. // html += '<img src="' + basePath + 'resource/images/icon/sina.png" title="新浪新闻" class="news-img" onclick="window.open(\'http://www.sina.com.cn/\')"/>';
  614. // html += '<img src="' + basePath + 'resource/images/icon/souhu.png" title="搜狐新闻" class="news-img" onclick="window.open(\'http://news.sohu.com//\')"/>';
  615. // html += '<img src="' + basePath + 'resource/images/icon/tencent.png" title="腾讯新闻" class="news-img" onclick="window.open(\'http://news.qq.com//\')"/>';
  616. // html += '<img src="' + basePath + 'resource/images/icon/yahoo.png" title="雅虎新闻" class="news-img" onclick="window.open(\'http://www.yahoo.com.cn//\')"/>';
  617. Ext.get("news").insertHtml('afterBegin', html);
  618. }
  619. });
  620. },
  621. _bench_note:function(){
  622. Ext.Ajax.request({
  623. url : basePath + 'common/datalist.action',
  624. params: {
  625. caller: 'NotifyJprocess',
  626. condition: 'prd_recipientid='+em_uu,
  627. page: 1,
  628. pageSize: parseInt(height*0.25/23),
  629. _noc:1
  630. },
  631. method : 'post',
  632. callback : function(options,success,response){
  633. Ext.get('note2').dom.innerHTML='';
  634. var res = new Ext.decode(response.responseText);
  635. if(res.exception || res.exceptionInfo){
  636. var err = res.exceptionInfo;
  637. if(err.indexOf('ERR_POWER') != -1) {
  638. Ext.get("note2").insertHtml('afterBegin',
  639. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  640. } else {
  641. showError(err);
  642. }
  643. return;
  644. }
  645. var notes = res.data!=null?Ext.decode(res.data):[];
  646. var html = '<ul>';
  647. Ext.each(notes, function(n,index){
  648. if(index<3){
  649. html += '<li>' +formatNote(n.PR_CONTEXT)+'<img src="' + basePath + 'resource/images/newitem.gif" /></li>';
  650. } else{html += '<li>' +formatNote(n.PR_CONTEXT)+'</li>';}
  651. });
  652. html += '</ul>';
  653. Ext.get("note2").insertHtml('afterBegin', html);
  654. }
  655. });
  656. },
  657. /**
  658. * 通知公告
  659. */
  660. _bench_notify: function(){
  661. Ext.Ajax.request({
  662. url : basePath + 'common/datalist.action',
  663. params: {
  664. caller: 'Note',
  665. condition: '',
  666. page: 1,
  667. pageSize:10,
  668. _noc:1
  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. var err = res.exceptionInfo;
  675. if(err.indexOf('ERR_POWER') != -1) {
  676. Ext.get("notify").insertHtml('afterBegin',
  677. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  678. } else {
  679. showError(err);
  680. }
  681. return;
  682. }
  683. var notes = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];
  684. /*Ext.Array.sort(notes, function(a, b){
  685. return b.no_apptime > a.no_apptime;
  686. });*/
  687. var height=Ext.getCmp('bench_notify').height;
  688. var html = '<div id="notifydata" style="font-size:12px;height:'+(height-45)+'px;overflow:hidden;"><ul>';
  689. var count=0;
  690. Ext.each(notes, function(n){
  691. if(n.CURRENTMASTER&&n.CURRENTMASTER!='DataCenter'){
  692. html += '<li style="height:24px;line-height:24px;">&nbsp;<img src="' + basePath +
  693. 'resource/images/mainpage/blogs.png"/>&nbsp;<a href="javascript:openTable('
  694. + n.no_id + ',\'Note\',\'通知\',\'jsps/oa/info/NoteR.jsp\',\'no_id\',null,null,' +'\''+n.CURRENTMASTER+'\''+ ')">'
  695. + Ext.String.charEllipsis(n.CURRENTMASTER+"-"+n.no_title, 80) + '</a>';
  696. }else html += '<li style="height:24px;line-height:24px;">&nbsp;<img src="' + basePath +
  697. 'resource/images/mainpage/blogs.png"/>&nbsp;<a href="javascript:openTable('
  698. + n.no_id + ',\'Note\',\'通知\',\'jsps/oa/info/NoteR.jsp\',\'no_id\',null'+ ')">'
  699. + Ext.String.charEllipsis(n.no_title, 50) + '</a>';
  700. if(count<4){
  701. html +='&nbsp;<img src="' + basePath + 'resource/images/mainpage/new.png"/></li>';
  702. }else html +='</li>';
  703. count++;
  704. });
  705. if(notes.length == 0){
  706. html = '<ul>没有记录';
  707. }
  708. html += '</ul></div>';
  709. Ext.get("notify").insertHtml('afterBegin', html);
  710. /*var $=function $(element){
  711. if(arguments.length>1){
  712. for(var i=0,length=arguments.length,elements=[];i<length;i++){
  713. elements.push($(arguments[i]));
  714. }
  715. return elements;
  716. }
  717. if(typeof element=="string"){
  718. return document.getElementById(element);
  719. }else{
  720. return element;
  721. }
  722. };
  723. var Class={
  724. create:function(){
  725. return function(){
  726. this.initialize.apply(this,arguments);
  727. };
  728. }
  729. };
  730. Function.prototype.bind=function(object){
  731. var method=this;
  732. return function(){
  733. method.apply(object,arguments);
  734. };
  735. };
  736. var Scroll=Class.create();
  737. Scroll.prototype={
  738. initialize:function(element,height){
  739. this.element=$(element);
  740. this.element.innerHTML+=this.element.innerHTML;
  741. this.height=height;
  742. this.maxHeight=this.element.scrollHeight/2;
  743. this.counter=0;
  744. this.scroll();
  745. this.timer="";
  746. this.element.onmouseover=this.stop.bind(this);
  747. this.element.onmouseout=function(){this.timer=setTimeout(this.scroll.bind(this),1000);}.bind(this);
  748. },
  749. scroll:function(){
  750. if(this.element.scrollTop<this.maxHeight){
  751. this.element.scrollTop++;
  752. this.counter++;
  753. }else{
  754. this.element.scrollTop=0;
  755. this.counter=0;
  756. }
  757. if(this.counter<this.height){
  758. this.timer=setTimeout(this.scroll.bind(this),20);
  759. }else{
  760. this.counter=0;
  761. this.timer=setTimeout(this.scroll.bind(this),3000);
  762. }
  763. },
  764. stop:function(){
  765. clearTimeout(this.timer);
  766. }
  767. };
  768. if(count*24>(height-45)) {setTimeout(function scroll(){
  769. new Scroll("notifydata",24);
  770. },8000);
  771. }*/
  772. }
  773. });
  774. },
  775. /**
  776. * 常用模块
  777. */
  778. _bench_link: function(){
  779. var me = this.workbench || this;
  780. Ext.Ajax.request({
  781. url : basePath + 'common/getCommonUse.action',
  782. method : 'get',
  783. callback : function(options,success,response){
  784. var res = new Ext.decode(response.responseText);
  785. if(res.exception || res.exceptionInfo){
  786. showError(res.exceptionInfo);
  787. return;
  788. }
  789. window._delete_bench_link = me._delete_bench_link;
  790. Ext.getCmp('bench_link').down('gridpanel').store.loadData(res.commonuse);
  791. }
  792. });
  793. },
  794. /**
  795. * 设置常用模块
  796. */
  797. _set_bench_link: function(snid){
  798. Ext.Ajax.request({
  799. url : basePath + 'common/setCommonUse.action',
  800. params: {
  801. snid: snid
  802. },
  803. method : 'post',
  804. callback : function(options,success,response){
  805. var res = new Ext.decode(response.responseText);
  806. if(res.exception || res.exceptionInfo){
  807. showError(res.exceptionInfo);
  808. return;
  809. }
  810. if(Ext.isIE) {
  811. setTimeout(function(){
  812. Ext.getCmp('link_grid').store.loadData(res.commonuse);
  813. }, 8000);
  814. } else {
  815. Ext.getCmp('link_grid').store.loadData(res.commonuse);
  816. }
  817. }
  818. });
  819. },
  820. _delete_bench_link: function(id){
  821. Ext.Ajax.request({
  822. url : basePath + 'common/deleteCommonUse.action',
  823. params: {
  824. id: id
  825. },
  826. method : 'post',
  827. callback : function(options,success,response){
  828. var res = new Ext.decode(response.responseText);
  829. if(res.exception || res.exceptionInfo){
  830. showError(res.exceptionInfo);
  831. return;
  832. }
  833. var grid = Ext.getCmp('link_grid');
  834. Ext.each(grid.store.data.items, function(item){
  835. if(item.data['cu_id'] == id){
  836. grid.store.remove(item);
  837. }
  838. });
  839. }
  840. });
  841. },
  842. /**
  843. * 查看我的考勤
  844. */
  845. _bench_schedule: function(){
  846. Ext.Ajax.request({
  847. url : basePath + 'oa/getMySign.action',
  848. async: false,
  849. method : 'post',
  850. callback : function(options,success,response){
  851. var res = new Ext.decode(response.responseText);
  852. if(res.exception || res.exceptionInfo){
  853. showError(res.exceptionInfo);
  854. return;
  855. }
  856. if(res.sign != null){
  857. Ext.getCmp('signin').signin = true;
  858. var d = new Date(res.sign.si_in);
  859. Ext.getCmp('signin').intime = res.sign.si_in;
  860. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 09:00:00', 'Y-m-d H:i:s').getTime();
  861. if(d > sin){
  862. Ext.getCmp('signin').tooltip = "签到时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  863. "&nbsp;&nbsp;迟到" + Math.floor((d - sin)/(60*60*1000)) + "小时" + Math.floor(((d - sin)%(60*60*1000))/(60*1000)) + "分钟" + "</font>";
  864. } else {
  865. Ext.getCmp('signin').tooltip = "签到时间:" + Ext.Date.format(d, 'H:i:s');
  866. Ext.getCmp('signin').setIconCls('x-button-icon-working');
  867. }
  868. if(res.sign.si_out) {
  869. d = new Date(res.sign.si_out);
  870. sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s').getTime();
  871. Ext.getCmp('signout').signout = true;
  872. if(d < sin) {
  873. Ext.getCmp('signout').setText("签退时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  874. "&nbsp;&nbsp;早退" + Math.floor((sin - d)/(60*60*1000)) + "小时" + Math.floor(((sin - d)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  875. } else {
  876. Ext.getCmp('signout').setText("签退时间:" + Ext.Date.format(d, 'H:i:s'));
  877. }
  878. }
  879. Ext.getCmp('signout').show();
  880. }
  881. }
  882. });
  883. showClock();
  884. },
  885. refreshTask:refreshTask
  886. };
  887. /**
  888. * 刷新待办事宜
  889. * */
  890. function refreshTask(onlyProcess){
  891. var grid = Ext.getCmp('bench_task').down('gridpanel');
  892. grid.store.removeAll();
  893. Ext.Ajax.request({
  894. url : basePath + 'common/datalist.action',
  895. params: {
  896. caller: 'JProCand',
  897. condition: 'jp_candidate=\'' + em_code + '\' AND jp_status=\'待审批'+'\' AND jp_flag=1',
  898. page: 1,
  899. pageSize: 20,
  900. _noc:1
  901. },
  902. method : 'post',
  903. callback : function(options,success,response){
  904. var res = new Ext.decode(response.responseText);
  905. if(res.exception || res.exceptionInfo){
  906. var err = res.exceptionInfo;
  907. showError(err);
  908. return;
  909. }
  910. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  911. if(task.length > 0){
  912. var items = new Array();
  913. Ext.Array.each(task,function(item){
  914. item.id=item.jp_nodeId;
  915. item.name=item.jp_name+" "+item.jp_codevalue+"("+item.jp_launcherName+")";
  916. item.note=item.jp_processnote;
  917. item.status=item.jp_status;
  918. item.type='可选流程';
  919. item.typecode='procand';
  920. items.push(item);
  921. });
  922. grid.store.add(items);
  923. }
  924. }
  925. });
  926. Ext.Ajax.request({
  927. url : basePath + 'common/datalist.action',
  928. params: {
  929. caller: 'JProcess!Me',
  930. condition: '(jp_nodedealman=\'' + em_code + '\' AND jp_status=\'待审批'+'\') or (jp_launcherid=\'' + em_code + '\' AND jp_status=\'未通过'+'\') ',
  931. page: 1,
  932. pageSize:20,
  933. _noc:1
  934. },
  935. method : 'post',
  936. callback : function(options,success,response){
  937. var res = new Ext.decode(response.responseText);
  938. if(res.exception || res.exceptionInfo){
  939. var err = res.exceptionInfo;
  940. showError(err);
  941. return;
  942. }
  943. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  944. if(task.length > 0){
  945. var items = new Array();
  946. Ext.Array.each(task,function(item){
  947. item.id=item.jp_nodeId;
  948. item.name=item.jp_name+" "+item.jp_codevalue +"("+item.jp_launcherName+")";
  949. item.note=item.jp_processnote;
  950. item.status=item.jp_status;
  951. if(!item.source || item.source==0){
  952. if(item.jp_status=='未通过'){
  953. item.type='未同意流程';
  954. item.typecode='unprocess';
  955. }else{
  956. item.type='待审批流程';
  957. item.typecode='process';
  958. }
  959. }else {
  960. item.type='待办转移流程';
  961. item.typecode='transferprocess';
  962. }
  963. items.push(item);
  964. });
  965. grid.store.add(items);
  966. }
  967. }
  968. });
  969. if(!onlyProcess){
  970. Ext.Ajax.request({
  971. url : basePath + 'common/datalist.action',
  972. params: {
  973. caller: 'ResourceAssignment',
  974. condition: 'ra_emid=' + em_uu + ' AND ra_taskpercentdone<100',
  975. page: 1,
  976. pageSize: 20,
  977. _noc:1
  978. },
  979. method : 'post',
  980. callback : function(options,success,response){
  981. var res = new Ext.decode(response.responseText);
  982. if(res.exception || res.exceptionInfo){
  983. var err = res.exceptionInfo;
  984. showError(err);
  985. return;
  986. }
  987. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  988. if(task.length > 0){
  989. var items = new Array();
  990. Ext.Array.each(task,function(item){
  991. item.id=item.ra_id;
  992. item.name=item.ra_taskname + (item.sourcecode || '');
  993. item.status=item.ra_status;
  994. item.type='待办任务';
  995. item.typecode=(item.ra_type || 'worktask');
  996. item.sourcelink=item.sourcelink;
  997. items.push(item);
  998. });
  999. grid.store.add(items);
  1000. }
  1001. }
  1002. });
  1003. }
  1004. getNotifyCount();
  1005. }
  1006. function getNotifyCount(){
  1007. var count=0;
  1008. Ext.Ajax.request({
  1009. url : basePath + 'common/getCountByTable.action',
  1010. params: {
  1011. tablename: 'pagingrelease left join pagingreleasedetail on pr_id=prd_prid',
  1012. condition: "prd_recipientid=" + em_uu+" and prd_readstatus=0 and nvl(pr_from,' ')='jprocess'",
  1013. _noc:1
  1014. },
  1015. method : 'post',
  1016. async:false,
  1017. callback : function(options,success,response){
  1018. var res = new Ext.decode(response.responseText);
  1019. if(res.exception || res.exceptionInfo){
  1020. var err = res.exceptionInfo;
  1021. showError(err);
  1022. return;
  1023. }
  1024. count=res.count;
  1025. }
  1026. });
  1027. var countinfo=document.getElementById('messagecount');
  1028. if(countinfo){
  1029. countinfo.innerHTML='知会('+count+")";
  1030. }
  1031. return count;
  1032. }
  1033. /**
  1034. * 打开一个tab
  1035. * @param id 当前record的ID
  1036. * @param caller
  1037. * @param title 标题
  1038. * @param link 链接
  1039. * @param key 主表ID字段
  1040. * @param detailKey 从表关联主表ID的字段
  1041. * @param condition 附加条件
  1042. */
  1043. function openTable(id, caller, title, link, key, detailKey, condition,relateMaster,limit){
  1044. var main = parent.Ext.getCmp("content-panel");
  1045. var item=main.items.items[0];
  1046. item.firstGrid=Ext.getCmp('task_grid');
  1047. var panel = Ext.getCmp('' + id);
  1048. var url = parseUrl(link);
  1049. if(caller){
  1050. panel = Ext.getCmp(caller);
  1051. url = link + '?whoami=' + caller;
  1052. }
  1053. if(id){
  1054. if(caller){
  1055. panel = Ext.getCmp(caller + id);
  1056. url = link + '?whoami=' + caller + '&formCondition=' + key + '=' + id + '&gridCondition=' + detailKey + '=' + id;
  1057. }
  1058. } else {
  1059. if(condition != null){
  1060. url += '&urlcondition=' + parseUrl(condition);
  1061. }
  1062. }
  1063. if(!limit){
  1064. if(url.indexOf('?') > 0)
  1065. url += '&_noc=1';
  1066. else
  1067. url += '?_noc=1';
  1068. }
  1069. if(relateMaster){
  1070. url+='&newMaster='+relateMaster;
  1071. }
  1072. if( relateMaster ){
  1073. var currentMaster = parent.window.sob;
  1074. if ( currentMaster && currentMaster != relateMaster) {// 与当前帐套不一致
  1075. if (parent.Ext) {
  1076. Ext.Ajax.request({
  1077. url: basePath + 'common/changeMaster.action',
  1078. params: {
  1079. to: relateMaster
  1080. },
  1081. callback: function(opt, s, r) {
  1082. if (s) {
  1083. var win = parent.Ext.create('Ext.Window', {
  1084. width: '100%',
  1085. height: '100%',
  1086. draggable: false,
  1087. closable: false,
  1088. modal: true,
  1089. id:'modalwindow',
  1090. historyMaster:currentMaster,
  1091. title: '创建到帐套' + relateMaster + '的临时会话',
  1092. html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  1093. buttonAlign: 'center',
  1094. buttons: [{
  1095. text: $I18N.common.button.erpCloseButton,
  1096. cls: 'x-btn-blue',
  1097. id: 'close',
  1098. handler: function(b) {
  1099. Ext.Ajax.request({
  1100. url: basePath + 'common/changeMaster.action',
  1101. params: {
  1102. to: currentMaster
  1103. },
  1104. callback: function(opt, s, r) {
  1105. if (s) {
  1106. b.up('window').close();
  1107. } else {
  1108. alert('切换到原帐套失败!');
  1109. }
  1110. }
  1111. });
  1112. }
  1113. }]
  1114. });
  1115. win.show();
  1116. } else {
  1117. alert('无法创建到帐套' + relateMaster + '的临时会话!');
  1118. }
  1119. }
  1120. });
  1121. }
  1122. return;
  1123. }
  1124. }
  1125. if(!panel){
  1126. panel = {
  1127. title : title.substring(0, title.toString().length > 5 ? 5 : title.toString().length),
  1128. tag : 'iframe',
  1129. tabConfig:{tooltip: title},
  1130. border : false,
  1131. layout : 'fit',
  1132. iconCls : 'x-tree-icon-tab-tab',
  1133. html : '<iframe id="iframe" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  1134. closable : true,
  1135. listeners : {
  1136. close : function(){
  1137. main.setActiveTab(main.getActiveTab().id);
  1138. }
  1139. }
  1140. };
  1141. openTab(panel, panel.id);
  1142. }else{
  1143. main.setActiveTab(panel);
  1144. }
  1145. }
  1146. function parseUrl(url) {
  1147. var id = url.substring(url.lastIndexOf('?')+1);
  1148. if (id == null) {
  1149. id = url.substring(0,url.lastIndexOf('.'));
  1150. }
  1151. if(contains(url, 'session:em_uu', true)){
  1152. url = url.replace(/session:em_uu/,em_uu);
  1153. }
  1154. if(contains(url, 'session:em_code', true)){
  1155. url = url.replace(/session:em_code/, "'" + em_code + "'");
  1156. }
  1157. if(contains(url, 'sysdate', true)){
  1158. url = url.replace(/sysdate/, "to_date('" + Ext.Date.toString(new Date()) + "','yyyy-mm-dd')");
  1159. }
  1160. if(contains(url, 'session:em_name', true)){
  1161. url = url.replace(/session:em_name/,"'"+em_name+"'" );
  1162. }
  1163. return url;
  1164. }
  1165. function openTab(panel, id){
  1166. var o = (typeof panel == "string" ? panel : id || panel.id);
  1167. var main = parent.Ext.getCmp("content-panel");
  1168. var tab = main.getComponent(o);
  1169. if (tab) {
  1170. main.setActiveTab(tab);
  1171. } else if(typeof panel!="string"){
  1172. panel.id = o;
  1173. var p = main.add(panel);
  1174. main.setActiveTab(p);
  1175. }
  1176. }
  1177. function taskItem(val, meta, record){
  1178. var rendermsg='';
  1179. if(record.data.CURRENTMASTER){
  1180. if(record.data.typecode=='worktask' || record.data.typecode=='projecttask'){
  1181. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment\',\'任务\',\'jsps/plm/record/workrecord.jsp\',\'ra_id\',\'wr_raid\',null,' +'\''+record.data.CURRENTMASTER+'\''+ ');">' + val + '</a>';
  1182. } else if(record.data.typecode=='billtask' || record.data.typecode=='mrptask'){
  1183. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment!Bill\',\'任务\',\'jsps/plm/record/billrecord.jsp\',\'ra_id\',null,null,\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1184. } else if(record.data.typecode=='kbitask' || record.data.typecode=='mrptask'){
  1185. rendermsg='<a href="javascript:openUrl(' +'\''+record.data['sourcelink'] + '\',\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1186. }else if(record.data.typecode=='process'||record.data.typecode=='unprocess' || record.data.typecode=='transferprocess') return '<a href="javascript:openTable(' + record.data['id'] + ',\'JProcess!Me\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null,null,' +'\''+record.data.CURRENTMASTER+'\'' +');">' + val + '</a>';
  1187. else rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'JProCand\',\'任务流程\',\'jsps/common/jtaketask.jsp\',\'jp_nodeId\',jp_flag=1,null,' +'\''+record.data.CURRENTMASTER+'\''+');">' + val + '</a>';
  1188. } else {
  1189. if(record.data.typecode=='worktask' || record.data.typecode=='projecttask'){
  1190. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment\',\'任务\',\'jsps/plm/record/workrecord.jsp\',\'ra_id\',\'wr_raid\'' + ');">' + val + '</a>';
  1191. } else if(record.data.typecode=='billtask' || record.data.typecode=='mrptask'){
  1192. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment!Bill\',\'任务\',\'jsps/plm/record/billrecord.jsp\',\'ra_id\',null);">' + val + '</a>';
  1193. } else if(record.data.typecode=='communicatetask'){
  1194. rendermsg='<a href="javascript:openTable(' + record.data['taskId'] + ',\'ResourceAssignment!Bill\',\'沟通任务\',\'jsps/common/JprocessCommunicate.jsp\',\'id\',null);">' + val + '</a>';
  1195. } else if(record.data.typecode=='kbitask' ){
  1196. rendermsg='<a href="javascript:openUrl(' +'\''+record.data['sourcelink'] + '\',\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1197. }else if(record.data.typecode=='process'||record.data.typecode=='unprocess' || record.data.typecode=='transferprocess') {
  1198. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'JProcess!Me\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');">' + val + '</a>';
  1199. if(record.data.note && record.data.note!=null && record.data.note !='null' ){
  1200. rendermsg+='</br><font color="#669933" >'+record.data.note+'</font>';
  1201. }
  1202. }
  1203. else rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'JProCand\',\'任务流程\',\'jsps/common/jtaketask.jsp\',\'jp_nodeId\',jp_flag=1' + ');">' + val + '</a>';
  1204. }
  1205. if(record.data.RN && record.data.RN==1){
  1206. return rendermsg+'&nbsp;<img src="' + basePath + 'resource/images/mainpage/new.png"/>';
  1207. }else return rendermsg;
  1208. }
  1209. function showMaster(val,meta,record){
  1210. if(record.data.CURRENTMASTER){
  1211. return val+'-<span style="color:red;">' + record.data.CURRENTMASTER + '</span>';
  1212. }else return val;
  1213. }
  1214. function flowItem(val, meta, record){
  1215. return '<a href="javascript:openTable(' + record.data['jp_nodeId'] + ',\'JProcess!Me\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');">' + val + '</a>';
  1216. }
  1217. function flowOverItem(val, meta, record){
  1218. return '<a href="javascript:openTable(' + record.data['jp_nodeId'] + ',\'JProcess!MeOver\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');">' + val + '</a>';
  1219. }
  1220. function getSurPlus(val, meta, record){
  1221. if(Ext.isEmpty(val))
  1222. return '--';
  1223. if(record.data.ra_taskpercentdone == 100){
  1224. return '<img src="' + basePath + 'resource/images/renderer/award2.png">' + '<span style="color:green;padding-left:2px">已完成</span>';
  1225. } else {
  1226. var bTime = new Date().getTime();
  1227. var eTime = Ext.Date.parse(record.data['ra_enddate'].substring(0, 10) + ' 23:59:59','Y-m-d H:i:s').getTime();
  1228. var allHour = (eTime - bTime)/(60*60*1000);
  1229. if(allHour < 0){
  1230. if(allHour < -24){
  1231. val = "<font color =red>过期" + Math.floor(Math.abs(allHour)/24) + "天" + Math.floor(Math.abs(allHour)%24) + "小时";
  1232. } else {
  1233. val = "<font color =red>过期" + Math.floor(Math.abs(allHour)) + "小时";
  1234. }
  1235. } else {
  1236. val = "<font color =blue>剩余" + Math.floor(allHour/24) + "天" + Math.floor(allHour%24) + "小时";
  1237. }
  1238. return val;
  1239. }
  1240. }
  1241. function percentdone(val, meta, record){
  1242. val == null || 0;
  1243. if(val < 30)
  1244. return '<img src="' + basePath + 'resource/images/renderer/remind2.png">'+'<span style="color:#436EEE;padding-left:2px">' + val + '</span>';
  1245. else if(val > 30 && val < 50)
  1246. return '<img src="' + basePath + 'resource/images/renderer/remind.png">'+'<span style="color:#5F9EA0;padding-left:2px">' + val + '</span>';
  1247. else if(val == 100){
  1248. return '<img src="' + basePath + 'resource/images/renderer/award1.png">'+'<span style="color:blue;padding-left:2px">' + val + '</span>';
  1249. }else if(val > 80){
  1250. return '<img src="' + basePath + 'resource/images/renderer/award2.png">'+'<span style="color:green;padding-left:2px">' + val + '</span>';
  1251. }
  1252. else
  1253. return val;
  1254. }
  1255. function showClock(){
  1256. var now = new Date();
  1257. var html = '';
  1258. var hours = now.getHours();
  1259. var minutes = now.getMinutes();
  1260. var seconds = now.getSeconds();
  1261. if(hours < 9 && Ext.getCmp('signin').signin == false){
  1262. Ext.getCmp('signin').setText("签到&nbsp;&nbsp;剩余" + (8 - hours) + "小时" + (60 - minutes) + "分钟" + (60 - seconds) + "秒");
  1263. } else {
  1264. if (Ext.getCmp('signin').signin == true) {
  1265. var intime = Number(Ext.getCmp('signin').intime);
  1266. if(intime && intime > 0) {
  1267. var time = now.getTime();
  1268. var h = Math.floor((time - intime)/(60*60*1000));
  1269. var m = Math.floor(((time - intime)%(60*60*1000))/(60*1000));
  1270. var s = Math.floor(((time - intime)%(60*1000))/(1000));
  1271. Ext.getCmp('signin').setText(Ext.getCmp('signin').tooltip + "<br/>&nbsp;<font color=blue>已工作" + (h) + "小时" + (m) + "分钟" + (s) + "秒</font>");
  1272. } else {
  1273. Ext.getCmp('signin').setText(Ext.getCmp('signin').tooltip);
  1274. }
  1275. if(Ext.getCmp('signout').signout == false) {
  1276. if(hours < 18){
  1277. Ext.getCmp('signout').setText("签退<br/>&nbsp;<font color=blue>距离下班" + (18 - hours) + "小时" + (60 - minutes) + "分钟" + (60 - seconds) + "秒</font>");
  1278. } else {
  1279. Ext.getCmp('signout').setText("签退<br/>&nbsp;<font color=blue>下班时间已到</font>");
  1280. }
  1281. }
  1282. } else {//还没签到
  1283. Ext.getCmp('signin').setText("签到&nbsp;&nbsp;<font color=red>迟到" + (hours - 9) + "小时" + (minutes) + "分钟" + (seconds) + "秒</font>");
  1284. }
  1285. }
  1286. if(hours <= 9){
  1287. hours = '0' + hours;
  1288. }
  1289. if(minutes <= 9){
  1290. minutes = '0' + minutes;
  1291. }
  1292. if(seconds < 10){
  1293. seconds = '0' + seconds;
  1294. }
  1295. var array = Ext.Array.toArray('' + hours + '-' + minutes + '-' + seconds);
  1296. Ext.each(array, function(n){
  1297. if (n == '-') {
  1298. html += '<a class="number" style="background-position: -' + 24*10 + 'px -0px"></a>';
  1299. } else {
  1300. html += '<a class="number" style="background-position: -' + 24*n + 'px -0px"></a>';
  1301. }
  1302. });
  1303. Ext.getCmp('clock').setText(html);
  1304. setTimeout("showClock();", 1000);
  1305. }
  1306. function signin(){
  1307. var hours = new Date().getHours();
  1308. if(hours >= 9){
  1309. Ext.MessageBox.prompt("原因", "请如实填写迟到原因", function (btn, text) {
  1310. if(btn == 'ok'){
  1311. _signin(text);
  1312. }
  1313. }, this, true, '睡觉睡过头了!');
  1314. } else {
  1315. _signin(null);
  1316. }
  1317. }
  1318. function _signin(reason){
  1319. Ext.Ajax.request({
  1320. url : basePath + 'oa/signin.action',
  1321. method : 'post',
  1322. async: false,
  1323. params: {
  1324. reason: reason
  1325. },
  1326. callback : function(options,success,response){
  1327. var res = new Ext.decode(response.responseText);
  1328. if(res.exception || res.exceptionInfo){
  1329. showError(res.exceptionInfo);
  1330. return;
  1331. }
  1332. if(res.success){
  1333. Ext.getCmp('signin').signin = true;
  1334. Ext.getCmp('signout').show();
  1335. var d = new Date();
  1336. Ext.getCmp('signin').intime = new Date().getTime();
  1337. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 09:00:00', 'Y-m-d H:i:s').getTime();
  1338. if(d > sin) {
  1339. Ext.getCmp('signin').setText("签到时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  1340. "&nbsp;&nbsp;迟到" + Math.floor((d - sin)/(60*60*1000)) + "小时" + Math.floor(((d - sin)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  1341. Ext.getCmp('signin').tooltip = "签到时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  1342. "&nbsp;&nbsp;迟到" + Math.floor((d - sin)/(60*60*1000)) + "小时" + Math.floor(((d - sin)%(60*60*1000))/(60*1000)) + "分钟" + "</font>";
  1343. } else {
  1344. Ext.getCmp('signin').setText("签到时间:" + Ext.Date.format(d, 'H:i:s'));
  1345. Ext.getCmp('signin').tooltip = "签到时间:" + Ext.Date.format(d, 'H:i:s');
  1346. }
  1347. Ext.getCmp('signin').setIconCls('x-button-icon-working');
  1348. alert("签到时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1349. }
  1350. }
  1351. });
  1352. }
  1353. function signout(){
  1354. var sout = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s');
  1355. if(sout > new Date()){
  1356. Ext.MessageBox.prompt("原因", "请如实填写早退原因", function (btn, text) {
  1357. if(btn == 'ok'){
  1358. _signout(text);
  1359. }
  1360. }, this, true, '太累了!');
  1361. } else {
  1362. _signout(null);
  1363. }
  1364. }
  1365. function _signout(reason) {
  1366. Ext.Ajax.request({
  1367. url : basePath + 'oa/signout.action',
  1368. method : 'post',
  1369. params: {
  1370. reason: reason
  1371. },
  1372. callback : function(options,success,response){
  1373. var res = new Ext.decode(response.responseText);
  1374. if(res.exception || res.exceptionInfo){
  1375. showError(res.exceptionInfo);
  1376. return;
  1377. }
  1378. if(res.success){
  1379. Ext.getCmp('signout').signout = true;
  1380. var d = new Date();
  1381. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s').getTime();
  1382. if(d < sin) {
  1383. Ext.getCmp('signout').setText("签退时间:<font color=red>" + Ext.Date.format(d, 'Y-m-d H:i:s') +
  1384. "&nbsp;&nbsp;早退" + Math.floor((sin - d)/(60*60*1000)) + "小时" + Math.floor(((sin - d)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  1385. } else {
  1386. Ext.getCmp('signout').setText("签退时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1387. }
  1388. alert("签退时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1389. }
  1390. }
  1391. });
  1392. }
  1393. function getMyBench(){
  1394. Ext.Ajax.request({
  1395. url : basePath + 'common/getWorkBench.action',
  1396. method : 'get',
  1397. callback : function(options,success,response){
  1398. var res = new Ext.decode(response.responseText);
  1399. if(res.exceptionInfo) {
  1400. showError(res.exceptionInfo);
  1401. } else {
  1402. var bench = res.benchs;
  1403. if(bench.length == 0){
  1404. bench = getDefaultBench();
  1405. }
  1406. var e = Ext.getCmp('bench').getEl().dom,
  1407. h = parseInt(Number(e.style.height.replace('px', ''))/3) - 1;
  1408. Ext.each(bench, function(b){
  1409. workbench.setWidth(b.wb_width);
  1410. if(b.wb_height > 0.6) {
  1411. workbench.setHeight(h*2);
  1412. } else {
  1413. workbench.setHeight(h);
  1414. }
  1415. var panel = workbench[b.wb_name].apply();
  1416. Ext.getCmp('bench').add(panel);
  1417. });
  1418. Ext.each(bench, function(b){
  1419. if(workbench["_" + b.wb_name]){
  1420. workbench["_" + b.wb_name].apply();
  1421. }
  1422. });
  1423. }
  1424. }
  1425. });
  1426. }
  1427. function getDefaultBench(){
  1428. return [{
  1429. wb_name: 'bench_task',
  1430. wb_width: 2/3,
  1431. wb_height: 2/3
  1432. },{
  1433. wb_name: 'bench_link',
  1434. wb_width: 1/3,
  1435. wb_height: 2/3
  1436. },{
  1437. wb_name: 'bench_notify',
  1438. wb_width: 1/3,
  1439. wb_height: 1/3
  1440. },{
  1441. wb_name: 'bench_news',
  1442. wb_width: 1/3,
  1443. wb_height: 1/3
  1444. },{
  1445. wb_name:'bench_subscription',
  1446. wb_width: 1/3,
  1447. wb_height: 1/3
  1448. }];
  1449. }
  1450. function getDueDate(val, meta, record){
  1451. var endDate = '';
  1452. if(record.data['jt_duedate'] == 0){
  1453. return "无限时";
  1454. } else{
  1455. endDate = Ext.Date.format(new Date(Ext.Date.parse(record.data['jp_launchTime'], 'Y-m-d H:i:s')
  1456. .getTime() + record.data['jt_duedate']*3600), 'Y-m-d H:i:s');
  1457. }
  1458. return endDate;
  1459. }
  1460. function formatNote(context){
  1461. context=context.replace(/<\s*\/?br>/g, " ");
  1462. context=context.replace('你有新流程需处理!'," ");
  1463. context=context.replace(/&nbsp;&nbsp;&nbsp;&nbsp;/g," ");
  1464. return context;
  1465. }
  1466. function getDefaultShort(){
  1467. return [{
  1468. sc_name: 'short_setting'
  1469. },{
  1470. sc_name: 'short_news'
  1471. },{
  1472. sc_name: 'short_address'
  1473. },{
  1474. sc_name: 'short_calendar'
  1475. },{
  1476. sc_name: 'short_email'
  1477. },{
  1478. sc_name: 'short_bbs'
  1479. }];
  1480. }