sysconfigCtrl.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. app.controller("sysconfigCtrl", ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "$window", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_sysinfo", "api_is_category", function (t, a, n, e, i, s, r, o, l, u, d, c, g, api_is_category) {
  3. a.langs = l.getAllLangs(), a.lang = "zh-cn", l.setCurrentLang(a.lang);
  4. var f = (t.user, r._, {
  5. idx: 0,
  6. sum: 1e3
  7. });
  8. // a.autoCloseIncidentHour = 24;//默认24小时自动关单
  9. a.changeAutoCloseIncidentHour = function(e){
  10. var v = parseFloat(e.target.value)?parseFloat(e.target.value):0;
  11. a.autoCloseIncidentHour.valueconfig = v > 0 ? v : 0;
  12. }
  13. //保存
  14. a.savesystem = function () {
  15. var arr = {};
  16. arr.systemConfiguration = [];
  17. angular.forEach(a.baseConfig, function (v) {
  18. if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds') {
  19. arr.systemConfiguration.push(v);//用户默认密码,登录有效时长
  20. }
  21. })
  22. arr.systemConfiguration.push(a.repairMain);//报修主体
  23. arr.systemConfiguration.push(a.ifCreate);//自动建单
  24. arr.systemConfiguration.push(a.reqHasCategory);//是否选择事件分类
  25. arr.systemConfiguration.push(a.incidentWithConsumable);//是否需要绑定耗材
  26. arr.systemConfiguration.push(a.wxIncidentWithCmdb);//是否需要绑定资产
  27. arr.systemConfiguration.push(a.requesterLgoinType);//保修人登录方式
  28. arr.systemConfiguration.push(a.autoCloseIncidentHour);//自动关单小时
  29. console.log(arr,99999);
  30. g.addData("systemConfiguration", arr).then(function (t) {
  31. if (t.status == 200) {
  32. //获取报修主体
  33. api_is_category.isCategory({ "idx": 0, "sum": 1000, "systemConfiguration": { "keyconfig": "repairMain" } })
  34. .then(function (res) {
  35. if (res.status == 200) {
  36. //存储报修主体到缓存
  37. sessionStorage.setItem("repair_main", JSON.stringify(res.list[0]));
  38. o.swal({
  39. title: "保存成功!",
  40. type: "success",
  41. confirmButtonColor: "#007AFF"
  42. })
  43. }
  44. })
  45. .catch(function (err) {
  46. console.log(err)
  47. })
  48. } else {
  49. o.swal({
  50. title: "操作异常!",
  51. text: "系统异常,请稍后重试,或者联系管理员!",
  52. type: "error"
  53. })
  54. }
  55. })
  56. }, a.ldloading = {}, a.refreshData = function (t, n) {
  57. a.ldloading[t.replace("-", "_")] = !0, angular.isUndefined(n) && (n = f), a.myData = [], g.fetchDataList("systemConfiguration", 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. a.baseConfig = [];//基本配置
  63. a.cacheConfig = [];//缓存配置
  64. a.repairMain = {};//报修主体
  65. console.log(a.myData,77777)
  66. angular.forEach(a.myData, function (v, i) {
  67. if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds' || v.keyconfig == 'formUri' || v.keyconfig == 'localhost' || v.keyconfig == 'verificationPath' || v.keyconfig == 'docpath') {
  68. a.baseConfig.push(v);//基本配置
  69. }
  70. if (v.keyconfig == 'userRedisIp' || v.keyconfig == 'userRedisPort') {
  71. a.cacheConfig.push(v);//缓存配置
  72. }
  73. if (v.keyconfig == 'repairMain') {
  74. a.repairMain = v;//报修主体
  75. }
  76. if (v.keyconfig == 'ifCreate') {
  77. a.ifCreate = v;//自动建单
  78. }
  79. if (v.keyconfig == 'reqHasCategory') {
  80. a.reqHasCategory = v;//是否选择事件分类
  81. }
  82. if (v.keyconfig == 'incidentWithConsumable') {
  83. a.incidentWithConsumable = v;//是否需要绑定耗材
  84. }
  85. if (v.keyconfig == 'wxIncidentWithCmdb') {
  86. a.wxIncidentWithCmdb = v;//是否需要绑定资产
  87. }
  88. if (v.keyconfig == 'requesterLgoinType') {
  89. a.requesterLgoinType = v;//报修人登录方式
  90. }
  91. if (v.keyconfig == 'autoCloseIncidentHour') {
  92. v.valueconfig = parseFloat(v.valueconfig)
  93. a.autoCloseIncidentHour = v;//自动关单小时
  94. }
  95. })
  96. }else{
  97. console.log(n.status);
  98. }
  99. }, function () {
  100. a.ldloading[t.replace("-", "_")] = !1
  101. })
  102. }, a.refreshData("expand-right", f)
  103. }]);