BillRecord.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.plm.record.BillRecord', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'plm.record.BillRecord','core.grid.Panel2','core.toolbar.Toolbar','core.form.Panel',
  9. 'core.button.Close','core.button.Over','core.button.Update','core.button.DeleteDetail',
  10. 'core.button.ChangeHandler','core.trigger.DbfindTrigger','core.form.FileField','core.button.Confirm',
  11. 'core.button.NoConfirm'
  12. ],
  13. init:function(){
  14. var me = this;
  15. me.control({
  16. 'erpFormPanel': {
  17. afterrender:function(form){
  18. Ext.defer(function(){
  19. var ra_id=form.down('#ra_id').getValue(),
  20. status=form.down('#ra_statuscode').getValue();
  21. if(ra_id){
  22. var data= me.getWorkRecord(ra_id);
  23. if(data.length>0){
  24. var index=me.getInsertIndex();
  25. form.insert(index,{
  26. xtype: 'fieldset',
  27. title: '<h2><img src="' + basePath + 'resource/images/icon/communicate.png" width=20/>处理明细</h2>',
  28. collapsible: true,
  29. //collapsed: true,
  30. columnWidth:1,
  31. layout: 'anchor',
  32. defaults: {
  33. anchor: '100%',
  34. labelStyle: 'padding-left:4px;'
  35. },
  36. items:[{
  37. autoScroll: true,
  38. xtype: 'dataview',
  39. tpl:Ext.create('Ext.XTemplate',
  40. '<tpl for=".">',
  41. '<div class="search-item">',
  42. '<h3><span>{WR_RECORDDATE}<br /> {WR_RECORDER}</span>',
  43. '<font color="blue">{WR_PROGRESS:this.formatKind} &nbsp;&nbsp;</font></h3>',
  44. '<p><font color="green">回复信息:</font> {WR_REDCORD}</p>',
  45. '</div></tpl>',
  46. {formatKind: function(value){
  47. if(value=='reply') return '回复处理';
  48. else if(value=='confirm') return '确认处理';
  49. else if(value=='noconfirm') return '驳回处理';}
  50. }),
  51. store: Ext.create('Ext.data.Store', {
  52. fields:[{name: 'WR_RECORDER' },
  53. {name: 'WR_RECORDDATE'},
  54. {name: 'WR_PROGRESS'},
  55. {name: 'WR_REDCORD'}],
  56. data:data
  57. })
  58. }]
  59. });
  60. }
  61. if(status!='FINISHED')
  62. form.add(me.createRecord());
  63. }
  64. },200);
  65. }
  66. },
  67. 'field[name=sourcecode]':{
  68. afterrender:function(f){
  69. if(f.value!=null && f.value!=''){
  70. f.setFieldStyle({
  71. 'color': 'red'
  72. });
  73. f.focusCls = 'mail-attach';
  74. var c = Ext.Function.bind(me.openSource, me);
  75. Ext.EventManager.on(f.inputEl, {
  76. mousedown : c,
  77. scope: f,
  78. buffer : 100
  79. });
  80. }
  81. }
  82. },
  83. 'erpUpdateButton' : {
  84. click : function(b) {
  85. var form = b.ownerCt.ownerCt,
  86. f = form.down('#wr_redcord');
  87. if(f && !Ext.isEmpty(f.getValue())) {
  88. me.onUpdate(form);
  89. }
  90. },
  91. afterrender:function(btn){
  92. var status=Ext.getCmp('ra_status');
  93. if(status.value == '待确认' || status.value =='已结束'){
  94. btn.hide();
  95. }
  96. }
  97. },
  98. 'erpChangeHandlerButton' : {
  99. afterrender : function(b) {
  100. var form = b.ownerCt.ownerCt,
  101. status = form.down('#ra_statuscode');
  102. if(status && (status.getValue() == 'FINISHED' || status.getValue()=='UNCONFIRMED')) {
  103. b.hide();
  104. } else {
  105. b.setDisabled(false);
  106. b.show();
  107. }
  108. },
  109. click : function(b) {
  110. warnMsg('确定变更该任务?', function(k){
  111. if(k == 'yes' || k == 'ok') {
  112. var form = b.ownerCt.ownerCt;
  113. me.onHandlerChange(form);
  114. }
  115. });
  116. }
  117. },
  118. 'erpOverButton' : {
  119. click : function(b) {
  120. warnMsg('确定已达到提出人要求,结束该任务?', function(k){
  121. if(k == 'yes' || k == 'ok') {
  122. var form = b.ownerCt.ownerCt;
  123. me.onOver(form);
  124. }
  125. });
  126. },
  127. afterrender:function(btn){
  128. var status=Ext.getCmp('ra_status'),resourcename=Ext.getCmp('ra_resourcename').getValue();
  129. btn.setText('回复');
  130. if(status.value =='待确认' || status.value =='已完成' || resourcename!=recorder){
  131. btn.hide();
  132. }
  133. }
  134. },
  135. 'erpConfirmButton' : {
  136. afterrender:function(btn){
  137. var status=Ext.getCmp('ra_status'),exhibitor=Ext.getCmp('recorder');
  138. if(status.value !='待确认' || exhibitor.value !=recorder || status =='已完成'){
  139. btn.hide();
  140. }
  141. },
  142. click : function(b) {
  143. var form = b.ownerCt.ownerCt;
  144. me.onConfirm(form);
  145. }
  146. },
  147. 'erpNoConfirmButton' : {
  148. afterrender:function(btn){
  149. var status=Ext.getCmp('ra_status'),exhibitor=Ext.getCmp('recorder');
  150. if(status.value !='待确认' || exhibitor.value !=recorder || status.value =='已完成'){
  151. btn.hide();
  152. }
  153. },
  154. click : function(b) {
  155. var form = b.ownerCt.ownerCt;
  156. me.onNoConfirm(form);
  157. }
  158. }
  159. });
  160. },
  161. openSource : function(e, el, obj) {
  162. var f = obj.scope;
  163. if(f.value) {
  164. this.FormUtil.onAdd(null, f.ownerCt.down('#sourcecode').value,
  165. f.ownerCt.down('#sourcelink').value + '&_noc=1');
  166. }
  167. },
  168. getInsertIndex:function(){
  169. var form=Ext.getCmp('form'),i=0;
  170. Ext.Array.each(form.items.items,function(item,index){
  171. if(item.name=='description'){
  172. i=index;
  173. }
  174. });
  175. return i+1;
  176. },
  177. getWorkRecord : function(id, form) {
  178. var me = this,data=[];
  179. Ext.Ajax.request({
  180. url : basePath + 'common/getFieldsDatas.action',
  181. params: {
  182. caller: 'WorkRecord',
  183. fields: 'wr_recorder,wr_recorddate,wr_redcord,WR_PROGRESS',
  184. condition: 'wr_raid=' + id + ' order by wr_recorddate'
  185. },
  186. async:false,
  187. method : 'post',
  188. callback : function(opt, s, res){
  189. console.log(res);
  190. var r = new Ext.decode(res.responseText);
  191. if(r.exceptionInfo){
  192. showError(r.exceptionInfo);return;
  193. }
  194. /* var status = form.down('#ra_statuscode');
  195. //alert(status.getValue());
  196. if(status && (status.getValue() != 'FINISHED' || status.getValue() != 'UNCONFIRMED')) {
  197. //form.down('erpUpdateButton').show();
  198. //form.down('erpOverButton').show();
  199. form.add(me.createRecord());
  200. } else {
  201. form.down('erpOverButton').hide();
  202. //form.down('erpConfirmButton').hide();
  203. }*/
  204. if(r.success && r.data){
  205. data= new Ext.decode(r.data);
  206. }
  207. }
  208. });
  209. return data;
  210. },
  211. createRecord : function(r, t, v) {
  212. var args = {columnWidth : 1};
  213. if (r) {
  214. args.fieldLabel = Ext.Date.format(Ext.Date.parse(t,'Y-m-d H:i:s'),'m-d H:i:s') + '<br>' + r;
  215. args.value = v;
  216. args.readOnly = true;
  217. args.fieldStyle = 'background:#f1f1f1;';
  218. args.labelSeparator = '';
  219. } else {
  220. args.fieldLabel = '回复信息';
  221. args.name = 'wr_redcord';
  222. args.id = 'wr_redcord';
  223. args.labelAlign='top';
  224. args.cls = 'form-field-allowBlank';
  225. }
  226. return Ext.create('Ext.form.field.TextArea', args);
  227. },
  228. onUpdate : function(form) {
  229. var id = form.down('#ra_id').getValue(),
  230. text = form.down('#wr_redcord').getValue();
  231. form.setLoading(true);
  232. Ext.Ajax.request({
  233. url : basePath + 'plm/record/updateBillRecord.action',
  234. params : {
  235. _noc : 1,
  236. caller : caller,
  237. wr_raid : id,
  238. wr_redcord : text
  239. },
  240. callback : function(opt, s, res) {
  241. form.setLoading(false);
  242. var r = Ext.decode(res.responseText);
  243. if (r.success) {
  244. showMessage('提示', '保存成功!', 1000);
  245. window.location.reload();
  246. } else if(r.exceptionInfo) {
  247. showError(r.exceptionInfo);
  248. }
  249. }
  250. });
  251. },
  252. onHandlerChange : function(form) {
  253. var me = this;
  254. var win = Ext.create('Ext.window.Window', {
  255. width : 300,
  256. height : 150,
  257. cls : 'custom-blue',
  258. title : '变更处理人',
  259. bodyStyle : 'background:#f1f2f5;',
  260. layout : {
  261. type : 'vbox',
  262. align : 'center',
  263. pack : 'center'
  264. },
  265. items : [{
  266. xtype : 'dbfindtrigger',
  267. name : 'ma_recorder',
  268. labelWidth : 75,
  269. fieldLabel : '新执行人',
  270. listeners : {
  271. aftertrigger : function(t, r) {
  272. t.setValue(r.get('em_name'));
  273. t.em_id = r.get('em_id');
  274. }
  275. }
  276. }],
  277. buttonAlign : 'center',
  278. buttons : [{
  279. text : '确认变更',
  280. cls : 'x-btn-blue',
  281. handler : function(b){
  282. var w = b.ownerCt.ownerCt,
  283. e = w.down('dbfindtrigger');
  284. if(e.em_id) {
  285. me.changeHandler(form, e.em_id);
  286. w.close();
  287. }
  288. }
  289. },{
  290. text : '取消',
  291. cls : 'x-btn-blue',
  292. handler : function(b) {
  293. b.ownerCt.ownerCt.close();
  294. }
  295. }]
  296. });
  297. win.show();
  298. },
  299. changeHandler : function(form, em_id) {
  300. var me = this, id = form.down('#ra_id').getValue();
  301. form.setLoading(true);
  302. Ext.Ajax.request({
  303. url : basePath + 'plm/record/changeBillTask.action',
  304. params : {
  305. caller : caller,
  306. _noc : 1,
  307. ra_id : id,
  308. em_id : em_id
  309. },
  310. callback : function(opt, s, res) {
  311. form.setLoading(false);
  312. var r = Ext.decode(res.responseText);
  313. if (r.success) {
  314. showMessage('提示', '变更成功!', 1000);
  315. me.BaseUtil.getActiveTab().close();
  316. } else if(r.exceptionInfo) {
  317. showError(r.exceptionInfo);
  318. }
  319. }
  320. });
  321. },
  322. onOver : function(form) {
  323. var id = form.down('#ra_id').getValue();
  324. text = form.down('#wr_redcord').getValue();
  325. form.setLoading(true);
  326. Ext.Ajax.request({
  327. url : basePath + 'plm/record/endBillTask.action',
  328. params : {
  329. caller : caller,
  330. _noc : 1,
  331. ra_id : id,
  332. record:text
  333. },
  334. callback : function(opt, s, res) {
  335. form.setLoading(false);
  336. var r = Ext.decode(res.responseText);
  337. if (r.success) {
  338. showMessage('提示', '结束成功!', 1000);
  339. window.location.reload();
  340. } else if(r.exceptionInfo) {
  341. showError(r.exceptionInfo);
  342. }
  343. }
  344. });
  345. },
  346. onConfirm : function(form) {
  347. var id = form.down('#ra_id').getValue();
  348. text = form.down('#wr_redcord').getValue();
  349. form.setLoading(true);
  350. Ext.Ajax.request({
  351. url : basePath + 'plm/record/confirmBillTask.action',
  352. params : {
  353. caller : caller,
  354. _noc : 1,
  355. ra_id : id,
  356. record:text
  357. },
  358. callback : function(opt, s, res) {
  359. form.setLoading(false);
  360. var r = Ext.decode(res.responseText);
  361. if (r.success) {
  362. showMessage('提示', '确认成功!', 1000);
  363. window.location.reload();
  364. } else if(r.exceptionInfo) {
  365. showError(r.exceptionInfo);
  366. }
  367. }
  368. });
  369. },
  370. onNoConfirm:function(form) {
  371. var id = form.down('#ra_id').getValue();
  372. text = form.down('#wr_redcord').getValue();
  373. form.setLoading(true);
  374. Ext.Ajax.request({
  375. url : basePath + 'plm/record/noConfirmBillTask.action',
  376. params : {
  377. caller : caller,
  378. _noc : 1,
  379. ra_id : id,
  380. record:text
  381. },
  382. callback : function(opt, s, res) {
  383. form.setLoading(false);
  384. var r = Ext.decode(res.responseText);
  385. if (r.success) {
  386. showMessage('提示', '驳回成功!', 1000);
  387. var main = parent.Ext.getCmp("content-panel");
  388. if(main) main.getActiveTab().close();
  389. } else if(r.exceptionInfo) {
  390. showError(r.exceptionInfo);
  391. }
  392. }
  393. });
  394. }
  395. });