7923de34f4143ac6abf79efb846f7041fe7a8edb.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /**
  2. * 功能:
  3. *
  4. *
  5. * @author HXB
  6. * @date 2015/09/18
  7. */
  8. questionBank = function() {
  9. /** 定义变量* */
  10. var _this = this;
  11. _this.listGrid = null;// 数据列表
  12. _this.searchPanel = null; // 查询面板
  13. $queryForm = null;// 查询区域表单
  14. $searchButt = null;// 查询按钮
  15. $more = null; // 更多
  16. _this.loadParams = null;// 列表加载参数
  17. //var curr_date = new Date();
  18. //部门id
  19. //var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  20. //var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  21. /** 私有方法* */
  22. /** *新增信息** */
  23. _this.addForm = function() {
  24. if(zTreeVersionId==""){
  25. top.Dialog.alert("请选择版本号!");
  26. hideRMenu();
  27. return;
  28. }
  29. $('#frmright', window.parent.document).attr('src',$.pathname() + "/page/business/exercise/examineManagement/questionBankAddEdit.jsp?versionId="+zTreeVersionId+"&fd_id=");
  30. };
  31. /** *修改信息** */
  32. _this.editForm = function() {
  33. var rows = _this.listGrid.getSelectedRows();
  34. var rowsLength = rows.length;
  35. if (rowsLength == 0) {
  36. top.Dialog.alert("请选中要修改的记录!");
  37. return;
  38. } else if (rowsLength > 1) {
  39. top.Dialog.alert("请选中一条要修改的记录!");
  40. return;
  41. } else {
  42. var fd_id = rows[0].FD_OBJECTID603;
  43. $.ajax({
  44. url : $.pathname() + '/ws/Examine/ExamineManagementService/getSumByquestionId/',
  45. type : 'post',
  46. data : {question_id:fd_id},
  47. dataType : 'json',
  48. timeout : 15000,
  49. async : false,
  50. success : function(data){
  51. if(data.SUM==0){
  52. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/exercise/examineManagement/questionBankAddEdit.jsp?fd_id='+fd_id);
  53. }else{
  54. top.Dialog.alert("当前题目正在使用中,不可修改!");
  55. return;
  56. }
  57. }
  58. });
  59. }
  60. };
  61. /** *删除信息** */
  62. _this.del = function() {
  63. var rows = _this.listGrid.getSelectedRows();
  64. var rowsLength = rows.length;
  65. if (rowsLength == 0) {
  66. top.Dialog.alert("请选中要删除的记录!");
  67. return;
  68. } else if (rowsLength > 1) {
  69. top.Dialog.alert("请选中一条要删除的记录!");
  70. return;
  71. }
  72. var url = $.pathname() + "/ws/crud/CRUDService/delete/";
  73. var params = {
  74. objectIDs : rows[0].FD_OBJECTID603,
  75. classid : 603
  76. };
  77. top.Dialog.confirm("确定要删除吗?|删除", function() {
  78. $.ajax({
  79. url : $.pathname() + '/ws/Examine/ExamineManagementService/getSumByquestionId/',
  80. type : 'post',
  81. data : {question_id:rows[0].FD_OBJECTID603},
  82. dataType : 'json',
  83. timeout : 15000,
  84. async : false,
  85. success : function(data){
  86. if(data.SUM==0){
  87. $.request.del(url, params, function(result) {
  88. if (result.Msg.sucsess == true) {
  89. top.Dialog.alert("删除成功!");
  90. // 刷新表格数据
  91. _this.listGrid.setOptions({data:result});
  92. _this.listGrid.rend();
  93. } else {
  94. top.Dialog.alert("删除失败!");
  95. }
  96. });
  97. }else{
  98. top.Dialog.alert("当前题目正在使用中,不可删除!");
  99. return;
  100. }
  101. }
  102. });
  103. });
  104. };
  105. /********导入题目*********/
  106. _this.importForm = function(){
  107. if(zTreeVersionId==""){
  108. top.Dialog.alert("请选择版本号!");
  109. hideRMenu();
  110. return;
  111. }
  112. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/exercise/examineManagement/question_import.jsp?versionId='+zTreeVersionId);
  113. };
  114. /*****绑定信息*****/
  115. _this.bind_Template = function(){
  116. var rows = _this.listGrid.getSelectedRows();
  117. var rowsLength = rows.length;
  118. if (rowsLength == 0) {
  119. top.Dialog.alert("请选中要绑定的记录!");
  120. return;
  121. }
  122. var ids='';
  123. for(var i =0;i<rowsLength;i++){
  124. ids += rows[i].FD_OBJECTID603+",";
  125. }
  126. ids = ids.substring(0,ids.length-1);
  127. var diag = new top.Dialog();
  128. diag.Title = '绑定模板';
  129. diag.URL = $.pathname() + '/page/business/exercise/examineManagement/questionTemplateBind.jsp';
  130. diag.OkButtonText = '确定';
  131. diag.OKEvent = function(){
  132. $form = diag.innerFrame.contentWindow.$("#editForm");
  133. var valid = $form.validationEngine({returnIsValid: true});
  134. if(!valid){
  135. return;
  136. }
  137. var template_id = diag.innerFrame.contentWindow.$("#TITLE_TEMPLATE").val();
  138. $.ajax({
  139. url : $.pathname() + '/ws/Examine/ExamineManagementService/getTaskByTemplate/',
  140. type : 'post',
  141. data : {template_id:template_id},
  142. dataType : 'json',
  143. timeout : 15000,
  144. async : false,
  145. success : function(data){
  146. if(data.length > 0){
  147. top.Dialog.alert("当前模板正在执行任务中,不可绑定");
  148. return;
  149. }
  150. var params = {
  151. template_id : template_id,
  152. ids : ids
  153. }
  154. var url = $.pathname() + '/ws/Examine/ExamineManagementService/bindTemplate/';
  155. $.ajax({
  156. url : url,
  157. type : 'post',
  158. data : params,
  159. dataType : 'json',
  160. timeout : 60000,
  161. success : function(data){
  162. if(data){
  163. top.Dialog.alert("绑定成功!");
  164. diag.close();
  165. //top.frmright.window.location.reload()
  166. }else{
  167. top.Dialog.alert("绑定失败!");
  168. return;
  169. }
  170. },
  171. error : function(){
  172. $.messager.alert('操作失败');
  173. }
  174. });
  175. }
  176. });
  177. };
  178. diag.CancelEvent = function(){
  179. diag.close();
  180. };
  181. diag.Width = 500; //宽度
  182. diag.Height = 250; //高度
  183. diag.ButtonAlign = 'center';//发送和取消按钮的位置
  184. diag.show();
  185. }
  186. /** **查看详细信息*** */
  187. _this.show = function(fdId) {
  188. if(fdId){
  189. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/exercise/examineManagement/questionBankDetail.jsp?fd_id='+fdId);
  190. }else{
  191. var rows = _this.listGrid.getSelectedRows();
  192. var rowsLength = rows.length;
  193. if (rowsLength == 0) {
  194. top.Dialog.alert("请选中要查看的记录!");
  195. return;
  196. } else if (rowsLength > 1) {
  197. top.Dialog.alert("请选中一条要查看的记录!");
  198. return;
  199. } else {
  200. var fd_id = _this.listGrid.getSelectedRow().FD_OBJECTID603;
  201. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/exercise/examineManagement/questionBankDetail.jsp?fd_id='+fd_id);
  202. }
  203. }
  204. };
  205. // 查询
  206. function search(obj) {
  207. $queryForm = $("#queryForm");
  208. if($("#QUESTION_NAME_603").val()=="题目名称"){
  209. $("#QUESTION_NAME_603").val("");
  210. }
  211. $queryForm.serialize();
  212. //获取选中的值
  213. var searchCondition = getSelectCon(conditionData);
  214. var queryParams = getQueryFormParams($queryForm);
  215. var params=$.extend({},_this.loadParams,queryParams);
  216. //与之前参数条件拼接
  217. params.condition = searchCondition.condition + params.condition;
  218. _this.listGrid.setOptions({"params":params});
  219. //加载数据
  220. // _this.listGrid.setNewPage(1);
  221. _this.listGrid.rend();
  222. //$(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  223. }
  224. // 更多
  225. function more() {
  226. $('#moreTable').toggle();
  227. /*$('#moreDiv').toggle(200,function(){
  228. $("#emptyCondition").click();
  229. $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  230. });*/
  231. }
  232. return {
  233. init : function() {
  234. $queryForm = $("#queryForm");
  235. //绑定查询面板的按钮点击事件
  236. $searchButt = $("#searchButt");// 查询按钮
  237. $searchButt.bind('click', function() {
  238. search();
  239. });
  240. $('#QUESTION_NAME_603').keydown(function(e){
  241. if(e.keyCode==13){
  242. search();
  243. }
  244. });
  245. //绑定更多的按钮点击事件
  246. $more = $("#more"); // 更多按钮
  247. $more.bind('click', function() {
  248. more();
  249. });
  250. $("#searchOne").bind('click',function(){
  251. search();
  252. })
  253. $(".l-grid-body-table .isPrimaryKey").live("click",function(){
  254. var rowdata = $(this).find("a").attr("data-fdid");
  255. if(rowdata){
  256. var fdId = rowdata;
  257. show(fdId);
  258. }
  259. });
  260. // 获得面板对象
  261. _this.searchPanel = $("#searchPanel");
  262. /*************获取当前日期*******************************************************/
  263. /* var currDate = getNowFormatDate();*/
  264. /*************获取当前日期*******************************************************/
  265. // 列表加载参数
  266. _this.loadParams = {
  267. listId : '603',
  268. condition : "is_del=0 and QUESTION_VERSION_ID in (select FD_OBJECTID from ECM_TRAIN_EXAMINE_VERSION where is_del=0 order by UPDATEDATE DESC limit 1)",
  269. direction : 'desc', // 排序方式
  270. sort : 'UPDATEDATE'
  271. };
  272. /** grid载入数据* */
  273. var grid_option={
  274. columns : [{
  275. display : '题目名称',
  276. name : 'QUESTION_NAME_603',
  277. width : "28%",
  278. //showTitle:true,
  279. isPrimaryKey:true,
  280. render:function(rowdata, rowindex, value, column){
  281. var fd_id = rowdata.FD_OBJECTID603;
  282. value = "<a href='javascript:;' data-fdid='"+fd_id+"' title='"+value+"'>"+value+"</a>";
  283. return value;
  284. }
  285. }, {
  286. display : '出题人',
  287. name : 'INPUT_NAME_603',
  288. width : "24%",
  289. isSort : true
  290. }, /*{
  291. display : '分值',
  292. name : 'QUESTION_SCORE_603',
  293. width : "18%",
  294. showTitle:true,
  295. render:function(rowdata, rowindex, value, column){
  296. var question_type = rowdata.QUESTION_TYPE_603;
  297. if(question_type=="4"){
  298. value = value.split("|")[0];
  299. }
  300. value = value+"分";
  301. return value;
  302. }
  303. },*/ {
  304. display : '题目类型',
  305. name : 'QUESTION_TYPE_603_SHOW',
  306. width : "24%",
  307. showTitle:true
  308. }, {
  309. display : '出题时间',
  310. name : 'INPUT_TIME_603',
  311. width : "24%",
  312. showTitle:true
  313. }],
  314. rownumbers : true,
  315. checkbox : true,
  316. pageSize : 10,
  317. percentWidthMode : true
  318. };
  319. var roleCons = roleButtonArr();
  320. var toolBarOpt={
  321. items : [ {
  322. text : '添加',
  323. click : 'addForm',
  324. iconClass : 'add1_tem',
  325. id : '26tj'
  326. }, {
  327. text : '删除',
  328. click : 'del',
  329. iconClass : 'delete_tem',
  330. id : '26sc'
  331. }, {
  332. text : '修改',
  333. click : 'editForm',
  334. iconClass : 'update_tem',
  335. id : '26xg'
  336. }, {
  337. text : '导入',
  338. click : 'importForm',
  339. iconClass : 'import_tem',
  340. id : '26dr'
  341. }/*{
  342. text : '绑定模板',
  343. click : 'bind_Template',
  344. iconClass : 'binding_tem',
  345. id : '26bd'
  346. }*/
  347. ],
  348. roleCons:""
  349. };
  350. var options={
  351. url :'/nwyj/ws/crud/CRUDService/queryQui',
  352. params: _this.loadParams,
  353. width:960,
  354. gridOptions:grid_option,
  355. paperOpration:{showInput:"true"},
  356. toolBarOptions:toolBarOpt
  357. };
  358. /**grid载入数据(定义数据列表)**/
  359. _this.listGrid =gridAndSingleRecode=$("#dataGrid").quickgridAndSingleRecode(options);
  360. }
  361. };
  362. }();
  363. $(function() {
  364. questionBank.init();
  365. });
  366. //切换到单条记录时,点击主键查看的接口
  367. function showPrimaryKey(row,index){//row为整条数据,index为第几字段,index是从0开始的
  368. var fdId = row.FD_OBJECTID603;
  369. show(fdId);
  370. }