* 'dev' of http://139.159.177.244:3000/yuanye/high-web:
  完成优惠券导出功能
pull/1/head
袁野 3 years ago
commit 9d87bc02fd
  1. 241
      src/app/admin/coupon/sales-code-list/sales-code-list.component.html
  2. 48
      src/app/admin/coupon/sales-code-list/sales-code-list.component.ts
  3. 2
      src/app/pipes/coupon-code.pipe.ts
  4. 13
      src/app/services/coupon.service.ts

@ -1,113 +1,115 @@
<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<nz-spin [nzSpinning]="exportLoading" nzTip="导出中...">
<!--条件搜索-->
<div class="inner-content">
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
<div nz-row>
<!--条件搜索-->
<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 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-option nzValue="99" nzLabel="预支付"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</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 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>
</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>
</form>
</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="180px">是否分发</th>
<th nzWidth="120px">使用门店</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.isAssignAgent === true ? '已分发' : '未分发'}}</td>
<td>{{data.storeName == null ? '暂无' : data.storeName}}</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>
<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>
<button (click)="showExportSalesCodeModal()" nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>导出消费码</button>
</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="60px">序号</th>
<th nzWidth="200px">消费码key</th>
<th nzWidth="230px">消费码</th>
<th nzWidth="100px">是否分发</th>
<th nzWidth="150px">使用门店</th>
<th nzWidth="150px">领取时间</th>
<th nzWidth="150px">消费时间</th>
<th nzWidth="150px">销售截止时间</th>
<th nzWidth="150px">使用截止时间</th>
<th nzWidth="150px">创建时间</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.codeKey}}</td>
<td>{{data.salesCode}}</td>
<td>{{data.isAssignAgent === true ? '已分发' : '未分发'}}</td>
<td>{{data.storeName == null ? '暂无' : data.storeName}}</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-spin>
<nz-modal [(nzVisible)]="isVisible" nzTitle="生成消费码" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<ng-container>
<form nz-form [formGroup]="codeForm">
@ -168,3 +170,40 @@
</tbody>
</nz-table>
</nz-modal>
<nz-modal [(nzVisible)]="exportSalesCodeModal" nzTitle="导出销售码" (nzOnCancel)="closeExportSalesCodeModal()" [nzFooter]="null">
<nz-spin [nzSpinning]="exportLoading" nzTip="导出中...">
<form nz-form [formGroup]="exportSalesCodeForm" >
<nz-form-item>
<nz-form-label [nzSm]="4" [nzXs]="24">
<span><i nz-icon nz-tooltip nzTooltipTitle="创建时间:导入销售码的时间 或 生成销售码的时间" nzType="question-circle" nzTheme="outline"></i>创建时间</span>
</nz-form-label>
<nz-form-control [nzSm]="18" [nzXs]="24">
<nz-range-picker formControlName="createTime"
[nzFormat]="'yyyy-MM-dd HH:mm:ss'"
[nzShowTime]="{ nzHideDisabledOptions: true }"
></nz-range-picker>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="4" [nzXs]="24">
<span>销售码状态</span>
</nz-form-label>
<nz-form-control [nzSm]="18" [nzXs]="24">
<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-option nzValue="99" nzLabel="预支付"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<div *nzModalFooter style="text-align: center;">
<button nz-button nzType="primary" [nzLoading]="exportLoading" (click)="exportSalesCodeData()">导出销售码</button>
</div>
</form>
</nz-spin>
</nz-modal>

@ -11,7 +11,7 @@ import {environment} from '../../../../environments/environment';
styleUrls: ['./sales-code-list.component.scss']
})
export class SalesCodeListComponent implements OnInit {
FILE_URL = environment.imageUrl;
searchForm: FormGroup; // 搜索框
codeForm: FormGroup; // 搜索框
requestData = []; // 列表数据
@ -19,6 +19,7 @@ export class SalesCodeListComponent implements OnInit {
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
exportLoading = false;
id = null;
name: string;
type: number;
@ -27,6 +28,9 @@ export class SalesCodeListComponent implements OnInit {
importErrorStudentArray = [];
errorStudentVisible = false;
exportSalesCodeModal = false;
exportSalesCodeForm: FormGroup;
constructor(
private form: FormBuilder,
private activatedRoute: ActivatedRoute,
@ -54,6 +58,11 @@ export class SalesCodeListComponent implements OnInit {
useEndTime: [null, [Validators.required]],
generateNum: [null, [Validators.required]],
});
this.exportSalesCodeForm = this.form.group({
createTime: [null],
status: [null],
});
}
// 查询列表
@ -147,4 +156,41 @@ export class SalesCodeListComponent implements OnInit {
this.importErrorStudentArray = data['errorData'];
this.errorStudentVisible = true;
}
/**
*
*/
showExportSalesCodeModal() {
this.exportSalesCodeModal = true;
}
/**
*
*/
exportSalesCodeData() {
this.exportLoading = true;
this.exportSalesCodeForm.value['couponId'] = this.id;
if (this.exportSalesCodeForm.value.createTime != null) {
this.exportSalesCodeForm.value['createTimeS'] = this.exportSalesCodeForm.value.createTime[0];
this.exportSalesCodeForm.value['createTimeE'] = this.exportSalesCodeForm.value.createTime[1];
} else {
this.exportSalesCodeForm.value['createTimeS'] = null;
this.exportSalesCodeForm.value['createTimeE'] = null;
}
this.coupon.exportStock(this.exportSalesCodeForm.value, data => {
if (data['return_code'] === '000000') {
window.location.href = this.FILE_URL + 'temporary/' + data['return_data'];
} else {
this.message.error(data['return_msg']);
}
this.exportLoading = false;
});
}
/**
*
*/
closeExportSalesCodeModal() {
this.exportSalesCodeModal = true;
}
}

@ -15,6 +15,8 @@ export class CouponCodePipe implements PipeTransform {
return '已使用';
case 4:
return '已过期';
case 99:
return '预支付';
}
}

@ -119,5 +119,18 @@ export class CouponService {
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public exportStock(params: object, callBack) {
this.http.post(environment.baseUrl + 'coupon/exportStock', params).subscribe(data => {
callBack(data);
});
}
}

Loading…
Cancel
Save