5f8690b2eeec343405b9538a69f1abfc1b1375bc.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. var loadParams11;
  213. if(zTreeVersionId==""){
  214. loadParams11 = $.extend({},_this.loadParams,loadParams);
  215. }else{
  216. loadParams11 = {
  217. "listId" :'603' ,
  218. "condition" : "is_del = 0 and QUESTION_VERSION_ID = '"+zTreeVersionId+"'",
  219. direction:'DESC',
  220. sort: 'UPDATEDATE'
  221. };
  222. }
  223. //获取选中的值
  224. var searchCondition = getSelectCon(conditionData);
  225. var queryParams = getQueryFormParams($queryForm);
  226. var params=$.extend({},loadParams11,queryParams);
  227. //与之前参数条件拼接
  228. params.condition = searchCondition.condition + params.condition;
  229. _this.listGrid.setOptions({"params":params});
  230. //加载数据
  231. // _this.listGrid.setNewPage(1);
  232. _this.listGrid.rend();
  233. //$(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  234. }
  235. // 更多
  236. function more() {
  237. $('#moreTable').toggle();
  238. /*$('#moreDiv').toggle(200,function(){
  239. $("#emptyCondition").click();
  240. $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  241. });*/
  242. }
  243. return {
  244. init : function() {
  245. $queryForm = $("#queryForm");
  246. //绑定查询面板的按钮点击事件
  247. $searchButt = $("#searchButt");// 查询按钮
  248. $searchButt.bind('click', function() {
  249. search();
  250. });
  251. $('#QUESTION_NAME_603').keydown(function(e){
  252. if(e.keyCode==13){
  253. search();
  254. }
  255. });
  256. //绑定更多的按钮点击事件
  257. $more = $("#more"); // 更多按钮
  258. $more.bind('click', function() {
  259. more();
  260. });
  261. $("#searchOne").bind('click',function(){
  262. search();
  263. })
  264. $(".l-grid-body-table .isPrimaryKey").live("click",function(){
  265. var rowdata = $(this).find("a").attr("data-fdid");
  266. if(rowdata){
  267. var fdId = rowdata;
  268. show(fdId);
  269. }
  270. });
  271. // 获得面板对象
  272. _this.searchPanel = $("#searchPanel");
  273. /*************获取当前日期*******************************************************/
  274. /* var currDate = getNowFormatDate();*/
  275. /*************获取当前日期*******************************************************/
  276. // 列表加载参数
  277. _this.loadParams = {
  278. listId : '603',
  279. condition : "is_del=0 and QUESTION_VERSION_ID in (select FD_OBJECTID from ECM_TRAIN_EXAMINE_VERSION where is_del=0 and INPUT_UNIT ='"+deptId+"' limit 1)",
  280. direction : 'desc', // 排序方式
  281. sort : 'UPDATEDATE'
  282. };
  283. /** grid载入数据* */
  284. var grid_option={
  285. columns : [{
  286. display : '题目名称',
  287. name : 'QUESTION_NAME_603',
  288. width : "28%",
  289. //showTitle:true,
  290. isPrimaryKey:true,
  291. render:function(rowdata, rowindex, value, column){
  292. var fd_id = rowdata.FD_OBJECTID603;
  293. value = "<a href='javascript:;' data-fdid='"+fd_id+"' title='"+value+"'>"+value+"</a>";
  294. return value;
  295. }
  296. }, {
  297. display : '出题人',
  298. name : 'INPUT_NAME_603',
  299. width : "24%",
  300. isSort : true
  301. }, /*{
  302. display : '分值',
  303. name : 'QUESTION_SCORE_603',
  304. width : "18%",
  305. showTitle:true,
  306. render:function(rowdata, rowindex, value, column){
  307. var question_type = rowdata.QUESTION_TYPE_603;
  308. if(question_type=="4"){
  309. value = value.split("|")[0];
  310. }
  311. value = value+"分";
  312. return value;
  313. }
  314. },*/ {
  315. display : '题目类型',
  316. name : 'QUESTION_TYPE_603_SHOW',
  317. width : "24%",
  318. showTitle:true
  319. }, {
  320. display : '出题时间',
  321. name : 'INPUT_TIME_603',
  322. width : "24%",
  323. showTitle:true
  324. }],
  325. rownumbers : true,
  326. checkbox : true,
  327. pageSize : 10,
  328. percentWidthMode : true
  329. };
  330. var roleCons = roleButtonArr();
  331. var toolBarOpt={
  332. items : [ {
  333. text : '添加',
  334. click : 'addForm',
  335. iconClass : 'add1_tem',
  336. id : '26tj'
  337. }, {
  338. text : '删除',
  339. click : 'del',
  340. iconClass : 'delete_tem',
  341. id : '26sc'
  342. }, {
  343. text : '修改',
  344. click : 'editForm',
  345. iconClass : 'update_tem',
  346. id : '26xg'
  347. }, {
  348. text : '导入',
  349. click : 'importForm',
  350. iconClass : 'import_tem',
  351. id : '26dr'
  352. }/*{
  353. text : '绑定模板',
  354. click : 'bind_Template',
  355. iconClass : 'binding_tem',
  356. id : '26bd'
  357. }*/
  358. ],
  359. roleCons:""
  360. };
  361. var options={
  362. url :'/nwyj/ws/crud/CRUDService/queryQui',
  363. params: _this.loadParams,
  364. width:960,
  365. gridOptions:grid_option,
  366. paperOpration:{showInput:"true"},
  367. toolBarOptions:toolBarOpt
  368. };
  369. /**grid载入数据(定义数据列表)**/
  370. _this.listGrid =gridAndSingleRecode=$("#dataGrid").quickgridAndSingleRecode(options);
  371. }
  372. };
  373. }();
  374. $(function() {
  375. questionBank.init();
  376. });
  377. //切换到单条记录时,点击主键查看的接口
  378. function showPrimaryKey(row,index){//row为整条数据,index为第几字段,index是从0开始的
  379. var fdId = row.FD_OBJECTID603;
  380. show(fdId);
  381. }