wxconfigCtrl.js 3.3 KB

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