Sin descripción

QuestionSetting.js 7.0KB

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