wxconfigCtrl.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. }
  20. // ,
  21. // {
  22. // "id": 2,
  23. // "autoCreateUser": a.repairs.autoCreateUser
  24. // }
  25. ]
  26. };
  27. } else {
  28. dataObj = {
  29. "wechatConfig": [
  30. {
  31. "id": 1,
  32. "autoCreateUser": a.maintenance.autoCreateUser,
  33. "autoCreateRequester": a.maintenance.autoCreateRequester
  34. }
  35. // ,
  36. // {
  37. // "id": 2,
  38. // "autoCreateUser": a.repairs.autoCreateUser
  39. // }
  40. ]
  41. };
  42. }
  43. api_wechat_operate.postWxList(dataObj).then(function (t) {
  44. console.log(t);
  45. t.status == 200 ? o.swal({
  46. title: "保存成功!",
  47. type: "success",
  48. confirmButtonColor: "#007AFF"
  49. }) : o.swal({
  50. title: "操作异常!",
  51. text: "系统异常,请稍后重试,或者联系管理员!",
  52. type: "error"
  53. })
  54. })
  55. }, a.ldloading = {}, a.refreshData = function (t, n) {
  56. a.ldloading[t.replace("-", "_")] = !0, angular.isUndefined(n) && (n = f), a.myData = [];
  57. api_wechat_operate.getWechatList(n).then(function (n) {
  58. if (n.status == 200) {
  59. var e = c.stripRestangular(n);
  60. a.myData = e.list, a.ldloading[t.replace("-", "_")] = !1
  61. console.log(a.myData)
  62. //左边微信运维,右边微信报修
  63. a.maintenance = {};//微信运维
  64. a.repairs = {};//微信报修
  65. angular.forEach(a.myData, function (v) {
  66. if (v.id == 1) {
  67. a.maintenance = v;;//微信运维
  68. }
  69. if (v.id == 2) {
  70. a.repairs = v;;//微信报修
  71. }
  72. })
  73. } else {
  74. console.log(n.status);
  75. }
  76. }, function () {
  77. a.ldloading[t.replace("-", "_")] = !1
  78. })
  79. //获取微信角色列表
  80. api_wx_role.getWxRole({ "idx": 0, "sum": 1000 })
  81. .then(res => {
  82. if (res.status == 200) {
  83. a.roleList = res.list;
  84. }
  85. })
  86. .catch(err => {
  87. console.log(err)
  88. })
  89. }, a.refreshData("expand-right", f)
  90. }]);