configuration-voluntarilyBuild.component.ts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import { Component, OnInit, Input } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import { Subject } from 'rxjs';
  4. import { debounceTime } from 'rxjs/operators';
  5. import { MainService } from "../../../services/main.service";
  6. import { Validators, FormGroup, FormBuilder } from '@angular/forms';
  7. import { ToolService } from 'src/app/services/tool.service';
  8. import { NzMessageService } from 'ng-zorro-antd';
  9. @Component({
  10. selector: "app-configuration-voluntarilyBuild",
  11. templateUrl: "./configuration-voluntarilyBuild.component.html",
  12. styleUrls: ["./configuration-voluntarilyBuild.component.less"],
  13. })
  14. export class ConfigurationVoluntarilyBuildComponent implements OnInit {
  15. constructor(
  16. private route: ActivatedRoute,
  17. private mainService: MainService,
  18. private fb: FormBuilder,
  19. private tool: ToolService,
  20. private message: NzMessageService,
  21. ) {}
  22. @Input() voluntarilyTabList: any[] = [];
  23. coopData: any = {}; //当前操作列
  24. hosId:any;
  25. hospitals:any = [];
  26. isDeptLoading: boolean = false;
  27. currentHospital:any;
  28. malfunctionData:any = [];
  29. allUserGroup:any = [];
  30. userData:any = [];
  31. changeCommonInpSubject = new Subject();
  32. ngOnInit() {
  33. this.activeDictionaryKey = this.voluntarilyTabList[0];
  34. this.changeCommonInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  35. if(v[0] === 'category'){
  36. this.searchApplicationCategory(v[1]);
  37. }
  38. });
  39. // 优先级
  40. setTimeout(() => {
  41. this.tablePriorityHeight = document.querySelector('#priorityTable').clientHeight - document.querySelector('#priorityTable .list-template__top').clientHeight - 8 - document.querySelector('#priorityTable .thead').clientHeight;
  42. }, 100)
  43. this.hosId = this.tool.getCurrentHospital().id;
  44. this.currentHospital = this.tool.getCurrentHospital();
  45. this.getCommonFaultsList();
  46. this.searchApplicationCategory()
  47. this.getEmergencyDic();
  48. this.getGroupList();
  49. }
  50. activeDictionaryKey:any;
  51. clickDictionaryKey(item){
  52. this.activeDictionaryKey = item;
  53. if(item.key=='alarmConfig'){
  54. this.getCommonFaultsList();
  55. }
  56. }
  57. // 获取处理组
  58. groupList:any = [];
  59. getGroupList() {
  60. let data = {
  61. idx: 0,
  62. sum: 99999,
  63. group2: {
  64. statisticalHosId: this.hosId
  65. }
  66. };
  67. this.mainService
  68. .getFetchDataList("simple/data", "group2", data)
  69. .subscribe((data) => {
  70. this.groupList = data.list || [];
  71. });
  72. }
  73. // 选择处理组
  74. changeGroup(e){
  75. this.validatePriorityForm.controls.userId.setValue(null);
  76. this.getUserList();
  77. }
  78. // 获取处理人
  79. userList:any = [];
  80. getUserList() {
  81. let data = {
  82. idx: 0,
  83. sum: 99999,
  84. user: {
  85. groupdata: {
  86. id: this.validatePriorityForm.value.groupId
  87. }
  88. }
  89. };
  90. this.mainService
  91. .getFetchDataList("data", "user", data)
  92. .subscribe((data) => {
  93. this.userList = data.list || [];
  94. });
  95. }
  96. // 获取告警优先级
  97. emergencyData:any = [];
  98. getEmergencyDic() {
  99. this.mainService.getDictionary("list", "alarm_urgency").subscribe((data) => {
  100. this.emergencyData = data || [];
  101. });
  102. }
  103. // 新增优先级弹框
  104. modelName = ""; //模态框名称
  105. modalPriority: boolean = false; //新增/编辑模态框
  106. add: boolean; //true:新增;false:编辑
  107. addPriorityModal() {
  108. this.modelName = "新增";
  109. this.add = true; //新增
  110. this.modalPriority = true;
  111. this.initForm();
  112. }
  113. //关闭新增/编辑弹框
  114. hidePriorityModal() {
  115. this.modalPriority = false;
  116. }
  117. changeCommonInp(type, e) {
  118. this.changeCommonInpSubject.next([type, e]);
  119. }
  120. // 获取故障现象数据
  121. isLoading:boolean = false;
  122. searchApplicationCategory(keyWord?){
  123. let postData = {
  124. category: {
  125. category: keyWord,
  126. selectType: "mutlQuery",
  127. hierarchy: 3,
  128. },
  129. };
  130. this.isLoading = true;
  131. this.mainService.incidentPost("listIncidentCategory", postData).subscribe(data => {
  132. this.isLoading = false;
  133. if (data.status == 200) {
  134. this.malfunctionData = data.data || [];
  135. }
  136. })
  137. }
  138. // 编辑
  139. editPriority(data) {
  140. console.log(data);
  141. this.modelName = "编辑";
  142. this.add = false;
  143. this.modalPriority = true;
  144. this.initForm();
  145. this.coopData = data;
  146. this.validatePriorityForm.controls.alarmUrgency.setValue(data.alarmUrgency.id);
  147. this.validatePriorityForm.controls.keywords.setValue(data.keywords?data.keywords:null);
  148. this.validatePriorityForm.controls.categoryId.setValue(data.categoryDTO?data.categoryDTO.id:null);
  149. this.validatePriorityForm.controls.groupId.setValue(data.groupDTO.id);
  150. if(data.groupDTO.id){
  151. this.getUserList()
  152. this.validatePriorityForm.controls.userId.setValue(data.userDTO?data.userDTO.id:null);
  153. }
  154. this.validatePriorityForm.controls.flag.setValue(data.flag);
  155. }
  156. // 新增/编辑表单提交
  157. btnLoading: boolean = false; //提交按钮loading状态
  158. submitPriorityForm(): void {
  159. for (const i in this.validatePriorityForm.controls) {
  160. this.validatePriorityForm.controls[i].markAsDirty();
  161. this.validatePriorityForm.controls[i].updateValueAndValidity();
  162. }
  163. if (this.validatePriorityForm.invalid) {
  164. return;
  165. }
  166. console.log(this.validatePriorityForm.value);
  167. this.btnLoading = true;
  168. let postData:any = {};
  169. if (this.add) {
  170. //增加
  171. postData = {
  172. alarmUrgency: {
  173. id: this.validatePriorityForm.value.alarmUrgency
  174. },
  175. keywords: this.validatePriorityForm.value.keywords || undefined,
  176. categoryId: this.validatePriorityForm.value.categoryId,
  177. groupId: this.validatePriorityForm.value.groupId,
  178. userId: this.validatePriorityForm.value.userId || undefined,
  179. flag: this.validatePriorityForm.value.flag,
  180. };
  181. } else {
  182. //编辑
  183. postData = {
  184. ...this.coopData,
  185. alarmUrgency: {
  186. id: this.validatePriorityForm.value.alarmUrgency
  187. },
  188. keywords: this.validatePriorityForm.value.keywords || undefined,
  189. categoryId: this.validatePriorityForm.value.categoryId,
  190. groupId: this.validatePriorityForm.value.groupId,
  191. userId: this.validatePriorityForm.value.userId || undefined,
  192. flag: this.validatePriorityForm.value.flag,
  193. };
  194. }
  195. this.mainService
  196. .simplePost(this.add ? "addData": "upData", "alarmConfig", postData)
  197. .subscribe((result) => {
  198. this.btnLoading = false;
  199. this.hidePriorityModal();
  200. let msg = "";
  201. if (this.add) {
  202. msg = "新增";
  203. } else {
  204. msg = "修改";
  205. }
  206. if (result.status == 200) {
  207. this.showPromptModal(msg, true, '');
  208. } else {
  209. this.showPromptModal(msg, false, result.msg);
  210. }
  211. });
  212. }
  213. // 初始化新增form表单
  214. validatePriorityForm: FormGroup; //新增/编辑表单
  215. initForm() {
  216. this.validatePriorityForm = this.fb.group({
  217. alarmUrgency: [null, [Validators.required]],
  218. keywords: [null, []],
  219. categoryId: [null, [Validators.required]],
  220. groupId: [null, [Validators.required]],
  221. userId: [null, []],
  222. flag: [null, [Validators.required]],
  223. });
  224. console.log(this.validatePriorityForm.controls)
  225. }
  226. // 获取列表
  227. loading1:boolean = false;
  228. commonFaultsList: any[] = []; //表格数据
  229. tablePriorityHeight:number = 0;
  230. getCommonFaultsList() {
  231. let data = {
  232. idx: 0,
  233. sum: 99999,
  234. alarmConfig: {
  235. hosId: this.hosId
  236. },
  237. };
  238. this.loading1 = true;
  239. this.mainService
  240. .getFetchDataList("simple/data", "alarmConfig", data)
  241. .subscribe((data) => {
  242. this.loading1 = false;
  243. this.commonFaultsList = data.list || [];
  244. });
  245. }
  246. delModal: boolean = false; //删除模态框
  247. tipsMsg1: string; //提示框信息
  248. tipsMsg2: string; //操作后信息
  249. confirmDelType: string; //确认的类型(启用/停用,删除)
  250. showDelModal(
  251. data,
  252. tipsMsg1: string,
  253. tipsMsg2: string,
  254. type: string,
  255. ) {
  256. this.confirmDelType = type;
  257. this.delModal = true;
  258. this.coopData = data;
  259. console.log(this.coopData);
  260. this.tipsMsg1 = tipsMsg1;
  261. this.tipsMsg2 = tipsMsg2;
  262. }
  263. // 隐藏删除框
  264. hideDelModal() {
  265. this.delModal = false;
  266. }
  267. // 确认删除
  268. confirmDel() {
  269. this.btnLoading = true;
  270. this.mainService
  271. .simplePost("rmvData", "alarmConfig", [this.coopData.id])
  272. .subscribe((data) => {
  273. this.btnLoading = false;
  274. this.delModal = false;
  275. if (data.status == 200) {
  276. this.showPromptModal(this.tipsMsg2, true, "");
  277. } else {
  278. this.showPromptModal(this.tipsMsg2, false, data.msg);
  279. }
  280. });
  281. }
  282. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  283. promptContent: string; //操作提示框提示信息
  284. ifSuccess: boolean; //操作成功/失败
  285. promptInfo: string; //操作结果提示信息
  286. promptModalShow: boolean; //操作提示框是否展示
  287. showPromptModal(con, success, promptInfo?) {
  288. this.promptModalShow = false;
  289. this.promptContent = con;
  290. this.ifSuccess = success;
  291. this.promptInfo = promptInfo;
  292. setTimeout(() => {
  293. this.promptModalShow = true;
  294. }, 100);
  295. this.getCommonFaultsList();
  296. }
  297. }