No Description

common.js 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. //代办搜索
  2. $(".db").click(function() {
  3. initTable()
  4. })
  5. //导出
  6. $('.export').click(function() {
  7. var params = dataParam()
  8. params.isdc = 1;
  9. exportFileFun(apiUrl, params)
  10. })
  11. $("#workorderlist").on("click-row.bs.table", function(e, row, ele) {
  12. $('.success').removeClass('success'); //去除之前选中的行的,选中样式
  13. $(ele).addClass('success'); //添加当前选中的 success样式用于区别
  14. });
  15. function initTable() {
  16. $.ajax({
  17. url: huayi.config.callcenter_url + apiUrl,
  18. type: 'get',
  19. data: dataParam(),
  20. dataType: "json",
  21. async: true,
  22. success: function(data) {
  23. if(data.data && data.data.length > 0) {
  24. columnsArray = []
  25. var result = data.data[0]
  26. var key = Object.keys(result)
  27. for(var i = 0; i < key.length; i++) {
  28. var title = key[i];
  29. var obj = {
  30. title: title,
  31. align: 'center',
  32. field: title //这里循环时field是bean的属性,动态数据加载,这里是个坑 我的bean是两层嵌套的,得按列数来查里面一层的beanList的第几个。这里这样写达不到效果,是个大坑
  33. }
  34. if(columnsWidth) {
  35. obj.width = columnsWidth
  36. }
  37. columnsArray.push(obj);
  38. }
  39. } else {
  40. columnsArray = []
  41. data.data = []
  42. }
  43. $('#workorderlist').bootstrapTable('destroy');
  44. $('#workorderlist').bootstrapTable({
  45. columns: columnsArray,
  46. data: data.data
  47. });
  48. }
  49. });
  50. }
  51. // 导出列表
  52. function exportFileFun(api, params) {
  53. var url = huayi.config.callcenter_url + api;
  54. if(typeof(params) !== "object") {
  55. return
  56. }
  57. // 分页为空
  58. Object.keys(params).forEach(function(key, index) {
  59. if(index === 0) {
  60. url += `?${key}=${params[key]}`
  61. } else {
  62. url += `&${key}=${params[key]}`
  63. }
  64. })
  65. window.location.href = url;
  66. }
  67. function selectMultiple(obj) {
  68. var maindeptId = "";
  69. var maindeptId_ = obj.val(); //坐席
  70. if(maindeptId_ != null) {
  71. $(maindeptId_).each(function(i, n) {
  72. var obj2 = '';
  73. obj2 = n + ",";
  74. maindeptId += obj2;
  75. })
  76. maindeptId = maindeptId.substring(0, maindeptId.length - 1)
  77. } else {
  78. maindeptId = ""
  79. }
  80. return maindeptId
  81. }
  82. function selectCommon(obj){
  83. params = Object.assign(obj.params,{
  84. token: $.cookie("token"),
  85. })
  86. $.getJSON(
  87. huayi.config.callcenter_url + obj.apiUrl,params ,
  88. function(data) {
  89. if(data.state.toLowerCase() == "success") {
  90. var content = data.data;
  91. $("<option value=''>请选择</option>").appendTo($("#"+obj.id));
  92. $(content).each(function(i, n) {
  93. $(
  94. "<option value='" +
  95. n[obj.selectValue] +
  96. "'>" +
  97. n[obj.selectName] +
  98. "</option>"
  99. ).appendTo($("#"+obj.id));
  100. });
  101. $("#"+obj.id).selectpicker({
  102. noneSelectedText: "请选择", //默认显示内容
  103. });
  104. $("#"+obj.id).selectpicker("refresh");
  105. }
  106. }
  107. );
  108. }
  109. //下拉框开始
  110. $(".Closed").click(function() {
  111. $(".ckxq").addClass("Hidens");
  112. });
  113. /*tree下拉框效果*/
  114. $(".inpBox .tree").click(function() {
  115. if($(this).parent().find(".addTree").is(":hidden")) {
  116. $(this).parent().find(".addTree").show();
  117. } else {
  118. $(this).parent().find(".addTree").hide();
  119. }
  120. });
  121. /*普通下拉框效果*/
  122. $(".inpBox .select").click(function() {
  123. if($(this).parent().find(".xl_common").is(":hidden")) {
  124. $(this).parent().find(".xl_common").show();
  125. } else {
  126. $(this).parent().find(".xl_common").hide();
  127. }
  128. });
  129. $(".xl").click(function() {
  130. if($(this).parent().find(".addTree").is(":hidden")) {
  131. $(this).parent().find(".addTree").show();
  132. } else {
  133. $(this).parent().find(".addTree").hide();
  134. }
  135. if($(this).parent().find(".xl_common").is(":hidden")) {
  136. $(this).parent().find(".xl_common").show();
  137. } else {
  138. $(this).parent().find(".xl_common").hide();
  139. }
  140. });
  141. $(".inpBox").mouseleave(function() {
  142. $(this).children(".addTree").hide();
  143. $(this).children(".xl_common").hide();
  144. })
  145. $(".xl_box").on("click", "li", function() {
  146. var obj = $(this).parent().parent().parent();
  147. obj.find("input").eq(0).val($(this).text());
  148. obj.find("input").eq(1).val($(this).attr("itemid"));
  149. obj.find(".xl_common").hide();
  150. })
  151. // 承办单位搜索
  152. $(".inps").bind("input propertychange", function() {
  153. $(".xlAdd").css("display", "none");
  154. $(".selDpart1").css("display", "block");
  155. if($(".inps").val() == "") {
  156. $(".selDpart1").css("display", "none");
  157. return;
  158. }
  159. var debounceDepart = debounce(depart, 500);
  160. debounceDepart($(".inps").val());
  161. });
  162. $("#reflectCategoryList").on("click", "li", function() {
  163. $(".reflectCategoryList-wrapper").hide();
  164. $("#reflectCategory").val($(this).attr("indexName"));
  165. $("#keyid").val($(this).attr("index"));
  166. });
  167. $("#sponsor").on("click", "li", function() {
  168. $(".selDpart1").css("display", "none");
  169. $(".inps").val($(this).html());
  170. $("#PID").val($(this).attr("index"));
  171. $("#Dpment").val($(this).attr("index"));
  172. $(".Cleans").show();
  173. console.log($("#PID").val())
  174. });
  175. ///部门
  176. function depart(dept) {
  177. $("#sponsor").empty();
  178. $.getJSON(
  179. huayi.config.callcenter_url + "Department/GetDeptList", {
  180. token: $.cookie("token"),
  181. iscbdw:iscbdw,
  182. deptname: dept,
  183. },
  184. function(data) {
  185. if(data.state.toLowerCase() == "success") {
  186. var content = data.data;
  187. console.log(content)
  188. $(content).each(function(i, n) {
  189. $(
  190. "<li index='" +
  191. n.F_DeptId +
  192. "'>" +
  193. n.F_DeptName +
  194. "</li>"
  195. ).appendTo("#sponsor");
  196. });
  197. }
  198. }
  199. );
  200. }
  201. function tree() {
  202. $.get(
  203. huayi.config.callcenter_url + "Department/GetDeptList", {
  204. token: $.cookie("token"),
  205. iscbdw:iscbdw
  206. },
  207. function(result) {
  208. result = $.parseJSON(result);
  209. $.fn.zTree.init(
  210. $("#addTreeDemo"),
  211. setting1,
  212. result.data
  213. ); //实例化树形图
  214. }
  215. );
  216. }
  217. var setting1 = {
  218. data: {
  219. key: {
  220. name: "F_DeptName",
  221. },
  222. simpleData: {
  223. enable: true,
  224. idKey: "F_DeptId",
  225. pIdKey: "F_PartentId",
  226. rootPId: 0,
  227. },
  228. },
  229. callback: {
  230. onClick: zTreeOnClick,
  231. },
  232. };
  233. function zTreeOnClick(event, treeId, treeNode) {
  234. if(treeNode.level >= 0) {
  235. $(".inps").val(treeNode.F_DeptName);
  236. $("#PID").val(treeNode.F_DeptId);
  237. $("#Dpment").val(treeNode.F_DeptId);
  238. $(".Cleans").show();
  239. }
  240. }
  241. function Close() {
  242. $(".lyxz").removeClass("cx");
  243. if($("audio").length > 0) {
  244. $("audio")[0].pause();
  245. }
  246. }
  247. //清除
  248. $(".Cleans ").click(function() {
  249. $('.inps').val("");
  250. $("#PID").val("");
  251. $("#Dpment").val("");
  252. })
  253. // 防抖函数
  254. function debounce(fun, delay) {
  255. return function(args) {
  256. var that = this;
  257. var _args = args;
  258. clearTimeout(fun.id);
  259. fun.id = setTimeout(function() {
  260. fun.call(that, _args);
  261. }, delay);
  262. };
  263. }
  264. // 下拉框结束