Viewport.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140
  1. Ext.define('erp.view.common.JProcess.Viewport', {
  2. extend: 'Ext.Viewport',
  3. layout: 'fit',
  4. id: 'viewPort',
  5. hideBorders: true,
  6. autoScroll: false,
  7. style: {
  8. background: '#D3D3D3'
  9. },
  10. BaseUtil: Ext.create('erp.util.BaseUtil'),
  11. initComponent: function() {
  12. var me = this;
  13. formCondition = this.BaseUtil.getUrlParam('formCondition'); //从url解析参数
  14. formCondition = (formCondition == null) ? "": formCondition.replace(/IS/g, "=");
  15. nodeId = nodeId != null ? nodeId: this.BaseUtil.getUrlParam('nodeId');
  16. if (formCondition != "") {
  17. nodeId = formCondition.split("=")[1];
  18. }
  19. var condition = formCondition == "" ? "jp_nodeId='" + nodeId + "'": formCondition;
  20. var panel = new Ext.panel.Panel({
  21. html: '<div style="background-color:#f0f0f0;font-size:15px"><h2>待审批单据信息</h2></div>'
  22. });
  23. var param = {
  24. caller: caller,
  25. condition: condition,
  26. _noc: 1
  27. };
  28. if (master) {
  29. param.master = master;
  30. }
  31. var nodesgrid = Ext.create('erp.view.common.JProcess.GridPanel', {
  32. anchor: '100%',
  33. deferLoadData:true
  34. });
  35. Ext.apply(me, {
  36. items: [{
  37. id: 'JProcessViewport',
  38. layout: 'auto',
  39. autoScroll: true,
  40. xtype: 'panel',
  41. style: {
  42. background: '#FFFFFF'
  43. },
  44. items: [{
  45. xtype: 'form',
  46. anchor: '100%',
  47. bodyStyle: {
  48. background: '#E3E3E3'
  49. },
  50. id: 'mainForm',
  51. items: [{
  52. id: 'app-header',
  53. xtype: 'box',
  54. height: 5,
  55. style: 'color: #596F8F;font-size: 16px;font-weight: 200;padding: 5px 5px;text-shadow: 0 1px 0 #fff'
  56. },{
  57. xtype: 'toolbar',
  58. id: 'currentNodeToolbar',
  59. layout: {
  60. type: 'hbox',
  61. align: 'right'
  62. },
  63. style: {
  64. background: 'transparent',
  65. border: 'none'
  66. },
  67. items: [{
  68. xtype: 'tbtext',
  69. id: 'processname'
  70. },
  71. '->', {
  72. xtype: 'tbtext',
  73. id: 'label1',
  74. text: ''
  75. },
  76. '->', {
  77. xtype: 'tbtext',
  78. id: 'label2',
  79. text: ''
  80. },
  81. {
  82. xtype: 'tbtext',
  83. id: 'label3',
  84. text: ''
  85. }]
  86. },
  87. {
  88. xtype: 'fieldcontainer',
  89. labelWidth: 250,
  90. layout: 'column',
  91. id: 'container',
  92. items: [{
  93. xtype: 'checkboxfield',
  94. boxLabel: '<span style="font-weight: bold !important;">变更办理人</span>',
  95. columnWidth: 0.4,
  96. readOnly:ISexecuted,
  97. disabled:ISexecuted,
  98. checked: false,
  99. id: 'alterAssignee',
  100. handler: function(checkBox, checked) {
  101. this.ownerCt.ownerCt.ownerCt.ownerCt.getAssigneeCombox(checkBox, checked);
  102. }
  103. },
  104. {
  105. xtype: 'toolbar',
  106. width: '78%',
  107. columnWidth: 0.6,
  108. layout: {
  109. type: 'hbox',
  110. align: 'right'
  111. },
  112. style: {
  113. background: 'transparent',
  114. border: 'none'
  115. },
  116. items: ['->', {
  117. xtype: 'tbtext',
  118. id: 'currentnode'
  119. },
  120. '-', {
  121. xtype: 'tbtext',
  122. id: 'launchername'
  123. },
  124. '-', {
  125. xtype: 'tbtext',
  126. id: 'launchtime'
  127. }]
  128. },
  129. {
  130. xtype: 'fieldcontainer',
  131. columnWidth: 1,
  132. id: 'container2',
  133. labelWidth: 100,
  134. layout: 'hbox'
  135. }]
  136. },
  137. {
  138. xtype: 'fieldcontainer',
  139. id: 'container3',
  140. labelWidth: 100,
  141. layout: 'column',
  142. labelSeparator: '',
  143. margin: '0 0 0 5',
  144. fieldLabel: '<h2>审批意见</h2>',
  145. items: [{
  146. xtype: 'textfield',
  147. name: 'dealMessage',
  148. id: 'dealMessage',
  149. hideLabel: true,
  150. columnWidth: 0.65,
  151. labelAlign: 'right',
  152. fieldStyle: 'background:#FFFAFA;color:#515151;'
  153. }]
  154. },{
  155. xtype: 'fieldcontainer',
  156. id: 'customSetup',
  157. labelWidth: 100,
  158. labelSeparator: '',
  159. fieldLabel: '<h2>审批要点</h2>',
  160. layout: 'column',
  161. hidden: true,
  162. margin: '0 72 0 5'
  163. },
  164. {
  165. xtype: 'fieldcontainer',
  166. id: 'container4',
  167. labelWidth: 100,
  168. layout: 'anchor'
  169. },
  170. {
  171. xtype:'mfilefield',
  172. id:'attachs',
  173. name:'attachs',
  174. collapsed: true,
  175. collapsible: true,
  176. frame:true,
  177. modify:true,
  178. style: '',
  179. title: '<img src="' + basePath + 'resource/images/icon/attach.png" width=20/>&nbsp;&nbsp;<span style="font-weight:bold;font-size:13px;">附件</span>',
  180. listeners : {
  181. afterrender: function(f){
  182. if(f.value != null && f.value.toString().trim() != ''){
  183. f.download(f.value);
  184. }
  185. }
  186. }
  187. },{
  188. xtype: 'fieldset',
  189. margin: '2 2 2 2',
  190. collapsible: true,
  191. collapsed: true,
  192. layout:'column',
  193. title: '<img src="' + basePath + 'resource/images/mainpage/info.png" width=20/>&nbsp;&nbsp;<span style="font-weight:bold;font-size:13px;">知会</span>',
  194. items: [Ext.create('erp.view.core.trigger.AddDbfindTrigger',{
  195. anchor:'100% 30%',
  196. emptyText:'选择知会人',
  197. fieldStyle: 'background:#FAFAFA;color:#515151;',
  198. hideLabel:true,
  199. name:'notifyPeople',
  200. id:'notifyPeople',
  201. group:0,
  202. columnWidth:0.4
  203. }),{
  204. name:'notifyPeopleid',
  205. id:'notifyPeopleid',
  206. xtype:'textfield',
  207. hidden:true
  208. },Ext.create('erp.view.core.trigger.AddDbfindTrigger',{
  209. anchor:'100% 30%',
  210. emptyText:'选择知会岗位',
  211. name:'notifyGroupName',
  212. id:'notifyGroupName',
  213. group:0,
  214. fieldStyle: 'background:#FAFAFA;color:#515151;padding-left:5px',
  215. hideLabel:true,
  216. columnWidth:0.4
  217. }),{
  218. name:'notifyGroup',
  219. id:'notifyGroup',
  220. xtype:'textfield',
  221. hidden:true
  222. },{
  223. text : '清空',
  224. xtype:'button',
  225. handler : function(b) {
  226. Ext.Array.each(b.ownerCt.items.items,function(item){
  227. item.reset();
  228. });
  229. }
  230. },{
  231. text : '确定',
  232. xtype:'button',
  233. handler : function(b) {
  234. var peoples=Ext.getCmp('notifyPeopleid').value;
  235. var groups=Ext.getCmp('notifyGroup').value;
  236. var peoplesname=Ext.getCmp('notifyPeople').value;
  237. var groupsname=Ext.getCmp('notifyGroupName').value;
  238. if((peoples==null || peoples=='' )&& (groups==null || groups=='')) showMessage('提示','先选择需要知会的岗位或人员!',1000);
  239. else me.saveNotify(peoples,groups,peoplesname,groupsname,me,b);
  240. }
  241. }]
  242. },{
  243. xtype: 'fieldset',
  244. margin: '2 2 2 2',
  245. collapsible: true,
  246. collapsed: true,
  247. layout:'column',
  248. title: '<img src="' + basePath + 'resource/images/icon/communicate.png" width=20/>&nbsp;&nbsp;<span style="font-weight:bold;font-size:13px;text-align:top;height:30px;">沟通</span>',
  249. items: [{
  250. name : 'com_record',
  251. id :'com_record',
  252. hideLabel : true,
  253. autoHeight : true,
  254. height:250,
  255. columnWidth:0.6,
  256. readOnly:true,
  257. xtype: 'htmleditor',
  258. enableColors: false,
  259. enableAlignments: false,
  260. enableFont: false,
  261. enableFontSize: false,
  262. enableFormat: false,
  263. enableLinks: false,
  264. enableLists: false,
  265. enableSourceEdit: false,
  266. frame: false,
  267. fieldStyle: 'border-bottom: none;'
  268. },{
  269. xtype:'form',
  270. columnWidth:0.4,
  271. height :250,
  272. layout:'anchor',
  273. frame:true,
  274. items:[{
  275. xtype:'textareafield',
  276. name :'communicaterecord',
  277. id:'communicaterecord',
  278. hideLabel:true,
  279. allowBlank:false,
  280. anchor:'100% 70%',
  281. fieldStyle: 'background:#FAFAFA;color:#515151;'
  282. },Ext.create('erp.view.core.trigger.MultiDbfindTrigger',{
  283. anchor:'100% 30%',
  284. emptyText:'选择沟通人',
  285. fieldStyle: 'background:#FAFAFA;color:#515151;',
  286. id:'communicator',
  287. name:'communicator',
  288. allowBlank:false,
  289. labelWidth : 50
  290. }),{
  291. id:'communicatorid',
  292. name:'communicatorid',
  293. xtype:'textfield',
  294. hidden:true
  295. }],
  296. buttonAlign : 'center',
  297. buttons : [{
  298. text : '重置',
  299. handler : function(b) {
  300. b.ownerCt.ownerCt.getForm().reset();
  301. }
  302. },{
  303. text : '确定',
  304. formBind: true,
  305. handler : function(b) {
  306. me.CommunicateWithOther(b.ownerCt.ownerCt,me);
  307. }
  308. }]
  309. }]
  310. },{
  311. xtype: 'toolbar',
  312. style: {
  313. background: 'transparent',
  314. border: 'none'
  315. },
  316. id: 'container5',
  317. anchor: '100%',
  318. layout: 'hbox',
  319. readOnly: ISexecuted,
  320. disabled: ISexecuted,
  321. items: [{
  322. xtype: 'splitter',
  323. width: 20
  324. },
  325. {
  326. xtype: 'button',
  327. text: '同&nbsp;&nbsp;&nbsp;&nbsp;意',
  328. iconCls: 'x-button-icon-agree',
  329. cls: 'x-btn-gray',
  330. width: 90,
  331. handler: function() {
  332. this.ownerCt.ownerCt.ownerCt.ownerCt.executeTask(1);
  333. }
  334. },
  335. {
  336. xtype: 'splitter',
  337. width: 10
  338. },
  339. {
  340. xtype: 'button',
  341. id:'disagree',
  342. text: '不 &nbsp;同 &nbsp;意',
  343. iconCls: 'x-button-icon-unagree',
  344. cls: 'x-btn-gray',
  345. width: 90,
  346. handler: function() {
  347. this.ownerCt.ownerCt.ownerCt.ownerCt.executeTask(2);
  348. }
  349. },
  350. {
  351. xtype: 'splitter',
  352. width: 10
  353. },{
  354. xtype: 'button',
  355. iconCls: 'x-button-icon-turn',
  356. text: '结束沟通',
  357. cls: 'x-btn-gray',
  358. iconCls:'x-button-icon-talk',
  359. width: 90,
  360. handler: function() {
  361. this.ownerCt.ownerCt.ownerCt.ownerCt.endcommunicateTask(me);
  362. }
  363. },{
  364. xtype: 'splitter',
  365. width: 10
  366. },{
  367. xtype: 'button',
  368. text: '结束流程',
  369. width: 90,
  370. iconCls: 'x-button-icon-end',
  371. cls: 'x-btn-gray',
  372. handler: function() {
  373. this.ownerCt.ownerCt.ownerCt.ownerCt.endProcess();
  374. }
  375. },{
  376. xtype: 'splitter',
  377. width: 10
  378. },{
  379. xtype: 'button',
  380. iconCls: 'x-button-icon-turn',
  381. text: '下一条',
  382. cls: 'x-btn-gray',
  383. width: 90,
  384. handler: function() {
  385. this.ownerCt.ownerCt.ownerCt.ownerCt.skipTask();
  386. }
  387. },
  388. {
  389. xtype: 'splitter',
  390. width: 10
  391. },
  392. /*{
  393. xtype: 'button',
  394. text: '结束流程',
  395. width: 90,
  396. iconCls: 'x-button-icon-end',
  397. cls: 'x-btn-gray',
  398. handler: function() {
  399. this.ownerCt.ownerCt.ownerCt.ownerCt.endProcess();
  400. }
  401. },
  402. {
  403. xtype: 'splitter',
  404. width: 10
  405. },
  406. {
  407. xtype: 'button',
  408. text: '删除流程',
  409. iconCls: 'tree-delete',
  410. disabled: true,
  411. width: 90,
  412. cls: 'x-btn-gray',
  413. handler: function() {
  414. this.ownerCt.ownerCt.ownerCt.ownerCt.deleteProcess();
  415. }
  416. },
  417. {
  418. xtype: 'splitter',
  419. width: 10
  420. },
  421. {
  422. xtype: 'button',
  423. text: '重置流程',
  424. iconCls: 'x-button-icon-reset',
  425. width: 90,
  426. cls: 'x-btn-gray',
  427. handler: function() {
  428. this.ownerCt.ownerCt.ownerCt.ownerCt.backProcess();
  429. }
  430. },
  431. {
  432. xtype: 'splitter',
  433. width: 10
  434. },*/
  435. {
  436. xtype: 'button',
  437. text: '关&nbsp;&nbsp;&nbsp;&nbsp;闭',
  438. iconCls: 'x-button-icon-close',
  439. cls: 'x-btn-gray',
  440. id:'closeProcess',
  441. width: 90,
  442. handler: function() {
  443. if(parent.Ext.getCmp('modalwindow')){
  444. Ext.Ajax.request({
  445. url: basePath + 'common/changeMaster.action',
  446. params: {
  447. to: parent.Ext.getCmp('modalwindow').historyMaster
  448. },
  449. callback: function(opt, s, r) {
  450. if (s) {
  451. var formUtil = Ext.create('erp.util.FormUtil');
  452. var tab = formUtil.getActiveTab();
  453. if(tab){
  454. tab.fireEvent('activate',tab);
  455. }
  456. parent.Ext.getCmp('modalwindow').close();
  457. } else {
  458. alert('切换到原账套失败!');
  459. }
  460. }
  461. });
  462. }
  463. else parent.Ext.getCmp('content-panel').getActiveTab().close();
  464. }
  465. }
  466. ]
  467. }]
  468. },
  469. panel, nodesgrid]
  470. }]
  471. });
  472. me.callParent(arguments);
  473. },
  474. getProcessData: function(params) {
  475. Ext.Ajax.request({
  476. url: basePath + form.saveUrl,
  477. params: params,
  478. method: 'post',
  479. async: false,
  480. callback: function(options, success, response) {
  481. var localJson = new Ext.decode(response.responseText);
  482. ProcessData = localJson.data;
  483. }
  484. });
  485. },
  486. getAssigneeCombox: function(checkBox, checked) {
  487. var processInstanceId = ProcessData.jp_processInstanceId,me=this;
  488. var button = Ext.create('Ext.Button', {
  489. text: '确定',
  490. cls: 'x-btn-gray',
  491. iconCls: 'x-button-icon-save',
  492. margin: '0 0 0 10',
  493. handler: function() {
  494. var value = Ext.getCmp('AssigneeComboxcode').getValue();
  495. /* var customs = Ext.getCmp('customSetup').items.items;
  496. var flag = 0;
  497. Ext.each(customs,
  498. function(cu) {
  499. if (!cu.items.items[1].allowBlank && (cu.items.items[1].getValue() == null || cu.items.items[1].getValue() == '')) {
  500. Ext.Msg.alert('提示', "<b>" + cu.items.items[0].value.fontcolor("Red") + "</b>为必填项!");
  501. flag++;
  502. return;
  503. }
  504. });
  505. if (flag > 0) {
  506. return;
  507. }
  508. var cValues = [];
  509. Ext.each(customs,
  510. function(cu) {
  511. if (cu.items.items[1].getValue() != null && cu.items.items[1].getValue() != '') {
  512. var value = cu.items.items[1].getValue() instanceof Date ? me.getStringByDate(cu.items.items[1].getValue()) : cu.items.items[1].getValue();
  513. var labelValue = cu.items.items[0].getFieldLabel() + "(" + value + ")";
  514. if(cu.items.items[1].logic!='') labelValue+='@'+cu.items.items[1].logic+'@';
  515. cValues.push(labelValue);
  516. }
  517. });
  518. var opd = cValues.join(";");*/
  519. if (!value) {
  520. Ext.Msg.alert('提示', '请先选择变更办理人!');
  521. return;
  522. } else {
  523. Ext.Ajax.request({
  524. url: basePath + 'common/setAssignee.action',
  525. params: {
  526. taskId: ProcessData.jp_nodeId,
  527. assigneeId: value,
  528. processInstanceId: processInstanceId,
  529. //customDes: opd,
  530. description: Ext.getCmp('changedescription').getValue(),
  531. _noc: 1,
  532. },
  533. success: function(response) {
  534. var jsonData = Ext.decode(response.responseText);
  535. if (jsonData.result) {
  536. var nextnode = jsonData.nextnode;
  537. function showResult(btn){
  538. me.dealNextStep(nextnode,jsonData._tomaster);
  539. }
  540. Ext.Msg.show({
  541. title:'提示',
  542. msg: '变更成功',
  543. buttons: Ext.Msg.OK,
  544. closable: false,
  545. fn: showResult
  546. });
  547. if (parent && parent.Ext.getCmp('content-panel')) {
  548. var firstGrid = parent.Ext.getCmp('content-panel').items.items[0].firstGrid;
  549. if (firstGrid && firstGrid != null) {
  550. firstGrid.loadNewStore();
  551. }
  552. }
  553. return;
  554. } else {
  555. Ext.Msg.alert('提示', "该任务不存在,无法变更!");
  556. }
  557. }
  558. });
  559. }
  560. }
  561. });
  562. var container = Ext.getCmp('container2');
  563. if (checked) {
  564. if(!ISexecuted){
  565. container.add([{
  566. fieldLabel: '变更办理人',
  567. xtype: 'multifield',
  568. name: 'AssigneeComboxcode',
  569. editable: false,
  570. width: 350,
  571. fieldStyle: 'background:#fffac0;color:#515151;',
  572. id: 'AssigneeComboxcode',
  573. secondname: 'em_name'
  574. },
  575. {
  576. xtype: 'textareatrigger',
  577. name: 'changedescription',
  578. id: 'changedescription',
  579. fieldStyle: 'background:#FFFAFA;color:#515151;',
  580. width: 350,
  581. labelAlign: 'right',
  582. fieldLabel: '变更描述'
  583. },
  584. button]);
  585. }
  586. } else {
  587. container.removeAll(true);
  588. }
  589. },
  590. deleteProcess: function() {
  591. Ext.Ajax.request({
  592. url: basePath + 'common/deleteProcess.action',
  593. params: {
  594. processInstanceId: ProcessData.jp_processInstanceId
  595. },
  596. success: function(response) {
  597. var text = response.responseText;
  598. jsonData = Ext.decode(text);
  599. if (jsonData.success) {
  600. Ext.Msg.alert('提示', "流程已删除!");
  601. }
  602. if (jsonData.exceptionInfo) {
  603. showError("该流程实例不存在");
  604. }
  605. }
  606. });
  607. },
  608. backProcess: function() {
  609. var mb = new Ext.window.MessageBox();
  610. mb.wait('系统正在处理', '请稍后');
  611. Ext.Ajax.request({
  612. url: basePath + 'common/backToLastNode.action',
  613. params: {
  614. processInstanceId: ProcessData.jp_processInstanceId,
  615. jnodeId: ProcessData.jp_nodeId
  616. },
  617. success: function(response) {
  618. mb.close();
  619. var text = response.responseText;
  620. jsonData = Ext.decode(text);
  621. if (jsonData.success) {
  622. Ext.Msg.alert('提示', '流程重置成功!');
  623. }
  624. if (jsonData.exceptionInfo) {
  625. showError(jsonData.exceptionInfo);
  626. }
  627. }
  628. });
  629. },
  630. endProcess: function() {
  631. var me=this,startdealtime = new Date(),taskId = ProcessData.jp_nodeId;
  632. Ext.Ajax.request({
  633. url: basePath + 'common/endProcessInstance.action',
  634. params: {
  635. processInstanceId: ProcessData.jp_processInstanceId,
  636. holdtime: ((startdealtime - basestarttime) / 1000).toFixed(0),
  637. nodeId: taskId
  638. },
  639. callback: function(options, success, response) {
  640. var text = response.responseText;
  641. jsonData = Ext.decode(text);
  642. if (jsonData.success) {
  643. Ext.Msg.alert('提示', "流程已结束!");
  644. }
  645. if (jsonData.exceptionInfo) {
  646. showError(jsonData.exceptionInfo);
  647. Ext.Msg.alert('提示', "该流程实例不存在!");
  648. }
  649. }
  650. });
  651. },
  652. dealNextStep: function(nextnode,toMaster) {
  653. var nextNodeId = null,tab=null,me=this;
  654. if(parent.Ext.getCmp('content-panel')) tab=parent.Ext.getCmp('content-panel').getActiveTab();
  655. function processResult() {
  656. var btn = arguments[0];
  657. if (btn == 'yes') {
  658. var confirm = new Ext.button.Button({
  659. text: '确定',
  660. handler: function(btn) {
  661. var items = Ext.ComponentQuery.query('window >tabpanel>panel>radio');
  662. var params = new Array();
  663. Ext.each(items,function(item){
  664. if(item.getValue()){
  665. var param = new Object();
  666. var label = item.boxLabel;//em_name(em_code) 2013-3-8 10:18:11
  667. var em_code = label.substring(label.lastIndexOf('(')+1,label.length-1);
  668. param.em_code = em_code;
  669. param.nodeId=item.name;
  670. params.push(JSON.stringify(param));
  671. }
  672. });
  673. Ext.Ajax.request({
  674. url: basePath + 'common/takeOverTask.action',
  675. async: false,
  676. params: {
  677. params:unescape(params),
  678. _noc: 1
  679. },
  680. callback: function(options, success, response) {
  681. var text = response.responseText;
  682. jsonData = Ext.decode(text);
  683. if (jsonData.success) {
  684. Ext.Msg.alert('提示', "指派成功!");
  685. me.dealNextStep(nextnode,toMaster);
  686. Ext.getCmp('assignwin').close();
  687. } else {
  688. Ext.Msg.alert('提示', "指派失败!");
  689. Ext.getCmp('assignwin').close();
  690. }
  691. }
  692. });
  693. }
  694. });
  695. var cancel = new Ext.button.Button({
  696. text: '取消',
  697. handler: function() {
  698. if (nextnode && nextnode != '-1') {
  699. me.loadNextTask(nextnode,toMaster);
  700. } else {
  701. //if (tab!=null )tab.close();
  702. var closeBtn = Ext.getCmp('closeProcess');
  703. closeBtn.handler();
  704. }
  705. }
  706. });
  707. var searchKey = new Object();
  708. var win = Ext.create('Ext.window.Window', {
  709. title: '指定下一步任务审批人',
  710. height: 450,
  711. width: 650,
  712. id: 'assignwin',
  713. modal:true,
  714. layout:'border',
  715. closable:false,
  716. buttons: [confirm, cancel],
  717. buttonAlign: 'center',
  718. items: []
  719. });
  720. win.add([{
  721. xtype:'textfield',
  722. margin:'10 20 10 20',
  723. fieldLabel:'快速搜索',
  724. labelStyle:'font-weight:bold;',
  725. id:'searchtextfield',
  726. region:'north',
  727. enableKeyEvents:true,
  728. listeners:{
  729. keydown:function(field,e){
  730. if(e.getKey()==Ext.EventObject.ENTER){
  731. searchKey[Ext.getCmp('assignTab').getActiveTab().id]=field.value;
  732. var results=Ext.Array.filter(jsonData.actorUsers[Ext.getCmp('assignTab').getActiveTab().id].JP_CANDIDATES,function(JP_CANDIDATE){
  733. if(field.value==undefined || JP_CANDIDATE.indexOf(field.value)!=-1) return JP_CANDIDATE;
  734. });
  735. Ext.Array.each(Ext.getCmp('assignTab').getActiveTab().personUsers,function(item){
  736. Ext.getCmp('assignTab').getActiveTab().remove(item);
  737. });
  738. addUserItems(Ext.getCmp('assignTab').getActiveTab(),jsonData.actorUsers[Ext.getCmp('assignTab').getActiveTab().id].JP_NODEID,results);
  739. }
  740. }
  741. }
  742. }]);
  743. var assignTab = new Ext.TabPanel({
  744. id : 'assignTab',
  745. enableTabScroll : true,
  746. closeAll : true,
  747. region:'center',
  748. minTabWidth :80,
  749. autoHeight:true,
  750. resizeTabs : true,
  751. listeners:{
  752. 'tabchange':function(tabPanel,newCard,oldCard,eOpts){
  753. Ext.getCmp('searchtextfield').setValue(searchKey[newCard.id]);
  754. }
  755. }
  756. });
  757. win.add(assignTab);
  758. for (var i = 0; i < jsonData.actorUsers.length; i++) {
  759. var panel=new Ext.Panel({
  760. id:i.toString(),
  761. width: 480,
  762. autoHeight:true,
  763. autoScroll:true,
  764. layout:'column',
  765. bodyStyle: 'background:#e0e0e0',
  766. title:jsonData.actorUsers[i].JP_NODENAME
  767. });
  768. assignTab.add(panel);
  769. addUserItems(panel,jsonData.actorUsers[i].JP_NODEID,jsonData.actorUsers[i].JP_CANDIDATES);
  770. }
  771. assignTab.setActiveTab(0);
  772. win.show();
  773. } else {
  774. //if (tab!=null )tab.close();
  775. var closeBtn = Ext.getCmp('closeProcess');
  776. closeBtn.handler();
  777. }
  778. }
  779. function addUserItems(panel,jp_nodeid,jp_candidates){
  780. var me=this;
  781. var maxSize=jp_candidates.length>24?24:jp_candidates.length,personUsers=new Array(),user=null,more=Ext.getCmp('more'+panel.id);
  782. if(more)more.destroy();
  783. for(var j=0;j<maxSize;j++){
  784. user=Ext.create('Ext.form.field.Radio',{
  785. name:jp_nodeid,
  786. boxLabel:jp_candidates[j],
  787. columnWidth: 0.33,
  788. fieldCls:'x-myradio',
  789. checked: j==0?true:false
  790. });
  791. personUsers.push(user);
  792. }
  793. panel.add(personUsers);
  794. panel.personUsers=personUsers;
  795. if(jp_candidates.length>maxSize){
  796. panel.add({ xtype: 'textfield',
  797. readOnly:true,
  798. labelSeparator:'',
  799. columnWidth:1,
  800. id:'more'+panel.id,
  801. fieldStyle : 'background:#e0e0e0;border-bottom:none;vertical-align:middle;border-top:none;border-right:none;border-bottom:none;border-left:none;',
  802. fieldLabel: '『<a href="#" class="terms">全部</a>』',
  803. listeners: {
  804. click: {
  805. element: 'labelEl',
  806. fn: function(e,el) {
  807. var target = e.getTarget('.terms');
  808. Ext.getCmp('more'+panel.id).destroy();
  809. if (target) {
  810. Ext.Array.each(panel.personUsers,function(item){
  811. panel.remove(item);
  812. });
  813. var personUsers=new Array();
  814. for(var i=0;i<jp_candidates.length;i++){
  815. user=Ext.create('Ext.form.field.Radio',{
  816. name:jp_nodeid,
  817. boxLabel:jp_candidates[i],
  818. columnWidth: 0.33,
  819. fieldCls:'x-myradio',
  820. checked: i==0?true:false
  821. });
  822. personUsers.push(user);
  823. }
  824. panel.add(personUsers);
  825. panel.personUsers=personUsers;
  826. e.preventDefault();
  827. }
  828. }
  829. }
  830. }
  831. });
  832. }
  833. }
  834. Ext.Ajax.request({
  835. url: basePath + 'common/dealNextStepOfPInstance.action',
  836. params: {
  837. processInstanceId: ProcessData.jp_processInstanceId,
  838. _noc: 1
  839. },
  840. callback: function(options, success, response) {
  841. var text = response.responseText;
  842. jsonData = Ext.decode(text);
  843. if (jsonData.hasNext) {
  844. if (jsonData.actorUsers.length > 0) {
  845. Ext.Msg.show({
  846. title: '提示',
  847. msg: '下一步审批节点有多位处理人,现在指定>>>',
  848. buttons: Ext.Msg.YESNO,
  849. icon: Ext.window.MessageBox.QUESTION,
  850. closable: false,
  851. fn: processResult
  852. });
  853. //nextNodeId = jsonData.nodeId;
  854. } else {
  855. if (nextnode && nextnode != '-1') {
  856. me.loadNextTask(nextnode,toMaster);
  857. } else {
  858. //if (tab!=null )tab.close();
  859. var closeBtn = Ext.getCmp('closeProcess');
  860. if(closeBtn){
  861. closeBtn.handler();
  862. }
  863. }
  864. return;
  865. }
  866. } else {
  867. tab.close();
  868. }
  869. }
  870. });
  871. },
  872. loadNextTask:function(nextnode,toMaster){
  873. var url="jsps/common/jprocessDeal.jsp?whoami=JProcess!Me&formCondition=jp_nodeId=" + nextnode;
  874. if(toMaster!=null){
  875. //changemaster
  876. url+='&_center=1';
  877. var modalwin=parent.Ext.getCmp('modalwindow');
  878. if(modalwin && modalwin.relateMaster!=toMaster){
  879. Ext.Ajax.request({
  880. url: basePath + 'common/changeMaster.action',
  881. params: {
  882. to: toMaster
  883. },
  884. async:false,
  885. callback: function(opt, s, r) {
  886. var localJson = new Ext.decode(r.responseText);
  887. var modalwin=parent.Ext.getCmp('modalwindow');
  888. modalwin.relateMaster=toMaster;
  889. modalwin.setTitle('创建到账套' + localJson.currentMaster + '的临时会话');
  890. }
  891. });
  892. }
  893. }
  894. window.location.href = basePath + url;
  895. },
  896. executeTask: function(value) {
  897. var me = this;
  898. var dealMessage = Ext.getCmp('dealMessage').getValue(); //处理信息 2013-3-6 20:58:14
  899. var customs = Ext.getCmp('customSetup').items.items;
  900. var attachs = Ext.getCmp('attachs').items.items[0].value;
  901. var flag = 0;
  902. Ext.each(customs,
  903. function(cu) {
  904. if (!cu.items.items[1].allowBlank && (cu.items.items[1].getValue() == null || cu.items.items[1].getValue() == '')) {
  905. Ext.Msg.alert('提示', "<b>" + cu.items.items[0].value.fontcolor("Red") + "</b>为必填项!");
  906. flag++;
  907. return;
  908. }
  909. });
  910. if (flag > 0) {
  911. return;
  912. }
  913. var cValues = [];
  914. Ext.each(customs,
  915. function(cu) {
  916. if (cu.items.items[1].getValue() != null && cu.items.items[1].getValue() != '') {
  917. var value =cu.items.items[1].getValue() instanceof Date ? me.getStringByDate(cu.items.items[1].getValue()) : cu.items.items[1].getValue();
  918. var labelValue = cu.items.items[0].value + "(" + value + ")";
  919. if(cu.items.items[1].logic!='') labelValue+='@'+cu.items.items[1].logic+'@';
  920. cValues.push(labelValue);
  921. }
  922. });
  923. var opd = cValues.join(";");
  924. switch (value) {
  925. case 1:
  926. {
  927. var taskId = ProcessData.jp_nodeId;
  928. var nodeName = ProcessData.jp_nodeName;
  929. var mb = new Ext.window.MessageBox();
  930. mb.wait('系统正在处理', '请稍后');
  931. var startdealtime = new Date();
  932. var form = (iframe_maindetail.contentWindow||iframe_maindetail.window).Ext.getCmp('form'),values=form.getValues();
  933. var bool = true;
  934. if (requiredFields != null) {
  935. if (!canexecute) {
  936. bool = false;
  937. mb.close();
  938. showError('请在同意之前先保存必填信息!');
  939. return false;
  940. }
  941. var fields = requiredFields.split(",");
  942. Ext.Array.each(fields,function(field) {
  943. if (form.down('#'+field) && (values[field] == null || values[field] == "" || conditionValidation==1)) {
  944. bool = false;
  945. mb.close();
  946. showError('请在同意之前先保存必填信息!');
  947. return false;
  948. }
  949. });
  950. }
  951. if (bool) {
  952. Ext.Ajax.request({
  953. url: basePath + 'common/review.action',
  954. params: {
  955. taskId: taskId,
  956. nodeName: nodeName,
  957. nodeLog: dealMessage,
  958. holdtime: ((startdealtime - basestarttime) / 1000).toFixed(0),
  959. customDes: opd,
  960. result: true,
  961. master: master,
  962. attachs:attachs,
  963. _noc: 1
  964. },
  965. callback: function(options, success, response) {
  966. try {
  967. var text = response.responseText;
  968. var jsonData = Ext.decode(text);
  969. if (jsonData.exceptionInfo != null) {
  970. mb.close();
  971. showError("<div style='color:red;font-size:15px;'>无法审批</div>" + jsonData.exceptionInfo);
  972. return;
  973. }
  974. else if (jsonData.success) {
  975. var nextnode = jsonData.nextnode;
  976. if (nextnode == '0') {
  977. mb.close();
  978. Ext.Msg.alert('提示', nodeName + '节点已审批!');
  979. return;
  980. } else {
  981. mb.close();
  982. function showResult(btn){
  983. if (jsonData.after != null && jsonData.after != "") {
  984. var str = jsonData.after;
  985. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') { //特殊情况:操作成功,但是出现警告,允许刷新页面
  986. str = str.replace('AFTERSUCCESS', '');
  987. me.dealNextStep(nextnode,jsonData._tomaster);
  988. showError(jsonData.after);
  989. } else showError(str);
  990. } else me.dealNextStep(nextnode,jsonData._tomaster);
  991. }
  992. Ext.Msg.show({
  993. title:'提示',
  994. msg: '审批成功!',
  995. buttons: Ext.Msg.OK,
  996. closable: false,
  997. fn: showResult
  998. });
  999. if (parent && parent.Ext.getCmp('content-panel')) {
  1000. var firstGrid = parent.Ext.getCmp('content-panel').items.items[0].firstGrid;
  1001. if (firstGrid && firstGrid != null) {
  1002. firstGrid.loadNewStore();
  1003. }
  1004. }
  1005. return;
  1006. }
  1007. } else {
  1008. mb.close();
  1009. Ext.Msg.alert('提示', "该任务已提交,不能重复操作!");
  1010. parent.Ext.getCmp('content-panel').getActiveTab().close();
  1011. }
  1012. } catch(e) {
  1013. showError(Ext.decode(response.responseText).exceptionInfo);
  1014. }
  1015. }
  1016. });
  1017. }
  1018. };
  1019. break;
  1020. case 2:
  1021. {
  1022. //不同意 去选择退回节点
  1023. //取处理历史记录
  1024. var grid = Ext.getCmp('historyGrid');
  1025. var nodegriddata = grid.store.data;
  1026. var combodata = new Array();
  1027. combodata.push({
  1028. display: '制单人',
  1029. value: 'RECORDER'
  1030. });
  1031. if(forknode==0){//并行节点只能回退至制单人
  1032. Ext.Array.each(nodegriddata.items,
  1033. function(item) {
  1034. if (item.data.jn_dealResult == '同意' && item.data.jn_attach == 'T') {
  1035. combodata.push({
  1036. display: item.data.jn_name,
  1037. value: item.data.jn_name
  1038. });
  1039. }
  1040. });
  1041. }
  1042. Ext.create('Ext.window.Window', {
  1043. title: '指定回退节点',
  1044. height: 200,
  1045. width: 400,
  1046. layout: 'column',
  1047. id: 'win',
  1048. buttonAlign: 'center',
  1049. defaults: {
  1050. fieldStyle: 'background:#FFFAFA;color:#515151;',
  1051. columnWidth: 0.9
  1052. },
  1053. allowDrag: false,
  1054. items: [{
  1055. xtype: 'combo',
  1056. fieldLabel: '回退节点',
  1057. name: 'backtask',
  1058. id: 'backtask',
  1059. isFormField : true,
  1060. listConfig: {
  1061. maxHeight: 180
  1062. },
  1063. fieldStyle: 'background:#fffac0;color:#515151;',
  1064. store: {
  1065. fields: ['display', 'value'],
  1066. data: [{
  1067. display: '制单人',
  1068. value: 'RECORDER'
  1069. }]
  1070. },
  1071. displayField: 'display',
  1072. valueField: 'value',
  1073. queryMode: 'local',
  1074. allowBlank: false,
  1075. value: 'RECORDER',
  1076. onTriggerClick: function(trigger) {
  1077. var me = this;
  1078. this.getStore().loadData(combodata);
  1079. if (!me.readOnly && !me.disabled) {
  1080. if (me.isExpanded) {
  1081. me.collapse();
  1082. } else {
  1083. me.expand();
  1084. }
  1085. me.inputEl.focus();
  1086. }
  1087. }
  1088. },
  1089. {
  1090. xtype: 'textarea',
  1091. fieldLabel: '回退原因',
  1092. name: 'unagreedescription',
  1093. id: 'unagreedescription',
  1094. fieldStyle: 'background:#fffac0;color:#515151;',
  1095. allowBlank: false,
  1096. isFormField : true
  1097. }],
  1098. buttons: [{
  1099. text: $I18N.common.button.erpConfirmButton,
  1100. xtype: 'button',
  1101. formBind: true,
  1102. handler: function() {
  1103. var taskId = ProcessData.jp_nodeId;
  1104. var nodeName = ProcessData.jp_nodeName;
  1105. var mb = new Ext.window.MessageBox();
  1106. var startdealtime = new Date();
  1107. var backTaskName = Ext.getCmp('backtask').value;
  1108. var dealMessage = Ext.getCmp('unagreedescription').value;
  1109. if(dealMessage==null || dealMessage==''){
  1110. showMessage('提示', '请先填写回退原因!', 1000);
  1111. return;
  1112. }
  1113. mb.wait('系统正在处理', '请稍后');
  1114. Ext.Ajax.request({
  1115. url: basePath + 'common/review.action',
  1116. params: {
  1117. taskId: taskId,
  1118. nodeName: nodeName,
  1119. backTaskName: backTaskName,
  1120. nodeLog: dealMessage,
  1121. holdtime: ((startdealtime - basestarttime) / 1000).toFixed(0),
  1122. result: false,
  1123. master: master,
  1124. attachs:attachs,
  1125. _noc: 1
  1126. },
  1127. callback: function(options, success, response) {
  1128. try{
  1129. var text = response.responseText;
  1130. var jsonData = Ext.decode(text);
  1131. mb.close();
  1132. if (jsonData.exceptionInfo != null) {
  1133. showError("<div style='color:red;font-size:15px;'>无法审批</div>" + jsonData.exceptionInfo);
  1134. return;
  1135. }
  1136. if (jsonData.success) {
  1137. var nextnode = jsonData.nextnode;
  1138. showMessage('提示', '你已不同意!', 1000);
  1139. Ext.getCmp('win').close();
  1140. if (jsonData.after != null && jsonData.after != "") {
  1141. showError(jsonData.after);
  1142. } else me.dealNextStep(nextnode,jsonData._tomaster);
  1143. if (parent && parent.Ext.getCmp('content-panel')) {
  1144. var firstGrid = parent.Ext.getCmp('content-panel').items.items[0].firstGrid;
  1145. if (firstGrid && firstGrid != null) {
  1146. firstGrid.loadNewStore();
  1147. }
  1148. }
  1149. return;
  1150. } else {
  1151. Ext.Msg.alert('提示', "该任务已处理,不能重复操作!");
  1152. parent.Ext.getCmp('content-panel').getActiveTab().close();
  1153. }
  1154. }catch(e) {
  1155. showError(Ext.decode(response.responseText).exceptionInfo);
  1156. }}
  1157. });
  1158. }
  1159. },
  1160. {
  1161. text: $I18N.common.button.erpCancelButton,
  1162. handler: function() {
  1163. Ext.getCmp('win').close();
  1164. }
  1165. }]
  1166. }).show();
  1167. return;
  1168. };
  1169. break;
  1170. default:
  1171. break;
  1172. }
  1173. },
  1174. nextTask: function() {
  1175. window.location.href = basePath + "jsps/common/jprocessDeal.jsp?whoami=JProcess!Me&formCondition=jp_nodeId=" + nextnodeId;
  1176. },
  1177. skipTask: function() {
  1178. var taskId = ProcessData.jp_nodeId;
  1179. var mb = new Ext.window.MessageBox();
  1180. mb.wait('系统正在跳过', '请稍后');
  1181. Ext.Ajax.request({
  1182. url: basePath + 'common/getNextProcess.action',
  1183. params: {
  1184. taskId: taskId,
  1185. _noc: 1
  1186. },
  1187. callback: function(options, success, response) {
  1188. mb.close();
  1189. var data = response.responseText;
  1190. var jsonData = Ext.decode(data);
  1191. if (jsonData.success && jsonData.nodeId!=-1) {
  1192. window.location.href = basePath + "jsps/common/jprocessDeal.jsp?whoami=JProcess!Me&formCondition=jp_nodeId=" + jsonData.nodeId;
  1193. } else {
  1194. showMessage('提示','已无待审批的单据',0);
  1195. parent.Ext.getCmp('content-panel').getActiveTab().close();
  1196. }
  1197. }
  1198. });
  1199. },
  1200. saveNotify:function(notifyPeople,notifyGroup,peoplesname,groupnames,me,b){
  1201. var data={
  1202. processInstanceId:ProcessData.jp_processInstanceId,
  1203. nodeId:ProcessData.jp_nodeId,
  1204. nodeName:ProcessData.jp_nodeName
  1205. };
  1206. if (notifyPeople!=null && notifyPeople!='')data.notifyPeopleid=notifyPeople;
  1207. if (notifyGroup !=null && notifyGroup!='')data.notifyGroup=notifyGroup;
  1208. if (peoplesname !=null && peoplesname!='')data.notifyPeople=peoplesname;
  1209. if (groupnames !=null && groupnames!='')data.notifyGroupName=groupnames;
  1210. me.setLoading(true);
  1211. Ext.Ajax.request({
  1212. url: basePath + 'common/saveProcessNotify.action',
  1213. params: {
  1214. data:unescape(Ext.JSON.encode(data).replace(/\\/g, "%")),
  1215. _noc: 1
  1216. },
  1217. callback: function(options, success, response) {
  1218. me.setLoading(false);
  1219. var data = response.responseText;
  1220. var jsonData = Ext.decode(data);
  1221. if (jsonData.success) {
  1222. showMessage('提示', '设置知会人员成功!', 1000);
  1223. Ext.Array.each(b.ownerCt.items.items,function(item){
  1224. item.reset();
  1225. });
  1226. } else {
  1227. showError(data.exceptionInfo);
  1228. }
  1229. }
  1230. });
  1231. },
  1232. endcommunicateTask:function (me){
  1233. var taskId = ProcessData.jp_nodeId;
  1234. me.setLoading(true);
  1235. Ext.Ajax.request({
  1236. url: basePath + 'common/endCommunicateTask.action',
  1237. params: {
  1238. taskId: taskId,
  1239. processInstanceId:ProcessData.jp_processInstanceId,
  1240. _noc: 1
  1241. },
  1242. callback: function(options, success, response) {
  1243. me.setLoading(false);
  1244. var data = response.responseText;
  1245. var jsonData = Ext.decode(data);
  1246. if (jsonData.success) {
  1247. /*me.getCommunicates(taskId,ProcessData.jp_processInstanceId);
  1248. form.reset();*/
  1249. showMessage('提示', '已成功结束沟通!', 1000);
  1250. } else {
  1251. showError(data.exceptionInfo);
  1252. }
  1253. }
  1254. });
  1255. },
  1256. CommunicateWithOther: function(owner,me){
  1257. var form=owner.getForm();
  1258. var data=form.getValues();
  1259. var taskId = ProcessData.jp_nodeId;
  1260. me.setLoading(true);
  1261. Ext.Ajax.request({
  1262. url: basePath + 'common/communicateWithOther.action',
  1263. params: {
  1264. taskId: taskId,
  1265. processInstanceId:ProcessData.jp_processInstanceId,
  1266. data:unescape(Ext.JSON.encode(data).replace(/\\/g, "%")),
  1267. _noc: 1
  1268. },
  1269. callback: function(options, success, response) {
  1270. me.setLoading(false);
  1271. var data = response.responseText;
  1272. var jsonData = Ext.decode(data);
  1273. if (jsonData.success) {
  1274. me.getCommunicates(taskId,ProcessData.jp_processInstanceId);
  1275. form.reset();
  1276. showMessage('提示', '已成功发起沟通!', 1000);
  1277. } else {
  1278. showError(data.exceptionInfo);
  1279. }
  1280. }
  1281. });
  1282. },
  1283. getCommunicates:function(nodeId,processInstanceId){
  1284. Ext.Ajax.request({
  1285. url: basePath + 'common/communicateTask.action',
  1286. params: {
  1287. taskId: nodeId,
  1288. processInstanceId:processInstanceId,
  1289. _noc: 1
  1290. },
  1291. callback: function(options, success, response) {
  1292. var data = response.responseText;
  1293. var jsonData = Ext.decode(data);
  1294. if (jsonData.success) {
  1295. Ext.getCmp('com_record').setValue('<ul style="font-size:90%;color:#3B3B3B;list-style-type:none;margin:0;padding:0;margin-left:10px;overflow:hidden;">'+jsonData.msg+'</ul>');
  1296. } else {
  1297. showError(data.exceptionInfo);
  1298. }
  1299. }
  1300. });
  1301. },
  1302. getFieldByType: function(type, i,cs,label,necessary) {
  1303. var logic='';
  1304. var bool=necessary=='Y';
  1305. var fieldStyle=bool?"background:#F5FFFA;":"background:#FFFAFA;";
  1306. if(cs.indexOf("@")>0)
  1307. logic=cs.substring(cs.indexOf("@")+1);
  1308. switch (type) {
  1309. case "S":
  1310. return Ext.create('Ext.form.FieldContainer',{
  1311. defaults: {
  1312. hideLabel: true
  1313. },
  1314. hideLabel:true,
  1315. columnWidth:0.8,
  1316. layout: {
  1317. type: 'table',
  1318. columns:2,
  1319. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1320. },
  1321. items: [{
  1322. xtype: 'displayfield',
  1323. maxWidth :window.innerWidth * 0.5,
  1324. value: (i+1)+'.'+label
  1325. },{
  1326. id:i,
  1327. labelSeparator:'',
  1328. padding:'0 0 0 10',
  1329. xtype:'textfield',
  1330. allowBlank:!bool,
  1331. logic:logic}]
  1332. });
  1333. break;
  1334. case "D":
  1335. return Ext.create('Ext.form.FieldContainer',{
  1336. defaults: {
  1337. hideLabel: true
  1338. },
  1339. hideLabel:true,
  1340. columnWidth:0.8,
  1341. layout: {
  1342. type: 'table',
  1343. columns:2,
  1344. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1345. },
  1346. items: [{
  1347. xtype: 'displayfield',
  1348. maxWidth :window.innerWidth * 0.5,
  1349. value: (i+1)+'.'+label
  1350. },{
  1351. id:i,
  1352. format: 'Y-m-d',
  1353. labelSeparator:'',
  1354. padding:'0 0 0 10',
  1355. logic:logic,
  1356. allowBlank:!bool,
  1357. xtype:'datefield'
  1358. }]
  1359. });
  1360. break;
  1361. case "N":
  1362. return Ext.create('Ext.form.FieldContainer',{
  1363. defaults: {
  1364. hideLabel: true
  1365. },
  1366. hideLabel:true,
  1367. columnWidth:0.8,
  1368. layout: {
  1369. type: 'hbox',
  1370. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1371. },
  1372. items: [{
  1373. xtype: 'displayfield',
  1374. maxWidth :window.innerWidth * 0.5,
  1375. value: (i+1)+'.'+label
  1376. },{
  1377. id: i,
  1378. labelSeparator:'',
  1379. padding:'0 0 0 10',
  1380. logic:logic,
  1381. allowBlank:!bool,
  1382. hideTrigger:true,
  1383. fieldStyle:fieldStyle,
  1384. xtype:'numberfield'
  1385. }]
  1386. });
  1387. break;
  1388. case "C":
  1389. if(cs.indexOf('[')>0){
  1390. var comstr=cs.substring(cs.indexOf('[')+1,cs.indexOf(']'));
  1391. var str=comstr.split(";");
  1392. var arr=new Array();
  1393. Ext.Array.each(str,function(s){
  1394. arr.push({"value":s});
  1395. });
  1396. var comStore = Ext.create('Ext.data.Store', {
  1397. fields: ['value'],
  1398. data: arr
  1399. });
  1400. return Ext.create('Ext.form.FieldContainer',{
  1401. defaults: {
  1402. hideLabel: true
  1403. },
  1404. hideLabel:true,
  1405. columnWidth:0.8,
  1406. layout: {
  1407. type: 'table',
  1408. columns:2,
  1409. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1410. },
  1411. items: [{
  1412. xtype: 'displayfield',
  1413. maxWidth :window.innerWidth * 0.5,
  1414. value: (i+1)+'.'+label
  1415. },{
  1416. store: comStore,
  1417. queryMode: 'local',
  1418. editable: false,
  1419. displayField: 'value',
  1420. padding:'0 0 0 10',
  1421. valueField: 'value',
  1422. logic:logic,
  1423. labelSeparator:'',
  1424. fieldStyle:fieldStyle,
  1425. xtype:'combo',
  1426. allowBlank:!bool
  1427. }]
  1428. });
  1429. }
  1430. break;
  1431. case "B":
  1432. var comStore = Ext.create('Ext.data.Store', {
  1433. fields: ['value'],
  1434. data: [{
  1435. "value": "是"
  1436. },{
  1437. "value": "否"
  1438. },{
  1439. "value": "不执行"
  1440. }]
  1441. });
  1442. return Ext.create('Ext.form.FieldContainer',{
  1443. defaults: {
  1444. hideLabel: true
  1445. },
  1446. hideLabel:true,
  1447. columnWidth:0.8,
  1448. layout: {
  1449. type: 'table',
  1450. columns:2,
  1451. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  1452. },
  1453. items: [{
  1454. xtype: 'displayfield',
  1455. maxWidth :window.innerWidth * 0.3,
  1456. value: (i+1)+'.'+label
  1457. },{
  1458. store: comStore,
  1459. queryMode: 'local',
  1460. editable: false,
  1461. displayField: 'value',
  1462. valueField: 'value',
  1463. columnWidth: 0.3,
  1464. padding:'0 0 0 10',
  1465. logic:logic,
  1466. fieldStyle:fieldStyle ,
  1467. blankText: "不允许为空",
  1468. allowBlank:!bool,
  1469. hideLabel:true,
  1470. xtype:'combo',
  1471. labelSeparator:''
  1472. }
  1473. ]
  1474. });
  1475. }
  1476. },
  1477. getStringByDate: function() {
  1478. var date = arguments[0];
  1479. var m = date.getMonth();
  1480. var month = m + 1;
  1481. return date.getFullYear() + "-" + month + "-" + date.getDate();
  1482. },
  1483. listeners: {
  1484. beforerender: function() {
  1485. var me = this;
  1486. formCondition = this.BaseUtil.getUrlParam('formCondition'); //从url解析参数
  1487. formCondition = (formCondition == null) ? "": formCondition.replace(/IS/g, "=");
  1488. var strArr = formCondition.split("=");
  1489. Ext.Ajax.request({
  1490. url: basePath + 'common/getCustomSetupOfTask.action',
  1491. params: {
  1492. nodeId: strArr[1],
  1493. master: master,
  1494. _noc: 1
  1495. },
  1496. success: function(response, options) {
  1497. var localJson = Ext.decode(response.responseText);
  1498. cs = localJson.cs;
  1499. var arr = null;
  1500. if (localJson.data != null) {
  1501. arr = localJson.data.split(";");
  1502. }
  1503. if(localJson.isApprove==1){
  1504. Ext.getCmp('disagree').setDisabled(true);
  1505. }
  1506. var customSetup = Ext.getCmp('customSetup');
  1507. if (cs != null && cs.length > 0) {
  1508. customSetup.show();
  1509. var csstr='';
  1510. for (var i = 0; i < cs.length; i++) {
  1511. csstr=cs[i].toString();
  1512. var i1 = csstr.indexOf('^');
  1513. var i2 = csstr.indexOf('$');
  1514. var value = csstr.substring(0, i1);
  1515. var type = csstr.substring(i1 + 1, i2);
  1516. var neccesary = csstr.substring(i2 +1,i2+2);
  1517. var field = me.getFieldByType(type, i,csstr,value,neccesary);
  1518. if (arr != null) {
  1519. field.items.items[1].setValue(arr[i].substring(arr[i].indexOf("(") + 1, arr[i].indexOf(")")));
  1520. }
  1521. customSetup.add(field);
  1522. }
  1523. }
  1524. }
  1525. });
  1526. },
  1527. afterrender: function() {
  1528. var me = this;
  1529. formCondition = this.BaseUtil.getUrlParam('formCondition'); //从url解析参数
  1530. formCondition = (formCondition == null) ? "": formCondition.replace(/IS/g, "=");
  1531. var strArr = formCondition.split("=");
  1532. nodeId = nodeId != null ? nodeId: this.BaseUtil.getUrlParam('nodeId');
  1533. nodeId =nodeId !=null?nodeId :strArr[1];
  1534. Ext.Ajax.request({
  1535. url: basePath + 'common/getProcessInstanceId.action',
  1536. params: {
  1537. jp_nodeId: nodeId,
  1538. master: master,
  1539. _noc: 1
  1540. },
  1541. success: function(response) {
  1542. var res = response.responseText;
  1543. processInstanceId = Ext.decode(res).processInstanceId;
  1544. me.getCommunicates(nodeId,processInstanceId);
  1545. Ext.getCmp('historyGrid').getOwnStore(processInstanceId);
  1546. Ext.Ajax.request({ //获取当前节点对应的JProcess对象
  1547. url: basePath + 'common/getCurrentNode.action',
  1548. params: {
  1549. jp_nodeId: nodeId,
  1550. master: master,
  1551. _noc: 1
  1552. },
  1553. success: function(response) {
  1554. var res = new Ext.decode(response.responseText);
  1555. ProcessData = res.info.currentnode;
  1556. forknode=res.info.forknode;
  1557. if(ProcessData.jp_pagingid && parent.Ext){
  1558. var win=parent.Ext.getCmp('msg-win-'+ProcessData.jp_pagingid);
  1559. if(win){
  1560. win.close();
  1561. }
  1562. }
  1563. Ext.getCmp('currentnode').setText('当前节点:<font size=2 color="red">' + ProcessData.jp_nodeName + '</font>');
  1564. Ext.getCmp('launchername').setText('发起人:<font size=2 color="red">' + ProcessData.jp_launcherName + '</font>');
  1565. Ext.getCmp('launchtime').setText('发起时间:<font size=2 color="red">' + Ext.Date.format(new Date(ProcessData.jp_launchTime), "Y-m-d H:i:s") + '</font>');
  1566. Ext.getCmp('label1').setText('<span style="font-weight: bold !important;font-size:18px">' + ProcessData.jp_name + '</span>');
  1567. var formCondition = ProcessData.jp_keyName + "IS" + ProcessData.jp_keyValue;
  1568. var gridCondition = '';
  1569. if (ProcessData.jp_keyName) {
  1570. gridCondition = ProcessData.jp_formDetailKey + 'IS' + ProcessData.jp_keyValue;
  1571. }
  1572. var caller = ProcessData.jp_caller;
  1573. var url = basePath + ProcessData.jp_url;
  1574. var queryType='form';
  1575. var myurl;
  1576. if (me.BaseUtil.contains(url, '?', true)) {
  1577. myurl = url + '&formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  1578. } else {
  1579. myurl = url + '?formCondition=' + formCondition + '&gridCondition=' + gridCondition;
  1580. }
  1581. myurl += '&_noc=1&datalistId=NaN'; // 不限制权限
  1582. if (master) {
  1583. myurl += '&newMaster=' + master;
  1584. }
  1585. if(myurl.indexOf('jsps/ma/jprocess/AutoJprocess.jsp?type=1')>0){
  1586. myurl+='&caller='+caller;
  1587. queryType='tabpanel';
  1588. }
  1589. panel = new Ext.panel.Panel({
  1590. id: 'mm',
  1591. style: {
  1592. background: '#f0f0f0',
  1593. border: 'none'
  1594. },
  1595. frame: true,
  1596. border: false,
  1597. layout: 'fit',
  1598. height: window.innerHeight,
  1599. iconCls: 'x-tree-icon-tab-tab',
  1600. //html: '<iframe id="iframe_maindetail" name = "iframe_maindetail" src="' + myurl + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  1601. items: {xtype: 'component',
  1602. id:'iframe_maindetail',
  1603. autoEl: {
  1604. tag: 'iframe',
  1605. style: 'height: 100%; width: 100%; border: none;',
  1606. src: myurl},
  1607. listeners: {
  1608. load: {
  1609. element: 'el',
  1610. fn: function (e) {
  1611. TaskId= window.setInterval(findToolbar, 1000);
  1612. }}
  1613. }}
  1614. });
  1615. var viewport = Ext.getCmp("JProcessViewport");
  1616. viewport.insert(2, panel);
  1617. //TaskId= window.setInterval(findToolbar, 1000);
  1618. function findToolbar() {
  1619. var childpanel,childtoolbar;
  1620. var w = iframe_maindetail.contentWindow||iframe_maindetail.window;
  1621. if (w.Ext) {
  1622. //childpanel = w.Ext.ComponentQuery.query(queryType)[0];
  1623. childpanels = w.Ext.ComponentQuery.query(queryType);
  1624. Ext.Array.each(childpanels,function(item,index){
  1625. if(item.dockedItems){
  1626. if(item.dockedItems.items.length>0){
  1627. childpanel = item;
  1628. return false;
  1629. }
  1630. }
  1631. });
  1632. childtoolbar = w.Ext.ComponentQuery.query(queryType+'>toolbar')[0];
  1633. var grid=w.Ext.ComponentQuery.query('grid')[0];
  1634. if (!childpanel || !childpanel.dockedItems) return;
  1635. Ext.Array.each(childpanel.dockedItems.items,
  1636. function(item) {
  1637. if (item.dock == 'bottom') {
  1638. item.removeAll();
  1639. toolbar = item;
  1640. }
  1641. });
  1642. if (childtoolbar != null && (grid==null || (grid!=null && grid.columns && grid.columns.length>0))) {
  1643. window.clearInterval(TaskId);
  1644. var button = res.info.button;
  1645. if (button != null && !ISexecuted) {
  1646. //带XTYPE的BUTTON
  1647. var buttontype = button.jb_fields;
  1648. var neccessaryField = button.jt_neccessaryfield;
  1649. if(buttontype=='updatedetail'){
  1650. grid=w.Ext.ComponentQuery.query('grid')[0];
  1651. if (neccessaryField != null) {
  1652. grid.readOnly=false;
  1653. grid.NoAdd=true;
  1654. var fields = neccessaryField.split(","),addItems=new Array(),fieldtype=null,editable=false;
  1655. Ext.Array.each(grid.columns,function(column){
  1656. editable=false;
  1657. Ext.Array.each(fields,function(field) {
  1658. var f =column.xtype;
  1659. if(column.dataIndex==field){
  1660. column.getEl().applyStyles('color:#FF0000');
  1661. column.neccessaryField=true;
  1662. editable=true;
  1663. if (f=="numbercolumn") {
  1664. column.editor={
  1665. xtype:'numberfield',
  1666. format:'0',
  1667. hideTrigger:true
  1668. };
  1669. } else if (f=="floatcolumn") {
  1670. column.editor={
  1671. xtype:'numberfield',
  1672. format:'0.00',
  1673. hideTrigger:true
  1674. };
  1675. } else if (f.indexOf("floatcolumn")>-1) {
  1676. var format = "0.";
  1677. var length =parseInt(f.substring(11));
  1678. for (var i = 0; i < length; i++) {
  1679. format += "0";
  1680. }
  1681. column.editor={
  1682. xtype:'numberfield',
  1683. format:format,
  1684. hideTrigger:true
  1685. };
  1686. } else if (f =="datecolumn") {
  1687. column.editor={
  1688. xtype:'datefield',
  1689. format:"Y-m-d",
  1690. hideTrigger:false
  1691. };
  1692. } else if (f =="datetimecolumn") {
  1693. column.editor={
  1694. xtype:'datetimefield',
  1695. format:"Y-m-d H:i:s",
  1696. hideTrigger:false
  1697. };
  1698. } else if (f =="timecolumn") {
  1699. column.editor={
  1700. xtype:'timefield',
  1701. format:"H:i",
  1702. hideTrigger:false
  1703. };
  1704. } else if (f =="monthcolumn") {
  1705. column.editor={
  1706. xtype:'monthdatefield',
  1707. hideTrigger:false
  1708. };
  1709. } else if (f =="textcolumn" || f=="textfield" || f=="text") {
  1710. column.editor={
  1711. xtype:'textfield'
  1712. };
  1713. } else if (f =="textareafield") {
  1714. column.editor={
  1715. xtype:'textareafield'
  1716. };
  1717. } else if (f=="textareatrigger") {
  1718. column.editor={
  1719. xtype:'textareatrigger',
  1720. hideTrigger:false
  1721. };
  1722. } else if (f=="dbfindtrigger") {
  1723. column.editor={
  1724. xtype:'dbfindtrigger',
  1725. hideTrigger:false
  1726. };
  1727. } else if (f =="multidbfindtrigger") {
  1728. column.editor={
  1729. xtype:'multidbfindtrigger',
  1730. hideTrigger:false
  1731. };
  1732. } else if (f=="datehourminutefield") {
  1733. column.editor={
  1734. xtype:'datehourminutefield',
  1735. hideTrigger:false
  1736. };
  1737. } else if (f=="checkbox") {
  1738. column.editor={
  1739. xtype:'checkbox',
  1740. cls:'x-grid-checkheader-editor',
  1741. hideTrigger:false
  1742. };
  1743. }
  1744. return false;
  1745. }
  1746. });
  1747. if(!editable) {
  1748. column.editor=null;
  1749. }
  1750. });
  1751. toolbar.add(['->', {
  1752. xtype: 'button',
  1753. text:'修改明细',
  1754. iconCls: 'x-button-icon-save',
  1755. cls: 'x-btn-gray',
  1756. handler:function(btn){
  1757. var values = {};
  1758. var jsonGridData = new Array();
  1759. var s = grid.getStore().data.items;//获取store里面的数据
  1760. var dd;
  1761. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  1762. var data = s[i].data;
  1763. dd = new Object();
  1764. if(s[i].dirty && !grid.GridUtil.isBlank(grid, data)){
  1765. Ext.each(grid.columns, function(c){
  1766. if((c.neccessaryField && c.logic!='ignore')|| c.logic=='keyField'){
  1767. if(c.xtype == 'datecolumn'){
  1768. c.format = c.format || 'Y-m-d';
  1769. if(Ext.isDate(data[c.dataIndex])){
  1770. dd[c.dataIndex] = Ext.Date.format(data[c.dataIndex], c.format);
  1771. }
  1772. } else if(c.xtype == 'datetimecolumn'){
  1773. if(Ext.isDate(data[c.dataIndex])){
  1774. dd[c.dataIndex] = Ext.Date.format(data[c.dataIndex], 'Y-m-d H:i:s');
  1775. }
  1776. } else if(c.xtype == 'numbercolumn'){
  1777. dd[c.dataIndex] = "" + s[i].data[c.dataIndex];
  1778. } else {
  1779. dd[c.dataIndex] = s[i].data[c.dataIndex];
  1780. }
  1781. }
  1782. });
  1783. jsonGridData.push(Ext.JSON.encode(dd));
  1784. }
  1785. }
  1786. childpanel.getForm().getFields().each(function(field) {
  1787. if (field.isDirty() && field.logic!='ignore' ) {
  1788. var data = field['getSubmitData'](true);
  1789. if (Ext.isObject(data)) {
  1790. Ext.iterate(data,
  1791. function(name, val) {
  1792. if (true && val === '') {
  1793. val = field.emptyText || '';
  1794. }
  1795. if (name in values) {
  1796. var bucket = values[name],
  1797. isArray = Ext.isArray;
  1798. if (!isArray(bucket)) {
  1799. bucket = values[name] = [bucket];
  1800. }
  1801. if (isArray(val)) {
  1802. values[name] = bucket.concat(val);
  1803. } else {
  1804. bucket.push(val);
  1805. }
  1806. } else {
  1807. values[name] = val;
  1808. }
  1809. });
  1810. }
  1811. }
  1812. });
  1813. values[ProcessData.jp_keyName] = ProcessData.jp_keyValue;
  1814. Ext.Ajax.request({
  1815. url: basePath + '/common/processUpdate.action',
  1816. method: 'post',
  1817. params: {
  1818. caller: caller,
  1819. processInstanceId:ProcessData.jp_processInstanceId,
  1820. formStore: unescape(Ext.JSON.encode(values).replace(/\\/g, "%")),
  1821. param: unescape(jsonGridData.toString()),
  1822. _noc: 1
  1823. },
  1824. callback: function(options, success, response) {
  1825. var localJson = new Ext.decode(response.responseText);
  1826. canexecute = true;
  1827. if (localJson.success) {
  1828. conditionValidation=0;
  1829. updateSuccess();
  1830. grid.GridUtil.loadNewStore(grid,{
  1831. caller:caller,
  1832. condition:ProcessData.jp_formDetailKey + '=' + ProcessData.jp_keyValue
  1833. });
  1834. } else if (localJson.exceptionInfo) {
  1835. var str = localJson.exceptionInfo;
  1836. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') { //特殊情况:操作成功,但是出现警告,允许刷新页面
  1837. str = str.replace('AFTERSUCCESS', '');
  1838. conditionValidation=0;
  1839. updateSuccess();
  1840. }else conditionValidation=1;
  1841. showError(str);
  1842. return;
  1843. } else {
  1844. updateFailure();
  1845. }
  1846. }
  1847. });
  1848. }
  1849. },
  1850. '->']);
  1851. }
  1852. }else if (buttontype.indexOf('#') > 0) {
  1853. if(buttontype.indexOf(',') > 0){
  1854. var btns = buttontype.replace(/xtype#/,'').split(',');
  1855. toolbar.add(['->']);
  1856. Ext.Array.each(btns,function(btn){
  1857. toolbar.add({
  1858. xtype: btn,
  1859. fireHandler: function(e){
  1860. var me = this,
  1861. handler = me.handler;
  1862. canexecute=true;
  1863. if(btn!='erpEditDetailButton'){
  1864. var updateStatus = function(from,to){
  1865. var form = me.ownerCt.ownerCt;
  1866. var statusCodeField = form.statuscodeField;
  1867. var tablename = form.tablename;
  1868. var keyField = form.keyField;
  1869. if(statusCodeField&&tablename&&keyField){
  1870. var w = window.frames['iframe_maindetail'].contentWindow;
  1871. tablename = tablename.toUpperCase();
  1872. if(tablename.indexOf('LEFT JOIN')>-1){
  1873. tablename = tablename.substring(0,tablename.indexOf('LEFT JOIN'));
  1874. }else if(tablename.indexOf('RIGHT JOIN')>-1){
  1875. tablename = tablename.substring(0,tablename.indexOf('RIGHT JOIN'));
  1876. }
  1877. if(w.Ext&&tablename){
  1878. var key = w.Ext.getCmp(keyField);
  1879. if(key&&key.value){
  1880. Ext.Ajax.request({
  1881. url:basePath + 'common/updateByCondition.action',
  1882. method:'post',
  1883. async:false,
  1884. params:{
  1885. table:tablename,
  1886. update:statusCodeField + "='"+to+"'",
  1887. condition:statusCodeField + "='"+from+"' and " +keyField + "='"+key.value+"'"
  1888. },
  1889. callback:function(options,success,response){
  1890. var res = Ext.decode(response.responseText);
  1891. if(res.exceptionInfo){
  1892. showError(res.exceptionInfo);
  1893. }
  1894. }
  1895. });
  1896. }
  1897. }
  1898. }
  1899. };
  1900. updateStatus('COMMITED','ENTERING');
  1901. me.fireEvent('click', me, e);
  1902. Ext.defer(function(){
  1903. updateStatus('ENTERING','COMMITED');
  1904. },500);
  1905. }else{
  1906. me.fireEvent('click', me, e,true);
  1907. }
  1908. if (handler) {
  1909. handler.call(me.scope || me, me, e,w.Ext.ComponentQuery.query('grid'),button.jt_neccessaryfield);
  1910. }
  1911. me.onBlur();
  1912. },
  1913. listeners:{
  1914. afterrender:function(btn){
  1915. Ext.defer(function(){
  1916. if(btn.hidden){
  1917. btn.show();
  1918. }
  1919. },500);
  1920. }
  1921. }
  1922. });
  1923. });
  1924. toolbar.add(['->']);
  1925. }else{
  1926. toolbar.add(['->', {
  1927. xtype: buttontype.split('#')[1],
  1928. text: button.jb_buttonname,
  1929. fireHandler: function(e){
  1930. var me = this,
  1931. handler = me.handler;
  1932. canexecute=true;
  1933. me.fireEvent('click', me, e);
  1934. if (handler) {
  1935. handler.call(me.scope || me, me, e);
  1936. }
  1937. me.onBlur();
  1938. }
  1939. },
  1940. '->']);
  1941. }
  1942. } else {
  1943. childtoolbar.add(['->', {
  1944. xtype: 'button',
  1945. text: button.jb_buttonname,
  1946. id: button.jb_id,
  1947. group: button.jb_fields,
  1948. iconCls: 'x-button-icon-save',
  1949. cls: 'x-btn-gray',
  1950. formBind: true,
  1951. handler: function() {
  1952. var values = {};
  1953. var necessaryValues = (iframe_maindetail.contentWindow||iframe_maindetail.window).Ext.getCmp('form').getValues();
  1954. var bool = true;
  1955. if (requiredFields != null) {
  1956. var fields = requiredFields.split(",");
  1957. Ext.Array.each(fields,
  1958. function(field) {
  1959. if (necessaryValues[field] == null || necessaryValues[field] == "") {
  1960. bool = false;
  1961. showError('保存之前请先填写必填的信息!');
  1962. return false;
  1963. }
  1964. });
  1965. }
  1966. if (bool) {
  1967. childpanel.getForm().getFields().each(function(field) {
  1968. //&& field.groupName==button.jb_fields 有些组件写的有问题
  1969. if (field.isDirty() && field.logic!='ignore' ) {
  1970. var data = field['getSubmitData'](true);
  1971. if (Ext.isObject(data)) {
  1972. Ext.iterate(data,
  1973. function(name, val) {
  1974. if (true && val === '') {
  1975. val = field.emptyText || '';
  1976. }
  1977. if (name in values) {
  1978. var bucket = values[name],
  1979. isArray = Ext.isArray;
  1980. if (!isArray(bucket)) {
  1981. bucket = values[name] = [bucket];
  1982. }
  1983. if (isArray(val)) {
  1984. values[name] = bucket.concat(val);
  1985. } else {
  1986. bucket.push(val);
  1987. }
  1988. } else {
  1989. values[name] = val;
  1990. }
  1991. });
  1992. }
  1993. }
  1994. });
  1995. var grids = w.Ext.ComponentQuery.query('itemgrid');
  1996. Ext.each(grids,function(g,index){
  1997. if(g.xtype=='itemgrid' && !g.readOnly){
  1998. g.saveValue();
  1999. }
  2000. });
  2001. values[ProcessData.jp_keyName] = ProcessData.jp_keyValue;
  2002. Ext.Ajax.request({
  2003. url: basePath + '/common/processUpdate.action',
  2004. method: 'post',
  2005. params: {
  2006. caller: caller,
  2007. processInstanceId:ProcessData.jp_processInstanceId,
  2008. formStore: unescape(Ext.JSON.encode(values).replace(/\\/g, "%")),
  2009. _noc: 1
  2010. },
  2011. callback: function(options, success, response) {
  2012. var localJson = new Ext.decode(response.responseText);
  2013. canexecute = true;
  2014. if (localJson.success) {
  2015. conditionValidation=0;
  2016. updateSuccess();
  2017. } else if (localJson.exceptionInfo) {
  2018. var str = localJson.exceptionInfo;
  2019. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') { //特殊情况:操作成功,但是出现警告,允许刷新页面
  2020. str = str.replace('AFTERSUCCESS', '');
  2021. conditionValidation=0;
  2022. updateSuccess();
  2023. }else conditionValidation=1;
  2024. showError(str);
  2025. return;
  2026. } else {
  2027. updateFailure();
  2028. }
  2029. }
  2030. });
  2031. }
  2032. }
  2033. },
  2034. '->']);
  2035. }
  2036. var items = w.Ext.ComponentQuery.query('form')[0].items.items;
  2037. var forms = w.Ext.ComponentQuery.query('form');
  2038. Ext.Array.each(forms,function(form){
  2039. if(form.dockedItems){
  2040. if(form.dockedItems.items.length>0){
  2041. items = form.items.items;
  2042. return false;
  2043. }
  2044. }
  2045. });
  2046. //var nameArray=button.jb_buttonname.split(";");
  2047. var fieldsArray=button.jb_fields.split(";");
  2048. requiredFields = neccessaryField;
  2049. var necFields=neccessaryField!=null?neccessaryField.split(","):[];
  2050. Ext.each(items,function(item) {
  2051. if (item.groupName == button.jb_buttonname && button.jb_fields.indexOf("#") > 0) {
  2052. if(item.xtype =='itemgrid'){
  2053. item.readOnly=false;
  2054. }else{
  2055. item.setReadOnly(false);
  2056. }
  2057. }
  2058. if (Ext.Array.contains(fieldsArray,item.groupName)) {
  2059. if(item.xtype =='itemgrid'){
  2060. item.readOnly=false;
  2061. }else{
  2062. item.setReadOnly(false);
  2063. }
  2064. if (item.xtype!='checkbox' && item.xtype!='itemgrid' && !Ext.Array.contains(necFields,item.name)) {
  2065. item.setFieldStyle("background:#FFFAFA;color:#515151;");
  2066. }
  2067. }
  2068. if(Ext.Array.contains(necFields,item.name)){
  2069. if(item.xtype =='itemgrid'){
  2070. item.readOnly=false;
  2071. }else{
  2072. item.setReadOnly(false);
  2073. }
  2074. if(item.xtype!='checkbox')
  2075. item.setFieldStyle("background:#fffac0;color:#515151;");
  2076. }
  2077. });
  2078. }
  2079. }
  2080. }
  2081. };
  2082. }
  2083. });
  2084. }
  2085. });
  2086. }
  2087. },
  2088. setLoading : function(b) {// 原this.getActiveTab().setLoading()换成此方法,解决Window模式下无loading问题
  2089. var mask = this.mask;
  2090. if (!mask) {
  2091. this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
  2092. msg : "处理中,请稍后...",
  2093. msgCls : 'z-index:10000;'
  2094. });
  2095. }
  2096. if (b)
  2097. mask.show();
  2098. else
  2099. mask.hide();
  2100. }
  2101. });