workBench.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479
  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_statuscode<>\'FINISHED'+'\') or (recorder=\'' + em_name + '\' AND ra_statuscode=\'UNCONFIRMED'+'\') ',
  533. page: 1,
  534. pageSize: 20,
  535. _noc:1
  536. },
  537. method : 'post',
  538. callback : function(options,success,response){
  539. var res = new Ext.decode(response.responseText);
  540. if(res.exception || res.exceptionInfo){
  541. var err = res.exceptionInfo;
  542. showError(err);
  543. return;
  544. }
  545. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  546. if(task.length > 0){
  547. var items = new Array();
  548. Ext.Array.each(task,function(item){
  549. item.id=item.ra_id;
  550. item.name=item.ra_taskname + (item.sourcecode || '');
  551. item.status=item.ra_status;
  552. item.type='待办任务';
  553. item.typecode=(item.ra_type || 'worktask');
  554. item.sourcelink=item.sourcelink;
  555. item.taskId=item.ra_taskid;
  556. items.push(item);
  557. });
  558. grid.store.add(items);
  559. }
  560. }
  561. });
  562. },
  563. _bench_news: function(){
  564. var me = this.workbench || this;
  565. me.getCmpNews();
  566. },
  567. /**
  568. * 内部新闻
  569. */
  570. getCmpNews: function(){
  571. Ext.Ajax.request({
  572. url : basePath + 'common/datalist.action',
  573. params: {
  574. caller: 'News',
  575. condition: '',
  576. page: 1,
  577. pageSize: parseInt(height*0.25/23),
  578. _noc:1
  579. },
  580. method : 'post',
  581. callback : function(options,success,response){
  582. var res = new Ext.decode(response.responseText);
  583. if(res.exception || res.exceptionInfo){
  584. var err = res.exceptionInfo;
  585. if(err.indexOf('ERR_POWER') != -1) {
  586. Ext.get("news").insertHtml('afterBegin',
  587. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  588. } else {
  589. showError(err);
  590. }
  591. return;
  592. }
  593. var news = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];
  594. /*Ext.Array.sort(news, function(a, b){
  595. return b.ne_releasedate > a.ne_releasedate;
  596. });*/
  597. var html = '<ul class="list-default">';
  598. Ext.each(news, function(n){
  599. var bTime = new Date().getTime();
  600. var eTime = Ext.Date.parse(n.ne_releasedate.substring(0, 10) + ' 23:59:59','Y-m-d H:i:s').getTime();
  601. var allHour = (eTime - bTime)/(60*60*1000);
  602. if(allHour<-72){
  603. html += '<li>' + n.ne_releasedate.substring(0, 10) + '&nbsp;<img src="' + basePath +
  604. 'resource/images/mainpage/new.png"/>&nbsp;<a href="javascript:openTable(null,null,\'新闻\',\'oa/news/view.action?ne_id=' + n.ne_id + '\',\'ne_id\',null' + ')">'
  605. + n.ne_theme + '</a></li>';
  606. } else{html += '<li>' + n.ne_releasedate.substring(0, 10) + '&nbsp;<img src="' + basePath +
  607. 'resource/images/mainpage/new.png"/>&nbsp;<a href="javascript:openTable(null,null,\'新闻\',\'oa/news/view.action?ne_id=' + n.ne_id + '\',\'ne_id\',null' + ')">'
  608. + n.ne_theme + '</a><img src="' + basePath +
  609. 'resource/images/newitem.gif" /></li>';}
  610. });
  611. html += '</ul>';
  612. Ext.get("news").insertHtml('afterBegin', html);
  613. }
  614. });
  615. },
  616. _bench_note:function(){
  617. Ext.Ajax.request({
  618. url : basePath + 'common/datalist.action',
  619. params: {
  620. caller: 'NotifyJprocess',
  621. condition: 'prd_recipientid='+em_uu,
  622. page: 1,
  623. pageSize: parseInt(height*0.25/23),
  624. _noc:1
  625. },
  626. method : 'post',
  627. callback : function(options,success,response){
  628. Ext.get('note2').dom.innerHTML='';
  629. var res = new Ext.decode(response.responseText);
  630. if(res.exception || res.exceptionInfo){
  631. var err = res.exceptionInfo;
  632. if(err.indexOf('ERR_POWER') != -1) {
  633. Ext.get("note2").insertHtml('afterBegin',
  634. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  635. } else {
  636. showError(err);
  637. }
  638. return;
  639. }
  640. var notes = res.data!=null?Ext.decode(res.data):[];
  641. var html = '<ul>';
  642. Ext.each(notes, function(n,index){
  643. if(index<3){
  644. html += '<li>' +formatNote(n.PR_CONTEXT)+'<img src="' + basePath + 'resource/images/newitem.gif" /></li>';
  645. } else{html += '<li>' +formatNote(n.PR_CONTEXT)+'</li>';}
  646. });
  647. html += '</ul>';
  648. Ext.get("note2").insertHtml('afterBegin', html);
  649. }
  650. });
  651. },
  652. /**
  653. * 通知公告
  654. */
  655. _bench_notify: function(){
  656. Ext.Ajax.request({
  657. url : basePath + 'common/datalist.action',
  658. params: {
  659. caller: 'Note',
  660. condition:" no_approver=\'"+em_name+"\' or no_ispublic=-1 or (no_ispublic=0 and (no_recipientid like '%org#'||\'"+em_defaultorid+"\'||'%' or no_recipientid like '%job#'||\'"+em_defaulthsid+"\'||'%' or no_recipientid like '%employee#'||\'"+em_id+"\'||'%'))",
  661. page: 1,
  662. pageSize:10,
  663. _noc:1
  664. },
  665. method : 'post',
  666. callback : function(options,success,response){
  667. var res = new Ext.decode(response.responseText);
  668. if(res.exception || res.exceptionInfo){
  669. var err = res.exceptionInfo;
  670. if(err.indexOf('ERR_POWER') != -1) {
  671. Ext.get("notify").insertHtml('afterBegin',
  672. '<div style="color:gray;font-size:26px; line-height: 60px;" align="center">(您无权限查看此信息)</div>');
  673. } else {
  674. showError(err);
  675. }
  676. return;
  677. }
  678. var notes = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : [];
  679. /*Ext.Array.sort(notes, function(a, b){
  680. return b.no_apptime > a.no_apptime;
  681. });*/
  682. var height=Ext.getCmp('bench_notify').height;
  683. var html = '<div id="notifydata" style="font-size:12px;height:'+(height-45)+'px;overflow:hidden;"><ul class="list-default">';
  684. var count=0;
  685. Ext.each(notes, function(n){
  686. if(n.CURRENTMASTER&&n.CURRENTMASTER!='DataCenter'){
  687. html += '<li style="height:24px;line-height:24px;">&nbsp;<img src="' + basePath +
  688. 'resource/images/mainpage/blogs.png"/>&nbsp;<a href="javascript:openTable('
  689. + n.no_id + ',\'Note\',\'通知\',\'jsps/oa/info/NoteR.jsp\',\'no_id\',null,null,' +'\''+n.CURRENTMASTER+'\''+ ')">'
  690. + Ext.String.charEllipsis(n.CURRENTMASTER+"-"+n.no_title, 80) + '</a>';
  691. }else html += '<li style="height:24px;line-height:24px;">&nbsp;<img src="' + basePath +
  692. 'resource/images/mainpage/blogs.png"/>&nbsp;<a href="javascript:openTable('
  693. + n.no_id + ',\'Note\',\'通知\',\'jsps/oa/info/NoteR.jsp\',\'no_id\',null'+ ')">'
  694. + Ext.String.charEllipsis(n.no_title, 50) + '</a>';
  695. if(count<4){
  696. html +='&nbsp;<img src="' + basePath + 'resource/images/mainpage/new.png"/></li>';
  697. }else html +='</li>';
  698. count++;
  699. });
  700. if(notes.length == 0){
  701. html = '<ul style="text-align:center;padding-top: 30px;color:#888">没有记录';
  702. }
  703. html += '</ul></div>';
  704. Ext.get("notify").insertHtml('afterBegin', html);
  705. /*var $=function $(element){
  706. if(arguments.length>1){
  707. for(var i=0,length=arguments.length,elements=[];i<length;i++){
  708. elements.push($(arguments[i]));
  709. }
  710. return elements;
  711. }
  712. if(typeof element=="string"){
  713. return document.getElementById(element);
  714. }else{
  715. return element;
  716. }
  717. };
  718. var Class={
  719. create:function(){
  720. return function(){
  721. this.initialize.apply(this,arguments);
  722. };
  723. }
  724. };
  725. Function.prototype.bind=function(object){
  726. var method=this;
  727. return function(){
  728. method.apply(object,arguments);
  729. };
  730. };
  731. var Scroll=Class.create();
  732. Scroll.prototype={
  733. initialize:function(element,height){
  734. this.element=$(element);
  735. this.element.innerHTML+=this.element.innerHTML;
  736. this.height=height;
  737. this.maxHeight=this.element.scrollHeight/2;
  738. this.counter=0;
  739. this.scroll();
  740. this.timer="";
  741. this.element.onmouseover=this.stop.bind(this);
  742. this.element.onmouseout=function(){this.timer=setTimeout(this.scroll.bind(this),1000);}.bind(this);
  743. },
  744. scroll:function(){
  745. if(this.element.scrollTop<this.maxHeight){
  746. this.element.scrollTop++;
  747. this.counter++;
  748. }else{
  749. this.element.scrollTop=0;
  750. this.counter=0;
  751. }
  752. if(this.counter<this.height){
  753. this.timer=setTimeout(this.scroll.bind(this),20);
  754. }else{
  755. this.counter=0;
  756. this.timer=setTimeout(this.scroll.bind(this),3000);
  757. }
  758. },
  759. stop:function(){
  760. clearTimeout(this.timer);
  761. }
  762. };
  763. if(count*24>(height-45)) {setTimeout(function scroll(){
  764. new Scroll("notifydata",24);
  765. },8000);
  766. }*/
  767. }
  768. });
  769. },
  770. /**
  771. * 常用模块
  772. */
  773. _bench_link: function(){
  774. var me = this.workbench || this;
  775. Ext.Ajax.request({
  776. url : basePath + 'common/getCommonUse.action',
  777. method : 'get',
  778. callback : function(options,success,response){
  779. var res = new Ext.decode(response.responseText);
  780. if(res.exception || res.exceptionInfo){
  781. showError(res.exceptionInfo);
  782. return;
  783. }
  784. window._delete_bench_link = me._delete_bench_link;
  785. Ext.getCmp('bench_link').down('gridpanel').store.loadData(res.commonuse);
  786. }
  787. });
  788. },
  789. /**
  790. * 设置常用模块
  791. */
  792. _set_bench_link: function(snid){
  793. Ext.Ajax.request({
  794. url : basePath + 'common/setCommonUse.action',
  795. params: {
  796. snid: snid
  797. },
  798. method : 'post',
  799. callback : function(options,success,response){
  800. var res = new Ext.decode(response.responseText);
  801. if(res.exception || res.exceptionInfo){
  802. showError(res.exceptionInfo);
  803. return;
  804. }
  805. if(Ext.isIE) {
  806. setTimeout(function(){
  807. Ext.getCmp('link_grid').store.loadData(res.commonuse);
  808. }, 8000);
  809. } else {
  810. Ext.getCmp('link_grid').store.loadData(res.commonuse);
  811. }
  812. }
  813. });
  814. },
  815. _delete_bench_link: function(id){
  816. Ext.Ajax.request({
  817. url : basePath + 'common/deleteCommonUse.action',
  818. params: {
  819. id: id
  820. },
  821. method : 'post',
  822. callback : function(options,success,response){
  823. var res = new Ext.decode(response.responseText);
  824. if(res.exception || res.exceptionInfo){
  825. showError(res.exceptionInfo);
  826. return;
  827. }
  828. var grid = Ext.getCmp('link_grid');
  829. Ext.each(grid.store.data.items, function(item){
  830. if(item.data['cu_id'] == id){
  831. grid.store.remove(item);
  832. }
  833. });
  834. }
  835. });
  836. },
  837. /**
  838. * 查看我的考勤
  839. */
  840. _bench_schedule: function(){
  841. Ext.Ajax.request({
  842. url : basePath + 'oa/getMySign.action',
  843. async: false,
  844. method : 'post',
  845. callback : function(options,success,response){
  846. var res = new Ext.decode(response.responseText);
  847. if(res.exception || res.exceptionInfo){
  848. showError(res.exceptionInfo);
  849. return;
  850. }
  851. if(res.sign != null){
  852. Ext.getCmp('signin').signin = true;
  853. var d = new Date(res.sign.si_in);
  854. Ext.getCmp('signin').intime = res.sign.si_in;
  855. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 09:00:00', 'Y-m-d H:i:s').getTime();
  856. if(d > sin){
  857. Ext.getCmp('signin').tooltip = "签到时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  858. "&nbsp;&nbsp;迟到" + Math.floor((d - sin)/(60*60*1000)) + "小时" + Math.floor(((d - sin)%(60*60*1000))/(60*1000)) + "分钟" + "</font>";
  859. } else {
  860. Ext.getCmp('signin').tooltip = "签到时间:" + Ext.Date.format(d, 'H:i:s');
  861. Ext.getCmp('signin').setIconCls('x-button-icon-working');
  862. }
  863. if(res.sign.si_out) {
  864. d = new Date(res.sign.si_out);
  865. sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s').getTime();
  866. Ext.getCmp('signout').signout = true;
  867. if(d < sin) {
  868. Ext.getCmp('signout').setText("签退时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  869. "&nbsp;&nbsp;早退" + Math.floor((sin - d)/(60*60*1000)) + "小时" + Math.floor(((sin - d)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  870. } else {
  871. Ext.getCmp('signout').setText("签退时间:" + Ext.Date.format(d, 'H:i:s'));
  872. }
  873. }
  874. Ext.getCmp('signout').show();
  875. }
  876. }
  877. });
  878. showClock();
  879. },
  880. refreshTask:refreshTask
  881. };
  882. /**
  883. * 刷新待办事宜
  884. * */
  885. function refreshTask(onlyProcess){
  886. var grid = Ext.getCmp('bench_task').down('gridpanel');
  887. grid.store.removeAll();
  888. Ext.Ajax.request({
  889. url : basePath + 'common/datalist.action',
  890. params: {
  891. caller: 'JProCand',
  892. condition: 'jp_candidate=\'' + em_code + '\' AND jp_status=\'待审批'+'\' AND jp_flag=1',
  893. page: 1,
  894. pageSize: 20,
  895. _noc:1
  896. },
  897. method : 'post',
  898. callback : function(options,success,response){
  899. var res = new Ext.decode(response.responseText);
  900. if(res.exception || res.exceptionInfo){
  901. var err = res.exceptionInfo;
  902. showError(err);
  903. return;
  904. }
  905. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  906. if(task.length > 0){
  907. var items = new Array();
  908. Ext.Array.each(task,function(item){
  909. item.id=item.jp_nodeId;
  910. item.name=item.jp_name+" "+item.jp_codevalue+"("+item.jp_launcherName+")";
  911. item.note=item.jp_processnote;
  912. item.status=item.jp_status;
  913. item.type='可选流程';
  914. item.typecode='procand';
  915. items.push(item);
  916. });
  917. grid.store.add(items);
  918. }
  919. }
  920. });
  921. Ext.Ajax.request({
  922. url : basePath + 'common/datalist.action',
  923. params: {
  924. caller: 'JProcess!Me',
  925. condition: '(jp_nodedealman=\'' + em_code + '\' AND jp_status=\'待审批'+'\') or (jp_launcherid=\'' + em_code + '\' AND jp_status=\'未通过'+'\') ',
  926. page: 1,
  927. pageSize:20,
  928. _noc:1
  929. },
  930. method : 'post',
  931. callback : function(options,success,response){
  932. var res = new Ext.decode(response.responseText);
  933. if(res.exception || res.exceptionInfo){
  934. var err = res.exceptionInfo;
  935. showError(err);
  936. return;
  937. }
  938. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  939. if(task.length > 0){
  940. var items = new Array();
  941. Ext.Array.each(task,function(item){
  942. item.id=item.jp_nodeId;
  943. item.name=item.jp_name+" "+item.jp_codevalue +"("+item.jp_launcherName+")";
  944. item.note=item.jp_processnote;
  945. item.status=item.jp_status;
  946. if(!item.source || item.source==0){
  947. if(item.jp_status=='未通过'){
  948. item.type='未同意流程';
  949. item.typecode='unprocess';
  950. }else{
  951. item.type='待审批流程';
  952. item.typecode='process';
  953. }
  954. }else {
  955. item.type='待办转移流程';
  956. item.typecode='transferprocess';
  957. }
  958. items.push(item);
  959. });
  960. grid.store.add(items);
  961. }
  962. }
  963. });
  964. if(!onlyProcess){
  965. Ext.Ajax.request({
  966. url : basePath + 'common/datalist.action',
  967. params: {
  968. caller: 'ResourceAssignment',
  969. condition : '(ra_emid=\'' + em_uu + '\' AND ra_statuscode<>\'FINISHED'+'\') or (recorder=\'' + em_name + '\' AND ra_statuscode=\'UNCONFIRMED'+'\') ',
  970. page: 1,
  971. pageSize: 20,
  972. _noc:1
  973. },
  974. method : 'post',
  975. callback : function(options,success,response){
  976. var res = new Ext.decode(response.responseText);
  977. if(res.exception || res.exceptionInfo){
  978. var err = res.exceptionInfo;
  979. showError(err);
  980. return;
  981. }
  982. var task = res.data != null ? Ext.decode(res.data.replace(/,}/g, '}').replace(/,]/g, ']')) : new Array();
  983. if(task.length > 0){
  984. var items = new Array();
  985. Ext.Array.each(task,function(item){
  986. item.id=item.ra_id;
  987. item.name=item.ra_taskname + (item.sourcecode || '');
  988. item.status=item.ra_status;
  989. item.type='待办任务';
  990. item.typecode=(item.ra_type || 'worktask');
  991. item.sourcelink=item.sourcelink;
  992. item.taskId=item.ra_taskid;
  993. items.push(item);
  994. });
  995. grid.store.add(items);
  996. }
  997. }
  998. });
  999. }
  1000. getNotifyCount();
  1001. }
  1002. function getNotifyCount(){
  1003. var count=0;
  1004. Ext.Ajax.request({
  1005. url : basePath + 'common/getCountByTable.action',
  1006. params: {
  1007. tablename: 'pagingrelease left join pagingreleasedetail on pr_id=prd_prid',
  1008. condition: "prd_recipientid=" + em_uu+" and prd_readstatus=0 and nvl(pr_from,' ')='jprocess'",
  1009. _noc:1
  1010. },
  1011. method : 'post',
  1012. async:false,
  1013. callback : function(options,success,response){
  1014. var res = new Ext.decode(response.responseText);
  1015. if(res.exception || res.exceptionInfo){
  1016. var err = res.exceptionInfo;
  1017. showError(err);
  1018. return;
  1019. }
  1020. count=res.count;
  1021. }
  1022. });
  1023. var countinfo=document.getElementById('messagecount');
  1024. if(countinfo){
  1025. countinfo.innerHTML='知会('+count+")";
  1026. }
  1027. return count;
  1028. }
  1029. /**
  1030. * 打开一个tab
  1031. * @param id 当前record的ID
  1032. * @param caller
  1033. * @param title 标题
  1034. * @param link 链接
  1035. * @param key 主表ID字段
  1036. * @param detailKey 从表关联主表ID的字段
  1037. * @param condition 附加条件
  1038. */
  1039. function openTable(id, caller, title, link, key, detailKey, condition,relateMaster,limit){
  1040. var main = parent.Ext.getCmp("content-panel");
  1041. var item=main.items.items[0];
  1042. item.firstGrid=Ext.getCmp('task_grid');
  1043. var panel = Ext.getCmp('' + id);
  1044. var url = parseUrl(link);
  1045. if(caller){
  1046. panel = Ext.getCmp(caller);
  1047. url = link + '?whoami=' + caller;
  1048. }
  1049. if(id){
  1050. if(caller){
  1051. panel = Ext.getCmp(caller + id);
  1052. url = link + '?whoami=' + caller + '&formCondition=' + key + '=' + id + '&gridCondition=' + detailKey + '=' + id;
  1053. }
  1054. } else {
  1055. if(condition != null){
  1056. url += '&urlcondition=' + parseUrl(condition);
  1057. }
  1058. }
  1059. if(!limit){
  1060. if(url.indexOf('?') > 0)
  1061. url += '&_noc=1';
  1062. else
  1063. url += '?_noc=1';
  1064. }
  1065. if(relateMaster){
  1066. url+='&newMaster='+relateMaster;
  1067. }
  1068. if( relateMaster ){
  1069. var currentMaster = parent.window.sob;
  1070. if ( currentMaster && currentMaster != relateMaster) {// 与当前账套不一致
  1071. if (parent.Ext) {
  1072. Ext.Ajax.request({
  1073. url: basePath + 'common/changeMaster.action',
  1074. params: {
  1075. to: relateMaster
  1076. },
  1077. callback: function(opt, s, r) {
  1078. if (s) {
  1079. url+='&_center=1';
  1080. var win = parent.Ext.create('Ext.Window', {
  1081. width: '100%',
  1082. height: '100%',
  1083. draggable: false,
  1084. closable: false,
  1085. modal: true,
  1086. title: '创建到账套' + relateMaster + '的临时会话',
  1087. id:'modalwindow',
  1088. historyMaster:currentMaster,
  1089. relateMaster:currentMaster,
  1090. html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  1091. buttonAlign: 'center',
  1092. buttons: [{
  1093. text: $I18N.common.button.erpCloseButton,
  1094. cls: 'x-btn-blue',
  1095. id: 'close',
  1096. handler: function(b) {
  1097. Ext.Ajax.request({
  1098. url: basePath + 'common/changeMaster.action',
  1099. params: {
  1100. to: currentMaster
  1101. },
  1102. callback: function(opt, s, r) {
  1103. if (s) {
  1104. b.up('window').close();
  1105. } else {
  1106. alert('切换到原账套失败!');
  1107. }
  1108. }
  1109. });
  1110. }
  1111. }]
  1112. });
  1113. win.show();
  1114. } else {
  1115. alert('无法创建到账套' + relateMaster + '的临时会话!');
  1116. }
  1117. }
  1118. });
  1119. }
  1120. return;
  1121. }
  1122. }
  1123. if(!panel){
  1124. panel = {
  1125. title : title.substring(0, title.toString().length > 5 ? 5 : title.toString().length),
  1126. tag : 'iframe',
  1127. tabConfig:{tooltip: title},
  1128. border : false,
  1129. layout : 'fit',
  1130. iconCls : 'x-tree-icon-tab-tab',
  1131. html : '<iframe id="iframe" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  1132. closable : true,
  1133. listeners : {
  1134. close : function(){
  1135. main.setActiveTab(main.getActiveTab().id);
  1136. }
  1137. }
  1138. };
  1139. openTab(panel, panel.id);
  1140. }else{
  1141. main.setActiveTab(panel);
  1142. }
  1143. }
  1144. function parseUrl(url) {
  1145. var id = url.substring(url.lastIndexOf('?')+1);
  1146. if (id == null) {
  1147. id = url.substring(0,url.lastIndexOf('.'));
  1148. }
  1149. if(contains(url, 'session:em_uu', true)){
  1150. url = url.replace(/session:em_uu/,em_uu);
  1151. }
  1152. if(contains(url, 'session:em_code', true)){
  1153. url = url.replace(/session:em_code/, "'" + em_code + "'");
  1154. }
  1155. if(contains(url, 'sysdate', true)){
  1156. url = url.replace(/sysdate/, "to_date('" + Ext.Date.toString(new Date()) + "','yyyy-mm-dd')");
  1157. }
  1158. if(contains(url, 'session:em_name', true)){
  1159. url = url.replace(/session:em_name/,"'"+em_name+"'" );
  1160. }
  1161. return url;
  1162. }
  1163. function openTab(panel, id){
  1164. var o = (typeof panel == "string" ? panel : id || panel.id);
  1165. var main = parent.Ext.getCmp("content-panel");
  1166. var tab = main.getComponent(o);
  1167. if (tab) {
  1168. main.setActiveTab(tab);
  1169. } else if(typeof panel!="string"){
  1170. panel.id = o;
  1171. var p = main.add(panel);
  1172. main.setActiveTab(p);
  1173. }
  1174. }
  1175. function taskItem(val, meta, record){
  1176. var rendermsg='';
  1177. if(record.data.CURRENTMASTER){
  1178. if(record.data.typecode=='worktask' || record.data.typecode=='projecttask'){
  1179. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment\',\'任务\',\'jsps/plm/record/workrecord.jsp\',\'ra_id\',\'wr_raid\',null,' +'\''+record.data.CURRENTMASTER+'\''+ ');">' + val + '</a>';
  1180. } else if(record.data.typecode=='billtask' || record.data.typecode=='mrptask'){
  1181. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment!Bill\',\'任务\',\'jsps/plm/record/billrecord.jsp\',\'ra_id\',null,null,\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1182. } else if(record.data.typecode=='kbitask' || record.data.typecode=='mrptask'){
  1183. rendermsg='<a href="javascript:openUrl(' +'\''+record.data['sourcelink'] + '\',\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1184. }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>';
  1185. 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>';
  1186. } else {
  1187. if(record.data.typecode=='worktask' || record.data.typecode=='projecttask'){
  1188. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment\',\'任务\',\'jsps/plm/record/workrecord.jsp\',\'ra_id\',\'wr_raid\'' + ');">' + val + '</a>';
  1189. } else if(record.data.typecode=='billtask' || record.data.typecode=='mrptask'){
  1190. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'ResourceAssignment!Bill\',\'任务\',\'jsps/plm/record/billrecord.jsp\',\'ra_id\',null);">' + val + '</a>';
  1191. } else if(record.data.typecode=='communicatetask'){
  1192. rendermsg='<a href="javascript:openTable(' + record.data['taskId'] + ',\'ResourceAssignment!Bill\',\'沟通任务\',\'jsps/common/JprocessCommunicate.jsp\',\'id\',null);">' + val + '</a>';
  1193. } else if(record.data.typecode=='kbitask' ){
  1194. rendermsg='<a href="javascript:openUrl(' +'\''+record.data['sourcelink'] + '\',\''+record.data.CURRENTMASTER+'\');">' + val + '</a>';
  1195. }else if(record.data.typecode=='process'||record.data.typecode=='unprocess' || record.data.typecode=='transferprocess') {
  1196. rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'JProcess!Me\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');" target="_blank">' + val + '</a>';
  1197. if(record.data.note && record.data.note!=null && record.data.note !='null' ){
  1198. rendermsg+='</br><font color="#669933" >'+record.data.note+'</font>';
  1199. }
  1200. }
  1201. else rendermsg='<a href="javascript:openTable(' + record.data['id'] + ',\'JProCand\',\'任务流程\',\'jsps/common/jtaketask.jsp\',\'jp_nodeId\',jp_flag=1' + ');">' + val + '</a>';
  1202. }
  1203. if(record.data.RN && record.data.RN==1){
  1204. return rendermsg+'&nbsp;<img src="' + basePath + 'resource/images/mainpage/new.png"/>';
  1205. }else return rendermsg;
  1206. }
  1207. function showMaster(val,meta,record){
  1208. if(record.data.CURRENTMASTER){
  1209. return val+'-<span style="color:red;">' + record.data.CURRENTMASTER + '</span>';
  1210. }else return val;
  1211. }
  1212. function flowItem(val, meta, record){
  1213. return '<a href="javascript:openTable(' + record.data['jp_nodeId'] + ',\'JProcess!Me\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');">' + val + '</a>';
  1214. }
  1215. function flowOverItem(val, meta, record){
  1216. return '<a href="javascript:openTable(' + record.data['jp_nodeId'] + ',\'JProcess!MeOver\',\'任务流程\',\'jsps/common/jprocessDeal.jsp\',\'jp_nodeId\',null' + ');">' + val + '</a>';
  1217. }
  1218. function getSurPlus(val, meta, record){
  1219. if(Ext.isEmpty(val))
  1220. return '--';
  1221. if(record.data.ra_taskpercentdone == 100){
  1222. return '<img src="' + basePath + 'resource/images/renderer/award2.png">' + '<span style="color:green;padding-left:2px">已完成</span>';
  1223. } else {
  1224. var bTime = new Date().getTime();
  1225. var eTime = Ext.Date.parse(record.data['ra_enddate'].substring(0, 10) + ' 23:59:59','Y-m-d H:i:s').getTime();
  1226. var allHour = (eTime - bTime)/(60*60*1000);
  1227. if(allHour < 0){
  1228. if(allHour < -24){
  1229. val = "<font color =red>过期" + Math.floor(Math.abs(allHour)/24) + "天" + Math.floor(Math.abs(allHour)%24) + "小时";
  1230. } else {
  1231. val = "<font color =red>过期" + Math.floor(Math.abs(allHour)) + "小时";
  1232. }
  1233. } else {
  1234. val = "<font color =blue>剩余" + Math.floor(allHour/24) + "天" + Math.floor(allHour%24) + "小时";
  1235. }
  1236. return val;
  1237. }
  1238. }
  1239. function percentdone(val, meta, record){
  1240. val == null || 0;
  1241. if(val < 30)
  1242. return '<img src="' + basePath + 'resource/images/renderer/remind2.png">'+'<span style="color:#436EEE;padding-left:2px">' + val + '</span>';
  1243. else if(val > 30 && val < 50)
  1244. return '<img src="' + basePath + 'resource/images/renderer/remind.png">'+'<span style="color:#5F9EA0;padding-left:2px">' + val + '</span>';
  1245. else if(val == 100){
  1246. return '<img src="' + basePath + 'resource/images/renderer/award1.png">'+'<span style="color:blue;padding-left:2px">' + val + '</span>';
  1247. }else if(val > 80){
  1248. return '<img src="' + basePath + 'resource/images/renderer/award2.png">'+'<span style="color:green;padding-left:2px">' + val + '</span>';
  1249. }
  1250. else
  1251. return val;
  1252. }
  1253. function showClock(){
  1254. var now = new Date();
  1255. var html = '';
  1256. var hours = now.getHours();
  1257. var minutes = now.getMinutes();
  1258. var seconds = now.getSeconds();
  1259. if(hours < 9 && Ext.getCmp('signin').signin == false){
  1260. Ext.getCmp('signin').setText("签到&nbsp;&nbsp;剩余" + (8 - hours) + "小时" + (60 - minutes) + "分钟" + (60 - seconds) + "秒");
  1261. } else {
  1262. if (Ext.getCmp('signin').signin == true) {
  1263. var intime = Number(Ext.getCmp('signin').intime);
  1264. if(intime && intime > 0) {
  1265. var time = now.getTime();
  1266. var h = Math.floor((time - intime)/(60*60*1000));
  1267. var m = Math.floor(((time - intime)%(60*60*1000))/(60*1000));
  1268. var s = Math.floor(((time - intime)%(60*1000))/(1000));
  1269. Ext.getCmp('signin').setText(Ext.getCmp('signin').tooltip + "<br/>&nbsp;<font color=blue>已工作" + (h) + "小时" + (m) + "分钟" + (s) + "秒</font>");
  1270. } else {
  1271. Ext.getCmp('signin').setText(Ext.getCmp('signin').tooltip);
  1272. }
  1273. if(Ext.getCmp('signout').signout == false) {
  1274. if(hours < 18){
  1275. Ext.getCmp('signout').setText("签退<br/>&nbsp;<font color=blue>距离下班" + (18 - hours) + "小时" + (60 - minutes) + "分钟" + (60 - seconds) + "秒</font>");
  1276. } else {
  1277. Ext.getCmp('signout').setText("签退<br/>&nbsp;<font color=blue>下班时间已到</font>");
  1278. }
  1279. }
  1280. } else {//还没签到
  1281. Ext.getCmp('signin').setText("签到&nbsp;&nbsp;<font color=red>迟到" + (hours - 9) + "小时" + (minutes) + "分钟" + (seconds) + "秒</font>");
  1282. }
  1283. }
  1284. if(hours <= 9){
  1285. hours = '0' + hours;
  1286. }
  1287. if(minutes <= 9){
  1288. minutes = '0' + minutes;
  1289. }
  1290. if(seconds < 10){
  1291. seconds = '0' + seconds;
  1292. }
  1293. var array = Ext.Array.toArray('' + hours + '-' + minutes + '-' + seconds);
  1294. Ext.each(array, function(n){
  1295. if (n == '-') {
  1296. html += '<a class="number" style="background-position: -' + 24*10 + 'px -0px"></a>';
  1297. } else {
  1298. html += '<a class="number" style="background-position: -' + 24*n + 'px -0px"></a>';
  1299. }
  1300. });
  1301. Ext.getCmp('clock').setText(html);
  1302. setTimeout("showClock();", 1000);
  1303. }
  1304. function signin(){
  1305. var hours = new Date().getHours();
  1306. if(hours >= 9){
  1307. Ext.MessageBox.prompt("原因", "请如实填写迟到原因", function (btn, text) {
  1308. if(btn == 'ok'){
  1309. _signin(text);
  1310. }
  1311. }, this, true, '睡觉睡过头了!');
  1312. } else {
  1313. _signin(null);
  1314. }
  1315. }
  1316. function _signin(reason){
  1317. Ext.Ajax.request({
  1318. url : basePath + 'oa/signin.action',
  1319. method : 'post',
  1320. async: false,
  1321. params: {
  1322. reason: reason
  1323. },
  1324. callback : function(options,success,response){
  1325. var res = new Ext.decode(response.responseText);
  1326. if(res.exception || res.exceptionInfo){
  1327. showError(res.exceptionInfo);
  1328. return;
  1329. }
  1330. if(res.success){
  1331. Ext.getCmp('signin').signin = true;
  1332. Ext.getCmp('signout').show();
  1333. var d = new Date();
  1334. Ext.getCmp('signin').intime = new Date().getTime();
  1335. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 09:00:00', 'Y-m-d H:i:s').getTime();
  1336. if(d > sin) {
  1337. Ext.getCmp('signin').setText("签到时间:<font color=red>" + Ext.Date.format(d, 'H:i:s') +
  1338. "&nbsp;&nbsp;迟到" + Math.floor((d - sin)/(60*60*1000)) + "小时" + Math.floor(((d - sin)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  1339. Ext.getCmp('signin').tooltip = "签到时间:<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. } else {
  1342. Ext.getCmp('signin').setText("签到时间:" + Ext.Date.format(d, 'H:i:s'));
  1343. Ext.getCmp('signin').tooltip = "签到时间:" + Ext.Date.format(d, 'H:i:s');
  1344. }
  1345. Ext.getCmp('signin').setIconCls('x-button-icon-working');
  1346. alert("签到时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1347. }
  1348. }
  1349. });
  1350. }
  1351. function signout(){
  1352. var sout = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s');
  1353. if(sout > new Date()){
  1354. Ext.MessageBox.prompt("原因", "请如实填写早退原因", function (btn, text) {
  1355. if(btn == 'ok'){
  1356. _signout(text);
  1357. }
  1358. }, this, true, '太累了!');
  1359. } else {
  1360. _signout(null);
  1361. }
  1362. }
  1363. function _signout(reason) {
  1364. Ext.Ajax.request({
  1365. url : basePath + 'oa/signout.action',
  1366. method : 'post',
  1367. params: {
  1368. reason: reason
  1369. },
  1370. callback : function(options,success,response){
  1371. var res = new Ext.decode(response.responseText);
  1372. if(res.exception || res.exceptionInfo){
  1373. showError(res.exceptionInfo);
  1374. return;
  1375. }
  1376. if(res.success){
  1377. Ext.getCmp('signout').signout = true;
  1378. var d = new Date();
  1379. var sin = Ext.Date.parse(Ext.Date.toString(new Date()) + ' 18:00:00', 'Y-m-d H:i:s').getTime();
  1380. if(d < sin) {
  1381. Ext.getCmp('signout').setText("签退时间:<font color=red>" + Ext.Date.format(d, 'Y-m-d H:i:s') +
  1382. "&nbsp;&nbsp;早退" + Math.floor((sin - d)/(60*60*1000)) + "小时" + Math.floor(((sin - d)%(60*60*1000))/(60*1000)) + "分钟" + "</font>");
  1383. } else {
  1384. Ext.getCmp('signout').setText("签退时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1385. }
  1386. alert("签退时间:" + Ext.Date.format(d, 'Y-m-d H:i:s'));
  1387. }
  1388. }
  1389. });
  1390. }
  1391. function getMyBench(){
  1392. Ext.Ajax.request({
  1393. url : basePath + 'common/getWorkBench.action',
  1394. method : 'get',
  1395. callback : function(options,success,response){
  1396. var res = new Ext.decode(response.responseText);
  1397. if(res.exceptionInfo) {
  1398. showError(res.exceptionInfo);
  1399. } else {
  1400. var bench = res.benchs;
  1401. if(bench.length == 0){
  1402. bench = getDefaultBench();
  1403. }
  1404. var e = Ext.getCmp('bench').getEl().dom,
  1405. h = parseInt(Number(e.style.height.replace('px', ''))/3) - 1;
  1406. Ext.each(bench, function(b){
  1407. workbench.setWidth(b.wb_width);
  1408. if(b.wb_height > 0.6) {
  1409. workbench.setHeight(h*2);
  1410. } else {
  1411. workbench.setHeight(h);
  1412. }
  1413. var panel = workbench[b.wb_name].apply();
  1414. Ext.getCmp('bench').add(panel);
  1415. });
  1416. Ext.each(bench, function(b){
  1417. if(workbench["_" + b.wb_name]){
  1418. workbench["_" + b.wb_name].apply();
  1419. }
  1420. });
  1421. }
  1422. }
  1423. });
  1424. }
  1425. function getDefaultBench(){
  1426. return [{
  1427. wb_name: 'bench_task',
  1428. wb_width: 2/3,
  1429. wb_height: 2/3
  1430. },{
  1431. wb_name: 'bench_link',
  1432. wb_width: 1/3,
  1433. wb_height: 2/3
  1434. },{
  1435. wb_name: 'bench_notify',
  1436. wb_width: 1/3,
  1437. wb_height: 1/3
  1438. },{
  1439. wb_name: 'bench_news',
  1440. wb_width: 1/3,
  1441. wb_height: 1/3
  1442. },{
  1443. wb_name:'bench_subscription',
  1444. wb_width: 1/3,
  1445. wb_height: 1/3
  1446. }];
  1447. }
  1448. function getDueDate(val, meta, record){
  1449. var endDate = '';
  1450. if(record.data['jt_duedate'] == 0){
  1451. return "无限时";
  1452. } else{
  1453. endDate = Ext.Date.format(new Date(Ext.Date.parse(record.data['jp_launchTime'], 'Y-m-d H:i:s')
  1454. .getTime() + record.data['jt_duedate']*3600), 'Y-m-d H:i:s');
  1455. }
  1456. return endDate;
  1457. }
  1458. function formatNote(context){
  1459. context=context.replace(/<\s*\/?br>/g, " ");
  1460. context=context.replace('你有新流程需处理!'," ");
  1461. context=context.replace(/&nbsp;&nbsp;&nbsp;&nbsp;/g," ");
  1462. return context;
  1463. }
  1464. function getDefaultShort(){
  1465. return [{
  1466. sc_name: 'short_setting'
  1467. },{
  1468. sc_name: 'short_news'
  1469. },{
  1470. sc_name: 'short_address'
  1471. },{
  1472. sc_name: 'short_calendar'
  1473. },{
  1474. sc_name: 'short_email'
  1475. },{
  1476. sc_name: 'short_bbs'
  1477. }];
  1478. }