Commit 10f09abe authored by wangqinghua's avatar wangqinghua

创建运维项目

parent 9448ef44
......@@ -26,60 +26,48 @@
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="principal">甲方名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="principal" id="principal">
<nz-form-explain *ngIf="validateForm.get('principal').dirty && validateForm.get('principal').errors">
用户登录名为2到16个字符!
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<!-- <nz-form-item>-->
<!-- <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="phone">乙方名称</nz-form-label>-->
<!-- <nz-form-control [nzSm]="14" [nzXs]="24">-->
<!-- <input nz-input formControlName="phone" id="phone">-->
<!-- </nz-form-control>-->
<!-- </nz-form-item>-->
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="phone">乙方名称</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="startDate">开始时间</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="phone" id="phone">
<nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').errors">手机号码错误!
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="phone">开始时间</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="phone" id="phone">
<nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').errors">手机号码错误!
</nz-form-explain>
<nz-date-picker
[nzFormat]="timeFormat"
formControlName="startDate" id="startDate"
nzPlaceHolder="终止时间"></nz-date-picker>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="phone">终止时间</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="endDate">终止时间</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="phone" id="phone">
<nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').errors">手机号码错误!
</nz-form-explain>
<nz-date-picker
[nzFormat]="timeFormat"
formControlName="endDate" id="endDate"
nzPlaceHolder="终止时间"></nz-date-picker>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="principal">项目金额</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="amount">项目金额</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="principal" id="principal">
<nz-form-explain *ngIf="validateForm.get('principal').dirty && validateForm.get('principal').errors">
用户登录名为2到16个字符!
</nz-form-explain>
<input nz-input formControlName="amount" id="amount">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="principal">单位负责人</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="officePrincipal">单位负责人</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="principal" id="principal">
<nz-form-explain *ngIf="validateForm.get('principal').dirty && validateForm.get('principal').errors">
用户登录名为2到16个字符!
</nz-form-explain>
<input nz-input formControlName="officePrincipal" id="officePrincipal">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="principal">乙方维护组长</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="aPrincipal">乙方维护组长</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="principal" id="principal">
<nz-form-explain *ngIf="validateForm.get('principal').dirty && validateForm.get('principal').errors">
用户登录名为2到16个字符!
</nz-form-explain>
<input nz-input formControlName="principal" id="aPrincipal">
</nz-form-control>
</nz-form-item>
......
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {opr_company_type} from '../../project.constants';
import {opr_company_type, project_type} from '../../project.constants';
import {SystemService} from '../../../system/system.service';
import {ProjectService} from '../../project.service';
@Component({
selector: 'smart-create-project',
templateUrl: './create-project.component.html',
styles: []
selector: 'smart-create-project',
templateUrl: './create-project.component.html',
styles: []
})
export class CreateProjectComponent implements OnInit {
@Output() done = new EventEmitter<any>();
tabNum = 0; //tabs面板的序列号
@Output() done = new EventEmitter<any>();
tabNum = 0; //tabs面板的序列号
timeFormat = 'yyyy-MM-dd';
title;
isVisible = false;
isOkLoading = false;
validateForm: FormGroup;
fileList: UploadFile[] = [];
opr_company_type = opr_company_type;
title;
isVisible = false;
isOkLoading = false;
validateForm: FormGroup;
fileList: UploadFile[] = [];
opr_company_type = project_type;
cID;
cID;
constructor(private fb: FormBuilder, private systemSer: SystemService,
private message: NzMessageService, private projectSer: ProjectService) {
}
ngOnInit(): void {
this.initForm();
}
initForm() {
this.validateForm = this.fb.group({
name: [null, [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
officeName: [null],
officePrincipal: [null],
aPrincipal: [null],
amount: [null],
type: [null],
planWorkNum: [null],
workNum: [null],
status: [null],
companyId: [null],
teamId: [null],
startDate: [null],
endDate: [null],
});
}
showAddModal(title) {
this.isVisible = true;
this.title = title;
}
showEditModal(data, title) {
this.isVisible = true;
this.title = title;
this.cID = data.id;
console.log(data);
this.validateForm.patchValue(data);
}
handleCancel() {
this.isVisible = false;
this.initForm();
}
constructor(private fb: FormBuilder, private systemSer: SystemService,
private message: NzMessageService, private projectSer: ProjectService) {
}
beforeUpload = (file: UploadFile): boolean => {
const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || 'application/octet-stream';
if (!isExcel) {
this.message.error('请上传正确的文件!');
} else {
this.fileList[0] = file;
ngOnInit(): void {
this.initForm();
}
return false;
};
handleOk() {
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
initForm() {
this.validateForm = this.fb.group({
name: [null, [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
officeName: [null],
officePrincipal: [null],
aPrincipal: [null],
amount: [null],
type: [null],
principal: [null],
startDate: [null],
endDate: [null],
});
}
if (this.validateForm.invalid) {
return false;
showAddModal(title) {
this.isVisible = true;
this.title = title;
}
this.isOkLoading = true;
if (this.title == '新增运维公司') {
this.create();
showEditModal(data, title) {
this.isVisible = true;
this.title = title;
this.cID = data.id;
this.validateForm.patchValue(data);
}
if (this.title == '编辑运维公司') {
this.update();
handleCancel() {
this.isVisible = false;
this.initForm();
}
}
create() {
this.projectSer.addMaintainCompany(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.initForm();
this.done.emit();
this.message.success('新增运维公司成功');
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
beforeUpload = (file: UploadFile): boolean => {
const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || 'application/octet-stream';
if (!isExcel) {
this.message.error('请上传正确的文件!');
} else {
this.fileList[0] = file;
}
);
}
return false;
};
update() {
this.validateForm.addControl('id', new FormControl(this.cID));
this.systemSer.updateUser(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.initForm();
this.done.emit();
this.message.success('更新信息成功');
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
handleOk() {
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
);
}
if (this.validateForm.invalid) {
return false;
}
this.isOkLoading = true;
if (this.title == '新增运维项目') {
this.create();
}
if (this.title == '编辑运维项目') {
this.update();
}
}
//tabs切换
tabsChange(num) {
this.tabNum = num;
}
create() {
this.validateForm.patchValue({
startDate: new Date(this.validateForm.value.startDate).getTime(),
endDate: new Date(this.validateForm.value.endDate).getTime(),
});
this.projectSer.addMaintainProject(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.initForm();
this.done.emit();
this.message.success('新增运维项目成功');
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
update() {
this.validateForm.addControl('id', new FormControl(this.cID));
this.projectSer.updateMaintainProject(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.initForm();
this.done.emit();
this.message.success('更新项目成功');
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
//tabs切换
tabsChange(num) {
this.tabNum = num;
}
}
......@@ -49,7 +49,7 @@
</nz-radio-group>
</div>
<div nz-col nzSpan="3">
<button (click)="search()"
<button (click)="handleOpenModal()"
nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>新增运维项目
</button>
</div>
......@@ -107,3 +107,5 @@
</tr>
</tbody>
</nz-table>
<smart-create-project #smartCreateProject (done)="getList()"></smart-create-project>
......@@ -10,6 +10,7 @@ import {CommonService} from '../../shared/common/common.service';
import {DatePipe} from '@angular/common';
import {ProjectService} from '../project.service';
import {project_status} from '../project.constants';
import {CreateProjectComponent} from '../modal/create-project/create-project.component';
@Component({
selector: 'app-opr-project',
......@@ -17,6 +18,7 @@ import {project_status} from '../project.constants';
styleUrls: ['./opr-project.component.css']
})
export class OprProjectComponent implements OnInit {
@ViewChild('smartCreateProject') smartCreateProject: CreateProjectComponent;
timeFormat = 'yyyy';
......@@ -38,7 +40,7 @@ export class OprProjectComponent implements OnInit {
keyword: ''
};
constructor(private workSer: WorkService, private message: NzMessageService,private projectSer:ProjectService,
constructor(private workSer: WorkService, private message: NzMessageService, private projectSer: ProjectService,
private router: Router, private commonSer: CommonService, private datePipe: DatePipe) {
}
......@@ -79,4 +81,8 @@ export class OprProjectComponent implements OnInit {
this.getList();
}
handleOpenModal() {
this.smartCreateProject.showAddModal('新增运维项目');
}
}
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