No Description

common.js 6.3KB

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