|
@@ -1,282 +0,0 @@
|
|
|
-import { HospitalService } from 'app/services/basedata/hospital.service';
|
|
|
-import { Component, OnInit, ViewChild, Output, EventEmitter, HostListener } from '@angular/core';
|
|
|
-import { NzNotificationService, NzModalService } from 'ng-zorro-antd';
|
|
|
-import { _HttpClient } from '@delon/theme';
|
|
|
-import { HospitalContacts } from 'app/entity/basedata/hospital-contacts';
|
|
|
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
-import { Hospital } from 'app/entity/basedata/hospital';
|
|
|
-import { BasedataHospitalHospitalNewComponent } from '../../hospital-new/hospital-new.component';
|
|
|
-import { HospitalContactsService } from 'app/services/basedata/hospital-contacts.service';
|
|
|
-import { I18NService } from '@core';
|
|
|
-import { BasedataHospitalHospitalDocEditContactsAddRowComponent } from './contacts-add-row/contacts-add-row.component';
|
|
|
-import { messageShared } from '@shared/utils/message';
|
|
|
-
|
|
|
-@Component({
|
|
|
- selector: 'app-basedata-hospital-hospital-doc-edit',
|
|
|
- templateUrl: './edit.component.html',
|
|
|
- styles: [
|
|
|
- `
|
|
|
- .base{
|
|
|
- position: absolute;
|
|
|
- bottom: 0px;
|
|
|
- width: 100%;
|
|
|
- border-top: 1px solid rgb(232, 232, 232);
|
|
|
- padding: 10px 16px;
|
|
|
- text-align: right;
|
|
|
- left: 0px;
|
|
|
- background: #fff;
|
|
|
- z-index:99;
|
|
|
- }
|
|
|
- .buttonDistance{
|
|
|
- margin-right:2%;
|
|
|
- }
|
|
|
- .textCenter{
|
|
|
- text-align:center
|
|
|
- }
|
|
|
-
|
|
|
- `
|
|
|
- ]
|
|
|
-})
|
|
|
-export class BasedataHospitalHospitalDocEditComponent implements OnInit {
|
|
|
-
|
|
|
- //元数据
|
|
|
- ngOnInit(): void {
|
|
|
- this.validateForm = this.fb.group({
|
|
|
- code: [null, [Validators.required]],
|
|
|
- name: [null, [Validators.required]],
|
|
|
- pig: [null]
|
|
|
- });
|
|
|
- this.initHospital();
|
|
|
- this.hospitalContacts = [];
|
|
|
- }
|
|
|
- constructor(
|
|
|
- private nzNotificationService: NzNotificationService,
|
|
|
- private hospitalService: HospitalService,
|
|
|
- private hospitalContactsService: HospitalContactsService,
|
|
|
- private fb: FormBuilder,
|
|
|
- private nzModalService:NzModalService,
|
|
|
- private i18NService:I18NService
|
|
|
- ) { }
|
|
|
- isLoading = false;
|
|
|
- drawerWidth = 1100;
|
|
|
- visible = false;
|
|
|
- validateForm: FormGroup;
|
|
|
- hospital: Hospital;
|
|
|
- enable = false;
|
|
|
- hospitalContact: HospitalContacts;
|
|
|
-
|
|
|
- @ViewChild("basedataHospitalHospitalNew") basedataHospitalHospitalNew: BasedataHospitalHospitalNewComponent
|
|
|
- @Output() afterSave = new EventEmitter();
|
|
|
- @HostListener('window:resize', ['$event'])
|
|
|
- onResize(event) {
|
|
|
- const width = event.target.innerWidth;
|
|
|
- if (width > 900) {
|
|
|
- this.drawerWidth = 900;
|
|
|
- } else {
|
|
|
- this.drawerWidth = width;
|
|
|
- }
|
|
|
- }
|
|
|
- //对<nz-form-control>标签逐一校验
|
|
|
- a = 0;
|
|
|
-
|
|
|
- save(): void {
|
|
|
-
|
|
|
- // this.hospitalContacts.forEach(element => {
|
|
|
- // console.log(this.hospitalContacts)
|
|
|
- // if (element.isDefault == true) {
|
|
|
- // element.isDefault="1";
|
|
|
- // this.a++
|
|
|
- // console.log("默认联系人有" + this.a)
|
|
|
- // }else{
|
|
|
- // element.isDefault="0";
|
|
|
- // }
|
|
|
- // });
|
|
|
- // this.hospital.hospitalContacts = this.hospitalContacts;
|
|
|
- if (this.enable) {
|
|
|
- this.hospital.enable = "1";
|
|
|
- } else {
|
|
|
- this.hospital.enable = "0";
|
|
|
- }
|
|
|
- for (const i in this.validateForm.controls) {
|
|
|
- this.validateForm.controls[i].markAsDirty();
|
|
|
- this.validateForm.controls[i].updateValueAndValidity();
|
|
|
- }
|
|
|
- //alert(JSON.stringify(this.hospital));
|
|
|
- //return;
|
|
|
- let valid = this.validateForm.valid;
|
|
|
- //验证通过保存
|
|
|
- if (valid) {
|
|
|
- this.hospitalService.editHospital(this.hospital).then((response) => {
|
|
|
- if (response.success) {
|
|
|
- this.nzNotificationService.success(this.i18NService.fanyi("successful.revision"), "");
|
|
|
- this.afterSave.emit();
|
|
|
- this.initHospital();
|
|
|
- this.close();
|
|
|
- } else {
|
|
|
- this.nzNotificationService.error(this.i18NService.fanyi("modification.failed"), messageShared(this.i18NService,response.message));
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- openEdit(id: string): void {
|
|
|
- this.visible = true;//打开drawer并清除校验提示信息
|
|
|
- this.hospital.id = id;
|
|
|
- // this.enable = true;
|
|
|
- // this.hospitalContacts = [];
|
|
|
- for (const i in this.validateForm.controls) {
|
|
|
- this.validateForm.controls[i].reset();
|
|
|
- }
|
|
|
- this.hospitalService.queryById(id).then((response) => {
|
|
|
- this.hospital = response.result;
|
|
|
- //装换是否停用
|
|
|
- if(this.hospital.enable=="0"){
|
|
|
- this.enable=false;
|
|
|
- }else{
|
|
|
- this.enable=true;
|
|
|
- }
|
|
|
- })
|
|
|
- this.getContacts(id);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- getContacts(id) {
|
|
|
- this.isLoading = true
|
|
|
- this.hospitalContact = {
|
|
|
- pkHospitalId: id
|
|
|
- }
|
|
|
- this.hospitalContactsService.getHospitalContacts(this.hospitalContact).then((response) => {
|
|
|
- console.log(this.i18NService.fanyi("the.data.queried.is"))
|
|
|
- console.log(response.result.records)
|
|
|
- this.hospitalContacts = response.result.records;
|
|
|
- this.hospitalContacts.forEach(element => {
|
|
|
- //转换是否默认
|
|
|
- if(element.isDefault=="1"){
|
|
|
- element.isDefault=true;
|
|
|
- }else{
|
|
|
- element.isDefault=false;
|
|
|
- }
|
|
|
- });
|
|
|
- this.isLoading = false
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- editNewContact() {
|
|
|
- this.basedataHospitalHospitalNew.editNewContact(this.hospital.id);
|
|
|
- }
|
|
|
-
|
|
|
- edit(id: string) {
|
|
|
- this.basedataHospitalHospitalNew.editContact(id);
|
|
|
- }
|
|
|
-
|
|
|
- close(): void {
|
|
|
- this.visible = false;//关闭drawer
|
|
|
- this.enable=false;
|
|
|
- this.hospital={}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除
|
|
|
- * @param id 联系人id
|
|
|
- */
|
|
|
- confirmDel(id: string) {
|
|
|
- this.isLoading = true
|
|
|
- this.hospitalContactsService.deleteHospitalContacts(id).then((response) => {
|
|
|
- if (response.success) {
|
|
|
- //删除成功
|
|
|
- this.nzNotificationService.success(this.i18NService.fanyi("successful.deletion"), "")
|
|
|
- this.getContacts(this.hospital.id)
|
|
|
- this.isLoading = false
|
|
|
- } else {
|
|
|
- //删除失败
|
|
|
- this.nzNotificationService.error(this.i18NService.fanyi("delete.failed"), response.message);
|
|
|
- this.getContacts(this.hospital.id)
|
|
|
- this.isLoading = false
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- cancelDel() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- initHospital() {
|
|
|
- this.hospital = {
|
|
|
- id: "",
|
|
|
- code: "",// 医院编码
|
|
|
- name: "",// 医院名称
|
|
|
- enable: "",// 是否停用
|
|
|
- memo: "",// 备注
|
|
|
- hospitalContacts: []
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- index = 1;
|
|
|
- hospitalContacts: any[] = [];
|
|
|
- // 生物分析方法号增行
|
|
|
- addRow(): void {
|
|
|
- this.nzModalService.create({
|
|
|
- nzTitle:this.i18NService.fanyi("hospital.contarts.add"),
|
|
|
- nzWidth:900,
|
|
|
- nzContent:BasedataHospitalHospitalDocEditContactsAddRowComponent,
|
|
|
- nzFooter:[
|
|
|
- {
|
|
|
- label: this.i18NService.fanyi("button.cancel"),
|
|
|
- type:"default",
|
|
|
- onClick: BasedataHospitalHospitalDocEditContactsAddRowComponent => {
|
|
|
- BasedataHospitalHospitalDocEditContactsAddRowComponent.close();
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: this.i18NService.fanyi("button.save"),
|
|
|
- type:"primary",
|
|
|
- onClick: BasedataHospitalHospitalDocEditContactsAddRowComponent => {
|
|
|
- BasedataHospitalHospitalDocEditContactsAddRowComponent.save(this.hospital.id,this.hospitalContacts).then(()=>{
|
|
|
- this.getContacts(this.hospital.id);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- * @param contratsId 联系人id
|
|
|
- */
|
|
|
- updateRow(contratsId){
|
|
|
- this.nzModalService.create({
|
|
|
- nzTitle:this.i18NService.fanyi("hospital.contarts.add"),
|
|
|
- nzWidth:900,
|
|
|
- nzContent:BasedataHospitalHospitalDocEditContactsAddRowComponent,
|
|
|
- nzComponentParams:{
|
|
|
- contratsId:contratsId
|
|
|
- },
|
|
|
- nzFooter:[
|
|
|
- {
|
|
|
- label: this.i18NService.fanyi("button.cancel"),
|
|
|
- type:"default",
|
|
|
- onClick: BasedataHospitalHospitalDocEditContactsAddRowComponent => {
|
|
|
- BasedataHospitalHospitalDocEditContactsAddRowComponent.close();
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- label: this.i18NService.fanyi("button.save"),
|
|
|
- type:"primary",
|
|
|
- onClick: BasedataHospitalHospitalDocEditContactsAddRowComponent => {
|
|
|
- BasedataHospitalHospitalDocEditContactsAddRowComponent.save(this.hospital.id,this.hospitalContacts).then(()=>{
|
|
|
- this.getContacts(this.hospital.id);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // 生物分析方法号删行
|
|
|
- deleteRow(index: number): void {
|
|
|
- this.hospitalContacts = this.hospitalContacts.filter(d => d.index !== index);
|
|
|
- }
|
|
|
-
|
|
|
-}
|