Няма описание

tj_manage.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. //初始化单页的区域滚动
  11. mui('.mui-scroll-wrapper').scroll();
  12. mui.plusReady(function() {
  13. // 产品代码
  14. var Product = [];
  15. $.ajax({
  16. type: "get",
  17. url: huayi.config.callcenter_url + 'Department/GetDeptList',
  18. async: false,
  19. data: {
  20. flag: "CPDM",
  21. token: localStorage.getItem("token")
  22. },
  23. dataType: 'json',
  24. success: function(res) {
  25. if (res.state.toLowerCase() === "success") {
  26. res = res.data;
  27. if (res && res.length > 0) {
  28. res.forEach(function(v, i) {
  29. var obj = {};
  30. obj.id = v.id;
  31. obj.text = v.text;
  32. obj.children = v.children;
  33. Product.push(obj);
  34. });
  35. }
  36. }
  37. }
  38. });
  39. // 角色
  40. var roleList = []
  41. $.ajax({
  42. type: "get",
  43. url: huayi.config.callcenter_url + 'RoleInfo/GetRoleList',
  44. async: false,
  45. data: {
  46. code: '',
  47. name: '',
  48. pageindex: 1,
  49. pagesize: 100,
  50. token: localStorage.getItem("token")
  51. },
  52. dataType: 'json',
  53. success: function(res) {
  54. res = res.rows;
  55. if (res && res.length > 0) {
  56. res.forEach(function(v, i) {
  57. var obj = {};
  58. obj.id = v.F_RoleId;
  59. obj.text = v.F_RoleName;
  60. roleList.push(obj);
  61. });
  62. }
  63. }
  64. });
  65. (function($, doc) {
  66. $.init();
  67. $.ready(function() {
  68. //产品代码
  69. var userPicker2 = new $.PopPicker({
  70. layer: 3
  71. });
  72. userPicker2.setData(Product);
  73. var showUserPickerButton2 = doc.getElementById('showUserPickerProduct');
  74. var F_Product = doc.getElementById('F_ProductType');
  75. showUserPickerButton2.addEventListener('tap', function(event) {
  76. userPicker2.show(function(items) {
  77. if (items[2].text == undefined) {
  78. if (items[1].text == undefined) {
  79. F_Product.value = items[0].text;
  80. F_Product.setAttribute("data-index", items[0].id);
  81. } else {
  82. F_Product.value = items[1].text;
  83. F_Product.setAttribute("data-index", items[1].id);
  84. }
  85. } else {
  86. F_Product.value = items[2].text;
  87. F_Product.setAttribute("data-index", items[2].id);
  88. }
  89. });
  90. }, false);
  91. var rolePicker = new $.PopPicker({
  92. layer: 1
  93. });
  94. rolePicker.setData(roleList)
  95. var showRolePickerButton = doc.getElementById('showRolePickerProduct');
  96. var role = doc.getElementById('role');
  97. showRolePickerButton.addEventListener('tap', function(event) {
  98. rolePicker.show(function(items) {
  99. role.value = items[0].text
  100. role.setAttribute("data-index", items[0].id);
  101. });
  102. }, false);
  103. })
  104. })(mui, document);
  105. })
  106. $('#xgPassword').on('tap', function() {
  107. // alert($('.F_UserName').val());
  108. // alert($('.password').val());
  109. // alert($("#F_ProductType").attr("data-index"));
  110. // alert($(".F_Mobile").val());
  111. if ($('.F_UserName').val() == '') {
  112. mui.alert('请输入用户名!')
  113. } else if ($('.password').val() == '') {
  114. mui.alert('请输入密码!')
  115. } else if ($("#F_ProductType").val() == '') {
  116. mui.alert('请选择部门!')
  117. } else if ($("#role").val() == '') {
  118. mui.alert('请选择角色!')
  119. } else {
  120. $.ajax({
  121. type: "post",
  122. dataType: 'json',
  123. url: huayi.config.callcenter_url + '/UserAccount/AddUsers',
  124. async: true,
  125. data: {
  126. username: $('.F_UserName').val(), //用户名
  127. password: $('.password').val(), //密码
  128. deptid: $("#F_ProductType").attr("data-index"), //部门
  129. roleid: $("#role").attr("data-index"),
  130. mobile: $(".F_Mobile").val(),
  131. token: localStorage.getItem("token")
  132. },
  133. success: function(data) {
  134. if (data.state == "success") {
  135. mui.alert('账号' + data.data.F_UserCode + '--密码' + data.data.F_Password, '添加成功',
  136. function() {
  137. var wobj = plus.webview.getWebviewById("Setting_manage");
  138. wobj.reload(true);
  139. });
  140. } else {
  141. mui.toast(data.message);
  142. }
  143. }
  144. });
  145. }
  146. })