incident-management.component.ts 22 KB

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