| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- mui.init({
- beforeback: function() {
- var list = plus.webview.currentWebview().opener();
- //refresh是A页面自定义事件
- mui.fire(list, 'refresh');
- //返回true,继续页面关闭逻辑
- return true;
- }
- });
- var F_RoleId = localStorage.getItem('F_RoleId');
- var F_UserCode = localStorage.getItem('F_UserCode');
- //初始化单页的区域滚动
- mui('.mui-scroll-wrapper').scroll();
- mui.plusReady(function() {
-
- var wv = plus.webview.currentWebview();
- var nameid = wv.nameid;
- var name = wv.name;
- // 角色
- var roleList = []
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'RoleInfo/GetRoleList',
- async: false,
- data: {
- code: '',
- name: '',
- pageindex: 1,
- pagesize: 100,
- token: localStorage.getItem("token")
- },
- dataType: 'json',
- success: function(res) {
- res = res.rows;
- if (res && res.length > 0) {
- res.forEach(function(v, i) {
- var obj = {};
- obj.id = v.F_RoleId;
- obj.text = v.F_RoleName;
- roleList.push(obj);
- });
- }
- }
- });
- mui.ajax(huayi.config.callcenter_url + '/UserAccount/GetUser', {
- data: {
- usercode:name,
- userid:nameid,
- token: localStorage.getItem("token"),
- },
- dataType: 'json', //服务器返回json格式数据
- async: false,
- type: 'get', //HTTP请求类型
- timeout: 10000, //超时时间设置为10秒;
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
- },
- success: function(data) {
- var RoleCode = data.data;
- $("#UserId").val(RoleCode.F_UserId) //用户id
- roleList.forEach((v,n) =>{
- if(v.id == RoleCode.F_RoleId) {
- $("#role").val(v.text)
- $("#role").attr("data-index", v.id)
- }
- })
- $(".F_UserName").val(RoleCode.F_UserName); //员工姓名
- $(".F_SeatGroup").val(RoleCode.depname); //部门
- $(".F_SeatGroup").attr("data-index",RoleCode.F_DeptId); //部门
- $(".rolname").val(RoleCode.F_UserCode); //员工工号
- $(".password").val(RoleCode.F_Password); //密码
- $(".F_Mobile").val(RoleCode.F_Mobile); //手机号
- },
- error: function(xhr, type, errorThrown) {
- //异常处理;
- }
- });
- // 产品代码
- var Product = [];
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + 'Department/GetDeptList',
- async: false,
- data: {
- flag: "CPDM",
- token:localStorage.getItem("token")
- },
- dataType: 'json',
- success: function(res) {
- if(res.state.toLowerCase() === "success") {
- res = res.data;
- if(res && res.length > 0) {
- res.forEach(function(v, i) {
- var obj = {};
- obj.id = v.id;
- obj.text = v.text;
- obj.children = v.children;
- Product.push(obj);
- });
- }
- }
- }
- });
-
- (function($, doc) {
- $.init();
- $.ready(function() {
- //产品代码
- var userPicker2 = new $.PopPicker({layer: 3});
- userPicker2.setData(Product);
- var showUserPickerButton2 = doc.getElementById('showUserPickerProduct');
- var F_Product = doc.getElementById('F_ProductType');
- showUserPickerButton2.addEventListener('tap', function(event) {
- userPicker2.show(function(items) {
-
- if (items[2].text==undefined) {
- F_Product.value = items[1].text;
- F_Product.setAttribute("data-index", items[1].id);
- }else if (items[1].text==undefined) {
- F_Product.value = items[0].text;
- F_Product.setAttribute("data-index", items[0].id);
- }else {
- F_Product.value =items[2].text;
- F_Product.setAttribute("data-index", items[2].id);
- }
-
-
- });
- }, false);
- var rolePicker = new $.PopPicker({
- layer: 1
- });
- rolePicker.setData(roleList)
- var showRolePickerButton = doc.getElementById('showRolePickerProduct');
- var role = doc.getElementById('role');
- showRolePickerButton.addEventListener('tap', function(event) {
- rolePicker.show(function(items) {
- role.value = items[0].text
- role.setAttribute("data-index", items[0].id);
- });
- }, false);
- })
- })(mui, document);
- })
- $('#deteBtn').on('tap', function() {
- var btnArray = ['否', '是'];
- var zhxx=$('.rolname').val();
- mui.confirm('确认删除?--"'+zhxx+'"的账号信息将被删除', '删除信息', btnArray, function(e) {
- if (e.index == 1) {
- $.ajax({
- type: "post",
- dataType: 'json',
- url: huayi.config.callcenter_url + '/UserAccount/DeleteUsers',
- async: true,
- data: {
- ids: $("#UserId").val(),
- token: localStorage.getItem("token")
- },
- success: function(data) {
- if(data.state == "success") {
- var wobj = plus.webview.getWebviewById("Setting_manage");
- wobj.reload(true);
- } else {
- mui.toast(data.message);
- }
- }
- });
- } else {
- mui.toast("删除取消")
- }
- })
-
- })
- $('#xgPassword').on('tap', function() {
-
- if ($("#RoldId").val()==F_RoleId&&$(".rolname").val()!=F_UserCode) {
- mui.toast("没有修改权限");
- }else{
- var btnArray = ['否', '是'];
- var zhxx=$('.rolname').val();
- mui.confirm('确认修改?--"'+zhxx+'"的账号信息将被修改', '修改信息', btnArray, function(e) {
- if (e.index == 1) {
- $.ajax({
- type: "post",
- dataType: 'json',
- url: huayi.config.callcenter_url + '/UserAccount/EditUsers',
- async: true,
- data: {
- userid:$("#UserId").val(), //用户id
- username: $('.F_UserName').val(), //用户名
- usercode: $('.rolname').val(), //账号
- Password: $('.password').val(), //密码
- mobile:$(".F_Mobile").val(), //手机号
- deptid:$("#F_ProductType").attr("data-index"), //部门
- roleid:$("#role").attr("data-index"),
- token: localStorage.getItem("token")
- },
- success: function(data) {
- if(data.state == "success") {
- mui.toast('修改成功!');
- setTimeout(function () {
- var wobj = plus.webview.getWebviewById("Setting_manage");
- wobj.reload(true);
- },1500)
- } else {
- mui.toast(data.message);
- }
- }
- });
- } else {
- mui.toast("删除取消")
- }
- })
- }
-
-
- })
|