|
@@ -1,77 +1,86 @@
|
1
|
|
-import { Component, OnInit } from '@angular/core';
|
2
|
|
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
3
|
|
-import { ActivatedRoute } from '@angular/router';
|
|
1
|
+import { Component, OnInit } from "@angular/core";
|
|
2
|
+import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
|
3
|
+import { ActivatedRoute } from "@angular/router";
|
4
|
4
|
import { MainService } from "../../services/main.service";
|
5
|
5
|
|
6
|
6
|
@Component({
|
7
|
|
- selector: 'app-sys-config',
|
8
|
|
- templateUrl: './sys-config.component.html',
|
9
|
|
- styleUrls: ['./sys-config.component.less']
|
|
7
|
+ selector: "app-sys-config",
|
|
8
|
+ templateUrl: "./sys-config.component.html",
|
|
9
|
+ styleUrls: ["./sys-config.component.less"],
|
10
|
10
|
})
|
11
|
11
|
export class SysConfigComponent implements OnInit {
|
12
|
12
|
validateForm: FormGroup;
|
13
|
|
- loading1 = false;//查询信息的loading
|
14
|
|
- loading2 = false;//保存信息的loading
|
15
|
|
- loading3 = false;//刷新字典缓存信息的loading
|
16
|
|
- initConfig = [];//接口配置列表
|
17
|
|
- config = [];//配置列表[key,value,id]
|
18
|
|
- promptContent: string;//操作提示框提示信息
|
19
|
|
- ifSuccess: boolean;//操作成功/失败
|
20
|
|
- promptInfo: string;//操作结果提示信息
|
21
|
|
- promptModalShow: boolean;//操作提示框是否展示
|
22
|
|
- coopBtns = { //初始化权限
|
|
13
|
+ loading1 = false; //查询信息的loading
|
|
14
|
+ loading2 = false; //保存信息的loading
|
|
15
|
+ loading3 = false; //刷新字典缓存信息的loading
|
|
16
|
+ initConfig = []; //接口配置列表
|
|
17
|
+ config = []; //配置列表[key,value,id]
|
|
18
|
+ promptContent: string; //操作提示框提示信息
|
|
19
|
+ ifSuccess: boolean; //操作成功/失败
|
|
20
|
+ promptInfo: string; //操作结果提示信息
|
|
21
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
22
|
+ coopBtns = {
|
|
23
|
+ //初始化权限
|
23
|
24
|
edit: false,
|
24
|
25
|
};
|
25
|
|
- menu = JSON.parse(localStorage.getItem('menu')) || [];//菜单
|
26
|
|
- constructor(private mainService: MainService, private fb: FormBuilder, private route: ActivatedRoute) { }
|
|
26
|
+ menu = JSON.parse(localStorage.getItem("menu")) || []; //菜单
|
|
27
|
+ constructor(
|
|
28
|
+ private mainService: MainService,
|
|
29
|
+ private fb: FormBuilder,
|
|
30
|
+ private route: ActivatedRoute
|
|
31
|
+ ) {}
|
27
|
32
|
|
28
|
33
|
ngOnInit() {
|
29
|
34
|
this.validateForm = this.fb.group({
|
30
|
35
|
defaultPwd: [null, [Validators.required]],
|
31
|
36
|
effectiveDuration: [null, [Validators.required]],
|
32
|
37
|
orderClearUserSwitch: [null, [Validators.required]],
|
33
|
|
- formUrl: [null, [Validators.required]],
|
34
|
|
- serviceUrl: [null, [Validators.required]],
|
35
|
|
- cachePath: [null, [Validators.required]],
|
36
|
|
- cachePort: [null, [Validators.required]],
|
|
38
|
+ formUrl: [{ value: null, disabled: true }, [Validators.required]],
|
|
39
|
+ serviceUrl: [{ value: null, disabled: true }, [Validators.required]],
|
|
40
|
+ cachePath: [{ value: null, disabled: true }, [Validators.required]],
|
|
41
|
+ cachePort: [{ value: null, disabled: true }, [Validators.required]],
|
|
42
|
+ busiViewDeptId: [null, [Validators.required]],
|
37
|
43
|
});
|
38
|
|
- this.getSysConfig();
|
|
44
|
+ this.getDeptType();
|
39
|
45
|
this.initCoopBtns();
|
40
|
46
|
}
|
41
|
47
|
// 获取当前菜单权限
|
42
|
48
|
initCoopBtns() {
|
43
|
49
|
// 二级菜单
|
44
|
|
- let secondMenus = []
|
45
|
|
- this.menu.forEach(e => {
|
46
|
|
- e.childrens.forEach(el => {
|
47
|
|
- secondMenus.push(el)
|
|
50
|
+ let secondMenus = [];
|
|
51
|
+ this.menu.forEach((e) => {
|
|
52
|
+ e.childrens.forEach((el) => {
|
|
53
|
+ secondMenus.push(el);
|
48
|
54
|
});
|
49
|
55
|
});
|
50
|
56
|
let link = this.route.parent.snapshot.routeConfig.path;
|
51
|
|
- let btns = []
|
52
|
|
- secondMenus.forEach(e => {
|
|
57
|
+ let btns = [];
|
|
58
|
+ secondMenus.forEach((e) => {
|
53
|
59
|
if (e.link == link) {
|
54
|
60
|
btns = e.childrens || [];
|
55
|
61
|
}
|
56
|
62
|
});
|
57
|
|
- btns.forEach(e => {
|
|
63
|
+ btns.forEach((e) => {
|
58
|
64
|
this.coopBtns[e.link] = true;
|
59
|
|
- })
|
|
65
|
+ });
|
60
|
66
|
}
|
61
|
67
|
// 刷新字典缓存
|
62
|
|
- refresh(){
|
|
68
|
+ refresh() {
|
63
|
69
|
this.loading3 = true;
|
64
|
|
- this.mainService.refreshDic().subscribe(result => {
|
65
|
|
- this.loading3 = false;
|
66
|
|
- if(result.status == 200){
|
67
|
|
- this.showPromptModal('刷新', true, '');
|
68
|
|
- }else{
|
69
|
|
- this.showPromptModal('刷新', false, '');
|
|
70
|
+ this.mainService.refreshDic().subscribe(
|
|
71
|
+ (result) => {
|
|
72
|
+ this.loading3 = false;
|
|
73
|
+ if (result.status == 200) {
|
|
74
|
+ this.showPromptModal("刷新", true, "");
|
|
75
|
+ } else {
|
|
76
|
+ this.showPromptModal("刷新", false, "");
|
|
77
|
+ }
|
|
78
|
+ },
|
|
79
|
+ (error) => {
|
|
80
|
+ this.loading3 = false;
|
|
81
|
+ this.showPromptModal("刷新", false, "");
|
70
|
82
|
}
|
71
|
|
- }, error => {
|
72
|
|
- this.loading3 = false;
|
73
|
|
- this.showPromptModal('刷新', false, '');
|
74
|
|
- })
|
|
83
|
+ );
|
75
|
84
|
}
|
76
|
85
|
// 保存
|
77
|
86
|
submitForm(): void {
|
|
@@ -79,73 +88,100 @@ export class SysConfigComponent implements OnInit {
|
79
|
88
|
this.validateForm.controls[i].markAsDirty();
|
80
|
89
|
this.validateForm.controls[i].updateValueAndValidity();
|
81
|
90
|
}
|
82
|
|
- let filterData = this.initConfig.filter(item => item.keyconfig === 'pwd' || item.keyconfig === 'conversationSeconds' || item.keyconfig === 'orderClearUserSwitch');
|
83
|
|
- filterData.forEach(item => {
|
84
|
|
- if (item.keyconfig === 'pwd') {
|
|
91
|
+ let filterData = this.initConfig.filter(
|
|
92
|
+ (item) =>
|
|
93
|
+ item.keyconfig === "pwd" ||
|
|
94
|
+ item.keyconfig === "conversationSeconds" ||
|
|
95
|
+ item.keyconfig === "orderClearUserSwitch" ||
|
|
96
|
+ item.keyconfig === "busiViewDeptId"
|
|
97
|
+ );
|
|
98
|
+ filterData.forEach((item) => {
|
|
99
|
+ if (item.keyconfig === "pwd") {
|
85
|
100
|
item.valueconfig = this.validateForm.controls.defaultPwd.value;
|
86
|
|
- } else if (item.keyconfig === 'conversationSeconds') {
|
|
101
|
+ } else if (item.keyconfig === "conversationSeconds") {
|
87
|
102
|
item.valueconfig = this.validateForm.controls.effectiveDuration.value;
|
88
|
|
- } else if (item.keyconfig === 'orderClearUserSwitch') {
|
89
|
|
- item.valueconfig = this.validateForm.controls.orderClearUserSwitch.value;
|
|
103
|
+ } else if (item.keyconfig === "orderClearUserSwitch") {
|
|
104
|
+ item.valueconfig =
|
|
105
|
+ this.validateForm.controls.orderClearUserSwitch.value;
|
|
106
|
+ } else if (item.keyconfig === "busiViewDeptId") {
|
|
107
|
+ item.valueconfig = this.validateForm.controls.busiViewDeptId.value;
|
90
|
108
|
}
|
91
|
|
- })
|
|
109
|
+ });
|
92
|
110
|
const postData = filterData;
|
93
|
111
|
this.loading2 = true;
|
94
|
|
- this.mainService.changeSysConfig(postData).subscribe(result => {
|
95
|
|
- this.loading2 = false;
|
96
|
|
- if (result['status'] == 200) {
|
97
|
|
- this.showPromptModal('保存', true, '');
|
98
|
|
- } else {
|
99
|
|
- this.showPromptModal('保存', false, '');
|
|
112
|
+ this.mainService.changeSysConfig(postData).subscribe(
|
|
113
|
+ (result) => {
|
|
114
|
+ this.loading2 = false;
|
|
115
|
+ if (result["status"] == 200) {
|
|
116
|
+ this.showPromptModal("保存", true, "");
|
|
117
|
+ } else {
|
|
118
|
+ this.showPromptModal("保存", false, "");
|
|
119
|
+ }
|
|
120
|
+ },
|
|
121
|
+ (error) => {
|
|
122
|
+ this.loading2 = false;
|
|
123
|
+ this.showPromptModal("保存", false, "");
|
100
|
124
|
}
|
101
|
|
- }, error => {
|
102
|
|
- this.loading2 = false;
|
103
|
|
- this.showPromptModal('保存', false, '');
|
104
|
|
- })
|
|
125
|
+ );
|
|
126
|
+ }
|
|
127
|
+ // 获取科室类型
|
|
128
|
+ deptTypes: any = [];
|
|
129
|
+ getDeptType() {
|
|
130
|
+ this.loading1 = true;
|
|
131
|
+ this.mainService.getDictionary("list", "dept_type").subscribe((result) => {
|
|
132
|
+ this.deptTypes = result;
|
|
133
|
+ this.getSysConfig();
|
|
134
|
+ });
|
105
|
135
|
}
|
106
|
136
|
// 获取系统配置
|
107
|
137
|
getSysConfig() {
|
108
|
|
- const postData = { "idx": 0, "sum": 99 };
|
109
|
|
- this.loading1 = true;
|
110
|
|
- this.mainService.getFetchDataList('simple/data', 'systemConfiguration', postData).subscribe(result => {
|
111
|
|
- this.loading1 = false;
|
112
|
|
- if (result.status == 200) {
|
113
|
|
- if (result.list && Array.isArray(result.list)) {
|
114
|
|
- this.initConfig = JSON.parse(JSON.stringify(result.list));
|
115
|
|
- this.config = result.list.map(item => {
|
116
|
|
- return [item.keyconfig, item.valueconfig, item.id, item.label];
|
117
|
|
- })
|
118
|
|
- this.config.forEach(c => {
|
119
|
|
- switch (c[0]) {
|
120
|
|
- case 'pwd':
|
121
|
|
- this.validateForm.controls.defaultPwd.setValue(c[1]);
|
122
|
|
- break;
|
123
|
|
- case 'conversationSeconds':
|
124
|
|
- this.validateForm.controls.effectiveDuration.setValue(c[1]);
|
125
|
|
- break;
|
126
|
|
- case 'orderClearUserSwitch':
|
127
|
|
- this.validateForm.controls.orderClearUserSwitch.setValue(c[1]);
|
128
|
|
- break;
|
129
|
|
- case 'formUri':
|
130
|
|
- this.validateForm.controls.formUrl.setValue(c[1]);
|
131
|
|
- break;
|
132
|
|
- case 'serviceUrl':
|
133
|
|
- this.validateForm.controls.serviceUrl.setValue(c[1]);
|
134
|
|
- break;
|
135
|
|
- case 'userRedisIp':
|
136
|
|
- this.validateForm.controls.cachePath.setValue(c[1]);
|
137
|
|
- break;
|
138
|
|
- case 'userRedisPort':
|
139
|
|
- this.validateForm.controls.cachePort.setValue(c[1]);
|
140
|
|
- break;
|
141
|
|
- }
|
142
|
|
- })
|
143
|
|
- } else {
|
144
|
|
- this.initConfig = [];
|
145
|
|
- this.config = [];
|
|
138
|
+ const postData = { idx: 0, sum: 99 };
|
|
139
|
+ this.mainService
|
|
140
|
+ .getFetchDataList("simple/data", "systemConfiguration", postData)
|
|
141
|
+ .subscribe((result) => {
|
|
142
|
+ this.loading1 = false;
|
|
143
|
+ if (result.status == 200) {
|
|
144
|
+ if (result.list && Array.isArray(result.list)) {
|
|
145
|
+ this.initConfig = JSON.parse(JSON.stringify(result.list));
|
|
146
|
+ this.config = result.list.map((item) => {
|
|
147
|
+ return [item.keyconfig, item.valueconfig, item.id, item.label];
|
|
148
|
+ });
|
|
149
|
+ this.config.forEach((c) => {
|
|
150
|
+ switch (c[0]) {
|
|
151
|
+ case "pwd":
|
|
152
|
+ this.validateForm.controls.defaultPwd.setValue(c[1]);
|
|
153
|
+ break;
|
|
154
|
+ case "conversationSeconds":
|
|
155
|
+ this.validateForm.controls.effectiveDuration.setValue(c[1]);
|
|
156
|
+ break;
|
|
157
|
+ case "orderClearUserSwitch":
|
|
158
|
+ this.validateForm.controls.orderClearUserSwitch.setValue(
|
|
159
|
+ c[1]
|
|
160
|
+ );
|
|
161
|
+ break;
|
|
162
|
+ case "formUri":
|
|
163
|
+ this.validateForm.controls.formUrl.setValue(c[1]);
|
|
164
|
+ break;
|
|
165
|
+ case "serviceUrl":
|
|
166
|
+ this.validateForm.controls.serviceUrl.setValue(c[1]);
|
|
167
|
+ break;
|
|
168
|
+ case "userRedisIp":
|
|
169
|
+ this.validateForm.controls.cachePath.setValue(c[1]);
|
|
170
|
+ break;
|
|
171
|
+ case "userRedisPort":
|
|
172
|
+ this.validateForm.controls.cachePort.setValue(c[1]);
|
|
173
|
+ break;
|
|
174
|
+ case "busiViewDeptId":
|
|
175
|
+ this.validateForm.controls.busiViewDeptId.setValue(c[1]+'');
|
|
176
|
+ break;
|
|
177
|
+ }
|
|
178
|
+ });
|
|
179
|
+ } else {
|
|
180
|
+ this.initConfig = [];
|
|
181
|
+ this.config = [];
|
|
182
|
+ }
|
146
|
183
|
}
|
147
|
|
- }
|
148
|
|
- })
|
|
184
|
+ });
|
149
|
185
|
}
|
150
|
186
|
// 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
151
|
187
|
showPromptModal(con, success, promptInfo) {
|
|
@@ -156,7 +192,6 @@ export class SysConfigComponent implements OnInit {
|
156
|
192
|
setTimeout(() => {
|
157
|
193
|
this.promptModalShow = true;
|
158
|
194
|
}, 100);
|
159
|
|
- this.getSysConfig();
|
|
195
|
+ this.getDeptType();
|
160
|
196
|
}
|
161
|
197
|
}
|
162
|
|
-
|