dispensing-batch.component.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { ActivatedRoute, Router } from "@angular/router";
  3. import {
  4. FormBuilder,
  5. Validators,
  6. FormGroup,
  7. FormControl,
  8. } from "@angular/forms";
  9. import { MainService } from "../../services/main.service";
  10. import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
  11. import { ToolService } from "../../services/tool.service";
  12. import { format, startOfDay, endOfDay, subDays} from "date-fns";
  13. import { NzMessageService } from "ng-zorro-antd";
  14. import { Subject } from "rxjs";
  15. import { debounceTime, filter } from "rxjs/operators";
  16. import host from "../../../assets/js/http";
  17. import { HttpRequest, HttpResponse, HttpClient } from '@angular/common/http';
  18. @Component({
  19. selector: "app-dispensing-batch",
  20. templateUrl: "./dispensing-batch.component.html",
  21. styleUrls: ["./dispensing-batch.component.less"],
  22. })
  23. export class DispensingBatchComponent implements OnInit {
  24. @ViewChild("osComponentRef1", {
  25. read: OverlayScrollbarsComponent,
  26. static: false,
  27. })
  28. osComponentRef1: OverlayScrollbarsComponent;
  29. constructor(
  30. private message: NzMessageService,
  31. private fb: FormBuilder,
  32. private route: ActivatedRoute,
  33. private router: Router,
  34. private mainService: MainService,
  35. private tool: ToolService,
  36. private http: HttpClient,
  37. ) {}
  38. ngOnInit() {
  39. this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((e) => {
  40. this.isDeptLoading = true;
  41. this.getDeparts(e);
  42. });
  43. this.hosId = this.tool.getCurrentHospital().id;
  44. this.coopBtns = this.tool.initCoopBtns(this.route);
  45. this.initForm();
  46. this.getAllHospital();
  47. this.getType();
  48. this.getDeptHandoverType();
  49. }
  50. listOfData: any[] = []; //表格数据
  51. promptContent: string; //操作提示框提示信息
  52. ifSuccess: boolean; //操作成功/失败
  53. promptInfo: string; //操作结果提示信息
  54. promptModalShow: boolean; //操作提示框是否展示
  55. modal: boolean = false; //新增/编辑模态框
  56. add: boolean; //true:新增;false:编辑
  57. validateForm: FormGroup; //新增/编辑表单
  58. coopId: number; //表格中执行操作的id
  59. department: number; //所属科室
  60. hosId: number;
  61. dateRange;//时间
  62. batchNumber; //批次号
  63. num; //编码
  64. deptalias; //别名
  65. type; //类型
  66. deptHandoverType; //类型
  67. pageIndex: number = 1; //页码
  68. listLength: number = 10; //总条数
  69. pageSize: number = 10; //每页条数
  70. btnLoading: boolean = false; //确认按钮loading状态
  71. printLoading: boolean = false; //批量打印按钮loading状态
  72. deptPhones: any = []; //新添加的科室电话列表
  73. isAddDeptsPhone = true; //添加新的科室电话是否禁用
  74. deptsPhoneId = 1; //科室电话自增id
  75. allParentdepart: any = []; //所有的父级科室列表
  76. hospitals1: any = []; //科室列表(搜索)
  77. rowData: object = {}; //打印选择列表
  78. editModal:boolean = false; //编辑时弹框
  79. searchParentDeptSubject = new Subject();
  80. // 初始化增删改按钮
  81. coopBtns: any = {};
  82. saveLoading:boolean = false;
  83. // 模板导出
  84. excelExport(){
  85. this.maskFlag = this.message.loading("下载模板中..", {
  86. nzDuration: 0,
  87. }).messageId;
  88. this.mainService.exportExcel("department", {}).subscribe(
  89. (data) => {
  90. this.message.remove(this.maskFlag);
  91. this.maskFlag = false;
  92. this.message.success('下载模板成功');
  93. var file = new Blob([data], {
  94. type: "application/vnd.ms-excel",
  95. });
  96. //trick to download store a file having its URL
  97. var fileURL = URL.createObjectURL(file);
  98. var a = document.createElement("a");
  99. a.href = fileURL;
  100. a.target = "_blank";
  101. a.download = "科室导入模板.xls";
  102. document.body.appendChild(a);
  103. a.click();
  104. },
  105. (err) => {
  106. this.message.remove(this.maskFlag);
  107. this.maskFlag = false;
  108. this.message.error('下载模板失败');
  109. }
  110. );
  111. }
  112. // 导入---start
  113. // model-取消
  114. isShow = false;
  115. hideExcelImport() {
  116. this.isShow = false;
  117. }
  118. // 触发
  119. excelImport() {
  120. this.isShow = true;
  121. }
  122. submitExcelImport({fileList}){
  123. this.isShow = false;
  124. const formData = new FormData();
  125. fileList.forEach((file: any) => {
  126. formData.append('file', file);
  127. });
  128. this.maskFlag = this.message.loading("正在导入中..", {
  129. nzDuration: 0,
  130. }).messageId;
  131. const req = new HttpRequest('Post', host.host + '/user/data/importExcel/department', formData, {
  132. reportProgress: true
  133. });
  134. this.http
  135. .request(req)
  136. .pipe(filter(e => e instanceof HttpResponse))
  137. .subscribe(
  138. (res:any) => {
  139. if(res.body.status == 200){
  140. this.message.remove(this.maskFlag);
  141. this.maskFlag = false;
  142. this.message.success('导入成功');
  143. this.getList();
  144. }else{
  145. this.message.remove(this.maskFlag);
  146. this.maskFlag = false;
  147. this.showPromptModal("导入", false, res.body.msg);
  148. }
  149. },
  150. () => {
  151. this.message.remove(this.maskFlag);
  152. this.maskFlag = false;
  153. this.message.error('导入失败');
  154. },
  155. );
  156. }
  157. // 导入---end
  158. //搜索父级科室
  159. isDeptLoading = false;
  160. changeInp(e) {
  161. this.searchParentDeptSubject.next(e);
  162. }
  163. // 打开父级科室下拉框baba
  164. isLoading = false;
  165. openDeptSelect(flag) {
  166. if (flag) {
  167. this.isLoading = true;
  168. this.getAllParentdepart().subscribe((result) => {
  169. this.isLoading = false;
  170. if (result.status == 200) {
  171. this.allParentdepart = result.list;
  172. }
  173. });
  174. }
  175. }
  176. // 配送建单
  177. coopData:any = {};
  178. addDateModal(data) {
  179. this.coopData = data;
  180. this.showDelModal1();
  181. }
  182. showDelModal1() {
  183. this.editModal = true;
  184. }
  185. hideDelModal1() {
  186. this.editModal = false;
  187. }
  188. // 编辑保存
  189. confirmDel1() {
  190. var that = this;
  191. for (const i in that.validateForm.controls) {
  192. that.validateForm.controls[i].markAsDirty();
  193. that.validateForm.controls[i].updateValueAndValidity();
  194. }
  195. if (that.validateForm.invalid) return;
  196. let data: any = {
  197. startTime:this.formStartDate?this.formStartDate:this.loadStartTime,//发起时间开始
  198. endTime:this.formEndDate?this.formEndDate:this.loadEndTime,//发起时间结束
  199. hosId:this.hosId,
  200. pharmacy:this.validateForm.value.department,
  201. id:that.coopId
  202. };
  203. that.saveLoading = true;
  204. that.mainService
  205. .simplePost("addData", "drugsBatch", data)
  206. .subscribe((data) => {
  207. that.saveLoading = false;
  208. that.hideModal();
  209. that.initForm();
  210. if (data.status == 200) {
  211. this.editModal = false;
  212. that.showPromptModal("编辑", true, "");
  213. } else {
  214. that.showPromptModal("编辑", false, data.msg);
  215. }
  216. });
  217. }
  218. //获取所有的父级科室列表
  219. getAllParentdepart(keyWord = "") {
  220. let postData: any = {
  221. idx: 0,
  222. sum: 10,
  223. department: {
  224. // hospital: { id: this.add ? this.tool.getCurrentHospital().id : this.hospital },
  225. keyWord: keyWord,
  226. },
  227. };
  228. if (this.coopItem) {
  229. // 过滤这个科室及其子科室
  230. postData.department.filterByDeptId = this.coopItem.id;
  231. }
  232. return this.mainService.getFetchDataList("data", "department", postData);
  233. }
  234. // 新添加科室号码
  235. addDeptPhone(e: MouseEvent) {
  236. e.preventDefault();
  237. this.deptPhones.push({ id: ++this.deptsPhoneId, phone: "" });
  238. this.deptsPhoneChange();
  239. }
  240. // 删除新添加科室号码
  241. removeDeptPhone(index: number, e: MouseEvent) {
  242. e.preventDefault();
  243. this.deptPhones.splice(index, 1);
  244. this.deptsPhoneChange();
  245. }
  246. //监听科室电话输入事件
  247. deptsPhoneChange(e?, phone?) {
  248. if (e !== undefined && phone !== undefined) {
  249. phone.phone = e;
  250. }
  251. // -------------判断添加按钮是否禁用 start
  252. this.isAddDeptsPhone = !this.validateForm.value.officeNum;
  253. if (!this.isAddDeptsPhone) {
  254. //如果没禁用
  255. this.isAddDeptsPhone = this.deptPhones.some((item) => item.phone === "");
  256. }
  257. // -------------判断添加按钮是否禁用 end
  258. }
  259. // 搜索
  260. search() {
  261. this.pageIndex = 1;
  262. this.getList();
  263. }
  264. // 重置
  265. reset() {
  266. this.pageIndex = 1;
  267. this.batchNumber = null;
  268. this.startDate = null;
  269. this.endDate = null;
  270. this.dateRange = [];
  271. this.getList();
  272. }
  273. // 表格数据
  274. loading1 = false;
  275. getList() {
  276. var that = this;
  277. let data = {
  278. idx: that.pageIndex - 1,
  279. sum: that.pageSize,
  280. drugsBatch: {
  281. batchNo:that.batchNumber,
  282. startTime: this.startDate,
  283. endTime: this.endDate,
  284. hosId: this.hosId
  285. },
  286. };
  287. if(that.batchNumber){
  288. data.drugsBatch.batchNo = that.batchNumber
  289. }else{
  290. delete data.drugsBatch.batchNo
  291. }
  292. this.loading1 = true;
  293. that.mainService
  294. .getFetchDataList("data", "drugsBatch", data)
  295. .subscribe((data) => {
  296. this.loading1 = false;
  297. that.listOfData = data.list;
  298. that.listLength = data.totalNum;
  299. });
  300. }
  301. // 日期选择
  302. startDate: string; //发起时间开始
  303. endDate: string; //发起时间结束
  304. changeDate(result?): void {
  305. if (!result) {
  306. this.startDate = this.endDate = "";
  307. return;
  308. }
  309. this.startDate = format(startOfDay(result[0]), 'yyyy-MM-dd HH:mm:ss');
  310. this.endDate = format(endOfDay(result[1]), 'yyyy-MM-dd HH:mm:ss');
  311. }
  312. // 新增、编辑日期选择
  313. formStartDate: string; //发起时间开始
  314. formEndDate: string; //发起时间结束
  315. formChangeDate(result?): void {
  316. if (!result) {
  317. this.formStartDate = this.formEndDate = "";
  318. return;
  319. }
  320. this.formStartDate = format(result[0], 'yyyy-MM-dd HH:mm:ss');
  321. this.formEndDate = format(result[1], 'yyyy-MM-dd HH:mm:ss');
  322. }
  323. // 获取所有科室
  324. getDeparts(dept) {
  325. var that = this;
  326. let data = {
  327. department: {
  328. dept,
  329. hospital: {
  330. id: this.hosId
  331. },
  332. type:{
  333. id:''
  334. }
  335. },
  336. idx: 0,
  337. sum: 20,
  338. };
  339. that.mainService.getDictionary("list", "dept_type").subscribe((res) => {
  340. let typeData = res.find(i=>i.value=='pharmacyRoom');
  341. if(typeData){
  342. data.department.type.id = typeData.id
  343. }
  344. that.mainService
  345. .getFetchDataList("data", "department", data)
  346. .subscribe((data) => {
  347. setTimeout(_=>{
  348. this.hospitals1 = data.list
  349. that.isDeptLoading = false;
  350. },500)
  351. });
  352. });
  353. }
  354. // 获取所有院区
  355. getAllHospital() {
  356. this.getDeparts('')
  357. this.getList();
  358. }
  359. // 切换院区选项
  360. buildings: any = []; //楼栋
  361. maskFlag: any = false;
  362. changeHosp(obj?) {
  363. let hospitalId;
  364. if (obj) {
  365. hospitalId = obj.hospital.id;
  366. }
  367. let hid;
  368. if (hospitalId || hospitalId == 0) {
  369. hid = hospitalId - 0;
  370. }
  371. // else {
  372. // hid = this.hospital - 0;
  373. // }
  374. let data = {
  375. hosId: this.add ? this.tool.getCurrentHospital().id : hid,
  376. };
  377. this.maskFlag = this.message.loading("正在加载中..", {
  378. nzDuration: 0,
  379. }).messageId;
  380. this.mainService
  381. .coopData("getBuildingOrFloor", "building", data)
  382. .subscribe((data) => {
  383. this.buildings = data.data;
  384. this.floors = [];
  385. // ---------
  386. if (obj) {
  387. //编辑
  388. let arr = this.buildings.map((item) => item.id);
  389. if (obj.building.id && arr.includes(obj.building.id)) {
  390. //有楼栋
  391. this.changeBuilding(obj.building.id, obj);
  392. this.validateForm.controls.building.setValue(obj.building.id + "");
  393. } else {
  394. //无楼栋
  395. this.floors = [];
  396. this.message.remove(this.maskFlag);
  397. this.maskFlag = false;
  398. this.modal = true;
  399. this.validateForm.controls.building.setValue(null);
  400. this.validateForm.controls.officeAddress.setValue(null);
  401. }
  402. } else {
  403. //新增
  404. this.message.remove(this.maskFlag);
  405. this.maskFlag = false;
  406. this.modal = true;
  407. }
  408. // ---------
  409. });
  410. }
  411. // 切换楼栋信息
  412. floors: Array<any> = []; //楼层
  413. floorLoading: boolean = false;
  414. changeBuilding(buildingId?, obj?) {
  415. var that = this;
  416. that.floors = [];
  417. var bid;
  418. if (buildingId || buildingId == 0) {
  419. bid = buildingId - 0;
  420. } else if (!that.add && that.validateForm.value.building) {
  421. bid = that.validateForm.value.building - 0;
  422. } else {
  423. return;
  424. }
  425. let data = {
  426. buildingId: bid,
  427. };
  428. this.floorLoading = true;
  429. that.mainService
  430. .coopData("getBuildingOrFloor", "floor", data)
  431. .subscribe((data) => {
  432. this.floorLoading = false;
  433. this.message.remove(this.maskFlag);
  434. this.maskFlag = false;
  435. this.modal = true;
  436. that.floors = data.data;
  437. if (obj) {
  438. let floorId = obj.floor.id;
  439. let arr = that.floors.map((item) => item["id"]);
  440. if (floorId && arr.includes(floorId)) {
  441. this.validateForm.controls.floor.setValue(floorId + "");
  442. } else {
  443. this.validateForm.controls.floor.setValue(null);
  444. this.validateForm.controls.officeAddress.setValue(null);
  445. }
  446. }
  447. });
  448. }
  449. // 获取科室类型
  450. types: Array<any> = [];
  451. getType() {
  452. var that = this;
  453. that.mainService.getDictionary("list", "dept_type").subscribe((data) => {
  454. console.log(data);
  455. that.types = data;
  456. });
  457. }
  458. // 获取科室汇总交接类型
  459. deptHandoverTypes: Array<any> = [];
  460. getDeptHandoverType() {
  461. var that = this;
  462. that.mainService.getDictionary("list", "dept_handover_type").subscribe((data) => {
  463. console.log(data);
  464. that.deptHandoverTypes = data;
  465. });
  466. }
  467. // 新增弹框
  468. showModal() {
  469. this.initForm();
  470. this.add = true;
  471. this.modal = true;
  472. this.isAddDeptsPhone = true;
  473. }
  474. hideModal() {
  475. this.coopItem = null;
  476. this.modal = false;
  477. this.initForm();
  478. }
  479. // 初始化新增form表单
  480. loadStartTime = '';
  481. loadEndTime = '';
  482. initForm() {
  483. this.validateForm = this.fb.group({
  484. dispensingTime: [null, [Validators.required]],
  485. department: [null, [Validators.required]]
  486. });
  487. let date = new Date();
  488. this.loadStartTime = format(subDays(date, 1), "yyyy-MM-dd") +' '+'08:00:00'
  489. this.loadEndTime = format(date, "yyyy-MM-dd") +' '+'08:00:00'
  490. this.validateForm.controls.dispensingTime.setValue([this.loadStartTime, this.loadEndTime]);
  491. }
  492. // 科室位置必填
  493. buildValidator = (control: FormControl): { [s: string]: boolean } => {
  494. if (
  495. this.validateForm &&
  496. this.validateForm.value &&
  497. (!this.validateForm.value.building ||
  498. !this.validateForm.value.floor ||
  499. !this.validateForm.value.officeAddress)
  500. ) {
  501. return { required: true };
  502. }
  503. };
  504. /**
  505. * 生成一个从 start 到 end 的连续数组
  506. * @param start
  507. * @param end
  508. */
  509. generateArray(start, end) {
  510. return Array.from(new Array(end).keys()).slice(start);
  511. }
  512. //服务时间选择
  513. // 禁用的小时
  514. startTime1Hourdis() {
  515. return [];
  516. }
  517. endTime1Hourdis() {
  518. return [];
  519. }
  520. startTime2Hourdis() {
  521. return [];
  522. }
  523. endTime2Hourdis() {
  524. return [];
  525. }
  526. // 禁用的分钟
  527. startTime1Mindis() {
  528. return [];
  529. }
  530. endTime1Mindis() {
  531. return [];
  532. }
  533. startTime2Mindis() {
  534. return [];
  535. }
  536. endTime2Mindis() {
  537. return [];
  538. }
  539. timeChange(e: boolean, type: string, num: number) {
  540. if (!e && this.validateForm.value[type + num]) {
  541. let hour = new Date(this.validateForm.value[type + num]).getHours();
  542. let minute = new Date(this.validateForm.value[type + num]).getMinutes();
  543. if (type == "startTime" && num === 1) {
  544. this.endTime1Hourdis = () => this.generateArray(0, hour);
  545. this.endTime1Mindis = () => this.generateArray(0, minute + 1);
  546. } else if (type == "startTime" && num === 2) {
  547. this.endTime2Hourdis = () => this.generateArray(0, hour);
  548. this.endTime2Mindis = () => this.generateArray(0, minute + 1);
  549. } else if (type == "endTime" && num === 1) {
  550. this.startTime1Hourdis = () => this.generateArray(hour + 1, 24);
  551. this.startTime1Mindis = () => this.generateArray(minute, 60);
  552. } else if (type == "endTime" && num === 2) {
  553. this.startTime2Hourdis = () => this.generateArray(hour + 1, 24);
  554. this.startTime2Mindis = () => this.generateArray(minute, 60);
  555. }
  556. }
  557. }
  558. // 表单提交
  559. submitForm(): void {
  560. var that = this;
  561. for (const i in that.validateForm.controls) {
  562. that.validateForm.controls[i].markAsDirty();
  563. that.validateForm.controls[i].updateValueAndValidity();
  564. }
  565. if (that.validateForm.invalid) return;
  566. let data: any = {
  567. startTime:this.formStartDate?this.formStartDate:this.loadStartTime,//发起时间开始
  568. endTime:this.formEndDate?this.formEndDate:this.loadEndTime,//发起时间结束
  569. hosId:this.hosId,
  570. pharmacy:this.validateForm.value.department
  571. };
  572. if (!that.add) {
  573. this.editModal = true
  574. }else{
  575. that.btnLoading = true;
  576. that.mainService
  577. .simplePost("addData", "drugsBatch", data)
  578. .subscribe((data) => {
  579. that.btnLoading = false;
  580. that.hideModal();
  581. that.initForm();
  582. if (data.status == 200) {
  583. that.showPromptModal(that.add ? "新增" : "编辑", true, "");
  584. } else {
  585. that.showPromptModal(that.add ? "新增" : "编辑", false, data.msg);
  586. }
  587. });
  588. }
  589. }
  590. // 编辑
  591. coopItem: any = null;
  592. edit(e, data) {
  593. e.stopPropagation();
  594. this.add = false;
  595. this.coopId = data.id;
  596. this.coopItem = data;
  597. this.validateForm.controls.department.setValue(data.pharmacy);
  598. this.validateForm.controls.dispensingTime.setValue([data.startTime,data.endTime]);
  599. this.loadStartTime = data.startTime
  600. this.loadEndTime = data.endTime
  601. this.modal = true
  602. }
  603. // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
  604. showPromptModal(con, success, promptInfo?) {
  605. this.promptModalShow = false;
  606. this.promptContent = con;
  607. this.ifSuccess = success;
  608. this.promptInfo = promptInfo;
  609. setTimeout(() => {
  610. this.promptModalShow = true;
  611. }, 100);
  612. this.getList();
  613. }
  614. delModal: boolean = false; //删除模态框
  615. coopIds: any;
  616. coopFlag: any = false;
  617. /**
  618. *
  619. * @param e 事件对象
  620. * @param id
  621. */
  622. showDelModal(e, id) {
  623. e.stopPropagation();
  624. this.delModal = true;
  625. this.coopId = id;
  626. }
  627. hideDelModal() {
  628. this.delModal = false;
  629. }
  630. // 确认删除
  631. confirmDel() {
  632. var that = this;
  633. that.btnLoading = true;
  634. that.mainService
  635. .coopTypeConfig(
  636. "rmvData",
  637. "drugsBatch",
  638. [that.coopId]
  639. )
  640. .subscribe((data) => {
  641. that.btnLoading = false;
  642. that.delModal = false;
  643. if (data.status==200) {
  644. that.showPromptModal("删除", true, "");
  645. } else {
  646. that.showPromptModal("删除", false, data.data[0].msg);
  647. }
  648. });
  649. }
  650. // 查看
  651. detail(e, data) {
  652. e.stopPropagation();
  653. this.router.navigateByUrl(`/dispensingDetail/${data.id}`);
  654. }
  655. // 选中表格中科室
  656. mapOfCheckedId: { [key: string]: boolean } = {};
  657. checkedDepIds = []; //已选中科室id
  658. refreshStatus(): void {
  659. this.isAllDisplayDataChecked = this.listOfData.every(
  660. (item) => this.mapOfCheckedId[item.id]
  661. );
  662. let arr = [];
  663. for (var k in this.mapOfCheckedId) {
  664. if (this.mapOfCheckedId[k]) {
  665. arr.push(Number(k));
  666. }
  667. }
  668. this.checkedDepIds = arr;
  669. console.log(this.checkedDepIds);
  670. }
  671. //表格整行选中
  672. selectedListData(id) {
  673. this.mapOfCheckedId[id] = !this.mapOfCheckedId[id];
  674. this.refreshStatus();
  675. }
  676. // 全选
  677. isAllDisplayDataChecked = false; //当前页是否全选
  678. checkAll(value: boolean): void {
  679. this.listOfData.forEach((item) => (this.mapOfCheckedId[item.id] = value));
  680. this.refreshStatus();
  681. }
  682. // 发药并打印
  683. printData = [];
  684. print(e, data, id){
  685. this.rowData = data
  686. e.stopPropagation();
  687. let that = this;
  688. that.printLoading = true;
  689. that.mainService
  690. .transfusionPrint("drugsBatch", id)
  691. .subscribe((res) => {
  692. let arr = res.data.drugsListDTOS;
  693. for(let i of arr){
  694. for(let t of i.drugsConfigureDTOS){
  695. t.deptName = i.pharmacyDTO?i.pharmacyDTO.dept:'-'
  696. }
  697. i.drugsConfigureDTOS.push({
  698. drugsInfoDTO:{
  699. drugName:'合计',
  700. specs:'',
  701. },
  702. actualCount:i.totalActual,
  703. cartonNum:i.totalCarton,
  704. deptName:''
  705. })
  706. }
  707. that.printData = arr;
  708. that.printLoading = false;
  709. that.btnLoading = false;
  710. that.printModal = false;
  711. setTimeout(() => {
  712. const printContent = document.getElementById("report");
  713. const WindowPrt = window.open("", "", "width=1000,height=900");
  714. WindowPrt.document.write(printContent.innerHTML);
  715. WindowPrt.document.close();
  716. WindowPrt.focus();
  717. WindowPrt.print();
  718. WindowPrt.close();
  719. setTimeout(()=>{
  720. this.getList();
  721. },200)
  722. }, 500);
  723. });
  724. }
  725. printModal = false;
  726. printE = '';
  727. printItemData = '';
  728. printItemId = '';
  729. dispensingPrint(e, data, id){
  730. this.printModal = true
  731. this.printE = e
  732. this.printItemData = data
  733. this.printItemId = id
  734. }
  735. confirmPrintDel(){
  736. this.btnLoading = true;
  737. this.print(this.printE, this.printItemData, this.printItemId)
  738. }
  739. hidePrintModal(){
  740. this.printModal = false
  741. }
  742. }