pull/1/head
parent
64d89bcde7
commit
0a2b69f11a
@ -0,0 +1,168 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">消费码KEY</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="salesCode"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">消费码状态</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select formControlName="status"> |
||||
<nz-option nzValue="1" nzLabel="待销售"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="待使用"></nz-option> |
||||
<nz-option nzValue="3" nzLabel="已使用"></nz-option> |
||||
<nz-option nzValue="4" nzLabel="已过期"></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>共计 {{total}} 条数据</span> |
||||
<span *ngIf="id != null" style="margin-left: 30px;;"> |
||||
卡券名称: |
||||
<span style="font-weight: bold; font-size: 20px">{{name}}({{type === 1 ? '内部卷' : '外部卷'}})</span> |
||||
</span> |
||||
<div class="operating-button"> |
||||
<button *ngIf="type === 1" nz-button nzType="primary" class="right-btn" (click)="showModal()"><i nz-icon |
||||
nzType="import" |
||||
nzTheme="outline"></i>生成消费码 |
||||
</button> |
||||
<nz-upload |
||||
*ngIf="type === 2" |
||||
[nzAccept]="'.xls,.xlsx'" |
||||
nzAction="{{WEB_SERVE_URL}}coupon/importStock?couponId={{id}}" |
||||
[nzHeaders]="{ authorization: 'authorization-text' }" |
||||
(nzChange)="handleChange($event)" |
||||
[nzShowUploadList]="false" |
||||
> |
||||
<button nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>导入消费码</button> |
||||
</nz-upload> |
||||
</div> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="180px">消费码</th> |
||||
<th nzWidth="70px">订单ID</th> |
||||
<th nzWidth="120px">领取时间</th> |
||||
<th nzWidth="120px">消费时间</th> |
||||
<th nzWidth="120px">销售截止时间</th> |
||||
<th nzWidth="120px">使用截止时间</th> |
||||
<th nzWidth="120px">创建时间</th> |
||||
<th nzWidth="80px" nzRight="0px">状态</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i + 1}}</td> |
||||
<td>{{data.salesCode}}</td> |
||||
<td>{{data.orderId == null ? '暂无' : data.orderId}}</td> |
||||
<td>{{data.receiveTime == null ? '未领取' : data.receiveTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.consumeTime == null ? '未消费' : data.consumeTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.useEndTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight="0px">{{data.status | couponCode}}</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="isVisible" nzTitle="生成消费码" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> |
||||
<ng-container> |
||||
<form nz-form [formGroup]="codeForm"> |
||||
<div nz-row> |
||||
<div nz-col nzSpan="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>销售截止日期</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择销售截止日期!"> |
||||
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'salesEndTime'" |
||||
></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'useEndTime'" nzRequired>使用截止日期</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择使用截止日期!"> |
||||
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'useEndTime'" |
||||
></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="12"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'generateNum'" nzRequired>消费码数量</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入消费码!"> |
||||
<input nz-input placeholder="请输入消费码 ..." [formControlName]="'generateNum'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
</form> |
||||
</ng-container> |
||||
</nz-modal> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="handleCancelError()" nzWidth="900px" [nzFooter]="null"> |
||||
<nz-table #errorStudentTable [nzData]="importErrorStudentArray"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px">序号</th> |
||||
<th nzWidth="150px">销售码</th> |
||||
<th nzWidth="150px">销售截止时间</th> |
||||
<th nzWidth="150px">使用截止时间</th> |
||||
<th nzWidth="300px">原因</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of errorStudentTable.data;let i = index"> |
||||
<td>{{ i + 1}}</td> |
||||
<td>{{data.salesCode}}</td> |
||||
<td>{{data.salesEndTime}}</td> |
||||
<td>{{data.useEndTime}}</td> |
||||
<td>{{data.errorMessage}}</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</nz-modal> |
@ -0,0 +1,153 @@ |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {ActivatedRoute} from '@angular/router'; |
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
||||
import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd'; |
||||
import {CouponService} from '../../../services/coupon.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-sales-code-list', |
||||
templateUrl: './sales-code-list.component.html', |
||||
styleUrls: ['./sales-code-list.component.scss'] |
||||
}) |
||||
export class SalesCodeListComponent implements OnInit { |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
codeForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
id = null; |
||||
name: string; |
||||
type: number; |
||||
isVisible = false; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
importErrorStudentArray = []; |
||||
errorStudentVisible = false; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private activatedRoute: ActivatedRoute, |
||||
private message: NzMessageService, |
||||
private modal: NzModalService, |
||||
private coupon: CouponService |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.couponId != null) { |
||||
this.id = queryParams.couponId; |
||||
this.name = queryParams.name; |
||||
this.type = Number(queryParams.type); |
||||
this.searchForm = this.form.group({ |
||||
status: [null], |
||||
salesCode: [null], |
||||
}); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} |
||||
}); |
||||
this.codeForm = this.form.group({ |
||||
salesEndTime: [null, [Validators.required]], |
||||
useEndTime: [null, [Validators.required]], |
||||
generateNum: [null, [Validators.required]], |
||||
}); |
||||
} |
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['couponId'] = this.id; |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.coupon.getCouponCodeList(whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.requestData = data['return_data'].list; |
||||
this.total = data['return_data'].total; |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
// 重置
|
||||
public resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
showModal(): void { |
||||
this.isVisible = true; |
||||
} |
||||
|
||||
handleOk(): void { |
||||
// tslint:disable-next-line:forin
|
||||
for (const i in this.codeForm.controls) { |
||||
this.codeForm.controls[i].markAsDirty(); |
||||
this.codeForm.controls[i].updateValueAndValidity(); |
||||
if (this.codeForm.controls[i].errors != null) { |
||||
this.message.error('必填项不能为空'); |
||||
return; |
||||
} |
||||
} |
||||
this.codeForm.value['couponId'] = this.id; |
||||
this.coupon.writeStock(this.codeForm.value , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.message.success('生成成功'); |
||||
} else { |
||||
this.message.create('error', '生成失败'); |
||||
} |
||||
}); |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
handleCancel(): void { |
||||
console.log('Button cancel clicked!'); |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
handleCancelError(): void { |
||||
this.errorStudentVisible = false; |
||||
} |
||||
|
||||
handleChange(info: NzUploadChangeParam): void { |
||||
if (info.file.status !== 'uploading') { |
||||
console.log(info.file, info.fileList); |
||||
} |
||||
if (info.file.status === 'done') { |
||||
if (info.file.response.return_code === '000000') { |
||||
this.loading = false; |
||||
if (info.file.response.return_data == null || info.file.response.return_data.length === 0) { |
||||
this.message.success('导入成功'); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} else { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzOkText: '查看失败数据', |
||||
nzContent: '只有部分数据导入成功', |
||||
nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) |
||||
}); |
||||
} |
||||
} else { |
||||
this.loading = false; |
||||
this.message.error(info.file.response.return_msg); |
||||
} |
||||
} else if (info.file.status === 'error') { |
||||
this.message.error('上传错误'); |
||||
} |
||||
} |
||||
|
||||
// 打开模态框
|
||||
showErrorStudentModal(data: []) { |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.importErrorStudentArray = data['errorData']; |
||||
this.errorStudentVisible = true; |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'couponCode' |
||||
}) |
||||
export class CouponCodePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '待销售'; |
||||
case 2: |
||||
return '待使用'; |
||||
case 3: |
||||
return '已使用'; |
||||
case 4: |
||||
return '已过期'; |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue