incident-management.component.ts 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. import { Component, OnInit, OnDestroy } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { MainService } from "../../services/main.service";
  4. import { ToolService } from "../../services/tool.service";
  5. import { Subject } from "rxjs";
  6. import { debounceTime } from "rxjs/operators";
  7. import { NzMessageService } from 'ng-zorro-antd/message';
  8. import { format, addDays, addHours } from 'date-fns';
  9. import { FormGroup, Validators, FormBuilder } from '@angular/forms';
  10. import cloneDeep from 'lodash-es/cloneDeep'
  11. @Component({
  12. selector: "app-incident-management",
  13. templateUrl: "./incident-management.component.html",
  14. styleUrls: ["./incident-management.component.less"],
  15. })
  16. export class IncidentManagementComponent implements OnInit, OnDestroy {
  17. constructor(
  18. public route: ActivatedRoute,
  19. private router: Router,
  20. private mainService: MainService,
  21. private tool: ToolService,
  22. private message: NzMessageService,
  23. private fb: FormBuilder,
  24. ) {}
  25. loginUser: any = localStorage.getItem("user")
  26. ? JSON.parse(localStorage.getItem("user")).user
  27. : null; //登录人信息
  28. listOfData: any[] = []; //表格数据
  29. coopId: string; //表格中执行操作的id
  30. hospital: string; //选中院区
  31. alldepart: any = []; //当前院区所属科室
  32. worker: number; //选择执行配送人员
  33. handleUserList: any = []; //处理人列表
  34. acceptUserList: any = []; //受理人列表
  35. gdState: number; //选择工单状态
  36. gdStates: any; //工单状态列表
  37. overdueStates: any; //逾期查询列表
  38. sourceList: any; //报修来源列表
  39. pageIndex: number = 1; //页码
  40. listLength: number = 10; //总条数
  41. pageSize: number = 10; //每页条数
  42. promptContent: string; //操作提示框提示信息
  43. ifSuccess: boolean; //操作成功/失败
  44. promptInfo: string; //操作结果提示信息
  45. promptModalShow: boolean; //操作提示框是否展示
  46. btnLoading: boolean = false; //提交按钮loading状态
  47. tabs:any[] = [
  48. // {key: 'all', value: '全部故障', num: 0, isRed: false},
  49. {key: 'todo', value: '待我接单', num: 0, isRed: true},
  50. {key: 'doing', value: '待我处理', num: 0, isRed: true},
  51. // {key: 'reassign', value: '重新指派', num: 0, isRed: false},
  52. // {key: 'callback', value: '待我回访', num: 0, isRed: false},
  53. {key: 'resolve', value: '由我解决', num: 0, isRed: false},
  54. {key: 'owns', value: '与我关联', num: 0, isRed: false},
  55. {key: 'storage', value: '暂存', num: 0, isRed: false},
  56. // {key: 'badEvaluate', value: '异常评价', num: 0, isRed: false},
  57. ]
  58. searchDTO: any = {};
  59. searchTimerSubject = new Subject();
  60. debounceSubject = new Subject(); //防抖
  61. maintainDept:any = []; //维修科室
  62. maintainGroup:any = []; //维修组
  63. hosIds:any; //当前院区
  64. // 初始化增删改按钮
  65. coopBtns: any = {};
  66. // 选择tab
  67. queryTask:string = 'todo';//默认待我接单
  68. changeTab(key){
  69. this.queryTask = key;
  70. let itemDept = this.maintainDept.find(i=>i.id == this.hosIds)
  71. if(itemDept){
  72. this.searchDTO.maintainDepartment = itemDept.id
  73. if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
  74. let arr = this.tool.getUserInfoPermission().dutyGroupList.filter(i=>i.hospital.id == itemDept.id)
  75. if(arr){
  76. this.maintainGroup = arr
  77. }else{
  78. this.maintainGroup = this.tool.getUserInfoPermission().dutyGroupList
  79. }
  80. }else{
  81. this.maintainGroup = this.tool.getUserInfoPermission().dutyGroupList
  82. }
  83. }
  84. this.getDeparts();
  85. this.getUsers('', 'handle');
  86. this.loading1 = true;
  87. this.debounceSubject.next(true);
  88. }
  89. ngOnInit() {
  90. this.maintainDept = this.tool.getUserInfoPermission().dutyList
  91. this.hosIds = this.tool.getCurrentHospital().id
  92. if(this.coopBtns.strideLook){
  93. this.defaDept()
  94. }
  95. this.initSearchForm();
  96. this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
  97. let fun = v[0];
  98. fun.call(this, v[1], v[2]);
  99. });
  100. this.debounceSubject.pipe(debounceTime(500)).subscribe((v:boolean) => {
  101. this.getList(v);
  102. });
  103. this.coopBtns = this.tool.initCoopBtns(this.route);
  104. this.initTabs();
  105. this.getGdStates();
  106. this.getOverdueStates();
  107. this.getSourceList();
  108. this.getIncidentCategoryList();
  109. this.loading1 = true;
  110. this.debounceSubject.next(true);
  111. this.autoRefresh();
  112. }
  113. ngOnDestroy(){
  114. this.cancelRefresh();
  115. }
  116. // 定时器自动刷新页面
  117. timer = null;
  118. autoRefresh(){
  119. this.cancelRefresh();
  120. this.timer = setInterval(() => {
  121. this.getList();
  122. }, 60000)
  123. }
  124. // 清除定时器
  125. cancelRefresh(){
  126. clearInterval(this.timer);
  127. }
  128. // 初始化tab
  129. initTabs(){
  130. if (this.coopBtns.all) {
  131. this.tabs.splice(0, 0 , {key: 'all', value: '全部故障', num: 0, isRed: false});
  132. }
  133. if (this.coopBtns.callback) {
  134. let index = this.tabs.findIndex(v => v.key == 'resolve');
  135. this.tabs.splice(index, 0 , {key: 'callback', value: '待我回访', num: 0, isRed: false});
  136. }
  137. if (this.coopBtns.reassign) {
  138. let index = this.tabs.findIndex(v => v.key == 'doing');
  139. this.tabs.splice(index + 1, 0 , {key: 'reassign', value: '重新指派', num: 0, isRed: false});
  140. }
  141. // if (this.coopBtns.badEvaluate) {
  142. // this.tabs.push({key: 'badEvaluate', value: '异常评价', num: 0, isRed: false});
  143. // }
  144. }
  145. defaDept(){
  146. let itemDept = this.maintainDept.find(i=>i.id == this.hosIds)
  147. if(itemDept){
  148. this.searchDTO.maintainDepartment = itemDept.id
  149. }
  150. this.getDeparts();
  151. this.getUsers('', 'handle');
  152. this.getUsers('', 'acceptUser');
  153. }
  154. // 选择维修科室
  155. deptChange(e){
  156. this.searchDTO.maintainGroup = null
  157. let arr = this.tool.getUserInfoPermission().dutyGroupList.filter(i=>i.hospital.id == e)
  158. if(arr){
  159. this.maintainGroup = arr
  160. }else{
  161. this.maintainGroup = this.tool.getUserInfoPermission().dutyGroupList
  162. }
  163. this.searchDTO.department = null
  164. this.searchDTO.todoingUser = null
  165. this.getDeparts();
  166. this.getUsers('', 'handle');
  167. }
  168. // 搜索
  169. search() {
  170. this.loading1 = true;
  171. this.debounceSubject.next(true);
  172. }
  173. // 重置
  174. reset() {
  175. this.searchDTO = {};
  176. if(this.coopBtns.strideLook){
  177. this.defaDept()
  178. }
  179. this.initSearchForm();
  180. this.loading1 = true;
  181. this.debounceSubject.next(true);
  182. }
  183. // 获取故障现象
  184. incidentCategoryList:any[] = [];
  185. getIncidentCategoryList(){
  186. let { hospital, type } = this.tool.getHospitalOrDuty();
  187. if(type === 'hospital' || type === 'department'){
  188. this.incidentCategoryList = [];
  189. return;
  190. };
  191. let postData = {
  192. hasThird: 'true',//只差有三级的故障现象列表
  193. category: {
  194. dutyIds: type === 'duty' ? hospital.id.toString() : undefined,
  195. },
  196. };
  197. this.mainService.incidentPost("listIncidentCategory", postData).subscribe(res => {
  198. let incidentCategoryList = res.data || [];
  199. incidentCategoryList = incidentCategoryList.map(v => ({...v, parentId: v.parent ? v.parent.id : undefined, title: v.category, key: v.id}));
  200. this.incidentCategoryList = this.tool.tranListToTreeDataLeaf(incidentCategoryList, undefined, "parentId");
  201. console.log(this.incidentCategoryList);
  202. })
  203. }
  204. // 获取处理人
  205. getUsers(e?, type?) {
  206. let that = this;
  207. let postData = {
  208. user: {
  209. name: e || "",
  210. hospital: { id: this.searchDTO.maintainDepartment?this.searchDTO.maintainDepartment:that.tool.getCurrentHospital().id },
  211. engineer: 1,
  212. simpleQuery: true,
  213. },
  214. idx: 0,
  215. sum: 20,
  216. };
  217. that.isLoading = true;
  218. that.mainService
  219. .getFetchDataList("data", "user", postData)
  220. .subscribe((data) => {
  221. that.isLoading = false;
  222. if(type === 'handle'){
  223. that.handleUserList = data.list;
  224. }else if(type === 'acceptUser'){
  225. that.acceptUserList = data.list;
  226. }
  227. });
  228. }
  229. onCalendarChangeDate(dateArr){
  230. console.log(dateArr)
  231. if(dateArr.length == 2){
  232. let dateStart = new Date(dateArr[0]);
  233. let dateEnd = new Date(dateArr[1]);
  234. dateStart.setHours(0,0,0);
  235. dateEnd.setHours(23,59,59);
  236. this.searchDTO.dateRange = [dateStart,dateEnd];
  237. }
  238. }
  239. // 优先级颜色
  240. priorityColor(priorityId) {
  241. // 极低|低
  242. if(priorityId == 1 || priorityId == 2){
  243. return '';
  244. } else if(priorityId == 3){
  245. return 'yellow';
  246. } else if(priorityId == 4 || priorityId == 5){
  247. return 'red';
  248. }
  249. }
  250. // 处理人+协同人
  251. transferSynergetic(incidentData){
  252. let str = incidentData.groupORHandlerUser || "";
  253. if(incidentData.synergetic && incidentData.synergetic.length){
  254. str += ',' + incidentData.synergetic.map(v => v.name).join(',');
  255. }
  256. return str;
  257. }
  258. // 延期记录
  259. transferHandlerLog = function (currentLog) {
  260. if(!currentLog){
  261. return '无';
  262. }
  263. currentLog = cloneDeep(currentLog);
  264. if(currentLog.extra1DTO && currentLog.extra2 && currentLog.startTime){
  265. if(currentLog.extra2==0.5){
  266. currentLog.extra2 = 4;
  267. return currentLog.extra1DTO.name+"<br>"+ format(addHours(currentLog.startTime, +currentLog.extra2), "MM月dd日")+"<br>"+ format(addHours(currentLog.startTime, +currentLog.extra2), "HH时mm分前完成");
  268. }else{
  269. return currentLog.extra1DTO.name+"<br>"+ format(addDays(currentLog.startTime, +currentLog.extra2), "MM月dd日前完成");
  270. }
  271. }else{
  272. return '无';
  273. }
  274. }
  275. // 判断当前人是否在工单组里
  276. isInGroup(data){
  277. return this.tool.getCurrentGroupList().some(v => data.currentLog && v.id == data.currentLog.groupId);
  278. }
  279. // 是否显示接单按钮
  280. computedReceive(data){
  281. let inUser = data.currentLog && data.currentLog.workerId == this.tool.getCurrentUserId();
  282. let inGroup = false;
  283. let groupList = this.tool.getCurrentGroupList();
  284. groupList.forEach(item => {
  285. if(data.currentLog){
  286. if (item.id == data.currentLog.groupId) {
  287. inGroup = true;
  288. }
  289. }
  290. })
  291. return data.state.value === 'pending' && (inUser || inGroup) && this.coopBtns.receive && data.deleteFlag !== 1;
  292. }
  293. // 是否显示处理按钮
  294. computedHandle(data){
  295. return this.coopBtns.handle && data.state.value === 'handler' && data.handlingPersonnelUser && data.handlingPersonnelUser.id == this.tool.getCurrentUserId() && data.deleteFlag !== 1;
  296. }
  297. // 是否显示换人处理按钮
  298. computedSubstitution(data){
  299. return (data.state.value === 'pending' || data.state.value === 'handler' || (data.state.value === 'reassign' && this.coopBtns.assign)) && data.deleteFlag !== 1;
  300. }
  301. // 是否显示延期处理按钮
  302. computedPostpone(data){
  303. return data.state.value == 'handler' && data.handlingPersonnelUser && data.handlingPersonnelUser.id == this.tool.getCurrentUserId() && data.deleteFlag !== 1;
  304. }
  305. // 是否显示设置责任部门按钮
  306. computedSetDuty(data){
  307. return this.coopBtns.settings && (data.state.value == 'resolved' || data.state.value == 'close') && data.deleteFlag !== 1;
  308. }
  309. // 是否显示回访按钮
  310. computedVisit(data){
  311. return this.coopBtns.visit && data.state.value == 'close' && data.deleteFlag !== 1;
  312. }
  313. // 是否显示编辑按钮
  314. computedEdit(data){
  315. return (data.state.value === 'pending' || data.state.value === 'reassign' || data.state.value === 'handler' || data.state.value === 'close') && this.coopBtns.edit && data.deleteFlag !== 1;
  316. }
  317. // 表格数据
  318. loading1 = false;
  319. getList(isInit = false) {
  320. let postData: any = {
  321. idx: isInit ? 0 : (this.pageIndex - 1),
  322. sum: this.pageSize,
  323. incident: {
  324. assignee: this.tool.getCurrentUserId(),
  325. acceptDate: (this.searchDTO.dateRange && this.searchDTO.dateRange[0]) ? format(this.searchDTO.dateRange[0], 'yyyy-MM-dd HH:mm:ss') : undefined,
  326. acceptDateEnd: (this.searchDTO.dateRange && this.searchDTO.dateRange[1]) ? format(this.searchDTO.dateRange[1], 'yyyy-MM-dd HH:mm:ss') : undefined,
  327. incidentsign: this.searchDTO.incidentsign,
  328. department: this.searchDTO.department ? { id: this.searchDTO.department } : undefined,
  329. statusId: this.searchDTO.statusId || undefined,
  330. todoingUser: this.searchDTO.todoingUser ? { id: this.searchDTO.todoingUser } : undefined,
  331. levelCategory: this.validateSearchForm.value.levelCategory ? { id: this.validateSearchForm.value.levelCategory } : undefined,
  332. acceptUser: this.validateSearchForm.value.acceptUser ? { id: this.validateSearchForm.value.acceptUser } : undefined,
  333. selectType: this.validateSearchForm.value.selectType || undefined,
  334. source: this.validateSearchForm.value.sourceValue ? { value: this.validateSearchForm.value.sourceValue } : undefined,
  335. deleteFlag: this.validateSearchForm.value.deleteFlag,
  336. candidateGroupId: null,
  337. },
  338. };
  339. if(this.queryTask === 'all' || this.queryTask === 'callback' || this.queryTask === 'badEvaluate'){
  340. let { hospital, type } = this.tool.getHospitalOrDuty();
  341. if(type === 'duty'){
  342. // 当前的所属责任部门
  343. postData.incident.duty = hospital;
  344. }else{
  345. // 当前的所属院区
  346. postData.incident.hosId = hospital.id;
  347. }
  348. }else{
  349. delete postData.incident.duty;
  350. delete postData.incident.hosId;
  351. }
  352. if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
  353. if(this.searchDTO.maintainDepartment){
  354. let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
  355. postData.incident.duty = itemDept;
  356. delete postData.incident.hosId;
  357. }
  358. }
  359. if(this.queryTask!='todo' && this.queryTask!='owns' && this.queryTask!='storage' && this.queryTask!='doing' && this.queryTask!='reassign'){
  360. postData.incident.candidateGroupId = this.searchDTO.maintainGroup
  361. }else{
  362. delete postData.incident.candidateGroupId;
  363. }
  364. postData.incident.queryTask = this.queryTask;
  365. if(this.queryTask === 'todo' || this.queryTask === 'owns'){
  366. postData.incident.candidateGroups = this.tool.getCurrentGroupList().map(v => v.id).toString();
  367. }else{
  368. delete postData.incident.candidateGroups;
  369. }
  370. this.loading1 = true;
  371. this.mainService
  372. .getFetchDataList("simple/data", "incident", postData)
  373. .subscribe((result) => {
  374. this.loading1 = false;
  375. let list = result.list || [];
  376. list.forEach((item) => {
  377. item.endDeptsName = item.endDepts ? item.endDepts.map(v => v.dept).toString() : '';
  378. item.computedEditFlag = this.computedEdit(item);
  379. item.computedVisitFlag = this.computedVisit(item);
  380. item.computedReceiveFlag = this.computedReceive(item);
  381. item.computedHandleFlag = this.computedHandle(item);
  382. item.computedSubstitutionFlag = this.computedSubstitution(item);
  383. item.computedPostponeFlag = this.computedPostpone(item);
  384. item.computedSetDutyFlag = this.computedSetDuty(item);
  385. });
  386. this.listOfData = list;
  387. this.listLength = result.totalNum;
  388. });
  389. // 获取数量
  390. this.getCount(postData.incident);
  391. }
  392. // 调用接口-查数量
  393. getCount = function (incident = {}){
  394. let postData = {
  395. incidentList: [],
  396. }
  397. this.tabs.forEach(v => {
  398. postData.incidentList.push({...incident, ...{queryTask: v.key}});
  399. })
  400. postData.incidentList.forEach(incident => {
  401. // 请求参数调整
  402. if(!incident){
  403. incident = {};
  404. }
  405. if(incident.queryTask === 'all' || incident.queryTask === 'callback' || incident.queryTask === 'badEvaluate'){
  406. let { hospital, type } = this.tool.getHospitalOrDuty();
  407. if(type === 'duty'){
  408. // 当前的所属责任部门
  409. incident.duty = hospital;
  410. }else{
  411. // 当前的所属院区
  412. incident.hosId = hospital.id;
  413. }
  414. }else{
  415. delete incident.duty;
  416. delete incident.hosId;
  417. }
  418. if(incident.queryTask!='todo' && incident.queryTask!='doing' && incident.queryTask!='storage'){
  419. if(this.searchDTO.maintainDepartment){
  420. let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
  421. incident.duty = itemDept;
  422. delete incident.hosId;
  423. }
  424. }
  425. incident.assignee = this.tool.getCurrentUserId();
  426. if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
  427. incident.candidateGroups = this.tool.getCurrentGroupList().map(v => v.id).toString();
  428. }else{
  429. delete incident.candidateGroups;
  430. }
  431. if(incident.queryTask!='todo' && incident.queryTask!='owns' && incident.queryTask!='storage' && incident.queryTask!='doing' && incident.queryTask!='reassign'){
  432. incident.candidateGroupId = this.searchDTO.maintainGroup
  433. }else{
  434. delete incident.candidateGroupId;
  435. }
  436. })
  437. this.mainService
  438. .getCount(postData)
  439. .subscribe((result) => {
  440. let myData = result.data || {};
  441. this.tabs.forEach(v => {
  442. v.num = myData[v.key];
  443. })
  444. });
  445. }
  446. // 获取所有科室
  447. getDeparts(dept?) {
  448. let data = {
  449. department: {
  450. searchType: 1,// 简单查询
  451. cascadeHosId: this.searchDTO.maintainDepartment?this.searchDTO.maintainDepartment:this.tool.getCurrentHospital().id,
  452. dept: dept,
  453. },
  454. idx: 0,
  455. sum: 20,
  456. };
  457. this.isLoading = true;
  458. this.mainService
  459. .getFetchDataList("data", "department", data)
  460. .subscribe((data) => {
  461. this.alldepart = data.list;
  462. this.isLoading = false;
  463. });
  464. }
  465. // 获取工单状态
  466. getGdStates() {
  467. this.mainService.getDictionary("list", "incident_status").subscribe((data) => {
  468. this.gdStates = data || [];
  469. });
  470. }
  471. // 获取逾期查询
  472. getOverdueStates() {
  473. this.mainService.getDictionary("list", "overdue_state").subscribe((data) => {
  474. this.overdueStates = data || [];
  475. });
  476. }
  477. // 获取报修来源
  478. getSourceList() {
  479. this.mainService.getDictionary("list", "incident_source").subscribe((data) => {
  480. this.sourceList = data || [];
  481. });
  482. }
  483. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  484. showPromptModal(con, success, promptInfo?) {
  485. this.promptModalShow = false;
  486. this.promptContent = con;
  487. this.ifSuccess = success;
  488. this.promptInfo = promptInfo;
  489. setTimeout(() => {
  490. this.promptModalShow = true;
  491. }, 100);
  492. this.loading1 = true;
  493. this.debounceSubject.next(false);
  494. }
  495. // 设置责任部门-弹窗
  496. setdutyModalShow = false; //弹窗开关
  497. setDuty(e, data) {
  498. e.stopPropagation();
  499. this.coopData = data;
  500. this.setdutyModalShow = true;
  501. }
  502. // 关闭弹窗
  503. closeSetdutyModelOrder(e) {
  504. this.setdutyModalShow = JSON.parse(e).show;
  505. }
  506. // 弹窗确定
  507. confirmSetdutyModelOrder(e){
  508. console.log(e);
  509. this.setdutyModalShow = false;
  510. this.getList(true);
  511. }
  512. // 编辑-弹窗
  513. editModalShow = false; //弹窗开关
  514. edit(e, data) {
  515. e.stopPropagation();
  516. this.coopData = data;
  517. this.editModalShow = true;
  518. }
  519. // 关闭弹窗
  520. closeEditModelOrder(e) {
  521. this.editModalShow = JSON.parse(e).show;
  522. }
  523. // 弹窗确定
  524. confirmEditModelOrder(e){
  525. console.log(e);
  526. this.editModalShow = false;
  527. this.getList(true);
  528. }
  529. // 回访-弹窗
  530. visitModalShow = false; //弹窗开关
  531. visit(e, data) {
  532. e.stopPropagation();
  533. this.coopData = data;
  534. this.visitModalShow = true;
  535. }
  536. // 关闭弹窗
  537. closeVisitModelOrder(e) {
  538. this.visitModalShow = JSON.parse(e).show;
  539. }
  540. // 弹窗确定
  541. confirmVisitModelOrder(e){
  542. console.log(e);
  543. this.visitModalShow = false;
  544. this.getList(true);
  545. }
  546. // 详情-弹窗
  547. detailModalShow = false; //弹窗开关
  548. detail(e, data) {
  549. e.stopPropagation();
  550. this.coopData = data;
  551. this.detailModalShow = true;
  552. }
  553. // 关闭弹窗
  554. closeDetailModelOrder(e) {
  555. this.detailModalShow = JSON.parse(e).show;
  556. }
  557. // 弹窗确定
  558. confirmDetailModelOrder(e){
  559. console.log(e);
  560. this.detailModalShow = false;
  561. this.getList(true);
  562. }
  563. // 查看巡检
  564. viewInspectionDetail(e, id) {
  565. e.stopPropagation();
  566. this.router.navigateByUrl("/main/incidentManagement/inspectionExecuteDetail/" + id);
  567. }
  568. // 延期处理-弹窗
  569. postponeModalShow = false; //弹窗开关
  570. postpone(e, data) {
  571. e.stopPropagation();
  572. this.coopData = data;
  573. this.postponeModalShow = true;
  574. }
  575. // 关闭弹窗
  576. closePostponeModelOrder(e) {
  577. this.postponeModalShow = JSON.parse(e).show;
  578. }
  579. // 弹窗确定
  580. confirmPostponeModelOrder(e){
  581. console.log(e);
  582. this.postponeModalShow = false;
  583. this.getList(true);
  584. }
  585. delModal: boolean = false; //删除模态框
  586. tipsMsg1: string; //提示框信息
  587. tipsMsg2: string; //操作后信息
  588. confirmDelType: string; //确认的类型(启用/停用,删除)
  589. showDelModal(
  590. e,
  591. data,
  592. tipsMsg1: string,
  593. tipsMsg2: string,
  594. type: string,
  595. ) {
  596. e.stopPropagation();
  597. this.confirmDelType = type;
  598. this.delModal = true;
  599. this.coopData = data;
  600. this.tipsMsg1 = tipsMsg1;
  601. this.tipsMsg2 = tipsMsg2;
  602. }
  603. // 隐藏删除框
  604. hideDelModal() {
  605. this.delModal = false;
  606. }
  607. // 确认删除
  608. confirmDel() {
  609. this.btnLoading = true;
  610. if (this.confirmDelType === "del") {
  611. //删除
  612. this.mainService
  613. .simplePost("rmvData", "incident", [this.coopData.id])
  614. .subscribe((data) => {
  615. this.btnLoading = false;
  616. this.delModal = false;
  617. if (data.status == 200) {
  618. this.showPromptModal(this.tipsMsg2, true, "");
  619. } else {
  620. this.showPromptModal(this.tipsMsg2, false, data.msg);
  621. }
  622. });
  623. }else if (this.confirmDelType === "receive") {
  624. //接单
  625. this.mainService
  626. .flowPost("incident/task/receive", { incident: this.coopData })
  627. .subscribe((data) => {
  628. this.btnLoading = false;
  629. this.delModal = false;
  630. if (data.state == 200) {
  631. this.showPromptModal(this.tipsMsg2, true, "");
  632. } else {
  633. this.showPromptModal(this.tipsMsg2, false, data.msg);
  634. }
  635. });
  636. }
  637. }
  638. // 导出
  639. loading2 = false;
  640. export() {
  641. let postData: any = {
  642. idx: 0,
  643. sum: 99999,
  644. incident: {
  645. assignee: this.tool.getCurrentUserId(),
  646. acceptDate: (this.searchDTO.dateRange && this.searchDTO.dateRange[0]) ? format(this.searchDTO.dateRange[0], 'yyyy-MM-dd HH:mm:ss') : undefined,
  647. acceptDateEnd: (this.searchDTO.dateRange && this.searchDTO.dateRange[1]) ? format(this.searchDTO.dateRange[1], 'yyyy-MM-dd HH:mm:ss') : undefined,
  648. incidentsign: this.searchDTO.incidentsign,
  649. department: this.searchDTO.department ? { id: this.searchDTO.department } : undefined,
  650. statusId: this.searchDTO.statusId || undefined,
  651. todoingUser: this.searchDTO.todoingUser ? { id: this.searchDTO.todoingUser } : undefined,
  652. levelCategory: this.validateSearchForm.value.levelCategory ? { id: this.validateSearchForm.value.levelCategory } : undefined,
  653. acceptUser: this.validateSearchForm.value.acceptUser ? { id: this.validateSearchForm.value.acceptUser } : undefined,
  654. selectType: this.validateSearchForm.value.selectType || undefined,
  655. source: this.validateSearchForm.value.sourceValue ? { value: this.validateSearchForm.value.sourceValue } : undefined,
  656. deleteFlag: this.validateSearchForm.value.deleteFlag,
  657. candidateGroupId: undefined
  658. },
  659. };
  660. if(this.queryTask === 'all' || this.queryTask === 'callback' || this.queryTask === 'badEvaluate'){
  661. let { hospital, type } = this.tool.getHospitalOrDuty();
  662. if(type === 'duty'){
  663. // 当前的所属责任部门
  664. postData.incident.duty = hospital;
  665. }else{
  666. // 当前的所属院区
  667. postData.incident.hosId = hospital.id;
  668. }
  669. }else{
  670. delete postData.incident.duty;
  671. delete postData.incident.hosId;
  672. }
  673. if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
  674. if(this.searchDTO.maintainDepartment){
  675. let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
  676. postData.incident.duty = itemDept;
  677. delete postData.incident.hosId;
  678. }
  679. }
  680. if(this.queryTask!='todo' && this.queryTask!='owns' && this.queryTask!='storage'){
  681. postData.incident.candidateGroupId = this.searchDTO.maintainGroup
  682. }else{
  683. delete postData.incident.candidateGroupId;
  684. }
  685. postData.incident.queryTask = this.queryTask;
  686. if(this.queryTask === 'todo' || this.queryTask === 'owns'){
  687. postData.incident.candidateGroups = this.tool.getCurrentGroupList().map(v => v.id).toString();
  688. }else{
  689. delete postData.incident.candidateGroups;
  690. }
  691. this.loading2 = true;
  692. this.mainService.downDataModel(postData).subscribe(
  693. (data) => {
  694. this.loading2 = false;
  695. this.showPromptModal("导出", true, "");
  696. var file = new Blob([data], {
  697. type: "application/vnd.ms-excel",
  698. });
  699. //trick to download store a file having its URL
  700. var fileURL = URL.createObjectURL(file);
  701. var a = document.createElement("a");
  702. a.href = fileURL;
  703. a.target = "_blank";
  704. a.download = "故障工单.xls";
  705. document.body.appendChild(a);
  706. a.click();
  707. },
  708. (err) => {
  709. this.loading2 = false;
  710. this.showPromptModal("导出", false, "");
  711. }
  712. );
  713. }
  714. // 科室边输边搜节流阀
  715. isLoading = false;
  716. changeInp(e) {
  717. this.searchTimer(this.getDeparts, e);
  718. }
  719. // 人员边输边搜节流阀
  720. changeUser(e, type) {
  721. this.searchTimer(this.getUsers, e, type);
  722. }
  723. // 边输入边搜索节流阀
  724. searchTimer(fun, e, type?) {
  725. this.isLoading = true;
  726. this.searchTimerSubject.next([fun, e, type]);
  727. }
  728. // 详细搜索
  729. searchModal: boolean = false; //新增/编辑模态框
  730. modelName = ""; //模态框名称
  731. validateSearchForm: FormGroup; //新增/编辑表单
  732. coopData: any = {}; //当前操作列
  733. // 显示弹框
  734. showSearchModal() {
  735. this.modelName = "详细搜索";
  736. this.searchModal = true;
  737. }
  738. //关闭新增/编辑弹框
  739. hideSearchModal() {
  740. this.searchModal = false;
  741. }
  742. // 详细搜索-提交
  743. submitSearchModal(){
  744. this.searchModal = false;
  745. this.getList(true);
  746. }
  747. // 初始化新增form表单
  748. initSearchForm() {
  749. this.validateSearchForm = this.fb.group({
  750. levelCategory: [null],
  751. acceptUser: [null],
  752. selectType: [null],
  753. deleteFlag: [0],
  754. sourceValue: [null],
  755. });
  756. }
  757. // 详细搜索提交
  758. submitForm(): void {
  759. for (const i in this.validateSearchForm.controls) {
  760. this.validateSearchForm.controls[i].markAsDirty();
  761. this.validateSearchForm.controls[i].updateValueAndValidity();
  762. }
  763. if (this.validateSearchForm.invalid) {
  764. return;
  765. }
  766. console.log(this.validateSearchForm.value)
  767. this.loading1 = true;
  768. this.debounceSubject.next(true);
  769. }
  770. // 处理-弹窗
  771. handleModalShow = false; //弹窗开关
  772. handle(e, data) {
  773. e.stopPropagation();
  774. this.coopData = data;
  775. this.handleModalShow = true;
  776. }
  777. // 关闭弹窗
  778. closeHandleModelOrder(e) {
  779. this.handleModalShow = JSON.parse(e).show;
  780. }
  781. // 弹窗确定
  782. confirmHandleModelOrder(e){
  783. console.log(e);
  784. this.handleModalShow = false;
  785. this.getList(true);
  786. }
  787. // 换人处理-弹窗
  788. substitutionModalShow = false; //弹窗开关
  789. substitution(e, data) {
  790. e.stopPropagation();
  791. this.coopData = data;
  792. this.substitutionModalShow = true;
  793. }
  794. // 关闭弹窗
  795. closeSubstitutionModelOrder(e) {
  796. this.substitutionModalShow = JSON.parse(e).show;
  797. }
  798. // 弹窗确定
  799. confirmSubstitutionModelOrder(e){
  800. console.log(e);
  801. this.substitutionModalShow = false;
  802. this.getList(true);
  803. }
  804. }