开封利通水务前端

satisfactionManagement.js 7.9KB

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