sysconfigCtrl.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. angular.forEach(a.linkConfig, function (v) {
  23. arr.systemConfiguration.push(v);
  24. })
  25. arr.systemConfiguration.push(a.repairMain);//报修主体
  26. arr.systemConfiguration.push(a.ifCreate);//自动建单
  27. arr.systemConfiguration.push(a.reqHasCategory);//是否选择事件分类
  28. arr.systemConfiguration.push(a.incidentWithConsumable);//是否需要绑定耗材
  29. arr.systemConfiguration.push(a.wxIncidentWithCmdb);//是否需要绑定资产
  30. arr.systemConfiguration.push(a.ifWorking);//是否开通上下班
  31. arr.systemConfiguration.push(a.ifRoom);//是否增加房间号选择
  32. arr.systemConfiguration.push(a.requesterLgoinType);//保修人登录方式
  33. arr.systemConfiguration.push(a.autoCloseIncidentHour);//自动关单小时
  34. console.log(arr,99999);
  35. g.addData("systemConfiguration", arr).then(function (t) {
  36. if (t.status == 200) {
  37. //获取报修主体
  38. api_is_category.isCategory({ "idx": 0, "sum": 1000 })
  39. .then(function (res) {
  40. if (res.status == 200) {
  41. //存储报修主体到缓存
  42. var list = res.list;
  43. var repairMain = list.find((v) => v.keyconfig == "repairMain"); //报修主体
  44. var incidentWithConsumable = list.find(
  45. (v) => v.keyconfig == "incidentWithConsumable"
  46. ); //是否绑定耗材
  47. var wxIncidentWithCmdb = list.find(
  48. (v) => v.keyconfig == "wxIncidentWithCmdb"
  49. ); //是否绑定资产
  50. sessionStorage.setItem(
  51. "repair_main",
  52. JSON.stringify(repairMain)
  53. );
  54. sessionStorage.setItem(
  55. "incidentWithConsumable",
  56. incidentWithConsumable.valueconfig
  57. );
  58. sessionStorage.setItem(
  59. "wxIncidentWithCmdb",
  60. wxIncidentWithCmdb.valueconfig
  61. );
  62. o.swal({
  63. title: "保存成功!",
  64. type: "success",
  65. confirmButtonColor: "#007AFF"
  66. })
  67. }
  68. })
  69. .catch(function (err) {
  70. console.log(err)
  71. })
  72. } else {
  73. o.swal({
  74. title: "操作异常!",
  75. text: "系统异常,请稍后重试,或者联系管理员!",
  76. type: "error"
  77. })
  78. }
  79. })
  80. }, a.ldloading = {}, a.refreshData = function (t, n) {
  81. a.ldloading[t.replace("-", "_")] = !0, angular.isUndefined(n) && (n = f), a.myData = [], g.fetchDataList("systemConfiguration", n).then(function (n) {
  82. if (n.status == 200) {
  83. var e = c.stripRestangular(n);
  84. a.myData = e.list, a.ldloading[t.replace("-", "_")] = !1
  85. console.log(a.myData);
  86. a.baseConfig = [];//基本配置
  87. a.cacheConfig = [];//缓存配置
  88. a.linkConfig = [];//链接配置
  89. a.repairMain = {};//报修主体
  90. console.log(a.myData,77777)
  91. angular.forEach(a.myData, function (v, i) {
  92. if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds' || v.keyconfig == 'formUri' || v.keyconfig == 'localhost' || v.keyconfig == 'verificationPath' || v.keyconfig == 'docpath') {
  93. a.baseConfig.push(v);//基本配置
  94. }
  95. if (v.keyconfig == 'userRedisIp' || v.keyconfig == 'userRedisPort') {
  96. a.cacheConfig.push(v);//缓存配置
  97. }
  98. if (v.keyconfig == 'wxBxQuestions' || v.keyconfig == 'wxGuide' || v.keyconfig == 'wxClQuestions') {
  99. a.linkConfig.push(v);//链接配置
  100. }
  101. if (v.keyconfig == 'repairMain') {
  102. a.repairMain = v;//报修主体
  103. }
  104. if (v.keyconfig == 'ifCreate') {
  105. a.ifCreate = v;//自动建单
  106. }
  107. if (v.keyconfig == 'reqHasCategory') {
  108. a.reqHasCategory = v;//是否选择事件分类
  109. }
  110. if (v.keyconfig == 'incidentWithConsumable') {
  111. a.incidentWithConsumable = v;//是否需要绑定耗材
  112. }
  113. if (v.keyconfig == 'wxIncidentWithCmdb') {
  114. a.wxIncidentWithCmdb = v;//是否需要绑定资产
  115. }
  116. if (v.keyconfig == 'ifWorking') {
  117. a.ifWorking = v;//是否开通上下班
  118. }
  119. if (v.keyconfig == 'ifRoom') {
  120. a.ifRoom = v;//是否增加房间号选择
  121. }
  122. if (v.keyconfig == 'requesterLgoinType') {
  123. a.requesterLgoinType = v;//报修人登录方式
  124. }
  125. if (v.keyconfig == 'autoCloseIncidentHour') {
  126. v.valueconfig = parseFloat(v.valueconfig)
  127. a.autoCloseIncidentHour = v;//自动关单小时
  128. }
  129. })
  130. }else{
  131. console.log(n.status);
  132. }
  133. }, function () {
  134. a.ldloading[t.replace("-", "_")] = !1
  135. })
  136. }, a.refreshData("expand-right", f)
  137. }]);