ZZDianXin_UI - 郑州电信 演示

QuestionsManagement.js 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. var Cids; //分类id
  2. var ids; //指标id
  3. var Left_Cids;
  4. var Left_CategoryName;
  5. var $tableLeft = $('#tbr');
  6. var $tableLeft1 = $('#tb1');
  7. var token = $.cookie("token");
  8. $(document).ready(function() {
  9. Finish();
  10. IndexCategoryGe();
  11. })
  12. //所有指标
  13. $(".rightAll").click(function() {
  14. if(Left_Cids){
  15. Left_Cids='';
  16. }
  17. Finish();
  18. });
  19. //搜索功能
  20. $(".searchGo").click(function() {
  21. Finish();
  22. });
  23. //回车搜索
  24. $('#KeyWords').on('keypress',function(e){
  25. if(e.keyCode==13){
  26. Finish();
  27. }
  28. })
  29. //下拉框
  30. $("#Quetions").on("change", function() {
  31. Finish();
  32. })
  33. ////左边表格
  34. /*获取选中行对象*/
  35. $tableLeft1.on("click-row.bs.table", function(e, row, ele) {
  36. $('.success').removeClass('success'); //去除之前选中的行的,选中样式
  37. $(ele).addClass('success'); //添加当前选中的 success样式用于区别
  38. Left_Cids = row.F_CategoryId; //分类ID
  39. Left_CategoryName = row.F_CategoryName; //分类名称
  40. Finish(); //右边列表
  41. });
  42. //获取试题分类列表 ///左边列表
  43. function IndexCategoryGe() {
  44. //销毁表格
  45. $tableLeft1.bootstrapTable('destroy');
  46. //初始化表格,动态从服务器加载数据
  47. $tableLeft1.bootstrapTable({
  48. method: "get", //使用get请求到服务器获取数据
  49. url: huayi.config.callcenter_url + "Questionnaire/GetQCategoryList",
  50. contentType: 'application/x-www-form-urlencoded',
  51. striped: true, //表格显示条纹
  52. pagination: true, //启动分页
  53. pageSize: 5, //每页显示的记录数
  54. pageNumber: 1, //当前第几页
  55. pageList: [5, 20, 50, 100], //记录数可选列表
  56. search: false, //是否启用查询
  57. showColumns: false, //显示下拉框勾选要显示的列
  58. showRefresh: false, //显示刷新按钮
  59. sidePagination: "server", //表示服务端请求
  60. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  61. //设置为limit可以获取limit, offset, search, sort, order
  62. queryParamsType: "undefined",
  63. queryParams: function queryParams(params) { //设置查询参数
  64. var param = {
  65. pageindex: params.pageNumber,
  66. pagesize: params.pageSize,
  67. token: token
  68. };
  69. return param;
  70. },
  71. onLoadSuccess: function() { //加载成功时执行
  72. // layer.msg("加载成功");
  73. },
  74. onLoadError: function() { //加载失败时执行
  75. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  76. }
  77. });
  78. }
  79. //删除左边删除
  80. $('.leftDelete').click(function() {
  81. if(Left_Cids) {
  82. layer.confirm('确定删除当前记录?', {
  83. btn: ['是', '否'] //按钮
  84. }, function() {
  85. DelIndexCategory(Left_Cids);
  86. Left_Cids='';
  87. });
  88. } else {
  89. layer.msg('没有可删除的选项!');
  90. }
  91. })
  92. //删除功能
  93. function DelIndexCategory(Left_Cids) {
  94. $.ajax({
  95. type: "get",
  96. url: huayi.config.callcenter_url + "Questionnaire/DeleteQCategory",
  97. //url: '//117.158.196.116:8878/IndexCategory/DelIndexCategory',
  98. dataType: 'json',
  99. data: {
  100. id: Left_Cids,
  101. token: token
  102. },
  103. async: true,
  104. success: function(data) {
  105. layer.msg("删除成功");
  106. IndexCategoryGe();
  107. }
  108. });
  109. }
  110. ///左边修改功能
  111. $(".leftChange ").click(function() {
  112. if(Left_Cids) {
  113. layer.prompt({
  114. title: '修改试题分类',
  115. value: Left_CategoryName,
  116. formType: 0,
  117. }, function(names, index) {
  118. $.post(huayi.config.callcenter_url + "Questionnaire/CreateOrUpdateQCategory", {
  119. id: Left_Cids,
  120. name: names,
  121. token: token
  122. }, function(data) {
  123. data = JSON.parse(data);
  124. //debugger
  125. if(data.state == "success") {
  126. layer.close(index);
  127. IndexCategoryGe();
  128. layer.msg("试题分类修改成功!");
  129. Left_Cids='';
  130. }
  131. });
  132. });
  133. } else {
  134. layer.msg('没有可修改的选项!');
  135. }
  136. // if(Left_Cids) {
  137. // Str = Left_Cids;
  138. // console.log(Str);
  139. // layer.open({
  140. // type: 2,
  141. // content: "../Questionnaire/modify.html?str=" + Str, //iframe的url,no代表不显示滚动条
  142. // title: '修改分类',
  143. // area: ['35%', '30%'], //宽高
  144. // });
  145. // // GetIndexCategory(Left_Cids);
  146. //
  147. // } else {
  148. // layer.msg('没有可修改的选项!');
  149. // }
  150. })
  151. //增加
  152. $(".leftAdd").click(function() {
  153. layer.prompt({
  154. title: '添加试题分类',
  155. formType: 0,
  156. }, function(names, index) {
  157. $.post(huayi.config.callcenter_url + "Questionnaire/CreateOrUpdateQCategory", {
  158. name: names,
  159. token: token
  160. }, function(data) {
  161. data = JSON.parse(data);
  162. //debugger
  163. if(data.state == "success") {
  164. layer.close(index);
  165. IndexCategoryGe();
  166. layer.msg("添加试题分类成功");
  167. }
  168. });
  169. });
  170. // layer.open({
  171. // type: 2,
  172. // content: "../Questionnaire/add.html", //iframe的url,no代表不显示滚动条
  173. // title: '添加分类',
  174. // area: ['35%', '30%'], //宽高
  175. // });
  176. });
  177. /////////////////////////右边表格
  178. function Finish() {
  179. //销毁表格
  180. $tableLeft.bootstrapTable('destroy');
  181. //初始化表格,动态从服务器加载数据
  182. $tableLeft.bootstrapTable({
  183. method: "get", //使用get请求到服务器获取数据
  184. url: huayi.config.callcenter_url + "Questionnaire/GetQuestionList",
  185. // url: "//117.158.196.116:8878/IndexBase/GetList",
  186. contentType: 'application/x-www-form-urlencoded',
  187. striped: true, //表格显示条纹
  188. pagination: true, //启动分页
  189. pageSize: 5, //每页显示的记录数
  190. pageNumber: 1, //当前第几页
  191. pageList: [5, 20, 50, 100], //记录数可选列表
  192. search: false, //是否启用查询
  193. showColumns: false, //显示下拉框勾选要显示的列
  194. showRefresh: false, //显示刷新按钮
  195. sidePagination: "server", //表示服务端请求
  196. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  197. //设置为limit可以获取limit, offset, search, sort, order
  198. queryParamsType: "undefined",
  199. queryParams: function queryParams(params) { //设置查询参数
  200. var param = {
  201. pageindex: params.pageNumber,
  202. pagesize: params.pageSize,
  203. CategoryId: Left_Cids,
  204. SelectType: $("#Quetions").val(),
  205. Key: $("#KeyWords").val().trim(),
  206. token: token,
  207. };
  208. return param;
  209. },
  210. onLoadSuccess: function() { //加载成功时执行
  211. // layer.msg("加载成功");
  212. },
  213. onLoadError: function() { //加载失败时执行
  214. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  215. }
  216. });
  217. }
  218. /*获取选中行对象*/
  219. $tableLeft.on("click-row.bs.table", function(e, row, ele) {
  220. $('.success').removeClass('success'); //去除之前选中的行的,选中样式
  221. $(ele).addClass('success'); //添加当前选中的 success样式用于区别
  222. Cids = row.F_QuestionId; //试题ID
  223. //console.log(Cids);
  224. ids = row.F_CategoryId; //分类ID
  225. });
  226. //增加
  227. $(".rightAdd").click(function() {
  228. layer.open({
  229. type: 2,
  230. content: "../Questionnaire/AddRight.html?str=" + Left_Cids, //iframe的url,no代表不显示滚动条
  231. title: '添加试题',
  232. area: ['45%', '60%'], //宽高
  233. });
  234. })
  235. //修改功能
  236. $(".rightChange ").click(function() {
  237. if(Cids) {
  238. layer.open({
  239. type: 2,
  240. content: "../Questionnaire/XgRight.html?Cids=" + Cids, //iframe的url,no代表不显示滚动条
  241. title: '修改试题',
  242. area: ['45%', '60%'], //宽高
  243. });
  244. Cids='';
  245. } else {
  246. layer.msg('没有可修改的选项!');
  247. }
  248. })
  249. //删除
  250. $('.rightDelete').click(function() {
  251. if(Cids) {
  252. layer.confirm('确定删除当前记录?', {
  253. btn: ['是', '否'] //按钮
  254. }, function() {
  255. Delet(Cids);
  256. Cids='';
  257. });
  258. } else {
  259. layer.msg('没有可删除的选项!');
  260. }
  261. })
  262. //编号
  263. function setCode(val, row, index) {
  264. return index + 1;
  265. }
  266. //类型操作
  267. function Type(val) {
  268. var cs = '';
  269. var vals = '';
  270. if(val == 1) {
  271. cs = 'w';
  272. vals = "问答题"
  273. } else if(val == 2) {
  274. cs = 'd';
  275. vals = "单选题"
  276. } else {
  277. cs = 'du'
  278. vals = "多选题"
  279. }
  280. return '<a class="' + cs + '">' + vals + '</a>'
  281. //console.log(val);
  282. }
  283. //操作
  284. function Code(val, row) {
  285. if(val > 1) {
  286. return '<a onclick="XG(' + row.F_QuestionId + ')">操作</a>'
  287. }
  288. }
  289. function XG(val) {
  290. layer.open({
  291. type: 2,
  292. content: "../Questionnaire/addCheck.html?str=" + val, //iframe的url,no代表不显示滚动条
  293. title: '试题选项',
  294. area: ['45%', '60%'], //宽高
  295. });
  296. }
  297. //删除试题
  298. function Delet(Cids) {
  299. $.ajax({
  300. type: "get",
  301. url: huayi.config.callcenter_url + "/Questionnaire/DeleteQuestion",
  302. dataType: 'json',
  303. data: {
  304. id: Cids,
  305. token: token
  306. },
  307. async: true,
  308. success: function(data) {
  309. if(data.state.toLowerCase() == 'success') {
  310. layer.msg("删除成功");
  311. Finish();
  312. }
  313. }
  314. });
  315. }