incident-management.component.ts 26 KB

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