暂无描述

common.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. //来源
  83. function LY(obj) {
  84. obj.empty();
  85. obj.append(
  86. '<option selected="selected" value="">请选择</option>'
  87. );
  88. $.getJSON(
  89. huayi.config.callcenter_url +
  90. "Dictionary/GetDicValueListById", {
  91. token: $.cookie("token"),
  92. id: 1,
  93. },
  94. function(data) {
  95. if(data.state.toLowerCase() == "success") {
  96. var content = data.data;
  97. $(content).each(function(i, n) {
  98. $(
  99. "<option value='" +
  100. n.F_ValueId +
  101. "'>" +
  102. n.F_Value +
  103. "</option>"
  104. ).appendTo(obj);
  105. });
  106. }
  107. }
  108. );
  109. }
  110. ///坐席
  111. function ZX(obj) {
  112. obj.empty();
  113. $.getJSON(
  114. huayi.config.callcenter_url + "UserAccount/GetSeatList", {
  115. token: $.cookie("token"),
  116. },
  117. function(data) {
  118. if(data.state.toLowerCase() == "success") {
  119. var content = data.data;
  120. $(
  121. "<option value=''>请选择</option>"
  122. ).appendTo(obj);
  123. $(content).each(function(i, n) {
  124. $(
  125. "<option value='" +
  126. n.F_UserCode +
  127. "'>" +
  128. n.F_UserName +
  129. "</option>"
  130. ).appendTo(obj);
  131. });
  132. obj.selectpicker({
  133. noneSelectedText: "请选择", //默认显示内容
  134. });
  135. obj.selectpicker("refresh");
  136. }
  137. }
  138. );
  139. }
  140. //下拉框开始
  141. $(".Closed").click(function() {
  142. $(".ckxq").addClass("Hidens");
  143. });
  144. /*tree下拉框效果*/
  145. $(".inpBox .tree").click(function() {
  146. if($(this).parent().find(".addTree").is(":hidden")) {
  147. $(this).parent().find(".addTree").show();
  148. } else {
  149. $(this).parent().find(".addTree").hide();
  150. }
  151. });
  152. /*普通下拉框效果*/
  153. $(".inpBox .select").click(function() {
  154. if($(this).parent().find(".xl_common").is(":hidden")) {
  155. $(this).parent().find(".xl_common").show();
  156. } else {
  157. $(this).parent().find(".xl_common").hide();
  158. }
  159. });
  160. $(".xl").click(function() {
  161. if($(this).parent().find(".addTree").is(":hidden")) {
  162. $(this).parent().find(".addTree").show();
  163. } else {
  164. $(this).parent().find(".addTree").hide();
  165. }
  166. if($(this).parent().find(".xl_common").is(":hidden")) {
  167. $(this).parent().find(".xl_common").show();
  168. } else {
  169. $(this).parent().find(".xl_common").hide();
  170. }
  171. });
  172. $(".inpBox").mouseleave(function() {
  173. $(this).children(".addTree").hide();
  174. $(this).children(".xl_common").hide();
  175. })
  176. $(".xl_box").on("click", "li", function() {
  177. var obj = $(this).parent().parent().parent();
  178. obj.find("input").eq(0).val($(this).text());
  179. obj.find("input").eq(1).val($(this).attr("itemid"));
  180. obj.find(".xl_common").hide();
  181. })
  182. // 承办单位搜索
  183. $(".inps").bind("input propertychange", function() {
  184. $(".xlAdd").css("display", "none");
  185. $(".selDpart1").css("display", "block");
  186. if($(".inps").val() == "") {
  187. $(".selDpart1").css("display", "none");
  188. return;
  189. }
  190. var debounceDepart = debounce(depart, 500);
  191. debounceDepart($(".inps").val());
  192. });
  193. $("#reflectCategoryList").on("click", "li", function() {
  194. $(".reflectCategoryList-wrapper").hide();
  195. $("#reflectCategory").val($(this).attr("indexName"));
  196. $("#keyid").val($(this).attr("index"));
  197. });
  198. $("#sponsor").on("click", "li", function() {
  199. $(".selDpart1").css("display", "none");
  200. $(".inps").val($(this).html());
  201. $("#PID").val($(this).attr("index"));
  202. $("#Dpment").val($(this).attr("index"));
  203. $(".Cleans").show();
  204. console.log($("#PID").val())
  205. });
  206. ///部门
  207. function depart(dept) {
  208. $("#sponsor").empty();
  209. $.getJSON(
  210. huayi.config.callcenter_url + "Department/GetDeptList", {
  211. token: $.cookie("token"),
  212. iscbdw:iscbdw,
  213. deptname: dept,
  214. },
  215. function(data) {
  216. if(data.state.toLowerCase() == "success") {
  217. var content = data.data;
  218. console.log(content)
  219. $(content).each(function(i, n) {
  220. $(
  221. "<li index='" +
  222. n.F_DeptId +
  223. "'>" +
  224. n.F_DeptName +
  225. "</li>"
  226. ).appendTo("#sponsor");
  227. });
  228. }
  229. }
  230. );
  231. }
  232. function tree() {
  233. $.get(
  234. huayi.config.callcenter_url + "Department/GetDeptList", {
  235. token: $.cookie("token"),
  236. iscbdw:iscbdw
  237. },
  238. function(result) {
  239. result = $.parseJSON(result);
  240. $.fn.zTree.init(
  241. $("#addTreeDemo"),
  242. setting1,
  243. result.data
  244. ); //实例化树形图
  245. }
  246. );
  247. }
  248. var setting1 = {
  249. data: {
  250. key: {
  251. name: "F_DeptName",
  252. },
  253. simpleData: {
  254. enable: true,
  255. idKey: "F_DeptId",
  256. pIdKey: "F_PartentId",
  257. rootPId: 0,
  258. },
  259. },
  260. callback: {
  261. onClick: zTreeOnClick,
  262. },
  263. };
  264. function zTreeOnClick(event, treeId, treeNode) {
  265. if(treeNode.level >= 0) {
  266. $(".inps").val(treeNode.F_DeptName);
  267. $("#PID").val(treeNode.F_DeptId);
  268. $("#Dpment").val(treeNode.F_DeptId);
  269. $(".Cleans").show();
  270. }
  271. }
  272. function Close() {
  273. $(".lyxz").removeClass("cx");
  274. if($("audio").length > 0) {
  275. $("audio")[0].pause();
  276. }
  277. }
  278. //清除
  279. $(".Cleans ").click(function() {
  280. $('.inps').val("");
  281. $("#PID").val("");
  282. $("#Dpment").val("");
  283. })
  284. // 防抖函数
  285. function debounce(fun, delay) {
  286. return function(args) {
  287. var that = this;
  288. var _args = args;
  289. clearTimeout(fun.id);
  290. fun.id = setTimeout(function() {
  291. fun.call(that, _args);
  292. }, delay);
  293. };
  294. }
  295. // 下拉框结束