repository-manage.component.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import { DomSanitizer } from '@angular/platform-browser';
  4. import {
  5. FormBuilder,
  6. Validators,
  7. FormGroup,
  8. FormControl,
  9. } from "@angular/forms";
  10. import { MainService } from "../../services/main.service";
  11. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  12. import { ToolService } from "../../services/tool.service";
  13. import { format, startOfDay, endOfDay, subDays} from "date-fns";
  14. import { NzMessageService } from "ng-zorro-antd";
  15. import { Subject } from "rxjs";
  16. import { debounceTime, filter } from "rxjs/operators";
  17. import host from "../../../assets/js/http";
  18. import { HttpRequest, HttpResponse, HttpClient } from '@angular/common/http';
  19. @Component({
  20. selector: "app-repository-manage",
  21. templateUrl: "./repository-manage.component.html",
  22. styleUrls: ["./repository-manage.component.less"],
  23. })
  24. export class RepositoryManageComponent implements OnInit {
  25. @ViewChild("osComponentRef1", {
  26. read: OverlayScrollbarsComponent,
  27. static: false,
  28. })
  29. osComponentRef1: OverlayScrollbarsComponent;
  30. constructor(
  31. private message: NzMessageService,
  32. private fb: FormBuilder,
  33. private route: ActivatedRoute,
  34. private router: Router,
  35. private mainService: MainService,
  36. private tool: ToolService,
  37. private http: HttpClient,
  38. private sanitizer: DomSanitizer
  39. ) {}
  40. ngOnInit() {
  41. this.maintainDept = this.tool.getUserInfoPermission().dutyList
  42. let itemDept = this.maintainDept.find(i=>i.id == this.hosId)
  43. if(itemDept){
  44. this.maintainDepartment = itemDept.id
  45. }
  46. this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((e) => {
  47. });
  48. this.hosId = this.tool.getCurrentHospital().id;
  49. this.coopBtns = this.tool.initCoopBtns(this.route);
  50. this.getList();
  51. }
  52. maintainDept:any = []; //维修科室
  53. maintainDepartment:any;
  54. hosIds:any; //当前院区
  55. richText:any;
  56. listOfData: any[] = []; //表格数据
  57. promptContent: string; //操作提示框提示信息
  58. ifSuccess: boolean; //操作成功/失败
  59. promptInfo: string; //操作结果提示信息
  60. promptModalShow: boolean; //操作提示框是否展示
  61. modal: boolean = false; //新增/编辑模态框
  62. add: boolean; //true:新增;false:编辑
  63. validateForm: FormGroup; //新增/编辑表单
  64. coopId: number; //表格中执行操作的id
  65. department: number; //所属科室
  66. hosId: number;
  67. loadAllConsumeDept: boolean = true;//是否加载所有消耗科室
  68. solutionNumber; //编号
  69. title; //标题
  70. num; //编码
  71. deptalias; //别名
  72. type; //类型
  73. deptHandoverType; //类型
  74. vIndex:number = 0;//版本号下标
  75. stepLength: number = 0; //步骤条
  76. pageIndex: number = 1; //页码
  77. listLength: number = 10; //总条数
  78. pageSize: number = 10; //每页条数
  79. btnLoading: boolean = false; //确认按钮loading状态
  80. btnLoading1: boolean = false; //审核通过按钮loading状态
  81. btnLoading2: boolean = false; //审核驳回按钮loading状态
  82. printLoading: boolean = false; //批量打印按钮loading状态
  83. deptPhones: any = []; //新添加的科室电话列表
  84. isAddDeptsPhone = true; //添加新的科室电话是否禁用
  85. deptsPhoneId = 1; //科室电话自增id
  86. allParentdepart: any = []; //所有的父级科室列表
  87. hospitals1: any = []; //科室列表(搜索)
  88. rowData: object = {}; //打印选择列表
  89. editModal:boolean = false; //编辑时弹框
  90. isSpinning: boolean = false; //页面loading状态
  91. detailData:any;
  92. solutionLogs:any;
  93. lookData:any;
  94. versionsData: any = []; //审核版本数据
  95. fileData: any = []; //上传的附件数据
  96. searchParentDeptSubject = new Subject();
  97. // 初始化增删改按钮
  98. coopBtns: any = {};
  99. saveLoading:boolean = false;
  100. taskTypeData:{id:''};
  101. rejectModal:boolean = false;
  102. rejectData:null;
  103. optType:string = '';
  104. // 导入---end
  105. //搜索父级科室
  106. isDeptLoading = false;
  107. changeInp(e) {
  108. this.searchParentDeptSubject.next(e);
  109. }
  110. // 配送建单
  111. coopData:any = {};
  112. addDateModal(data) {
  113. this.coopData = data;
  114. this.showDelModal1();
  115. }
  116. showDelModal1() {
  117. this.editModal = true;
  118. }
  119. hideDelModal1() {
  120. this.editModal = false;
  121. }
  122. // 编辑保存
  123. confirmDel1() {
  124. var that = this;
  125. for (const i in that.validateForm.controls) {
  126. that.validateForm.controls[i].markAsDirty();
  127. that.validateForm.controls[i].updateValueAndValidity();
  128. }
  129. if (that.validateForm.invalid) return;
  130. let data: any = {
  131. hosId:this.hosId,
  132. pharmacy:this.validateForm.value.department,
  133. id:that.coopId,
  134. loadAllConsumeDept:this.validateForm.value.loadAllConsumeDept?1:0
  135. };
  136. that.saveLoading = true;
  137. that.mainService
  138. .simplePost("addData", "drugsBatch", data)
  139. .subscribe((data) => {
  140. that.saveLoading = false;
  141. that.hideModal();
  142. if (data.status == 200) {
  143. this.editModal = false;
  144. that.showPromptModal("编辑", true, "");
  145. } else {
  146. that.showPromptModal("编辑", false, data.msg);
  147. }
  148. });
  149. }
  150. // 搜索
  151. search() {
  152. this.pageIndex = 1;
  153. this.getList();
  154. }
  155. // 重置
  156. reset() {
  157. this.pageIndex = 1;
  158. this.solutionNumber = null;
  159. this.title = null;
  160. this.getList();
  161. }
  162. // 表格数据
  163. loading1 = false;
  164. getList() {
  165. var that = this;
  166. let data = {
  167. idx: that.pageIndex - 1,
  168. sum: that.pageSize,
  169. solution: {
  170. title:this.title,
  171. solutionNumber:this.solutionNumber,
  172. hosId: this.hosId,
  173. },
  174. };
  175. if(this.maintainDepartment){
  176. data.solution.hosId = this.maintainDepartment;
  177. }
  178. this.loading1 = true;
  179. that.mainService
  180. .getFetchDataList("data", "solution", data)
  181. .subscribe((data) => {
  182. this.loading1 = false;
  183. that.listOfData = data.list;
  184. that.listLength = data.totalNum;
  185. });
  186. }
  187. // 版本号点击
  188. versionsClick(data, index){
  189. this.vIndex = index
  190. this.lookData = data
  191. let content = data.content
  192. if(content){
  193. this.richText = this.sanitizer.bypassSecurityTrustHtml(content);
  194. }else{
  195. this.richText = ''
  196. }
  197. }
  198. // 点击附件
  199. fileClick(data){
  200. console.log(222,data)
  201. let a: any = document.createElement('a') // 创建一个元素
  202. a.style = 'display: none' // 不能在页面中被看到,把他隐藏起来
  203. a.style.height = '0px' // 给个0高度,避免影响页面布局
  204. a.download = data.name;
  205. a.href = data.url // 文件url地址
  206. document.body.appendChild(a) // 将其绑定在body上才能发挥作用
  207. a.click() // 触发a标签的click事件
  208. document.body.removeChild(a) // 删除该元素
  209. }
  210. hideModal() {
  211. this.modal = false;
  212. }
  213. // 审核通过
  214. confirmDel4() {
  215. let data: any = {
  216. id:this.rowId,
  217. operationType: 'approve'
  218. };
  219. this.btnLoading1 = true;
  220. this.mainService
  221. .simplePost("updData", "solution", data)
  222. .subscribe((data) => {
  223. this.btnLoading1 = false;
  224. this.hideDelModal4()
  225. if (data.status == 200) {
  226. this.showPromptModal("审核", true, "");
  227. } else {
  228. this.showPromptModal("审核", false, data.msg);
  229. }
  230. });
  231. }
  232. hideDelModal4() {
  233. this.auditModal = false;
  234. }
  235. // 审核驳回
  236. rejectCancel(){
  237. this.rejectModal = false
  238. }
  239. // 审核驳回
  240. rejectOk(){
  241. if(this.rejectData==null){
  242. this.message.error('请输入整改意见')
  243. return
  244. }
  245. let data: any = {
  246. id:this.rowId,
  247. operationType: 'approve',
  248. rejectReason:this.rejectData
  249. };
  250. this.btnLoading2 = true;
  251. this.mainService
  252. .simplePost("updData", "solution", data)
  253. .subscribe((data) => {
  254. this.btnLoading2 = false;
  255. this.rejectCancel()
  256. if (data.status == 200) {
  257. this.showPromptModal("驳回", true, "");
  258. } else {
  259. this.showPromptModal("驳回", false, data.msg);
  260. }
  261. });
  262. }
  263. closeModel(){
  264. this.hideModal()
  265. }
  266. // 表单提交
  267. auditModal = false;
  268. submitForm(type): void {
  269. var that = this;
  270. if(type==1){
  271. this.auditModal = true
  272. }else{
  273. this.rejectData = null
  274. this.rejectModal = true
  275. }
  276. }
  277. // 升级
  278. upgrade(e, data){
  279. e.stopPropagation();
  280. this.router.navigateByUrl(`/repositoryManageAdd/${data.id}?type=upgrade`);
  281. }
  282. // 新增
  283. addForm(){
  284. this.router.navigateByUrl(`/repositoryManageAdd/0`);
  285. }
  286. // 查看
  287. look(e, data){
  288. e.stopPropagation();
  289. this.optType = 'look'
  290. this.rowId = data.id
  291. this.vIndex = 0
  292. this.modal = true
  293. var that = this;
  294. let query = {
  295. idx: 0,
  296. sum: 9999,
  297. solution: {
  298. hosId: this.hosId,
  299. operationType:'lookOver',
  300. solutionNumber:data.solutionNumber
  301. }
  302. };
  303. this.isSpinning = true
  304. that.mainService
  305. .getFetchDataList("data", "solution", query)
  306. .subscribe((res) => {
  307. this.getFile()
  308. let data = res.list
  309. this.detailData = data
  310. let content = data[0].content
  311. if(content){
  312. this.richText = this.sanitizer.bypassSecurityTrustHtml(content);
  313. }else{
  314. this.richText = ''
  315. }
  316. for(let i of data){
  317. if(i.solutionLogs.length>0){
  318. for(let t of i.solutionLogs){
  319. t.time = format(t.operationTime, 'yyyy-MM-dd HH:mm')
  320. }
  321. }
  322. }
  323. this.lookData = data[0]
  324. this.solutionLogs = data[0].solutionLogs
  325. this.stepLength = this.solutionLogs.length
  326. this.isSpinning = false
  327. });
  328. }
  329. getFile(){
  330. this.mainService
  331. .getPreviewImage('solution', this.rowId)
  332. .subscribe((res:any)=> {
  333. this.fileData = res.data.map((v) =>{
  334. return{
  335. name: v.name,
  336. url: location.origin + '/file' + v.relativeFilePath
  337. }
  338. });
  339. });
  340. }
  341. // 审核
  342. rowId=null;
  343. audit(e, data){
  344. e.stopPropagation();
  345. this.rowId = data.id
  346. this.vIndex = 0
  347. this.optType = 'audit'
  348. this.modal = true
  349. var that = this;
  350. let query = {
  351. idx: 0,
  352. sum: 9999,
  353. solution: {
  354. hosId: this.hosId,
  355. operationType:'lookOver',
  356. solutionNumber:data.solutionNumber
  357. }
  358. };
  359. this.isSpinning = true
  360. that.mainService
  361. .getFetchDataList("data", "solution", query)
  362. .subscribe((res) => {
  363. this.getFile()
  364. let data = res.list
  365. this.detailData = data
  366. this.richText = this.sanitizer.bypassSecurityTrustHtml(data[0].content);
  367. for(let i of data[0].solutionLogs){
  368. i.time = format(i.operationTime, 'yyyy-MM-dd HH:mm')
  369. }
  370. this.lookData = data[0]
  371. this.solutionLogs = data[0].solutionLogs
  372. this.stepLength = this.solutionLogs.length
  373. this.isSpinning = false
  374. });
  375. }
  376. // 编辑
  377. edit(e, data) {
  378. e.stopPropagation();
  379. this.router.navigateByUrl(`/repositoryManageAdd/${data.id}?type=edit`);
  380. }
  381. // 停用
  382. pauseModal = false;
  383. pause(e, data){
  384. e.stopPropagation();
  385. this.pauseModal = true;
  386. this.coopId = data.id;
  387. }
  388. // 确认停用
  389. confirmDel2() {
  390. var that = this;
  391. that.btnLoading = true;
  392. let data: any = {
  393. id:this.coopId,
  394. operationType: 'deactivate'
  395. };
  396. this.mainService
  397. .simplePost("updData", "solution", data)
  398. .subscribe((data) => {
  399. that.btnLoading = false;
  400. that.pauseModal = false;
  401. if (data.status == 200) {
  402. this.showPromptModal("停用", true, "");
  403. } else {
  404. this.showPromptModal("停用", false, data.msg);
  405. }
  406. });
  407. }
  408. hideDelModal2() {
  409. this.pauseModal = false;
  410. }
  411. // 恢复
  412. renewModal = false;
  413. renew(e, data){
  414. e.stopPropagation();
  415. this.renewModal = true;
  416. this.coopId = data.id;
  417. }
  418. // 确认恢复
  419. confirmDel3() {
  420. var that = this;
  421. that.btnLoading = true;
  422. let data: any = {
  423. id:this.coopId,
  424. operationType: 'recover'
  425. };
  426. this.mainService
  427. .simplePost("updData", "solution", data)
  428. .subscribe((data) => {
  429. that.btnLoading = false;
  430. that.renewModal = false;
  431. if (data.status == 200) {
  432. this.showPromptModal("恢复", true, "");
  433. } else {
  434. this.showPromptModal("恢复", false, data.msg);
  435. }
  436. });
  437. }
  438. hideDelModal3() {
  439. this.renewModal = false;
  440. }
  441. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  442. showPromptModal(con, success, promptInfo?) {
  443. this.promptModalShow = false;
  444. this.promptContent = con;
  445. this.ifSuccess = success;
  446. this.promptInfo = promptInfo;
  447. setTimeout(() => {
  448. this.promptModalShow = true;
  449. }, 100);
  450. this.getList();
  451. }
  452. delModal: boolean = false; //删除模态框
  453. coopIds: any;
  454. coopFlag: any = false;
  455. /**
  456. *
  457. * @param e 事件对象
  458. * @param id
  459. */
  460. showDelModal(e, id) {
  461. e.stopPropagation();
  462. this.delModal = true;
  463. this.coopId = id;
  464. }
  465. hideDelModal() {
  466. this.delModal = false;
  467. }
  468. // 确认删除
  469. confirmDel() {
  470. var that = this;
  471. that.btnLoading = true;
  472. that.mainService
  473. .coopTypeConfig(
  474. "rmvData",
  475. "solution",
  476. [that.coopId]
  477. )
  478. .subscribe((data) => {
  479. that.btnLoading = false;
  480. that.delModal = false;
  481. if (data.status==200) {
  482. that.showPromptModal("删除", true, "");
  483. } else {
  484. that.showPromptModal("删除", false, data.data[0].msg);
  485. }
  486. });
  487. }
  488. detail(e, data) {
  489. e.stopPropagation();
  490. this.router.navigateByUrl(`/dispensingDetail/${data.id}`);
  491. }
  492. }