PingAnYeXianSZCG_Web 前端代码

QuestionSetting.js 7.5KB

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