sysconfigCtrl.js 6.7 KB

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