开封利通水务前端

QuestionSetting.js 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. var keys;
  2. var Cids; //分类id
  3. var ids; //指标id
  4. var CategoryName; //分类名称
  5. var Sort; //排序
  6. var Score; //分数
  7. var Title; //标题
  8. var Remark; //备注
  9. var Pid; //父id
  10. var Left_Cids;
  11. var Left_Sort;
  12. var Left_Score;
  13. var Left_Pid;
  14. var $tableLeft = $('#tbr');
  15. var $tableLeft1 = $('#tb1');
  16. var token = $.cookie("token");
  17. IndexCategoryGe();
  18. //搜索功能
  19. $(".searchGo").click(function() {
  20. Left_Cids='';
  21. IndexCategoryGe();
  22. });
  23. //*删除*/
  24. $(".inpBox").hover(function(event) {
  25. $(this).children(".de_icon").show();
  26. event.stopPropagation();
  27. }, function() {
  28. $(this).children(".de_icon").hide();
  29. });
  30. $(".de_icon").click(function(event) {
  31. event.stopPropagation();
  32. $(this).siblings("input").eq(0).val("");
  33. $(this).siblings("input").eq(1).val("");
  34. if($(this).siblings("div").find("ul").attr("id") == "zrbmtree") {
  35. getRY($(".zrid"), $("#zrbm").val());
  36. }
  37. });
  38. $(".inpBox").mouseleave(function() {
  39. $(this).children(".addTree").hide();
  40. })
  41. $(".xl").click(function() {
  42. if($(this).parent().find(".addTree").is(":hidden")) {
  43. $(this).parent().find(".addTree").show();
  44. } else {
  45. $(this).parent().find(".addTree").hide();
  46. }
  47. });
  48. //清空选项
  49. function Clean() {
  50. $(".model").hide();
  51. $("._CategoryName").val("");
  52. $("._Score").val('');
  53. $("._Sort").val('');
  54. $(".F_Title").val('');
  55. $(".F_Remark").val('');
  56. }
  57. ///////////////////////////////////左边表格
  58. /*获取选中行对象*/
  59. $tableLeft1.on("click-row.bs.table", function(e, row, ele) {
  60. $('.success').removeClass('success'); //去除之前选中的行的,选中样式
  61. $(ele).addClass('success'); //添加当前选中的 success样式用于区别
  62. Left_Cids = row.F_PagerId; //问卷ID
  63. $(".IMG_content").hide();
  64. $('#tbr').show();
  65. XQ(Left_Cids); ///获取问卷
  66. });
  67. //z获取问卷列表
  68. function IndexCategoryGe() {
  69. //销毁表格
  70. $tableLeft1.bootstrapTable('destroy');
  71. //初始化表格,动态从服务器加载数据
  72. $tableLeft1.bootstrapTable({
  73. method: "get", //使用get请求到服务器获取数据
  74. url: huayi.config.callcenter_url + "Questionnaire/GetPagerInfoList",
  75. contentType: 'application/x-www-form-urlencoded',
  76. striped: true, //表格显示条纹
  77. pagination: true, //启动分页
  78. pageSize: 10, //每页显示的记录数
  79. pageNumber: 1, //当前第几页
  80. pageList: [10, 20, 50, 100], //记录数可选列表
  81. search: false, //是否启用查询
  82. showColumns: false, //显示下拉框勾选要显示的列
  83. showRefresh: false, //显示刷新按钮
  84. sidePagination: "server", //表示服务端请求
  85. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  86. //设置为limit可以获取limit, offset, search, sort, order
  87. queryParamsType: "undefined",
  88. queryParams: function queryParams(params) { //设置查询参数
  89. var param = {
  90. PageIndex: params.pageNumber,
  91. PageSize: params.pageSize,
  92. Key: $("#KeyWords").val(),
  93. token: token
  94. };
  95. return param;
  96. },
  97. onLoadSuccess: function() { //加载成功时执行
  98. // layer.msg("加载成功");
  99. },
  100. onLoadError: function() { //加载失败时执行
  101. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  102. }
  103. });
  104. }
  105. //编号
  106. function setCode(val, row, index) {
  107. return index + 1;
  108. }
  109. //操作
  110. function Code(val) {
  111. return '<a onclick="Add(' + val + ')">操作</a>'
  112. }
  113. //右边操作
  114. function Add(val) {
  115. layer.open({
  116. type: 2,
  117. content: "template/addSetting.html?str=" + val, //iframe的url,no代表不显示滚动条
  118. title: '问卷信息',
  119. area: ['80%', '75%'], //宽高
  120. });
  121. }
  122. //删除
  123. $('.leftDelete').click(function() {
  124. if(Left_Cids) {
  125. layer.confirm('确定删除当前记录?', {
  126. icon: 7,
  127. btn: ['是', '否'] //按钮
  128. }, function() {
  129. DelIndexCategory(Left_Cids);
  130. });
  131. } else {
  132. layer.msg('没有可删除的选项!');
  133. }
  134. })
  135. //删除功能
  136. function DelIndexCategory(Left_Cids) {
  137. $.ajax({
  138. type: "get",
  139. url: huayi.config.callcenter_url + "/Questionnaire/DeletePagerInfo",
  140. dataType: 'json',
  141. data: {
  142. id: Left_Cids,
  143. token: $.cookie("token"),
  144. },
  145. async: true,
  146. success: function(data) {
  147. layer.msg("删除成功");
  148. IndexCategoryGe();
  149. }
  150. });
  151. }
  152. ///修改功能
  153. $(".leftChange ").click(function() {
  154. var Str = Left_Cids;
  155. if(Left_Cids) {
  156. layer.open({
  157. type: 2,
  158. content: "template/addOrEditQus.html?str=" + Str, //iframe的url,no代表不显示滚动条
  159. title: '修改问卷',
  160. area: ['50%', '60%'], //宽高
  161. });
  162. } else {
  163. layer.msg('没有可修改的选项!');
  164. Clean();
  165. }
  166. })
  167. //增加
  168. $(".leftAdd").click(function() {
  169. var Str = Left_Cids;
  170. layer.open({
  171. type: 2,
  172. content: "template/addOrEditQus.html", //iframe的url,no代表不显示滚动条
  173. title: '增加问卷',
  174. area: ['50%', '60%'], //宽高
  175. });
  176. });
  177. ////////////////////////////////////////////////////////////////右边表格
  178. //详情展示
  179. function XQ(Left_Cids) {
  180. $('.WJ_box').show();
  181. $(".Qus_box").empty();
  182. $.ajax({
  183. type: "get",
  184. url: huayi.config.callcenter_url + "/Questionnaire/GetPagerInfoQ",
  185. async: true,
  186. dataType: "json",
  187. data: {
  188. pid: Left_Cids,
  189. token: $.cookie("token"),
  190. },
  191. success: function(data) {
  192. if(data.state.toLowerCase() == 'success') {
  193. $('.Title').text(data.data.F_Title);
  194. $("#F_Remark").text(data.data.F_Remark);
  195. $("#startText").text(data.data.F_StartText);
  196. $("#endText").text(data.data.F_EndText);
  197. var Questions = data.data.F_Questions;
  198. var html = '';
  199. for(var i = 0; i < Questions.length; i++) {
  200. var questype = Questions[i].questype;
  201. var Quesid = Questions[i].quesid;
  202. var quesremark = Questions[i].quesremark;//试题说明
  203. if(quesremark){
  204. quesremark = ' 【' + quesremark +'】';
  205. }else{
  206. quesremark = "";
  207. }
  208. html += '<li >';
  209. html += '<div class="Back">';
  210. html += '<h3 class="size-14 QuesTitle" indexs="' + Questions[i].quesid + '">' + Questions[i].questitle + quesremark + ' </h3>';
  211. html += '</div>';
  212. //判断类型
  213. if(questype == 2) { //问答题
  214. //选项
  215. if(Questions[i].quesitems.length > 0) {
  216. html += '<div>';
  217. var quesitems = Questions[i].quesitems;
  218. for(var j = 0; j < quesitems.length; j++) {
  219. html += '<label style="font-weight: normal;">'
  220. html += '' + (j + 1) + '.';
  221. html += '<input type="radio" index_="' + quesitems[j].itemid + '" value="' + quesitems[j].itemname + '" name="ltype' + Quesid + '" style="margin-left:5px;"> ' + quesitems[j].itemname + '</label>'
  222. }
  223. html += '</div>'
  224. html += '</li>'
  225. }
  226. } else if(questype == 1) {
  227. html += '<div>';
  228. html += '<textarea index="' + Questions[i].quesid + '"name="" rows="" cols="" style="width: 100%;"></textarea>'
  229. html += '</div>'
  230. } else {
  231. if(Questions[i].quesitems.length > 0) {
  232. html += '<div>';
  233. var quesitems = Questions[i].quesitems;
  234. for(var j = 0; j < quesitems.length; j++) {
  235. html += '<label style="font-weight: normal;">'
  236. html += '' + (j + 1) + '.';
  237. html += '<input type="checkbox" value="' + quesitems[j].itemname + '" name="checks" > ' + quesitems[j].itemname + '</label>'
  238. }
  239. html += '</div>'
  240. html += '</li >';
  241. }
  242. }
  243. }
  244. $(html).appendTo(".Qus_box");
  245. }
  246. }
  247. });
  248. }