效果图:
html代码:
<nz-table
#groupingTable
[nzData]="listOfDisplayData"
nzBordered
nzSize="middle"
nzShowPagination="false"
[nzWidthConfig]="widthConfig"
[nzScroll]="scrollConfig"
nzFrontPagination="false"
>
<thead>
<tr style="position: relative;background-color: blueviolet;" >
<th colspan="4" class="fontWhite" style="background-color: blueviolet;border: none;">Pilot Job Task Analysis (JTA)</th>
<th colspan="1" nzWidth="120px" class="firstTh" style="background-color: chartreuse;border: none;">Task Competency Level</th>
<th colspan="1" nzWidth="120px" class="firstTh" style="background-color:darkgrey;border: none;">PF / PM / Both (B)</th>
<th *ngFor="let skill of Skills" colspan="1" nzWidth="120px" class="firstTh" style="background-color:turquoise;border: none;">{{skill.competencyName}}</th>
<th *ngFor="let knowledge of Knowledges" colspan="1" nzWidth="120px" class="firstTh" style="background-color:orange;border: none;">{{knowledge.competencyName}}</th>
<th *ngFor="let attitude of Attitudes" colspan="1" nzWidth="120px" class="firstTh" style="background-color:burlywood;border: none;">{{attitude.competencyName}}</th>
<th colspan="1" nzWidth="120px" class="firstTh" style="background-color:yellow;border: none;">Train (T)/No-Train (N) Decision</th>
<th colspan="1" nzWidth="120px" style="background-color:beige;border: none;">References</th>
</tr>
<tr style="border: none;">
<th colspan="4" class="fontWhite" style="background-color: blueviolet;border: none;"></th>
<th colspan="1" style="background-color: chartreuse;border: none;"></th>
<th colspan="1" style="background-color:darkgrey;border: none;"></th>
<th *ngFor="let skill of Skills" colspan="1" nzWidth="150px" style="background-color:turquoise;border: none;">{{skill.index}}</th>
<th *ngFor="let knowledge of Knowledges" colspan="1" nzWidth="150px" style="background-color:orange;border: none;">{{knowledge.index}}</th>
<th *ngFor="let attitude of Attitudes" colspan="1" nzWidth="150px" style="background-color:burlywood;border: none;">{{attitude.index}}</th>
<th colspan="1" style="background-color:yellow;border: none;"></th>
<th colspan="1" style="background-color:beige;border: none;">Chapter & Section</th>
</tr>
<tr>
<th colspan="1" >Task #</th>
<th colspan="1" >Function</th>
<th colspan="1" >Task</th>
<th colspan="1" >Sub-Task</th>
<th colspan="2" style="background-color: beige;" ></th>
<th [attr.colspan]="this.CompetencyCount" class="fontWhite" style="background-color:black;" >Skills, Knowledge, Attitude</th>
<th colspan="1" style="background-color: beige;" ></th>
<th colspan="1" style="background-color: beige;" ></th>
</tr>
<tr>
<th colspan="1" style="background-color: beige;" ></th>
<th colspan="1" style="background-color: beige;" ></th>
<th colspan="1" style="background-color: beige;" ></th>
<th colspan="1" style="background-color: beige;" ></th>
<th [attr.colspan]="this.CompetencyCount+2" style="background-color: beige;" >NOTE: The SKA levels here equate to the final assessment levels.</th>
<th colspan="1" style="background-color: beige;" ></th>
<th colspan="1" style="background-color: beige;" ></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of groupingTable.data">
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" (click)="test()" >{{ data.taskCode }}</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >{{ data.function }}</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >{{ data.task }}</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >{{ data.subTask }}</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >
<ng-container *ngIf="data.taskCompetencyLevel!=null;">
<nz-select style="width: 100%;" [(ngModel)]="data.taskCompetencyLevel">
<nz-option nzValue="C1" nzLabel="C1"></nz-option>
<nz-option nzValue="C2" nzLabel="C2"></nz-option>
<nz-option nzValue="C3" nzLabel="C3"></nz-option>
</nz-select>
</ng-container>
</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >
<ng-container *ngIf="data.pfpmBoth!=null;">
<nz-select style="width: 100%;" [(ngModel)]="data.pfpmBoth">
<nz-option nzValue="PF" nzLabel="PF"></nz-option>
<nz-option nzValue="PM" nzLabel="PM"></nz-option>
<nz-option nzValue="B" nzLabel="B"></nz-option>
</nz-select>
</ng-container>
</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" *ngFor="let skill of Skills" nzWidth="150px" >
<ng-container *ngIf="data.skillList[skill.competencyName];">
<nz-select style="width: 100%;" [(ngModel)]="data.skillList[skill.competencyName].competencyScore">
<nz-option nzValue="S1" nzLabel="S1"></nz-option>
<nz-option nzValue="S2" nzLabel="S2"></nz-option>
<nz-option nzValue="S3" nzLabel="S3"></nz-option>
</nz-select>
</ng-container>
</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" *ngFor="let knowledge of Knowledges" nzWidth="150px" >
<ng-container *ngIf="data.knowledgeList[knowledge.competencyName];">
<nz-select style="width: 100%;" [(ngModel)]="data.knowledgeList[knowledge.competencyName].competencyScore">
<nz-option nzValue="K1" nzLabel="K1"></nz-option>
<nz-option nzValue="K2" nzLabel="K2"></nz-option>
<nz-option nzValue="K3" nzLabel="K3"></nz-option>
</nz-select>
</ng-container>
</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" *ngFor="let attitude of Attitudes" nzWidth="150px" >
<ng-container *ngIf="data.attitudeList[attitude.competencyName];">
<nz-select style="width: 100%;" [(ngModel)]="data.attitudeList[attitude.competencyName].competencyScore">
<nz-option nzValue="A1" nzLabel="A1"></nz-option>
<nz-option nzValue="A2" nzLabel="A2"></nz-option>
<nz-option nzValue="A3" nzLabel="A3"></nz-option>
</nz-select>
</ng-container>
</td>
<td [style.color]="data.jtaType==1?'white':'black'" [style.border]="data.jtaType==1?'none':''" [style.background-color]="data.jtaType==1?'#041981':''" colspan="1" >
<ng-container *ngIf="data.trainNoTrainDecision!=null;">
<nz-select style="width: 100%;" [(ngModel)]="data.trainNoTrainDecision">
<nz-option nzValue="T" nzLabel="T"></nz-option>
<nz-option nzValue="NT" nzLabel="NT"></nz-option>
</nz-select>
</ng-container>
</td>
<td colspan="1">{{ data.references }}</td>
</tr>
</tbody>
</nz-table>
ts代码:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-view-jta',
templateUrl: './view-jta.component.html',
styleUrls:["./view-jta.component.less"]
})
export class ViewJtaComponent implements OnInit{
// widthConfig = ['100px', '200px', '200px', '100px', '100px', '200px', '200px', '100px'];
widthConfig = [];
// scrollConfig = { x: '1200px', y: '240px' };
scrollConfig={ };;
listOfDisplayData: any[] = [];
mainData: any[] = [];
Skills = [];
Knowledges = [];
Attitudes = [];
CompetencyCount = 0;
sortValue: 'ascend' | 'descend' | null = null;
filterName = [{ text: 'Joe', value: 'Joe' }, { text: 'John', value: 'John' }];
searchName: string[] = [];
search(searchName: string[]): void {
this.searchName = searchName;
this.listOfDisplayData = this.mainData.sort((a, b) =>
this.sortValue === 'ascend' ? (a.age > b.age ? 1 : -1) : b.age > a.age ? 1 : -1
);
}
//#region 构造函数
constructor() {
}
ngOnInit(): void {
this.Skills = [{index:1,competencyName:"Application of Procedures"},{index:2,competencyName:"Communication"},{index:3,competencyName:"Problem Solving and Decision Making"}];
this.Knowledges = [{index:1,competencyName:"Transfer of Knowledge"}];
this.Attitudes = [{index:1,competencyName:"Leadership and Teamwork"},{index:2,competencyName:"Teamwork"}];
this.CompetencyCount = this.Skills.length+this.Knowledges.length+this.Attitudes.length;
var currentSkills: { [key: string]: { competencyName: string; competencyScore:string} } = {};
var currentKnowledges: { [key: string]: { competencyName: string; competencyScore:string} } = {};
var currentAttitudes: { [key: string]: { competencyName: string; competencyScore:string} } = {};
// var currentSkills = [{index:1,competencyName:"Application of Procedures",competencyScore:"S1"},{index:3,competencyName:"Problem Solving and Decision Making",competencyScore:"S3"}];
// var currentKnowledges = [{index:1,competencyName:"Transfer of Knowledge",competencyScore:"K1"}];
currentSkills["Application of Procedures"] = {competencyName :"Application of Procedures",competencyScore:"S1" };
currentSkills["Problem Solving and Decision Making"] = {competencyName :"Problem Solving and Decision Making",competencyScore:"S3" };
currentKnowledges["Transfer of Knowledge"] = {competencyName :"Transfer of Knowledge",competencyScore:"K1" };
currentAttitudes["Leadership and Teamwork"] = {competencyName :"Leadership and Teamwork",competencyScore:"A1" };
this.mainData.push({jtaType:1,taskCode:"01",function:"Perform Pre-Departure Ground Operations",task:"2",subTask:"3",taskCompetencyLevel:"C1",pfpmBoth:"B",skillList:currentSkills,knowledgeList:currentKnowledges,attitudeList:currentAttitudes,trainNoTrainDecision:"NT",references:"16"});
this.mainData.push({jtaType:2,taskCode:"01.01",function:"",task:"Perform Mission Preparation Procedures",subTask:"3",taskCompetencyLevel:"C2",pfpmBoth:"5",skillList:currentSkills,knowledgeList:currentKnowledges,attitudeList:currentAttitudes,trainNoTrainDecision:"15",references:"16"});
this.mainData.push({jtaType:2,taskCode:"01.01.01",function:"",task:"",subTask:"Comply with Company, NAA and other applicable guidance and regulations regarding mission preparation ",taskCompetencyLevel:"4",pfpmBoth:"5",skillList:currentSkills,knowledgeList:currentKnowledges,attitudeList:currentAttitudes,trainNoTrainDecision:"15",references:"16"});
this.listOfDisplayData = [...this.mainData];
}
//根据字符串去验证是否有值,有值显示,无值不显示;
//CompetencyName:需要排查是否存在的数据
//CompetencyList:数据库存储的列表数据
showTd(CompetencyName,CompetencyList)
{
var result = false;
CompetencyList.forEach(element => {
if(element.competencyName == CompetencyName)
{
result = true;
return;
}
});
return result;
}
setCurrentData(CompetencyName,CompetencyList)
{
//data.skillList[skill.competencyName].competencyScore
var currentScore = CompetencyList.find(obj=>obj.competencyName == CompetencyName).competencyScore;
return currentScore;
}
test()
{
console.log(this.mainData)
}
}
样式代码:
.fontWhite{
color: white;
}
.fontBlack{
color: black;
}
.firstTh {
transform-origin: bottom left;
transform: skewX(-30deg);
width: 200px;
}