123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- import { Component, OnInit, ViewChild } from "@angular/core";
- import { ActivatedRoute, Router } from "@angular/router";
- import { DomSanitizer } from '@angular/platform-browser';
- import {
- FormBuilder,
- Validators,
- FormGroup,
- FormControl,
- } from "@angular/forms";
- import { MainService } from "../../services/main.service";
- import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
- import { ToolService } from "../../services/tool.service";
- import { format, startOfDay, endOfDay, subDays} from "date-fns";
- import { NzMessageService } from "ng-zorro-antd";
- import { Subject } from "rxjs";
- import { debounceTime, filter } from "rxjs/operators";
- import host from "../../../assets/js/http";
- import { HttpRequest, HttpResponse, HttpClient } from '@angular/common/http';
- @Component({
- selector: "app-repository-manage",
- templateUrl: "./repository-manage.component.html",
- styleUrls: ["./repository-manage.component.less"],
- })
- export class RepositoryManageComponent implements OnInit {
- @ViewChild("osComponentRef1", {
- read: OverlayScrollbarsComponent,
- static: false,
- })
- osComponentRef1: OverlayScrollbarsComponent;
- constructor(
- private message: NzMessageService,
- private fb: FormBuilder,
- private route: ActivatedRoute,
- private router: Router,
- private mainService: MainService,
- private tool: ToolService,
- private http: HttpClient,
- private sanitizer: DomSanitizer
- ) {}
- ngOnInit() {
- this.maintainDept = this.tool.getUserInfoPermission().dutyList
- let itemDept = this.maintainDept.find(i=>i.id == this.hosId)
- if(itemDept){
- this.maintainDepartment = itemDept.id
- }
- this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((e) => {
- });
- this.hosId = this.tool.getCurrentHospital().id;
- this.coopBtns = this.tool.initCoopBtns(this.route);
- this.getList();
- }
- maintainDept:any = []; //维修科室
- maintainDepartment:any;
- hosIds:any; //当前院区
- richText:any;
- listOfData: any[] = []; //表格数据
- promptContent: string; //操作提示框提示信息
- ifSuccess: boolean; //操作成功/失败
- promptInfo: string; //操作结果提示信息
- promptModalShow: boolean; //操作提示框是否展示
- modal: boolean = false; //新增/编辑模态框
- add: boolean; //true:新增;false:编辑
- validateForm: FormGroup; //新增/编辑表单
- coopId: number; //表格中执行操作的id
- department: number; //所属科室
- hosId: number;
- loadAllConsumeDept: boolean = true;//是否加载所有消耗科室
- solutionNumber; //编号
- title; //标题
- num; //编码
- deptalias; //别名
- type; //类型
- deptHandoverType; //类型
- vIndex:number = 0;//版本号下标
- stepLength: number = 0; //步骤条
- pageIndex: number = 1; //页码
- listLength: number = 10; //总条数
- pageSize: number = 10; //每页条数
- btnLoading: boolean = false; //确认按钮loading状态
- btnLoading1: boolean = false; //审核通过按钮loading状态
- btnLoading2: boolean = false; //审核驳回按钮loading状态
- printLoading: boolean = false; //批量打印按钮loading状态
- deptPhones: any = []; //新添加的科室电话列表
- isAddDeptsPhone = true; //添加新的科室电话是否禁用
- deptsPhoneId = 1; //科室电话自增id
- allParentdepart: any = []; //所有的父级科室列表
- hospitals1: any = []; //科室列表(搜索)
- rowData: object = {}; //打印选择列表
- editModal:boolean = false; //编辑时弹框
- isSpinning: boolean = false; //页面loading状态
- detailData:any;
- solutionLogs:any;
- lookData:any;
- versionsData: any = []; //审核版本数据
- fileData: any = []; //上传的附件数据
- searchParentDeptSubject = new Subject();
- // 初始化增删改按钮
- coopBtns: any = {};
- saveLoading:boolean = false;
- taskTypeData:{id:''};
- rejectModal:boolean = false;
- rejectData:null;
- optType:string = '';
- // 导入---end
- //搜索父级科室
- isDeptLoading = false;
- changeInp(e) {
- this.searchParentDeptSubject.next(e);
- }
- // 配送建单
- coopData:any = {};
- addDateModal(data) {
- this.coopData = data;
- this.showDelModal1();
- }
- showDelModal1() {
- this.editModal = true;
- }
- hideDelModal1() {
- this.editModal = false;
- }
- // 编辑保存
- confirmDel1() {
- var that = this;
- for (const i in that.validateForm.controls) {
- that.validateForm.controls[i].markAsDirty();
- that.validateForm.controls[i].updateValueAndValidity();
- }
- if (that.validateForm.invalid) return;
- let data: any = {
- hosId:this.hosId,
- pharmacy:this.validateForm.value.department,
- id:that.coopId,
- loadAllConsumeDept:this.validateForm.value.loadAllConsumeDept?1:0
- };
- that.saveLoading = true;
- that.mainService
- .simplePost("addData", "drugsBatch", data)
- .subscribe((data) => {
- that.saveLoading = false;
- that.hideModal();
- if (data.status == 200) {
- this.editModal = false;
- that.showPromptModal("编辑", true, "");
- } else {
- that.showPromptModal("编辑", false, data.msg);
- }
- });
- }
- // 搜索
- search() {
- this.pageIndex = 1;
- this.getList();
- }
- // 重置
- reset() {
- this.pageIndex = 1;
- this.solutionNumber = null;
- this.title = null;
- this.getList();
- }
- // 表格数据
- loading1 = false;
- getList() {
- var that = this;
- let data = {
- idx: that.pageIndex - 1,
- sum: that.pageSize,
- solution: {
- title:this.title,
- solutionNumber:this.solutionNumber,
- hosId: this.hosId,
- },
- };
- if(this.maintainDepartment){
- data.solution.hosId = this.maintainDepartment;
- }
- this.loading1 = true;
- that.mainService
- .getFetchDataList("data", "solution", data)
- .subscribe((data) => {
- this.loading1 = false;
- that.listOfData = data.list;
- that.listLength = data.totalNum;
- });
- }
- // 版本号点击
- versionsClick(data, index){
- this.vIndex = index
- this.lookData = data
- let content = data.content
- if(content){
- this.richText = this.sanitizer.bypassSecurityTrustHtml(content);
- }else{
- this.richText = ''
- }
- }
- // 点击附件
- fileClick(data){
- console.log(222,data)
- let a: any = document.createElement('a') // 创建一个元素
- a.style = 'display: none' // 不能在页面中被看到,把他隐藏起来
- a.style.height = '0px' // 给个0高度,避免影响页面布局
- a.download = data.name;
- a.href = data.url // 文件url地址
- document.body.appendChild(a) // 将其绑定在body上才能发挥作用
- a.click() // 触发a标签的click事件
- document.body.removeChild(a) // 删除该元素
- }
- hideModal() {
- this.modal = false;
- }
- // 审核通过
- confirmDel4() {
- let data: any = {
- id:this.rowId,
- operationType: 'approve'
- };
- this.btnLoading1 = true;
- this.mainService
- .simplePost("updData", "solution", data)
- .subscribe((data) => {
- this.btnLoading1 = false;
- this.hideDelModal4()
- if (data.status == 200) {
- this.showPromptModal("审核", true, "");
- } else {
- this.showPromptModal("审核", false, data.msg);
- }
- });
- }
- hideDelModal4() {
- this.auditModal = false;
- }
- // 审核驳回
- rejectCancel(){
- this.rejectModal = false
- }
- // 审核驳回
- rejectOk(){
- if(this.rejectData==null){
- this.message.error('请输入整改意见')
- return
- }
- let data: any = {
- id:this.rowId,
- operationType: 'approve',
- rejectReason:this.rejectData
- };
- this.btnLoading2 = true;
- this.mainService
- .simplePost("updData", "solution", data)
- .subscribe((data) => {
- this.btnLoading2 = false;
- this.rejectCancel()
- if (data.status == 200) {
- this.showPromptModal("驳回", true, "");
- } else {
- this.showPromptModal("驳回", false, data.msg);
- }
- });
- }
- closeModel(){
- this.hideModal()
- }
- // 表单提交
- auditModal = false;
- submitForm(type): void {
- var that = this;
- if(type==1){
- this.auditModal = true
- }else{
- this.rejectData = null
- this.rejectModal = true
- }
- }
- // 升级
- upgrade(e, data){
- e.stopPropagation();
- this.router.navigateByUrl(`/repositoryManageAdd/${data.id}?type=upgrade`);
- }
- // 新增
- addForm(){
- this.router.navigateByUrl(`/repositoryManageAdd/0`);
- }
- // 查看
- look(e, data){
- e.stopPropagation();
- this.optType = 'look'
- this.rowId = data.id
- this.vIndex = 0
- this.modal = true
- var that = this;
- let query = {
- idx: 0,
- sum: 9999,
- solution: {
- hosId: this.hosId,
- operationType:'lookOver',
- solutionNumber:data.solutionNumber
- }
- };
- this.isSpinning = true
- that.mainService
- .getFetchDataList("data", "solution", query)
- .subscribe((res) => {
- this.getFile()
- let data = res.list
- this.detailData = data
- let content = data[0].content
- if(content){
- this.richText = this.sanitizer.bypassSecurityTrustHtml(content);
- }else{
- this.richText = ''
- }
- for(let i of data){
- if(i.solutionLogs.length>0){
- for(let t of i.solutionLogs){
- t.time = format(t.operationTime, 'yyyy-MM-dd HH:mm')
- }
- }
- }
- this.lookData = data[0]
- this.solutionLogs = data[0].solutionLogs
- this.stepLength = this.solutionLogs.length
- this.isSpinning = false
- });
- }
- getFile(){
- this.mainService
- .getPreviewImage('solution', this.rowId)
- .subscribe((res:any)=> {
- this.fileData = res.data.map((v) =>{
- return{
- name: v.name,
- url: location.origin + '/file' + v.relativeFilePath
- }
- });
- });
- }
- // 审核
- rowId=null;
- audit(e, data){
- e.stopPropagation();
- this.rowId = data.id
- this.vIndex = 0
- this.optType = 'audit'
- this.modal = true
- var that = this;
- let query = {
- idx: 0,
- sum: 9999,
- solution: {
- hosId: this.hosId,
- operationType:'lookOver',
- solutionNumber:data.solutionNumber
- }
- };
- this.isSpinning = true
- that.mainService
- .getFetchDataList("data", "solution", query)
- .subscribe((res) => {
- this.getFile()
- let data = res.list
- this.detailData = data
- this.richText = this.sanitizer.bypassSecurityTrustHtml(data[0].content);
- for(let i of data[0].solutionLogs){
- i.time = format(i.operationTime, 'yyyy-MM-dd HH:mm')
- }
- this.lookData = data[0]
- this.solutionLogs = data[0].solutionLogs
- this.stepLength = this.solutionLogs.length
- this.isSpinning = false
- });
- }
- // 编辑
- edit(e, data) {
- e.stopPropagation();
- this.router.navigateByUrl(`/repositoryManageAdd/${data.id}?type=edit`);
- }
- // 停用
- pauseModal = false;
- pause(e, data){
- e.stopPropagation();
- this.pauseModal = true;
- this.coopId = data.id;
- }
- // 确认停用
- confirmDel2() {
- var that = this;
- that.btnLoading = true;
- let data: any = {
- id:this.coopId,
- operationType: 'deactivate'
- };
- this.mainService
- .simplePost("updData", "solution", data)
- .subscribe((data) => {
- that.btnLoading = false;
- that.pauseModal = false;
- if (data.status == 200) {
- this.showPromptModal("停用", true, "");
- } else {
- this.showPromptModal("停用", false, data.msg);
- }
- });
- }
- hideDelModal2() {
- this.pauseModal = false;
- }
- // 恢复
- renewModal = false;
- renew(e, data){
- e.stopPropagation();
- this.renewModal = true;
- this.coopId = data.id;
- }
- // 确认恢复
- confirmDel3() {
- var that = this;
- that.btnLoading = true;
- let data: any = {
- id:this.coopId,
- operationType: 'recover'
- };
- this.mainService
- .simplePost("updData", "solution", data)
- .subscribe((data) => {
- that.btnLoading = false;
- that.renewModal = false;
- if (data.status == 200) {
- this.showPromptModal("恢复", true, "");
- } else {
- this.showPromptModal("恢复", false, data.msg);
- }
- });
- }
- hideDelModal3() {
- this.renewModal = false;
- }
- // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
- showPromptModal(con, success, promptInfo?) {
- this.promptModalShow = false;
- this.promptContent = con;
- this.ifSuccess = success;
- this.promptInfo = promptInfo;
- setTimeout(() => {
- this.promptModalShow = true;
- }, 100);
- this.getList();
- }
- delModal: boolean = false; //删除模态框
- coopIds: any;
- coopFlag: any = false;
- /**
- *
- * @param e 事件对象
- * @param id
- */
- showDelModal(e, id) {
- e.stopPropagation();
- this.delModal = true;
- this.coopId = id;
- }
- hideDelModal() {
- this.delModal = false;
- }
- // 确认删除
- confirmDel() {
- var that = this;
- that.btnLoading = true;
- that.mainService
- .coopTypeConfig(
- "rmvData",
- "solution",
- [that.coopId]
- )
- .subscribe((data) => {
- that.btnLoading = false;
- that.delModal = false;
- if (data.status==200) {
- that.showPromptModal("删除", true, "");
- } else {
- that.showPromptModal("删除", false, data.data[0].msg);
- }
- });
- }
- detail(e, data) {
- e.stopPropagation();
- this.router.navigateByUrl(`/dispensingDetail/${data.id}`);
- }
- }
|