Нет описания

xg_manage.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. mui.init({
  2. beforeback: function() {    
  3. var list = plus.webview.currentWebview().opener();    
  4. //refresh是A页面自定义事件
  5. mui.fire(list, 'refresh');
  6. //返回true,继续页面关闭逻辑
  7. return true;
  8. }
  9. });
  10. var F_RoleId = localStorage.getItem('F_RoleId');
  11. var F_UserCode = localStorage.getItem('F_UserCode');
  12. //初始化单页的区域滚动
  13. mui('.mui-scroll-wrapper').scroll();
  14. mui.plusReady(function() {
  15. var wv = plus.webview.currentWebview();
  16. var nameid = wv.nameid;
  17. var name = wv.name;
  18. mui.ajax(huayi.config.callcenter_url + '/UserAccount/GetUser', {
  19. data: {
  20. usercode:name,
  21. userid:nameid,
  22. token: localStorage.getItem("token"),
  23. },
  24. dataType: 'json', //服务器返回json格式数据
  25. async: false,
  26. type: 'get', //HTTP请求类型
  27. timeout: 10000, //超时时间设置为10秒;
  28. headers: {
  29. 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
  30. },
  31. success: function(data) {
  32. var RoleCode = data.data;
  33. $("#UserId").val(RoleCode.F_UserId) //用户id
  34. $("#RoldId").val(RoleCode.F_RoleId)
  35. $(".F_UserName").val(RoleCode.F_UserName); //员工姓名
  36. $(".F_SeatGroup").val(RoleCode.depname); //部门
  37. $(".F_SeatGroup").attr("data-index",RoleCode.F_DeptId); //部门
  38. $(".rolname").val(RoleCode.F_UserCode); //员工工号
  39. $(".password").val(RoleCode.F_Password); //密码
  40. $(".F_Mobile").val(RoleCode.F_Mobile); //手机号
  41. },
  42. error: function(xhr, type, errorThrown) {
  43. //异常处理;
  44. }
  45. });
  46. // 产品代码
  47. var Product = [];
  48. $.ajax({
  49. type: "get",
  50. url: huayi.config.callcenter_url + 'Department/GetDeptList',
  51. async: false,
  52. data: {
  53. flag: "CPDM",
  54. token:localStorage.getItem("token")
  55. },
  56. dataType: 'json',
  57. success: function(res) {
  58. if(res.state.toLowerCase() === "success") {
  59. res = res.data;
  60. if(res && res.length > 0) {
  61. res.forEach(function(v, i) {
  62. var obj = {};
  63. obj.id = v.id;
  64. obj.text = v.text;
  65. obj.children = v.children;
  66. Product.push(obj);
  67. });
  68. }
  69. }
  70. }
  71. });
  72. (function($, doc) {
  73. $.init();
  74. $.ready(function() {
  75. //产品代码
  76. var userPicker2 = new $.PopPicker({layer: 3});
  77. userPicker2.setData(Product);
  78. var showUserPickerButton2 = doc.getElementById('showUserPickerProduct');
  79. var F_Product = doc.getElementById('F_ProductType');
  80. showUserPickerButton2.addEventListener('tap', function(event) {
  81. userPicker2.show(function(items) {
  82. if (items[2].text==undefined) {
  83. F_Product.value = items[1].text;
  84. F_Product.setAttribute("data-index", items[1].id);
  85. }else if (items[1].text==undefined) {
  86. F_Product.value = items[0].text;
  87. F_Product.setAttribute("data-index", items[0].id);
  88. }else {
  89. F_Product.value =items[2].text;
  90. F_Product.setAttribute("data-index", items[2].id);
  91. }
  92. });
  93. }, false);
  94. })
  95. })(mui, document);
  96. })
  97. $('#deteBtn').on('tap', function() {
  98. var btnArray = ['否', '是'];
  99. var zhxx=$('.rolname').val();
  100. mui.confirm('确认删除?--"'+zhxx+'"的账号信息将被删除', '删除信息', btnArray, function(e) {
  101. if (e.index == 1) {
  102. $.ajax({
  103. type: "post",
  104. dataType: 'json',
  105. url: huayi.config.callcenter_url + '/UserAccount/DeleteUsers',
  106. async: true,
  107. data: {
  108. ids: $("#UserId").val(),
  109. token: localStorage.getItem("token")
  110. },
  111. success: function(data) {
  112. if(data.state == "success") {
  113. var wobj = plus.webview.getWebviewById("Setting_manage");
  114. wobj.reload(true);
  115. } else {
  116. mui.toast(data.message);
  117. }
  118. }
  119. });
  120. } else {
  121. mui.toast("删除取消")
  122. }
  123. })
  124. })
  125. $('#xgPassword').on('tap', function() {
  126. if ($("#RoldId").val()==F_RoleId&&$(".rolname").val()!=F_UserCode) {
  127. mui.toast("没有修改权限");
  128. }else{
  129. var btnArray = ['否', '是'];
  130. var zhxx=$('.rolname').val();
  131. mui.confirm('确认修改?--"'+zhxx+'"的账号信息将被修改', '修改信息', btnArray, function(e) {
  132. if (e.index == 1) {
  133. $.ajax({
  134. type: "post",
  135. dataType: 'json',
  136. url: huayi.config.callcenter_url + '/UserAccount/EditUsers',
  137. async: true,
  138. data: {
  139. userid:$("#UserId").val(), //用户id
  140. username: $('.F_UserName').val(), //用户名
  141. usercode: $('.rolname').val(), //账号
  142. Password: $('.password').val(), //密码
  143. mobile:$(".F_Mobile").val(), //手机号
  144. deptid:$("#F_ProductType").attr("data-index"), //部门
  145. token: localStorage.getItem("token")
  146. },
  147. success: function(data) {
  148. if(data.state == "success") {
  149. mui.toast('修改成功!');
  150. setTimeout(function () {
  151. var wobj = plus.webview.getWebviewById("Setting_manage");
  152. wobj.reload(true);
  153. },1500)
  154. } else {
  155. mui.toast(data.message);
  156. }
  157. }
  158. });
  159. } else {
  160. mui.toast("删除取消")
  161. }
  162. })
  163. }
  164. })