StartExamForm.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. Ext.define('erp.view.hr.emplmana.StartExamForm',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.StartExamForm',
  4. id: 'form',
  5. title: '试 卷 ',
  6. // frame : true,
  7. autoScroll : true,
  8. bodyStyle:'background:transition !important',
  9. buttonAlign : 'center',
  10. FormUtil: Ext.create('erp.util.FormUtil'),
  11. confirmUrl:'',
  12. fieldDefaults : {
  13. margin : '4 2 4 2',
  14. //fieldStyle : "background:#FFFAFA;color:#515151;",
  15. labelAlign : "right",
  16. msgTarget: 'side',
  17. blankText : $I18N.common.form.blankText
  18. },
  19. initComponent : function(){
  20. this.callParent(arguments);
  21. formCondition = getUrlParam('id');//从url解析参数
  22. formCondition = (formCondition == null) ? id : formCondition.replace(/IS/g,"=");
  23. //集团版
  24. var master=getUrlParam('newMaster');
  25. var param = {caller: this.caller || caller, id: this.formCondition || formCondition, _noc: (getUrlParam('_noc') || this._noc)};
  26. if(master){
  27. param.master=master;
  28. }
  29. this.createItemsAndButtons(this,this.params || param);
  30. /*this.title = this.FormUtil.getActiveTab().title;*/
  31. },
  32. createItemsAndButtons:function(form,params){
  33. Ext.Ajax.request({//拿到form的items
  34. url : basePath + 'hr/emplmana/getExam.action',
  35. params: params,
  36. method : 'post',
  37. callback : function(options, success, response){
  38. if (!response) return;
  39. var res = new Ext.decode(response.responseText);
  40. if(res.exceptionInfo != null){
  41. showError(res.exceptionInfo);return;
  42. }
  43. var items=new Array();
  44. var data=res.data;
  45. Ext.each(data,function(name,index){
  46. var item=new Object();
  47. if(data[index][3]=='单选题'){
  48. item.xtype='radiogroup';
  49. item.id='q_'+data[index][1];
  50. item.fieldLabel=data[index][1]+'.'+data[index][2];
  51. item.labelAlign='top';
  52. item.labelSeparator='';
  53. item.labelStyle='background:#E4F2FD;';
  54. item.exdid=data[index][0];
  55. //item.labelStyle='background:#FFFAFA;color:#515151;';
  56. item.columns=1;
  57. item.items=new Array();
  58. var answs=data[index][4].split("#");
  59. Ext.each(answs,function(name,inde){
  60. var i=new Object();
  61. i.xtype= 'radiofield';
  62. i.name= data[index][1]+'.'+data[index][2];
  63. i.id=i.name+''+inde;
  64. i.anvalue= ["A","B","C","D","E","F","G"][inde];
  65. i.labelStyle='background:#FFFFFF;';
  66. i.boxLabel= answs[inde].replace(/(^\s*)|(\s*$)/g, "");
  67. item.items.push(i);
  68. });
  69. items.push(item);
  70. }else if(data[index][3]=='多选题'){
  71. item.xtype='checkboxgroup';
  72. item.id='q_'+data[index][1];
  73. item.fieldLabel=data[index][1]+'.'+data[index][2];
  74. item.labelAlign='top';
  75. item.labelSeparator='';
  76. item.exdid=data[index][0];
  77. item.labelStyle='background:#E4F2FD;';
  78. item.columns=1;
  79. item.items=new Array();
  80. var answs=data[index][4].split("#");
  81. Ext.each(answs,function(name,inde){
  82. var i=new Object();
  83. i.xtype= 'checkboxfield';
  84. i.name= data[index][1]+'.'+data[index][2];
  85. i.anvalue= ["A","B","C","D","E","F","G"][inde];
  86. i.boxLabel= answs[inde].replace(/(^\s*)|(\s*$)/g, "");
  87. item.items.push(i);
  88. });
  89. items.push(item);
  90. }else if(data[index][3]=='简答题'){
  91. item.xtype='textareafield';
  92. item.exdid=data[index][0];
  93. item.id='q_'+data[index][1];
  94. item.labelAlign='top';
  95. item.fieldLabel=data[index][1]+'.'+data[index][2];
  96. item.labelSeparator='';
  97. item.width=800;
  98. items.push(item);
  99. }
  100. });
  101. form.add(items);
  102. }
  103. });
  104. },
  105. buttons: [/*{
  106. xtype: 'erpStartAccountButton'
  107. },*/{
  108. xtype: 'erpSubmitButton'
  109. },{
  110. xtype: 'erpDeleteButton'
  111. }]
  112. });