sysconfigCtrl.js 6.1 KB

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