parent
6195edd2ba
commit
5137406d0f
@ -0,0 +1,166 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
<!--条件搜索--> |
||||
<nz-spin [nzSpinning]="loadingObject.spinning" nzTip="{{loadingObject.msg}}"> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)"> |
||||
<div nz-row> |
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">终端类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzAllowClear formControlName="termType"> |
||||
<nz-option *ngFor="let item of termTypeArray" nzLabel="{{item.codeName}}" nzValue="{{item.codeValue}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">版本类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzAllowClear formControlName="versionType"> |
||||
<nz-option *ngFor="let item of versionTypeArray" nzLabel="{{item.codeName}}" nzValue="{{item.codeValue}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">状态</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzAllowClear formControlName="status"> |
||||
<nz-option nzLabel="已发布" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="未发布" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
|
||||
<div nz-row> |
||||
<div nz-col nzSpan="24" class="search-button"> |
||||
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button> |
||||
<button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
|
||||
<div class="inner-content"> |
||||
<span>共计 {{dataObject.total?dataObject.total:0}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" (click)="showEditModal(null)">新增版本</button> |
||||
</div> |
||||
<!--数组表格 --> |
||||
<nz-table #basicTable |
||||
[nzData]="dataObject.list" |
||||
[nzTotal]="dataObject.total" |
||||
[nzFrontPagination]="false" |
||||
[nzLoading]="tableLoading" |
||||
[nzPageIndex]="whereObject.pageNum" |
||||
(nzPageIndexChange)="requestData($event)" |
||||
[nzScroll]="{ x: '1150px'}"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px">终端类型</th> |
||||
<th nzWidth="80px">版本类型</th> |
||||
<th nzWidth="80px">版本号</th> |
||||
<th nzWidth="80px">状态</th> |
||||
<th nzWidth="150px">版本内容</th> |
||||
<th nzWidth="140px">创建时间</th> |
||||
<th nzWidth="140px">发布时间</th> |
||||
<th nzWidth="150px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data;let i = index"> |
||||
<td>{{data.termType}}</td> |
||||
<td>{{data.versionType == 1?'小版本':'大版本'}}</td> |
||||
<td>{{data.version}}</td> |
||||
<td>{{data.status == 1?'已发布':'未发布'}}</td> |
||||
<td nzEllipsis>{{data.content}}</td> |
||||
<td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td>{{data.releaseTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a nz-dropdown [nzDropdownMenu]="menu">其他操作 <i nz-icon nzType="down"></i> </a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item (click)="showOpenDetail(data)"><a >查看详情</a></li> |
||||
<li nz-menu-item *ngIf="data.status == 2" (click)="showReleaseConfirm(data.id)"><a >发布版本</a></li> |
||||
<li nz-menu-item *ngIf="data.status == 2" (click)="showDelConfirm(data.id)"><a >删除版本</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
</nz-spin> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="editVersionModal" nzTitle="新增版本" (nzOnCancel)="closeEditModal()" nzWidth="500px" [nzFooter]="null"> |
||||
<form nz-form [formGroup]="editVersionModalForm"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>终端类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select formControlName="termType"> |
||||
<nz-option *ngFor="let data of termTypeArray" nzLabel="{{data.codeName}}" nzValue="{{data.codeValue}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>版本类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select formControlName="versionType"> |
||||
<nz-option *ngFor="let data of versionTypeArray" nzLabel="{{data.codeName}}" nzValue="{{data.codeValue}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>新版本号</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="version" placeholder="请输入新版本号" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>版本内容</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<textarea rows="4" nz-input placeholder="版本更新内容" formControlName="content"></textarea> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>更新文件</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-upload |
||||
nzAction="http://122.9.135.148:9902/v1/fileUpload/uploadfile" |
||||
(nzChange)="fileHandleChange($event)" |
||||
> |
||||
<button nz-button><i nz-icon nzType="upload"></i>文件上传</button> |
||||
</nz-upload> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<div style="text-align: center;"> |
||||
<button nz-button nzType="primary" style="width: 150px;" (click)="submitEdit()">确定</button> |
||||
</div> |
||||
</form> |
||||
</nz-modal> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="versionDetailModal" nzTitle="版本详情" (nzOnCancel)="closeVersionDetail()" nzWidth="500px" [nzFooter]="null"> |
||||
<nz-descriptions nzBordered nzLayout="vertical"> |
||||
<nz-descriptions-item nzTitle="终端类型" [nzSpan]="1">{{versionDetailObject.termType}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="版本类型" [nzSpan]="1">{{versionDetailObject.versionType == 1?'小版本':'大版本'}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="版本编号" [nzSpan]="1">{{versionDetailObject.version}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="文件路径" [nzSpan]="3"><a target="_blank" href="{{versionDetailObject.fileUrl}}">{{versionDetailObject.fileUrl}}</a></nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="版本内容" [nzSpan]="3"> |
||||
<pre>{{versionDetailObject.content}}</pre> |
||||
</nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</nz-modal> |
@ -0,0 +1,3 @@ |
||||
.table-td-operation a { |
||||
padding: 0px 5px; |
||||
} |
@ -0,0 +1,25 @@ |
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { VersionComponent } from './version.component'; |
||||
|
||||
describe('VersionComponent', () => { |
||||
let component: VersionComponent; |
||||
let fixture: ComponentFixture<VersionComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ VersionComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(VersionComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,257 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
||||
import {LocalStorageService} from '../../../services/local-storage.service'; |
||||
import {NzMessageService, NzModalService, NzUploadFile} from 'ng-zorro-antd'; |
||||
import {StoreService} from '../../../services/store.service'; |
||||
import {SystemVersionService} from '../../../services/system-version.service'; |
||||
|
||||
@Component({ |
||||
selector: 'app-version', |
||||
templateUrl: './version.component.html', |
||||
styleUrls: ['./version.component.scss'] |
||||
}) |
||||
export class VersionComponent implements OnInit { |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
FILE_URL = environment.imageUrl; |
||||
loading = false; |
||||
dataObject: any = {}; |
||||
tableLoading = true; |
||||
searchForm: FormGroup; |
||||
pageNum: number; |
||||
whereObject: any = {}; |
||||
loadingObject = { |
||||
spinning: false, |
||||
msg: '加载中' |
||||
}; |
||||
|
||||
termTypeArray = [ |
||||
{ |
||||
codeValue: 'APP', |
||||
codeName: 'APP' |
||||
} |
||||
]; |
||||
versionTypeArray = [ |
||||
{ |
||||
codeValue: '1', |
||||
codeName: '小版本' |
||||
}, |
||||
{ |
||||
codeValue: '2', |
||||
codeName: '大版本' |
||||
} |
||||
]; |
||||
versionDetailModal = false; |
||||
versionDetailObject: any = {}; |
||||
editVersionModal = false; |
||||
editVersionModalForm: FormGroup; |
||||
versionFileUrl; |
||||
constructor(private store: LocalStorageService, // 数据请求
|
||||
private modal: NzModalService, |
||||
private message: NzMessageService, |
||||
private systemVersionService: SystemVersionService, |
||||
private storeService: StoreService, |
||||
private form: FormBuilder) { } |
||||
|
||||
ngOnInit(): void { |
||||
this.searchForm = this.form.group({ |
||||
termType: [null], |
||||
versionType: [null], |
||||
status: [null], |
||||
}); |
||||
this.editVersionModalForm = this.form.group({ |
||||
id: [null], |
||||
termType: ['APP', [Validators.required]], |
||||
versionType: ['1', [Validators.required]], |
||||
version: [null, [Validators.required]], |
||||
content: [null, [Validators.required]], |
||||
fileUrl: [null], |
||||
}); |
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 请求数据 |
||||
*/ |
||||
requestData(pageNum) { |
||||
this.tableLoading = true; |
||||
this.whereObject['pageNum'] = pageNum; |
||||
this.whereObject['pageSize'] = 10; |
||||
this.systemVersionService.getVersionList(this.whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.dataObject = data['return_data']; |
||||
} else { |
||||
this.modal.error(data['return_msg']); |
||||
} |
||||
this.tableLoading = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 搜索 |
||||
* @param whereObject 条件 |
||||
*/ |
||||
search(whereObject: object) { |
||||
this.whereObject = whereObject; |
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 重置 |
||||
*/ |
||||
resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
/** |
||||
* 展示编辑模态框 |
||||
*/ |
||||
showEditModal(id: number) { |
||||
this.editVersionModal = true; |
||||
} |
||||
|
||||
/** |
||||
* 提交编辑数据 |
||||
*/ |
||||
submitEdit() { |
||||
for (const i in this.editVersionModalForm.controls) { |
||||
this.editVersionModalForm.controls[i].markAsDirty(); |
||||
this.editVersionModalForm.controls[i].updateValueAndValidity(); |
||||
} |
||||
console.log(this.editVersionModalForm.value); |
||||
console.log(this.editVersionModalForm.status); |
||||
if (this.editVersionModalForm.status == null || this.editVersionModalForm.status !== 'VALID') { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '请规范填写所有的必填项信息', |
||||
}); |
||||
return; |
||||
} |
||||
if (this.versionFileUrl == null || this.versionFileUrl.length === 0) { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '未上传更新文件', |
||||
}); |
||||
return; |
||||
} |
||||
this.editVersionModalForm.value.fileUrl = 'https://hsg.dctpay.com/filesystem/' + this.versionFileUrl; |
||||
this.systemVersionService.editVersion(this.editVersionModalForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.modal.success({ |
||||
nzTitle: '提示', |
||||
nzContent: '新增成功', |
||||
nzOnOk: () => this.requestData(1) |
||||
}); |
||||
this.closeEditModal(); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'], |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
/** |
||||
* 关闭编辑模态框 |
||||
*/ |
||||
closeEditModal() { |
||||
this.editVersionModal = false; |
||||
} |
||||
|
||||
/** |
||||
* 弹出发布对话框 |
||||
*/ |
||||
showReleaseConfirm(id: number): void { |
||||
this.modal.confirm({ |
||||
nzTitle: '警告', |
||||
nzContent: '确定发布版本吗?', |
||||
nzOkText: '是', |
||||
nzCancelText: '否', |
||||
nzOkType: 'danger', |
||||
nzOnOk: () => this.requestRelease(id) |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发布数据 |
||||
* |
||||
*/ |
||||
requestRelease(id: number) { |
||||
this.loading = true; |
||||
this.systemVersionService.releaseVersion(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.modal.success({ |
||||
nzTitle: '提示', |
||||
nzContent: '操作成功', |
||||
nzOnOk: () => this.requestData(this.whereObject['pageNum']) |
||||
}); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'] |
||||
}); |
||||
} |
||||
this.loading = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 弹出退款对话框 |
||||
*/ |
||||
showDelConfirm(id: number): void { |
||||
this.modal.confirm({ |
||||
nzTitle: '警告', |
||||
nzContent: '确定删除吗?', |
||||
nzOkText: '是', |
||||
nzCancelText: '否', |
||||
nzOkType: 'danger', |
||||
nzOnOk: () => this.requestDel(id) |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 删除数据 |
||||
* |
||||
*/ |
||||
requestDel(id: number) { |
||||
this.loading = true; |
||||
this.systemVersionService.delVersion(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.modal.success({ |
||||
nzTitle: '提示', |
||||
nzContent: '操作成功', |
||||
nzOnOk: () => this.requestData(this.whereObject['pageNum']) |
||||
}); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'] |
||||
}); |
||||
} |
||||
this.loading = false; |
||||
}); |
||||
} |
||||
|
||||
fileHandleChange(info: { file: NzUploadFile }): void { |
||||
switch (info.file.status) { |
||||
case 'uploading': |
||||
break; |
||||
case 'done': |
||||
this.versionFileUrl = info.file.response.return_data[0]; |
||||
break; |
||||
case 'error': |
||||
this.message.error('上传失败'); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
|
||||
showOpenDetail(data: object) { |
||||
this.versionDetailObject = data; |
||||
this.versionDetailModal = true; |
||||
} |
||||
|
||||
closeVersionDetail() { |
||||
this.versionDetailModal = false; |
||||
} |
||||
} |
@ -0,0 +1,60 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class SystemVersionService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private commonsService: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 编辑版本 |
||||
* @param object |
||||
* @param callBack |
||||
*/ |
||||
editVersion(object: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'sysVersion/editVersion', object).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发布版本 |
||||
* @param id |
||||
* @param callBack |
||||
*/ |
||||
releaseVersion(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'sysVersion/releaseVersion?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 删除版本 |
||||
* @param id |
||||
* @param callBack |
||||
*/ |
||||
delVersion(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'sysVersion/delVersion?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询版本列表 |
||||
* @param paramObject |
||||
* @param callBack |
||||
*/ |
||||
getVersionList(paramObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'sysVersion/getVersionList?' + this.commonsService.getWhereCondition(paramObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue