configuration-hospital.component.ts 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. import { Component, OnInit, Input } from "@angular/core";
  2. import { ActivatedRoute } from "@angular/router";
  3. import { MainService } from "../../../services/main.service";
  4. import { ToolService } from 'src/app/services/tool.service';
  5. import { NzMessageService } from 'ng-zorro-antd';
  6. import { Subject } from 'rxjs';
  7. import { debounceTime } from 'rxjs/operators';
  8. @Component({
  9. selector: "app-configuration-hospital",
  10. templateUrl: "./configuration-hospital.component.html",
  11. styleUrls: ["./configuration-hospital.component.less"],
  12. })
  13. export class ConfigurationHospitalComponent implements OnInit {
  14. constructor(
  15. private route: ActivatedRoute,
  16. private mainService: MainService,
  17. private tool: ToolService,
  18. private message: NzMessageService,
  19. ) {}
  20. coopData: any = {}; //当前操作列
  21. currentHospital; //当前院区
  22. maintainDept:any=[];
  23. @Input() hospitalTabList: any[] = [];
  24. changeCommonInpSubject = new Subject();
  25. ngOnInit() {
  26. this.activeDictionaryKey = this.hospitalTabList[0];
  27. this.maintainDept = this.tool.getUserInfoPermission().dutyList
  28. this.currentHospital = this.tool.getCurrentHospital();
  29. this.changeCommonInpSubject.pipe(debounceTime(500)).subscribe((v) => {
  30. if(v[0] === 'category'){
  31. this.searchApplicationCategory(v[1]);
  32. }
  33. });
  34. this.getDicType();
  35. this.searchApplicationCategory();
  36. }
  37. activeDictionaryKey:any;
  38. clickDictionaryKey(item){
  39. this.activeDictionaryKey = item;
  40. this.getList();
  41. }
  42. // 获取评价字典
  43. dicData:any=[];
  44. alarmData:any = [];
  45. getDicType(){
  46. this.mainService.getDictionary("list", "incident_degree").subscribe((data) => {
  47. this.dicData = data
  48. this.getList();
  49. });
  50. this.mainService.getDictionary("list", "alarm_urgency").subscribe((data) => {
  51. this.alarmData = data
  52. });
  53. }
  54. itsmQuoteOtherDeptWorkHourType:any;
  55. itsmQuoteOtherDeptConsumableType:any;
  56. radioChange(data){
  57. console.log(123,data)
  58. if(data.key=='itsmParentConsumable' && data.value==1){
  59. let item = this.hospitalList.find(i=>i.key == 'itsmQuoteOtherDeptConsumable')
  60. item.show = true
  61. item.value = '0'
  62. this.itsmQuoteOtherDeptConsumableType = false
  63. let item2 = this.hospitalList.find(i=>i.key == 'itsmConsumableQuoteDept')
  64. item2.value = null
  65. }else if(data.key=='itsmParentConsumable' && data.value==0){
  66. let item = this.hospitalList.find(i=>i.key == 'itsmQuoteOtherDeptConsumable')
  67. item.show = false
  68. }
  69. if(data.key=='itsmQuoteOtherDeptWorkHour' && data.value==1){
  70. this.itsmQuoteOtherDeptWorkHourType = true
  71. }else if(data.key=='itsmQuoteOtherDeptWorkHour' && data.value==0){
  72. this.itsmQuoteOtherDeptWorkHourType = false
  73. let item = this.hospitalList.find(i=>i.key == 'itsmWorkHourQuoteDept')
  74. item.value = null
  75. }
  76. if(data.key=='itsmQuoteOtherDeptConsumable' && data.value==1){
  77. this.itsmQuoteOtherDeptConsumableType = true
  78. }else if(data.key=='itsmQuoteOtherDeptConsumable' && data.value==0){
  79. this.itsmQuoteOtherDeptConsumableType = false
  80. let item = this.hospitalList.find(i=>i.key == 'itsmConsumableQuoteDept')
  81. item.value = null
  82. }
  83. if(data.key=='itsmSimpleHandle' && data.value==1){
  84. let item = this.hospitalList.find(i=>i.key == 'itsmWriteSolution')
  85. item.show = false
  86. }else if(data.key=='itsmSimpleHandle' && data.value==0){
  87. let item = this.hospitalList.find(i=>i.key == 'itsmWriteSolution')
  88. item.show = true
  89. }
  90. }
  91. changeSelect(data){
  92. }
  93. // 获取故障现象数据
  94. isLoading:boolean = false;
  95. malfunctionData:any = [];
  96. searchApplicationCategory(keyWord?){
  97. let postData = {
  98. category: {
  99. category: keyWord,
  100. selectType: "mutlQuery",
  101. hierarchy: 3,
  102. },
  103. };
  104. this.isLoading = true;
  105. this.mainService.incidentPost("listIncidentCategory", postData).subscribe(data => {
  106. this.isLoading = false;
  107. if (data.status == 200) {
  108. this.malfunctionData = data.data || [];
  109. }
  110. })
  111. }
  112. // 是否开启告警自动建单
  113. alarmAutoSwitch:boolean = false;
  114. radioAutoChange(data){
  115. if(data.key=='itsmAlarmAutoCreate' && data.value==1){
  116. this.alarmAutoSwitch = true
  117. }else if(data.key=='itsmAlarmAutoCreate' && data.value==0){
  118. this.alarmAutoSwitch = false
  119. this.hospitalList[1].value = null
  120. this.hospitalList[2].value = null
  121. }
  122. }
  123. changeCommonInp(type, e) {
  124. this.changeCommonInpSubject.next([type, e]);
  125. }
  126. // 新增/编辑表单提交
  127. btnLoading: boolean = false; //提交按钮loading状态
  128. submitMessageForm(): void {
  129. this.btnLoading = true;
  130. for(let i of this.hospitalList){
  131. if(i.key=='itsmUserBadEvaluationRange' || i.key=='itsmCallbackBadEvaluationRange'){
  132. i.value = i.value.join(',')
  133. }
  134. }
  135. if(this.activeDictionaryKey.key=='alarm'){
  136. if(this.hospitalList[0].value==1){
  137. this.hospitalList[2].value = this.hospitalList[2].value.join(',')
  138. }
  139. }
  140. setTimeout(_=>{
  141. this.mainService
  142. .simplePost("addListData", "hospitalConfig", this.hospitalList)
  143. .subscribe((result) => {
  144. this.btnLoading = false;
  145. let msg = "保存";
  146. if (result.status == 200) {
  147. this.showPromptModal(msg, true, '');
  148. } else {
  149. this.showPromptModal(msg, false, result.msg);
  150. }
  151. });
  152. },50)
  153. }
  154. // 获取列表
  155. loading1:boolean = false;
  156. hospitalList:any[] = [];
  157. getList() {
  158. let data = {
  159. idx: 0,
  160. sum: 9999,
  161. hospitalConfig: {
  162. hosId: this.currentHospital.id,
  163. model: 'itsm',
  164. value2: this.activeDictionaryKey.key
  165. },
  166. };
  167. this.loading1 = true;
  168. this.mainService
  169. .getFetchDataList("simple/data", "hospitalConfig", data)
  170. .subscribe((data) => {
  171. this.loading1 = false;
  172. if (data.status == 200) {
  173. data.list.forEach(i =>{
  174. i.show = false
  175. })
  176. let newData = data.list
  177. for(let i of newData){
  178. if(i.key=='itsmParentConsumable' && i.value==1){
  179. let item = newData.find(i=>i.key == 'itsmQuoteOtherDeptConsumable')
  180. item.show = true
  181. item.value = '0'
  182. this.itsmQuoteOtherDeptConsumableType = false
  183. let item2 = newData.find(i=>i.key == 'itsmConsumableQuoteDept')
  184. item2.value = null
  185. }else if(i.key=='itsmParentConsumable' && i.value==0){
  186. let item = newData.find(i=>i.key == 'itsmQuoteOtherDeptConsumable')
  187. item.show = false
  188. }
  189. if(i.key=='itsmQuoteOtherDeptWorkHour' && i.value==1){
  190. this.itsmQuoteOtherDeptWorkHourType = true
  191. let item = newData.find(i=>i.key == 'itsmWorkHourQuoteDept')
  192. item.value = Number(item.value)
  193. }else if(i.key=='itsmQuoteOtherDeptWorkHour' && i.value==0){
  194. this.itsmQuoteOtherDeptWorkHourType = false
  195. }
  196. if(i.key=='itsmQuoteOtherDeptConsumable' && i.value==1){
  197. this.itsmQuoteOtherDeptConsumableType = true
  198. let item = newData.find(i=>i.key == 'itsmConsumableQuoteDept')
  199. item.value = Number(item.value)
  200. }else if(i.key=='itsmQuoteOtherDeptConsumable' && i.value==0){
  201. this.itsmQuoteOtherDeptConsumableType = false
  202. }
  203. if(i.key=='itsmUserEvaluation' || i.key=='itsmCallbackEvaluation' || i.key=='itsmAlarmDefaultCategory'){
  204. if(i.value){
  205. i.value = Number(i.value)
  206. }
  207. }
  208. if(i.key=='itsmUserBadEvaluationRange' || i.key=='itsmCallbackBadEvaluationRange' || i.key=='itsmAlarmUrgentRange'){
  209. if(i.value){
  210. let arr = i.value.split(',')
  211. arr = arr.map(i=>i = parseInt(i))
  212. i.value = arr
  213. }
  214. }
  215. if(i.key=='itsmSimpleHandle' && i.value==1){
  216. let item = newData.find(i=>i.key == 'itsmWriteSolution')
  217. item.show = false
  218. }else if(i.key=='itsmSimpleHandle' && i.value==0){
  219. let item = newData.find(i=>i.key == 'itsmWriteSolution')
  220. item.show = true
  221. }
  222. if(i.key=='itsmAlarmAutoCreate' && i.value==1){
  223. this.alarmAutoSwitch = true
  224. }else if(i.key=='itsmAlarmAutoCreate' && i.value==0){
  225. this.alarmAutoSwitch = false
  226. let item1 = newData.find(i=>i.key == 'itsmAlarmUrgentRange')
  227. if(item1.value){
  228. item1.value = null
  229. }
  230. let item2 = newData.find(i=>i.key == 'itsmAlarmDefaultCategory')
  231. if(item2.value){
  232. item2.value = null
  233. }
  234. }
  235. }
  236. this.hospitalList = newData || [];
  237. }else{
  238. this.message.error(data.msg || "请求数据失败");
  239. }
  240. });
  241. }
  242. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  243. promptContent: string; //操作提示框提示信息
  244. ifSuccess: boolean; //操作成功/失败
  245. promptInfo: string; //操作结果提示信息
  246. promptModalShow: boolean; //操作提示框是否展示
  247. showPromptModal(con, success, promptInfo?) {
  248. this.promptModalShow = false;
  249. this.promptContent = con;
  250. this.ifSuccess = success;
  251. this.promptInfo = promptInfo;
  252. setTimeout(() => {
  253. this.promptModalShow = true;
  254. }, 100);
  255. this.getList();
  256. }
  257. }