* 'dev' of http://139.159.177.244:3000/yuanye/high-web:
  完成优惠券导出功能
pull/1/head
袁野 3 years ago
commit 9d87bc02fd
  1. 77
      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,9 +1,9 @@
<!-- start 面包屑 -->
<app-breadcrumb></app-breadcrumb>
<!-- end 面包屑 -->
<!--条件搜索-->
<div class="inner-content">
<nz-spin [nzSpinning]="exportLoading" nzTip="导出中...">
<!--条件搜索-->
<div class="inner-content">
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
<div nz-row>
@ -24,6 +24,7 @@
<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>
@ -39,10 +40,9 @@
</div>
</div>
</form>
</div>
</div>
<div class="inner-content">
<div class="inner-content">
<span>共计 {{total}} 条数据</span>
<span *ngIf="id != null" style="margin-left: 30px;;">
卡券名称:
@ -63,6 +63,7 @@
>
<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"
@ -79,21 +80,23 @@
(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>
<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>
@ -105,9 +108,8 @@
<td nzRight="0px">{{data.status | couponCode}}</td>
</tbody>
</nz-table>
</div>
</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