Commit c4cfbfed authored by Chen Jiping's avatar Chen Jiping

完善

parent 8297e29c
...@@ -102,10 +102,10 @@ ...@@ -102,10 +102,10 @@
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{j}}.text">序号</nz-form-label> <nz-form-label [nzSpan]="6" nzFor="{{j}}.index">序号</nz-form-label>
<nz-form-control [nzSpan]="6"> <nz-form-control [nzSpan]="6">
<input nz-input type="text" id="{{j}}.index" placeholder="请录入序号" [(ngModel)]="data.index" <nz-input-number [nzMin]="1" id="{{j}}.index" placeholder="请录入序号" [(ngModel)]="data.index"
(blur)="save()"> (ngModelChange)="saveIndex(data)"></nz-input-number>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
......
import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef} from '@angular/core'; import {Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef} from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd/message'
@Component({ @Component({
selector: 'app-form', selector: 'app-form',
...@@ -15,13 +15,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -15,13 +15,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
item; item;
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef) { constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef, private message: NzMessageService) {
} }
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {};
this.item.title = this.getDefaultTile(); this.item.title = this.getDefaultTile();
...@@ -98,6 +98,39 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -98,6 +98,39 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.refresh(); this.refresh();
} }
saveIndex(item){
console.log(item);
let canSave = true;
for(let i = 0; i < this.item.exercisesArr.length; ++ i){
let exercises = this.item.exercisesArr[i];
if(item == exercises){
continue;
}
else if(exercises.index == item.index){
canSave = false;
break;
}
}
console.log(canSave);
if(canSave){
this.save();
}
else{
let id = this.message.error('已经存在相同的顺序号', {nzDuration: 0 }).messageId;
setTimeout(() => {
this.message.remove(id);
}, 2500);
}
}
/** /**
* 刷新 渲染页面 * 刷新 渲染页面
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment