From 3a4e0ec815b784c696690f05d06dc043fe2a971c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 3 Jul 2020 13:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=98=E6=9B=B4=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-comment.component.html | 8 +++++++- .../editable-tag/editable-tag.component.ts | 20 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/app/view/admin/admin-comment/admin-comment.component.html b/src/app/view/admin/admin-comment/admin-comment.component.html index 594422c..481cbba 100644 --- a/src/app/view/admin/admin-comment/admin-comment.component.html +++ b/src/app/view/admin/admin-comment/admin-comment.component.html @@ -8,5 +8,11 @@ - + + diff --git a/src/app/view/admin/components/editable-tag/editable-tag.component.ts b/src/app/view/admin/components/editable-tag/editable-tag.component.ts index ee8174c..851a289 100644 --- a/src/app/view/admin/components/editable-tag/editable-tag.component.ts +++ b/src/app/view/admin/components/editable-tag/editable-tag.component.ts @@ -9,6 +9,7 @@ import { SimpleChanges, ViewChild } from '@angular/core'; +import {NzModalRef, NzModalService} from 'ng-zorro-antd'; @Component({ selector: 'editable-tag', @@ -39,7 +40,7 @@ export class EditableTagComponent implements OnInit, OnChanges { private static instanceArray: EditableTagComponent[] = [] - constructor() { + constructor(private modal: NzModalService) { EditableTagComponent.instanceArray.push(this); } @@ -53,11 +54,15 @@ export class EditableTagComponent implements OnInit, OnChanges { @Input() showBorder: boolean; @Input() text: string; @Input() key: any; + @Input() showConfirmModal: boolean; + @Output() modalOK = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); + @Output() modalCancel = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); private tmpKey: any; private doubleClickInfo = { date: null, }; + confirmModal?: NzModalRef; ngOnInit(): void { if (this.showEditIcon == null) { @@ -104,14 +109,23 @@ export class EditableTagComponent implements OnInit, OnChanges { handleInputConfirm(): void { - this.valueChange.emit({ + const value = { value: this.inputValue, originalValue: this.text, changed: this.inputValue !== this.text - }) + } + this.valueChange.emit(value) this.text = this.inputValue; this.inputValue = ''; this.inputVisible = false; + if (this.showConfirmModal && value.changed) { + this.confirmModal = this.modal.confirm({ + nzTitle: '数据变更', + nzContent: '是否提交修改,点击确定提交修改,点击取消则恢复原数据', + nzOnOk: () => this.modalOK.emit(value), + nzOnCancel: () => this.modalCancel.emit(value) + }); + } } }