wxconfigCtrl.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. app.controller("wxconfigCtrl", ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "$window", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_sysinfo", "api_wechat_operate", "api_wx_role", function (t, a, n, e, i, s, r, o, l, u, d, c, g, api_wechat_operate, api_wx_role) {
  3. a.langs = l.getAllLangs(), a.lang = "zh-cn", l.setCurrentLang(a.lang);
  4. a.roleList = [];//微信配置角色列表
  5. var f = {
  6. idx: 0,
  7. sum: 10
  8. };
  9. a.savesystem = function (t) {
  10. var dataObj = {};
  11. if (a.maintenance.autoCreateUser == 1) {//自动创建
  12. dataObj = {
  13. "wechatConfig": [
  14. {
  15. "id": 1,
  16. "autoCreateUser": a.maintenance.autoCreateUser,
  17. "wechatUserRole": a.maintenance.wechatUserRole,
  18. "autoCreateRequester": a.maintenance.autoCreateRequester,
  19. "reqBind": a.maintenance.reqBind,
  20. "userBind": a.maintenance.userBind
  21. }
  22. // ,
  23. // {
  24. // "id": 2,
  25. // "autoCreateUser": a.repairs.autoCreateUser
  26. // }
  27. ]
  28. };
  29. } else {
  30. dataObj = {
  31. "wechatConfig": [
  32. {
  33. "id": 1,
  34. "autoCreateUser": a.maintenance.autoCreateUser,
  35. "autoCreateRequester": a.maintenance.autoCreateRequester,
  36. "reqBind": a.maintenance.reqBind,
  37. "userBind": a.maintenance.userBind
  38. }
  39. // ,
  40. // {
  41. // "id": 2,
  42. // "autoCreateUser": a.repairs.autoCreateUser
  43. // }
  44. ]
  45. };
  46. }
  47. api_wechat_operate.postWxList(dataObj).then(function (t) {
  48. console.log(t);
  49. t.status == 200 ? o.swal({
  50. title: "保存成功!",
  51. type: "success",
  52. confirmButtonColor: "#007AFF"
  53. }) : o.swal({
  54. title: "操作异常!",
  55. text: "系统异常,请稍后重试,或者联系管理员!",
  56. type: "error"
  57. })
  58. })
  59. }, a.ldloading = {}, a.refreshData = function (t, n) {
  60. a.ldloading[t.replace("-", "_")] = !0, angular.isUndefined(n) && (n = f), a.myData = [];
  61. api_wechat_operate.getWechatList(n).then(function (n) {
  62. if (n.status == 200) {
  63. var e = c.stripRestangular(n);
  64. a.myData = e.list, a.ldloading[t.replace("-", "_")] = !1
  65. console.log(a.myData)
  66. //左边微信运维,右边微信报修
  67. a.maintenance = {};//微信运维
  68. a.repairs = {};//微信报修
  69. angular.forEach(a.myData, function (v) {
  70. if (v.id == 1) {
  71. a.maintenance = v;;//微信运维
  72. }
  73. if (v.id == 2) {
  74. a.repairs = v;;//微信报修
  75. }
  76. })
  77. } else {
  78. console.log(n.status);
  79. }
  80. }, function () {
  81. a.ldloading[t.replace("-", "_")] = !1
  82. })
  83. //获取微信角色列表
  84. api_wx_role.getWxRole({ "idx": 0, "sum": 1000 })
  85. .then(res => {
  86. if (res.status == 200) {
  87. a.roleList = res.list;
  88. }
  89. })
  90. .catch(err => {
  91. console.log(err)
  92. })
  93. }, a.refreshData("expand-right", f)
  94. }]);