BillTask.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.plm.task.BillTask', {
  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 : [ 'core.form.Panel', 'plm.task.BillTask', 'core.grid.Panel2',
  8. 'core.toolbar.Toolbar', 'core.button.Add', 'core.button.Close', 'core.button.Over',
  9. 'core.trigger.TextAreaTrigger', 'core.trigger.DbfindTrigger','core.form.MultiField' ],
  10. init : function() {
  11. var me = this;
  12. this.control({
  13. 'field[name=sourcecode]' : {
  14. afterrender : function(f) {
  15. f.setFieldStyle({
  16. 'color' : 'red'
  17. });
  18. f.focusCls = 'mail-attach';
  19. var c = Ext.Function.bind(me.openSource, me);
  20. Ext.EventManager.on(f.inputEl, {
  21. mousedown : c,
  22. scope : f,
  23. buffer : 100
  24. });
  25. }
  26. },
  27. 'field[name=id]' : {
  28. afterrender : function(f) {
  29. var id = f.getValue();
  30. if (!Ext.isEmpty(id)) {
  31. me.getWorkRecord(id, f.ownerCt);
  32. }
  33. }
  34. },
  35. 'erpCloseButton' : {
  36. click : function(btn) {
  37. this.FormUtil.beforeClose(this);
  38. }
  39. },
  40. 'erpOverButton' : {
  41. click : function(b) {
  42. warnMsg('确定结束该任务?', function(k){
  43. if(k == 'yes' || k == 'ok') {
  44. var form = b.ownerCt.ownerCt;
  45. me.onOver(form);
  46. }
  47. });
  48. }
  49. }
  50. });
  51. },
  52. openSource : function(e, el, obj) {
  53. var f = obj.scope;
  54. if (f.value) {
  55. this.FormUtil.onAdd(null, f.ownerCt.down('#sourcecode').value,
  56. f.ownerCt.down('#sourcelink').value + '&_noc=1');
  57. }
  58. },
  59. getWorkRecord : function(id, form) {
  60. var me = this;
  61. Ext.Ajax.request({
  62. url : basePath + 'common/getFieldsDatas.action',
  63. params: {
  64. caller: 'WorkRecord',
  65. fields: 'wr_recorder,wr_recorddate,wr_redcord',
  66. condition: 'wr_taskid=' + id + ' order by wr_recorddate'
  67. },
  68. method : 'post',
  69. callback : function(opt, s, res){
  70. var r = new Ext.decode(res.responseText);
  71. if(r.exceptionInfo){
  72. showError(r.exceptionInfo);return;
  73. }
  74. var status = form.down('#handstatuscode');
  75. if(status && status.getValue() != 'FINISHED') {
  76. form.down('erpOverButton').show();
  77. } else {
  78. form.down('erpOverButton').hide();
  79. }
  80. if(r.success && r.data){
  81. var datas = typeof r.data === 'string' ? Ext.decode(r.data) : r.data;
  82. if(datas.length > 0 ) {
  83. Ext.each(datas, function(){
  84. form.add(me.createRecord(this.WR_RECORDER, this.WR_RECORDDATE, this.WR_REDCORD));
  85. });
  86. }
  87. }
  88. }
  89. });
  90. },
  91. createRecord : function(r, t, v) {
  92. var args = {columnWidth : 1};
  93. if (r) {
  94. args.fieldLabel = Ext.Date.format(Ext.Date.parse(t,'Y-m-d H:i:s'),'m-d H:i:s') + '<br>' + r;
  95. args.value = v;
  96. args.readOnly = true;
  97. args.fieldStyle = 'background:#f1f1f1;';
  98. args.labelSeparator = '';
  99. } else {
  100. args.fieldLabel = '处理情况描述';
  101. args.name = 'wr_redcord';
  102. args.id = 'wr_redcord';
  103. args.cls = 'form-field-allowBlank';
  104. }
  105. return Ext.create('Ext.form.field.TextArea', args);
  106. },
  107. onOver : function(form) {
  108. var id = form.down('#id').getValue();
  109. form.setLoading(true);
  110. Ext.Ajax.request({
  111. url : basePath + 'plm/record/endBillTask.action',
  112. params : {
  113. caller : caller,
  114. _noc : 1,
  115. id : id
  116. },
  117. callback : function(opt, s, res) {
  118. form.setLoading(false);
  119. var r = Ext.decode(res.responseText);
  120. if (r.success) {
  121. showMessage('提示', '结束成功!', 1000);
  122. window.location.reload();
  123. } else if(r.exceptionInfo) {
  124. showError(r.exceptionInfo);
  125. }
  126. }
  127. });
  128. }
  129. });