sysconfigCtrl.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. "use strict";
  2. app.controller("sysconfigCtrl", ["$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "$window", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_sysinfo", "api_is_category", "api_wx_role", function (t, a, n, e, i, s, r, o, l, u, d, c, g, api_is_category, api_wx_role) {
  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.roleList = [];
  15. a.getRoleList = function(integralRole){
  16. api_wx_role.getWxRole({ "idx": 0, "sum": 1000 }).then(function (data) {
  17. a.roleList = data.list || [];
  18. angular.forEach(a.myData, function (v, i) {
  19. if (v.keyconfig == 'integralRole') {
  20. a.integralRole.valueconfig = a.roleList.filter(function (vv) {
  21. return v.valueconfig.indexOf(vv.id) > -1;
  22. });
  23. console.log(a.integralRole.valueconfig)
  24. }
  25. })
  26. });
  27. }
  28. //保存
  29. a.savesystem = function () {
  30. var arr = {};
  31. arr.systemConfiguration = [];
  32. angular.forEach(a.baseConfig, function (v) {
  33. if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds') {
  34. arr.systemConfiguration.push(v);//用户默认密码,登录有效时长
  35. }
  36. })
  37. angular.forEach(a.linkConfig, function (v) {
  38. arr.systemConfiguration.push(v);
  39. })
  40. arr.systemConfiguration.push(a.repairMain);//报修主体
  41. arr.systemConfiguration.push(a.ifCreate);//自动建单
  42. arr.systemConfiguration.push(a.reqHasCategory);//是否选择事件分类
  43. arr.systemConfiguration.push(a.incidentWithConsumable);//是否需要绑定耗材
  44. arr.systemConfiguration.push(a.wxIncidentWithCmdb);//是否需要绑定资产
  45. arr.systemConfiguration.push(a.ifWorking);//是否开通上下班
  46. arr.systemConfiguration.push(a.integralMechanism);//积分机制
  47. if(a.integralMechanism.valueconfig == 1){
  48. if(Array.isArray(a.integralRole.valueconfig)){
  49. var integralRole = a.myData.find(v => v.keyconfig == 'integralRole');
  50. arr.systemConfiguration.push(Object.assign({}, integralRole, {valueconfig: a.integralRole.valueconfig.map(v => v.id).toString()}));//积分控制角色
  51. }else{
  52. arr.systemConfiguration.push(a.integralRole);//积分控制角色
  53. }
  54. }else{
  55. var integralRole = a.myData.find(v => v.keyconfig == 'integralRole');
  56. arr.systemConfiguration.push(Object.assign({}, integralRole, {valueconfig: ''}));//积分控制角色
  57. a.integralRole.valueconfig = [];
  58. }
  59. arr.systemConfiguration.push(a.ifRoom);//是否增加房间号选择
  60. arr.systemConfiguration.push(a.requesterLgoinType);//保修人登录方式
  61. arr.systemConfiguration.push(a.autoCloseIncidentHour);//自动关单小时
  62. console.log(arr,99999);
  63. g.addData("systemConfiguration", arr).then(function (t) {
  64. if (t.status == 200) {
  65. //获取报修主体
  66. api_is_category.isCategory({ "idx": 0, "sum": 1000 })
  67. .then(function (res) {
  68. if (res.status == 200) {
  69. //存储报修主体到缓存
  70. var list = res.list;
  71. list.forEach(v => {
  72. switch (v.keyconfig) {
  73. case "repairMain": //报修主体
  74. sessionStorage.setItem("repair_main", JSON.stringify(v));
  75. break;
  76. case "incidentWithConsumable": //是否绑定耗材
  77. sessionStorage.setItem("incidentWithConsumable", v.valueconfig);
  78. break;
  79. case "wxIncidentWithCmdb": //是否绑定资产
  80. sessionStorage.setItem("wxIncidentWithCmdb", v.valueconfig);
  81. break;
  82. case "ifRoom": //是否增加房间号选择
  83. sessionStorage.setItem("ifRoom", v.valueconfig);
  84. break;
  85. case "integralMechanism": //积分机制
  86. sessionStorage.setItem("integralMechanism", v.valueconfig);
  87. break;
  88. case "integralRole": //积分控制角色
  89. sessionStorage.setItem("integralRole", v.valueconfig);
  90. break;
  91. }
  92. });
  93. o.swal({
  94. title: "保存成功!",
  95. type: "success",
  96. confirmButtonColor: "#007AFF"
  97. })
  98. }
  99. })
  100. .catch(function (err) {
  101. console.log(err)
  102. })
  103. } else {
  104. o.swal({
  105. title: "操作异常!",
  106. text: "系统异常,请稍后重试,或者联系管理员!",
  107. type: "error"
  108. })
  109. }
  110. })
  111. };
  112. a.ldloading = {};
  113. a.refreshData = function (t, n) {
  114. a.ldloading[t.replace("-", "_")] = !0;
  115. angular.isUndefined(n) && (n = f);
  116. a.myData = [];
  117. g.fetchDataList("systemConfiguration", n).then(function (n) {
  118. if (n.status == 200) {
  119. var e = c.stripRestangular(n);
  120. a.myData = e.list, a.ldloading[t.replace("-", "_")] = !1
  121. console.log(a.myData);
  122. a.baseConfig = [];//基本配置
  123. a.cacheConfig = [];//缓存配置
  124. a.linkConfig = [];//链接配置
  125. a.repairMain = {};//报修主体
  126. a.integralRole = {valueconfig:[]};
  127. console.log(a.myData,77777)
  128. angular.forEach(a.myData, function (v, i) {
  129. if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds' || v.keyconfig == 'formUri' || v.keyconfig == 'localhost' || v.keyconfig == 'verificationPath' || v.keyconfig == 'docpath') {
  130. a.baseConfig.push(v);//基本配置
  131. }
  132. if (v.keyconfig == 'userRedisIp' || v.keyconfig == 'userRedisPort') {
  133. a.cacheConfig.push(v);//缓存配置
  134. }
  135. if (v.keyconfig == 'wxBxQuestions' || v.keyconfig == 'wxGuide' || v.keyconfig == 'wxClQuestions') {
  136. a.linkConfig.push(v);//链接配置
  137. }
  138. if (v.keyconfig == 'repairMain') {
  139. a.repairMain = v;//报修主体
  140. }
  141. if (v.keyconfig == 'ifCreate') {
  142. a.ifCreate = v;//自动建单
  143. }
  144. if (v.keyconfig == 'reqHasCategory') {
  145. a.reqHasCategory = v;//是否选择事件分类
  146. }
  147. if (v.keyconfig == 'incidentWithConsumable') {
  148. a.incidentWithConsumable = v;//是否需要绑定耗材
  149. }
  150. if (v.keyconfig == 'wxIncidentWithCmdb') {
  151. a.wxIncidentWithCmdb = v;//是否需要绑定资产
  152. }
  153. if (v.keyconfig == 'ifWorking') {
  154. a.ifWorking = v;//是否开通上下班
  155. }
  156. if (v.keyconfig == 'integralMechanism') {
  157. a.integralMechanism = v;//积分机制
  158. }
  159. if (v.keyconfig == 'integralRole') {
  160. // a.integralRole = v;//积分控制角色
  161. console.log(v);
  162. a.getRoleList(v);
  163. }
  164. if (v.keyconfig == 'ifRoom') {
  165. a.ifRoom = v;//是否增加房间号选择
  166. }
  167. if (v.keyconfig == 'requesterLgoinType') {
  168. a.requesterLgoinType = v;//报修人登录方式
  169. }
  170. if (v.keyconfig == 'autoCloseIncidentHour') {
  171. v.valueconfig = parseFloat(v.valueconfig)
  172. a.autoCloseIncidentHour = v;//自动关单小时
  173. }
  174. })
  175. }else{
  176. console.log(n.status);
  177. }
  178. }, function () {
  179. a.ldloading[t.replace("-", "_")] = !1
  180. })
  181. };
  182. a.refreshData("expand-right", f);
  183. }]);