Feedback.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.sys.Feedback', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. currentManfield:null,
  7. views:[
  8. 'core.form.Panel','sys.Feedback','core.form.MultiField','core.button.Reply',
  9. 'core.button.Add','core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  10. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.ForBidden',
  11. 'core.button.ResForBidden','core.form.FileField','core.button.TurnProject','core.button.TurnBuglist','core.button.Checktask','core.button.Endfeedback',
  12. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger','core.button.Canceltask','core.button.Back','core.button.Confirm',
  13. 'core.button.ChangeHandler'
  14. ],
  15. RelativeFields:{
  16. TechnicalService:{
  17. remarkField:'fb_descriptiontecservice',
  18. plandateField:'fb_plandatetecservice',
  19. resultField:'fb_resulttecservice'
  20. },
  21. ProductDept:{
  22. remarkField:'fb_descriptionpro',
  23. plandateField:'fb_plandatepro',
  24. resultField:'fb_resultpro'
  25. },
  26. 'R&D':{
  27. remarkField:'fb_descriptionrd',
  28. plandateField:'fb_plandaterd',
  29. resultField:'fb_resultrd'
  30. },
  31. Test:{
  32. remarkField:'fb_testdescription',
  33. resultField:'fb_resulttest'
  34. }
  35. },
  36. init:function(){
  37. var me = this;
  38. this.control({
  39. 'erpFormPanel': {
  40. afterrender:function(form){
  41. Ext.defer(function(){
  42. var _k=form.down('#fb_kind').getValue(),
  43. _p=form.down('#fb_position').getValue(),
  44. fbid=form.down('#fb_id').getValue(),
  45. _status=form.down('#fb_statuscode').getValue(),info=null,hasfocused=false,handmanid=null;
  46. if(_status!='ENTERING' && _status!='REPLYED'){
  47. info=me.getCurrentFlow(_k,_p);
  48. if(_p=='End'){
  49. var datalistId = getUrlParam('datalistId');
  50. var datalist = parent.Ext.getCmp(datalistId);
  51. if(datalist){
  52. var record = datalist.currentRecord;
  53. if (record.get('fb_position')=='End')handmanid=record.get('em_id');
  54. }
  55. }else {
  56. handmanid=form.down('#'+info['ff_handmanfield']).getValue();
  57. me.currentManfield=info['ff_handmanfield'];
  58. Ext.getCmp(info['ff_handmanfield']).on('change',function(){
  59. var buttons=Ext.ComponentQuery.query('erpChangeHandlerButton');
  60. if(buttons) buttons[0].setDisabled(false);
  61. });
  62. }
  63. if(handmanid==emid){
  64. Ext.Array.each(form.items.items,function(item){
  65. if(item.groupName==info['ff_caption']){
  66. if(item.fieldLabel=='处理时间' || item.fieldLabel=='回复时间' ){
  67. item.setValue(new Date());
  68. item.setReadOnly(false);
  69. }else if(item.fieldLabel=='预计完成时间' && item.value){
  70. }else if(item.name=='fb_backman'){
  71. item.setValue(em_name);
  72. }else {
  73. if(!hasfocused) {item.focus(false, 200); hasfocused=true;} item.setReadOnly(false);
  74. item.setFieldStyle("background:#fffac0;color:#515151;");
  75. if(me.RelativeFields[_p] && item.name==me.RelativeFields[_p].remarkField) item.setValue(null);
  76. }
  77. }
  78. });
  79. }else {
  80. form.down('erpConfirmButton').hide();
  81. form.down('erpChangeHandlerButton').hide();
  82. form.down('erpBackButton').hide();
  83. }
  84. }
  85. //插入处理日志
  86. if(fbid){
  87. var data= me.loadNewStore(fbid);
  88. var index=me.getInsertIndex();
  89. form.insert(index,{
  90. xtype: 'fieldset',
  91. title: '<h2><img src="' + basePath + 'resource/images/icon/communicate.png" width=20/>处理明细</h2>',
  92. collapsible: true,
  93. //collapsed: true,
  94. columnWidth:1,
  95. layout: 'anchor',
  96. defaults: {
  97. anchor: '100%',
  98. labelStyle: 'padding-left:4px;'
  99. },
  100. items:[{
  101. autoScroll: true,
  102. xtype: 'dataview',
  103. tpl:Ext.create('Ext.XTemplate',
  104. '<tpl for=".">',
  105. '<div class="search-item">',
  106. '<h3><span>{fl_date}<br /> {fl_man}</span>',
  107. '<font color="blue">{fl_position:this.formatTitle} &nbsp;&nbsp;</font></h3>',
  108. '<p>处理方式 :<font color="green">{fl_kind:this.formatKind}</font> {fl_remark}</p>',
  109. '</div></tpl>',
  110. {formatKind: function(value){
  111. if(value=='PLAN') return '回复处理';
  112. else if(value=='CHANGEHANDLER') return '变更处理人';
  113. else if(value=='REVIEW') return '确认处理';}
  114. },{
  115. formatTitle:function(value){
  116. if(value=='TechnicalService') return '技术支持部处理信息';
  117. else if(value=='R&D') return '研发部处理信息';
  118. else if(value=='ProductDept') return '产品部处理信息';
  119. else if(value=='Test') return '测试部处理信息';
  120. else if(value=='End') return '回复处理';
  121. }
  122. }),
  123. store: Ext.create('Ext.data.Store', {
  124. fields:[{name: 'fl_man' },
  125. {name: 'fl_date'},
  126. {name: 'fl_position'},
  127. {name: 'fl_remark'},
  128. {name: 'fl_kind'}
  129. ],
  130. data:data
  131. })
  132. }]
  133. });
  134. }
  135. },200);
  136. }
  137. },
  138. 'erpSaveButton': {
  139. click: function(btn){
  140. var form = me.getForm(btn);
  141. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  142. me.BaseUtil.getRandomNumber();//自动添加编号
  143. }
  144. this.FormUtil.beforeSave(this);
  145. }
  146. },
  147. 'erpDeleteButton' : {
  148. click: function(btn){
  149. me.FormUtil.onDelete(Ext.getCmp('fb_id').value);
  150. }
  151. },
  152. 'erpTurnProject' : {
  153. click: function(btn){
  154. me.FormUtil.onDelete(Ext.getCmp('fb_id').value);
  155. }
  156. },
  157. 'erpCanceltaskButton':{
  158. click: function(btn){
  159. Ext.Ajax.request({
  160. url : basePath + '/sys/feedback/canceltask.action',
  161. params: {
  162. id: Ext.getCmp('fb_id').value,
  163. },
  164. method : 'post',
  165. callback : function(options,success,response){
  166. var localJson = new Ext.decode(response.responseText);
  167. if(localJson.exceptionInfo){
  168. var str = localJson.exceptionInfo;
  169. showError(str);
  170. }else{
  171. alert('修改成功!');
  172. }
  173. }
  174. });
  175. }
  176. },
  177. 'erpChangeHandlerButton':{
  178. click:function(btn){
  179. var newhandmanid=Ext.getCmp(me.currentManfield);
  180. var oldemid=newhandmanid.originalValue;
  181. var newemid=newhandmanid.value;
  182. var data=me.getDirtyValues(),allowsave=false;
  183. Ext.each(Ext.Object.getKeys(data), function(k){
  184. if(me.FormUtil.contains(k, 'ext-', true)){
  185. delete data[k];
  186. }
  187. if(!me.FormUtil.contains(k, 'fb_man', true) && !me.FormUtil.contains(k, 'fb_description', true)){
  188. delete data[k];
  189. }
  190. });
  191. if(oldemid==newemid){
  192. showError('未做任何处理人修改!'); return;
  193. }
  194. data.fb_id=Ext.getCmp('fb_id').getValue();
  195. data.fb_position=Ext.getCmp('fb_position').getValue();
  196. data.fb_kind=Ext.getCmp('fb_kind').getValue();
  197. me.FormUtil.setLoading(true);
  198. Ext.Ajax.request({
  199. url: basePath + 'sys/feedback/changeHandler.action',
  200. params:{
  201. data:unescape(escape(Ext.JSON.encode(data)))
  202. },
  203. method: 'post',
  204. callback: function(options,success,response){
  205. me.FormUtil.setLoading(false);
  206. var res=Ext.decode(response.responseText);
  207. if(res.exceptionInfo){
  208. showError(localJson.exceptionInfo);return;
  209. }else if(res.success){
  210. showMessage('提示','变更成功!',1000);
  211. window.location.reload();
  212. }
  213. btn.setDisabled(true);
  214. }
  215. });
  216. },
  217. afterrender:function(btn){
  218. var status=Ext.getCmp('fb_statuscode').getValue(),position=Ext.getCmp('fb_position').getValue();
  219. if(status!='AUDITED' || position=='End') btn.hide();
  220. }
  221. },
  222. 'erpTurnBuglist' : {
  223. click: function(btn){
  224. var form= Ext.getCmp('form');
  225. Ext.Ajax.request({
  226. url : basePath + form.turnBuglistUrl,
  227. params: {
  228. id: Ext.getCmp('fb_id').value
  229. },
  230. method : 'post',
  231. callback : function(options,success,response){
  232. var localJson = new Ext.decode(response.responseText);
  233. if(localJson.exceptionInfo){
  234. var str = localJson.exceptionInfo;
  235. showError(str);
  236. }else{
  237. window.location.href = basePath + "jsps/plm/test/newchecklist.jsp?formCondition=cl_idIS" + localJson.id+"&gridCondition=cld_clidIS"+localJson.id;
  238. }
  239. }
  240. });
  241. }
  242. },
  243. 'erpUpdateButton': {
  244. click: function(btn){
  245. this.FormUtil.onUpdate(this);
  246. }
  247. },
  248. 'erpAddButton': {
  249. click: function(){
  250. me.FormUtil.onAdd('addFeedback', '新增系统问题反馈', 'jsps/sys/Feedback.jsp?caller=Feedback');
  251. }
  252. },
  253. 'erpCloseButton': {
  254. click: function(btn){
  255. me.FormUtil.beforeClose(me);
  256. }
  257. },
  258. 'erpSubmitButton': {
  259. afterrender: function(btn){
  260. var status = Ext.getCmp('fb_statuscode');
  261. if(status && status.value != 'ENTERING'){
  262. btn.hide();
  263. }
  264. },
  265. click: function(btn){
  266. me.FormUtil.onSubmit(Ext.getCmp('fb_id').value);
  267. }
  268. },
  269. 'erpResSubmitButton': {
  270. afterrender: function(btn){
  271. var status = Ext.getCmp('fb_statuscode');
  272. if(status && status.value != 'COMMITED'){
  273. btn.hide();
  274. }
  275. },
  276. click: function(btn){
  277. me.FormUtil.onResSubmit(Ext.getCmp('fb_id').value);
  278. }
  279. },
  280. 'erpReplyButton': {
  281. afterrender: function(btn){
  282. var status = Ext.getCmp('fb_statuscode');
  283. if(status && status.value != 'AUDITED'){
  284. btn.hide();
  285. }
  286. },
  287. click: function(btn){
  288. var form= Ext.getCmp('form');
  289. Ext.Ajax.request({
  290. url : basePath + form.replyUrl,
  291. params: {
  292. id: Ext.getCmp('fb_id').value,
  293. comment:Ext.getCmp('fb_uasdetail').getValue(),
  294. },
  295. method : 'post',
  296. callback : function(options,success,response){
  297. var localJson = new Ext.decode(response.responseText);
  298. if(localJson.exceptionInfo){
  299. var str = localJson.exceptionInfo;
  300. showError(str);
  301. }else{
  302. alert('回复成功');
  303. window.location.href = basePath + "jsps/sys/Feedback.jsp?caller=UASFeedback&&formCondition=fb_idIS" + Ext.getCmp('ts_id').value;
  304. }
  305. }
  306. });
  307. }
  308. },
  309. 'erpAuditButton': {
  310. afterrender: function(btn){
  311. var status = Ext.getCmp('fb_statuscode');
  312. if(status && status.value != 'COMMITED'){
  313. btn.hide();
  314. }
  315. },
  316. click: function(btn){
  317. me.FormUtil.onAudit(Ext.getCmp('fb_id').value);
  318. }
  319. },
  320. 'erpBackButton':{
  321. afterrender:function(btn){
  322. var status=Ext.getCmp('fb_statuscode').getValue(),currentposition=Ext.getCmp('fb_position').getValue(),relativefield=null,form=btn.ownerCt;
  323. if(status!='AUDITED' || currentposition=='End' ) btn.hide();
  324. if(status=='AUDITED' && currentposition !='End'){
  325. relativefield=me.RelativeFields[currentposition].plandateField;
  326. if(!relativefield || (relativefield && Ext.getCmp(relativefield).value)){
  327. btn.hide();
  328. }
  329. }
  330. },
  331. click:function(btn){
  332. var data=me.getDirtyValues(),allowsave=false;
  333. Ext.each(Ext.Object.getKeys(data), function(k){
  334. if(me.FormUtil.contains(k, 'ext-', true)){
  335. delete r[k];
  336. }
  337. if(me.FormUtil.contains(k, 'fb_plandate', true)){
  338. allowsave=true;
  339. }
  340. });
  341. if(!allowsave){
  342. showError('回复需设置预计完成时间!'); return;
  343. }
  344. Ext.Ajax.request({
  345. url : basePath + '/sys/feedback/backPlan.action',
  346. params: {
  347. data:unescape(escape(Ext.JSON.encode(data)))
  348. },
  349. method : 'post',
  350. callback : function(options,success,response){
  351. var localJson = new Ext.decode(response.responseText);
  352. if(localJson.exceptionInfo){
  353. var str = localJson.exceptionInfo;
  354. showError(str);
  355. }else{
  356. showMessage('提示','回复成功!',1000);
  357. window.location.reload();
  358. }
  359. }
  360. });
  361. }
  362. },
  363. 'erpConfirmButton':{
  364. afterrender:function(btn){
  365. var status=Ext.getCmp('fb_statuscode').getValue();
  366. if(status!='AUDITED') btn.hide();
  367. },
  368. click:function(btn){
  369. var data=me.getDirtyValues();
  370. Ext.each(Ext.Object.getKeys(data), function(k){
  371. if(me.FormUtil.contains(k, 'ext-', true)){
  372. delete r[k];
  373. }
  374. });
  375. Ext.Ajax.request({
  376. url : basePath + '/sys/feedback/confirm.action',
  377. params: {
  378. data:unescape(escape(Ext.JSON.encode(data)))
  379. },
  380. method : 'post',
  381. callback : function(options,success,response){
  382. var localJson = new Ext.decode(response.responseText);
  383. if(localJson.exceptionInfo){
  384. var str = localJson.exceptionInfo;
  385. showError(str);
  386. }else{
  387. showMessage('提示','确认成功!',1000);
  388. window.location.reload();
  389. }
  390. }
  391. });
  392. }
  393. },
  394. 'dbfindtrigger[name=fb_module]': {
  395. afterrender: function(f){
  396. f.onTriggerClick = function(){
  397. me.getModuleTree();
  398. };
  399. f.autoDbfind = false;
  400. }
  401. },
  402. 'treepanel': {
  403. itemmousedown: function(selModel, record){
  404. var tree = selModel.ownerCt;
  405. me.loadTree(tree, record);
  406. }
  407. },
  408. 'erpChecktaskButton':{
  409. click: function(btn){
  410. Ext.Ajax.request({
  411. url : basePath + '/sys/feedback/changestatus.action',
  412. params: {
  413. id: Ext.getCmp('fb_id').value,
  414. },
  415. method : 'post',
  416. callback : function(options,success,response){
  417. var localJson = new Ext.decode(response.responseText);
  418. if(localJson.exceptionInfo){
  419. var str = localJson.exceptionInfo;
  420. showError(str);
  421. }else{
  422. alert('修改成功!');
  423. }
  424. }
  425. });
  426. }
  427. },
  428. 'erpEndfeedbackButton':{
  429. click: function(btn){
  430. Ext.Ajax.request({
  431. url : basePath + '/sys/feedback/Endfeedback.action',
  432. params: {
  433. id: Ext.getCmp('fb_id').value,
  434. },
  435. method : 'post',
  436. callback : function(options,success,response){
  437. var localJson = new Ext.decode(response.responseText);
  438. if(localJson.exceptionInfo){
  439. var str = localJson.exceptionInfo;
  440. showError(str);
  441. }else{
  442. alert('修改成功!');
  443. }
  444. }
  445. });
  446. }
  447. },
  448. 'erpResAuditButton': {
  449. afterrender: function(btn){
  450. var status = Ext.getCmp('fb_statuscode');
  451. if(status && status.value != 'AUDITED'){
  452. btn.hide();
  453. }
  454. },
  455. click: function(btn){
  456. me.FormUtil.onResAudit(Ext.getCmp('fb_id').value);
  457. }
  458. }
  459. });
  460. },
  461. getForm: function(btn){
  462. return btn.ownerCt.ownerCt;
  463. },
  464. getModuleTree: function(){
  465. var w = Ext.create('Ext.Window',{
  466. title: '查找模板',
  467. height: "100%",
  468. width: "80%",
  469. maximizable : true,
  470. buttonAlign : 'center',
  471. layout : 'anchor',
  472. items: [{
  473. anchor: '100% 100%',
  474. xtype: 'treepanel',
  475. rootVisible: false,
  476. useArrows: true,
  477. store: Ext.create('Ext.data.TreeStore', {
  478. root : {
  479. text: 'root',
  480. id: 'root',
  481. expanded: true
  482. }
  483. })
  484. }],
  485. buttons : [{
  486. text : '关 闭',
  487. iconCls: 'x-button-icon-close',
  488. cls: 'x-btn-gray',
  489. handler : function(btn){
  490. btn.ownerCt.ownerCt.close();
  491. }
  492. },{
  493. text: '确定',
  494. iconCls: 'x-button-icon-confirm',
  495. cls: 'x-btn-gray',
  496. handler: function(btn){
  497. var t = btn.ownerCt.ownerCt.down('treepanel');
  498. if(!Ext.isEmpty(t.title)) {
  499. Ext.getCmp('fb_module').setValue(t.title);
  500. }
  501. btn.ownerCt.ownerCt.close();
  502. }
  503. }]
  504. });
  505. w.show();
  506. this.loadTree(w.down('treepanel'), null);
  507. },
  508. loadTree: function(tree, record){
  509. var pid = 0;
  510. if(record) {
  511. if (record.get('leaf')) {
  512. return;
  513. } else {
  514. if(record.isExpanded() && record.childNodes.length > 0){
  515. record.collapse(true, true);//收拢
  516. return;
  517. } else {
  518. if(record.childNodes.length != 0){
  519. record.expand(false, true);//展开
  520. return;
  521. }
  522. }
  523. }
  524. pid = record.get('id');
  525. }
  526. tree.setLoading(true);
  527. Ext.Ajax.request({
  528. url : basePath + 'common/lazyTree.action?_noc=1',
  529. params: {
  530. parentId: pid,
  531. condition: 'sn_using=1'
  532. },
  533. callback : function(options,success,response){
  534. tree.setLoading(false);
  535. var res = new Ext.decode(response.responseText);
  536. if(res.tree){
  537. if(record) {
  538. record.appendChild(res.tree);
  539. record.expand(false,true);//展开
  540. tree.setTitle(record.getPath('text', '/').replace('root', '').replace('//', '/'));
  541. } else {
  542. tree.store.setRootNode({
  543. text: 'root',
  544. id: 'root',
  545. expanded: true,
  546. children: res.tree
  547. });
  548. }
  549. } else if(res.exceptionInfo){
  550. showError(res.exceptionInfo);
  551. }
  552. }
  553. });
  554. },
  555. getCurrentFlow: function(kind,position) {
  556. var result = false;
  557. Ext.Ajax.request({
  558. url : basePath + 'common/getFieldsData.action',
  559. async: false,
  560. params: {
  561. caller: 'FeedBackFlow',
  562. fields: 'ff_caption,ff_handmanfield',
  563. condition: 'ff_code=\'' + kind + '\' and ff_step=\''+position+'\''
  564. },
  565. method : 'post',
  566. callback : function(opt, s, res){
  567. var r = new Ext.decode(res.responseText);
  568. if(r.exceptionInfo){
  569. showError(r.exceptionInfo);return;
  570. } else if(r.success && r.data){
  571. result = r.data;
  572. }
  573. }
  574. });
  575. return result;
  576. },
  577. getDirtyValues:function(){
  578. var form=Ext.getCmp('form'),values=this.getEditValues(form);
  579. values.fb_id=Ext.getCmp('fb_id').getValue();
  580. values.fb_position=Ext.getCmp('fb_position').getValue();
  581. values.fb_kind=Ext.getCmp('fb_kind').getValue();
  582. return values;
  583. },
  584. getEditValues:function(form){
  585. var values=new Object(),formvalues=form.getForm().getValues();
  586. Ext.Array.each(form.items.items,function(item){
  587. if(!item.readOnly && item.name && item.value){
  588. values[item.name]=formvalues[item.name];
  589. }
  590. });
  591. return values;
  592. },
  593. loadNewStore: function(id){
  594. var data=null;
  595. Ext.Ajax.request({//拿到grid的columns
  596. url : basePath + "common/loadNewGridStore.action",
  597. params: {
  598. caller:'Feedback',
  599. condition:'fl_fbid='+id +' order by fl_id asc'
  600. },
  601. async:false,
  602. method : 'post',
  603. callback : function(options,success,response){
  604. var res = new Ext.decode(response.responseText);
  605. if(res.exceptionInfo){
  606. showError(res.exceptionInfo);return;
  607. }
  608. data = res.data;
  609. }
  610. });
  611. return data;
  612. },
  613. getInsertIndex:function(){
  614. var form=Ext.getCmp('form'),i=0;
  615. Ext.Array.each(form.items.items,function(item,index){
  616. if(item.name=='fb_position'){
  617. i=index;
  618. }
  619. });
  620. return i+1;
  621. }
  622. });