parent
0eaf435888
commit
be6cff36c4
@ -0,0 +1,255 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
优惠包管理 |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
编辑优惠券包 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
|
||||
<div class="inner-content"> |
||||
<div class="main"> |
||||
<nz-steps [nzCurrent]="current"> |
||||
<nz-step nzTitle="配置基本信息"></nz-step> |
||||
<nz-step nzTitle="配置优惠券"></nz-step> |
||||
</nz-steps> |
||||
<form style="margin-top: 30px;" *ngIf="current === 0" nz-form [formGroup]="validateForm"> |
||||
<div nz-row> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>优惠券包标题</nz-form-label> |
||||
<nz-form-control [nzSpan]="8" nzErrorTip="请输入优惠券包标题"> |
||||
<input nz-input type="text" formControlName="title" placeholder="请输入优惠券包标题标题" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>使用归属</nz-form-label> |
||||
<nz-form-control [nzSpan]="8" nzErrorTip="请选择使用归属"> |
||||
<nz-select formControlName="usingAttribution" nzAllowClear nzPlaceHolder="选择使用归属类型"> |
||||
<nz-option *ngFor="let item of usingAttribution" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>优惠券包类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="8" nzErrorTip="请选择优惠券包类型"> |
||||
<nz-select nzShowSearch nzAllowClear formControlName="salesType" nzPlaceHolder="请选择优惠券包类型"> |
||||
<nz-option nzLabel="售卖" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="赠送" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24" *ngIf="validateForm.value['salesType'] === '1'"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>售卖价格</nz-form-label> |
||||
<nz-form-control [nzSpan]="8" nzErrorTip="请输入售卖价格"> |
||||
<nz-input-group nzSuffix="RMB" nzPrefix="¥"> |
||||
<input type="text" formControlName="price" placeholder="请输入售卖价格" nz-input /> |
||||
</nz-input-group> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24" *ngIf="validateForm.value['salesType'] === '1'"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>限购数量</nz-form-label> |
||||
<nz-form-control [nzSpan]="8" nzErrorTip="请输入限购数量"> |
||||
<nz-input-number formControlName="purchaseNum" [nzMin]="1" [nzMax]="99" [nzStep]="1"></nz-input-number> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>列表展示图</nz-form-label> |
||||
<nz-form-control [nzSpan]="8"> |
||||
<nz-upload |
||||
nzAction="{{POST_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="listImg" |
||||
[nzShowButton]="listImg.length < 1" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>轮播展示图</nz-form-label> |
||||
<nz-form-control [nzSpan]="8"> |
||||
<nz-upload |
||||
nzAction="{{POST_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[nzMultiple]="true" |
||||
[(nzFileList)]="bannerImg" |
||||
[nzShowButton]="bannerImg.length < 5" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="3" nzRequired>详情展示图</nz-form-label> |
||||
<nz-form-control [nzSpan]="8"> |
||||
<nz-upload |
||||
nzAction="{{POST_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="detailsImg" |
||||
[nzMultiple]="true" |
||||
[nzShowButton]="detailsImg.length < 5" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modal" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modal> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
<div style="margin-top: 60px;" *ngIf="current === 1"> |
||||
<span>共计 {{11}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" (click)="getAdd()" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
</div> |
||||
<nz-table #basicTable [nzData]="listOfData"> |
||||
<thead> |
||||
<tr> |
||||
<th>奖励名称</th> |
||||
<th>数量</th> |
||||
<th>图片</th> |
||||
<th>操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data"> |
||||
<td>{{ data.name }}</td> |
||||
<td>{{ data.num }}</td> |
||||
<td> |
||||
<img class="head_img" src="{{FILE_URL + data.img}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt=""> |
||||
</td> |
||||
<td> |
||||
<a (click)="deleteActivateAward(data.id)">删除</a> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
|
||||
</div> |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="24" class="search-area"> |
||||
<button nz-button [nzType]="'primary'" (click)="pre()">上一步</button> |
||||
<button nz-button [nzType]="'primary'" (click)="getNest()">{{current == 0 ? '下一步': '提交'}}</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="isVisible" nzTitle="配置奖励" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> |
||||
<div class="title">基本信息</div> |
||||
<form nz-form [formGroup]="validateFormAward" class="login-form"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>奖励名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入奖励名称"> |
||||
<input nz-input type="text" formControlName="name" placeholder="请输入奖励名称" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>奖励数量</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入奖励数量"> |
||||
<input nz-input type="number" formControlName="num" placeholder="请输入奖励名称" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>奖励图片</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-upload |
||||
nzAction="{{POST_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="logoFile" |
||||
[nzShowButton]="logoFile.length < 1" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</form> |
||||
<div class="title" >奖品信息</div> |
||||
<div nz-row *ngFor="let control of listOfControl; let i = index"> |
||||
<div nz-col class="gutter-row" [nzSpan]="20"> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>代理商</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请选择代理商"> |
||||
<nz-select *ngIf="control.isEdit" nzShowSearch nzAllowClear [(ngModel)]="control.agentId" (ngModelChange)="getDiscount($event , i)" nzPlaceHolder="请选择代理商状态"> |
||||
<nz-option *ngFor="let item of agentData" nzLabel="{{item.agentName}}" nzValue="{{item.id}}"></nz-option> |
||||
</nz-select> |
||||
<span *ngIf="!control.isEdit">{{control.agentName}}</span> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>优惠券</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请选择优惠券"> |
||||
<nz-select *ngIf="control.isEdit" nzShowSearch nzAllowClear [(ngModel)]="control.prizeId" (ngModelChange)="getDiscountName($event , i)" nzPlaceHolder="请选择优惠券"> |
||||
<nz-option *ngFor="let item of discountList" nzLabel="{{item['highDiscount'].discountName}}" nzValue="{{item['highDiscount'].id}}"></nz-option> |
||||
</nz-select> |
||||
<span *ngIf="!control.isEdit">{{control.prizeName}}</span> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>奖励数量</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入奖励数量"> |
||||
<input nz-input type="number" *ngIf="control.isEdit" [(ngModel)]="control.prizeNum" placeholder="请输入奖励数量" /> |
||||
<span *ngIf="!control.isEdit">{{control.prizeNum}}</span> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
<div nz-col class="gutter-row" [nzSpan]="4"> |
||||
<button nz-button nzType="default" (click)="removeField(i , $event)"><i nz-icon nzType="delete" nzTheme="outline"></i>删除</button> |
||||
<br/> |
||||
<button class="btn" *ngIf="control.isEdit" nz-button nzType="primary" (click)="addField(i)"><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
</div> |
||||
</div> |
||||
</nz-modal> |
@ -0,0 +1,66 @@ |
||||
.main { |
||||
width: 90%; |
||||
margin-left: 5%; |
||||
.idCard { |
||||
img { |
||||
width: 200px; |
||||
} |
||||
.userImg { |
||||
width: 90px; |
||||
} |
||||
} |
||||
.post_p_l { |
||||
margin-left: 5% ; |
||||
} |
||||
.main_post_p { |
||||
font-size: 12px; |
||||
color: #999999; |
||||
margin-top: -10px; |
||||
} |
||||
.btn { |
||||
margin-top: 20px; |
||||
} |
||||
.bottom_solid { |
||||
border-bottom: 1px solid #e4e4e4; |
||||
} |
||||
.btn-post { |
||||
width: 20%; |
||||
margin-left: 40%; |
||||
margin-top: 40px; |
||||
} |
||||
|
||||
} |
||||
.pics{ |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
} |
||||
.pic{ |
||||
width:10rem; |
||||
height:8rem; |
||||
margin-right: 1rem; |
||||
position: relative; |
||||
} |
||||
.delPic{ |
||||
width:1rem !important; |
||||
height:1rem; |
||||
position: absolute; |
||||
right: -10px;top:-10px; |
||||
} |
||||
.btn { |
||||
margin-top: 20px; |
||||
} |
||||
.title { |
||||
width: 100%; |
||||
height: 46px; |
||||
line-height: 46px; |
||||
font-size: 16px; |
||||
text-align: center; |
||||
color: #1890ff; |
||||
background-color: #f3f9ff; |
||||
margin-bottom: 20px; |
||||
} |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,409 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
||||
import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {ActivatedRoute} from '_@angular_router@9.0.7@@angular/router'; |
||||
import {CouponService} from '../../../services/coupon.service'; |
||||
import {ActivateService} from '../../../services/activate.service'; |
||||
import {NzUploadFile} from 'ng-zorro-antd'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {AgentService} from '../../../services/agent.service'; |
||||
import {CommonsService} from "../../../services/commons.service"; |
||||
import {DiscountPackageService} from "../../../services/discount-package.service"; |
||||
|
||||
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
||||
return new Promise((resolve, reject) => { |
||||
const reader = new FileReader(); |
||||
reader.readAsDataURL(file); |
||||
reader.onload = () => resolve(reader.result); |
||||
reader.onerror = error => reject(error); |
||||
}); |
||||
} |
||||
|
||||
@Component({ |
||||
selector: 'app-discount-package-edit', |
||||
templateUrl: './discount-package-edit.component.html', |
||||
styleUrls: ['./discount-package-edit.component.scss'] |
||||
}) |
||||
export class DiscountPackageEditComponent implements OnInit { |
||||
|
||||
validateForm!: FormGroup; |
||||
validateFormAward!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
agentId: number; |
||||
listOfOption: string[] = []; |
||||
listOfData = []; |
||||
agentData = []; |
||||
usingAttribution = []; |
||||
current = 0; |
||||
listOfControl = [{ |
||||
isEdit: true, |
||||
agentId: null, |
||||
agentName: null, |
||||
prizeNum: null, |
||||
prizeId: null, |
||||
prizeName: null, |
||||
loading : false |
||||
}]; |
||||
FILE_URL = environment.imageUrl; |
||||
POST_URL = environment.baseUrl; |
||||
isVisible = false; |
||||
logoFile = []; |
||||
previewImage: string | undefined = ''; |
||||
previewVisible = false; |
||||
discountList = []; // 列表数据
|
||||
|
||||
listImg = []; |
||||
bannerImg = []; |
||||
detailsImg = []; |
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private coupon: CouponService, |
||||
private activate: ActivateService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
private agent: AgentService, |
||||
private commonsService: CommonsService, |
||||
private disCountPackage: DiscountPackageService, |
||||
) { } |
||||
|
||||
ngOnInit(): void { |
||||
this.commonsService.getDictionary('USING_ATTRIBUTION', data => { |
||||
this.usingAttribution = data['return_data']; |
||||
}); |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.id != null) { |
||||
this.editFlag = true; |
||||
this.id = queryParams.id; |
||||
this.getDetails(queryParams.id); |
||||
} |
||||
}); |
||||
this.validateForm = this.fb.group({ |
||||
title: [null, [Validators.required]], |
||||
usingAttribution: [null, [Validators.required]], |
||||
salesType: [null, [Validators.required]], |
||||
price: [null], |
||||
purchaseNum: [null], |
||||
}); |
||||
|
||||
this.validateFormAward = this.fb.group({ |
||||
name: [null, [Validators.required]], |
||||
num: [null, [Validators.required]], |
||||
}); |
||||
|
||||
const whereObject = { |
||||
pageNum: 1 , |
||||
pageSize: 800 , |
||||
status: 2 |
||||
}; |
||||
|
||||
const whereObjectA = { |
||||
pageNum: 1 , |
||||
pageSize: 800 , |
||||
type: 1 |
||||
}; |
||||
|
||||
this.getCouponList(whereObject); |
||||
this.getListAgent(whereObjectA); |
||||
|
||||
|
||||
} |
||||
|
||||
public getCouponList(whereObject) { |
||||
whereObject.status = 2; |
||||
this.coupon.getCouponList(whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.listOfOption = data['return_data'].list; |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 绑定优惠券
|
||||
public getDiscount(id: number , i ): void { |
||||
this.listOfControl[i].agentName = this.agentData.find(item => { |
||||
return item.id === id; |
||||
}).agentName; |
||||
this.agentId = id; |
||||
const whereObject = {}; |
||||
whereObject['pageNum'] = 1; |
||||
whereObject['pageSize'] = 10000; |
||||
whereObject['agentId'] = id; |
||||
this.agent.getDiscountAgentList(whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.discountList = data['return_data'].list; |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
getDiscountName(id: number , i ) { |
||||
this.listOfControl[i].prizeName = this.discountList.find(item => { |
||||
return item['highDiscount'].id === id; |
||||
})['highDiscount'].discountName; |
||||
console.log(this.listOfControl); |
||||
} |
||||
|
||||
public getListAgent(whereObject) { |
||||
this.agent.getListAgent(whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.agentData = data['return_data'].list; |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 图片查看
|
||||
handlePreview = async (file: NzUploadFile) => { |
||||
if (!file.url && !file.preview) { |
||||
// tslint:disable-next-line:no-non-null-assertion
|
||||
file.preview = await getBase64(file.originFileObj!); |
||||
} |
||||
this.previewImage = file.url || file.preview; |
||||
this.previewVisible = true; |
||||
} |
||||
|
||||
// 返回
|
||||
getBack() { |
||||
history.back(); |
||||
} |
||||
|
||||
// 重置
|
||||
public resetForm(): void { |
||||
this.validateForm.reset(); |
||||
} |
||||
|
||||
// 基本信息提交
|
||||
public editInfo(): void { |
||||
// tslint:disable-next-line:forin
|
||||
for (const i in this.validateForm.controls) { |
||||
this.validateForm.controls[i].markAsDirty(); |
||||
this.validateForm.controls[i].updateValueAndValidity(); |
||||
if (this.validateForm.controls[i].errors != null) { |
||||
this.message.error('必填项不能为空'); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
// 图片判断
|
||||
this.imgIsPost(); |
||||
|
||||
|
||||
if (this.editFlag) { |
||||
this.validateForm.value.id = this.id; |
||||
this.disCountPackage.updateCouponPackageInfo(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.editFlag = true; |
||||
this.id = data['return_data'].id; |
||||
this.current += 1; |
||||
this.message.success('编辑成功'); |
||||
} else { |
||||
this.message.create('error', '编辑失败'); |
||||
} |
||||
}); |
||||
} else { |
||||
this.disCountPackage.insertCouponPackageInfo(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.editFlag = true; |
||||
this.id = data['return_data'].id; |
||||
this.current += 1; |
||||
this.message.success('编辑成功'); |
||||
} else { |
||||
this.message.create('error', '编辑失败'); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
public imgIsPost(): boolean { |
||||
if (this.listImg.length !== 0) { |
||||
if (this.listImg[0]['response'] != null) { |
||||
this.validateForm.value.couponImg = this.listImg[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.couponImg = this.listImg[0].name; |
||||
} |
||||
} else { |
||||
this.message.error('请上传列表图片'); |
||||
return false; |
||||
} |
||||
|
||||
const bannerImg = []; |
||||
|
||||
if (this.bannerImg.length !== 0) { |
||||
for (const i of this.bannerImg) { |
||||
if (i['response'] != null) { |
||||
bannerImg.push(i['response']['return_data'][0]); |
||||
} else { |
||||
bannerImg.push(i.name); |
||||
} |
||||
} |
||||
} else { |
||||
this.message.error('请上传轮播展示图'); |
||||
return false; |
||||
} |
||||
const detailsImg = []; |
||||
|
||||
if (this.detailsImg.length !== 0) { |
||||
for (const i of this.detailsImg) { |
||||
if (i['response'] != null) { |
||||
detailsImg.push(i['response']['return_data'][0]); |
||||
} else { |
||||
detailsImg.push(i.name); |
||||
} |
||||
} |
||||
} else { |
||||
this.message.error('请上传详情展示图'); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
// 查询详情
|
||||
public getDetails(id) { |
||||
this.activate.getDetailById(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
data['return_data'].time = [new Date(data['return_data']['startTime']), new Date(data['return_data']['endTime'])]; |
||||
data['return_data'].type = String(data['return_data'].type); |
||||
data['return_data'].productIdArray = data['return_data'].ruleArray[0].productIdArray; |
||||
this.validateForm.patchValue(data['return_data']); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
this.getListByActivityId(id); |
||||
|
||||
} |
||||
|
||||
getListByActivityId(id: number ) { |
||||
this.activate.getListByActivityId(id , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.listOfData = data['return_data']; |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 上一步
|
||||
pre(): void { |
||||
this.current -= 1; |
||||
} |
||||
|
||||
// 下一步
|
||||
getNest(): void { |
||||
if (this.current === 0) { |
||||
this.editInfo(); |
||||
} else { |
||||
history.back(); |
||||
} |
||||
|
||||
} |
||||
|
||||
// 完成
|
||||
done(): void { |
||||
|
||||
} |
||||
|
||||
// 新增
|
||||
addField(i): void { |
||||
if ( |
||||
this.listOfControl[i].prizeId == null || |
||||
this.listOfControl[i].prizeNum == null || |
||||
this.listOfControl[i].agentId == null |
||||
) { |
||||
this.message.error('请填写必填项!'); |
||||
return; |
||||
} |
||||
this.listOfControl[i].isEdit = false; |
||||
const control = { |
||||
isEdit: true, |
||||
agentId: null, |
||||
agentName: null, |
||||
prizeNum: null, |
||||
prizeId: null, |
||||
prizeName: null, |
||||
loading : false |
||||
}; |
||||
this.listOfControl.push(control); |
||||
|
||||
} |
||||
|
||||
// 删除资质
|
||||
removeField(i, e: MouseEvent): void { |
||||
e.preventDefault(); |
||||
if (this.listOfControl.length > 1) { |
||||
this.listOfControl.splice(i, 1); |
||||
this.listOfControl[i - 1].isEdit = true; |
||||
} |
||||
} |
||||
|
||||
|
||||
// 添加配置
|
||||
getAdd(): void { |
||||
this.isVisible = true; |
||||
} |
||||
|
||||
|
||||
handleOk(): void { |
||||
|
||||
// tslint:disable-next-line:forin
|
||||
for (const i in this.validateFormAward.controls) { |
||||
this.validateFormAward.controls[i].markAsDirty(); |
||||
this.validateFormAward.controls[i].updateValueAndValidity(); |
||||
if (this.validateFormAward.controls[i].errors != null) { |
||||
this.message.error('必填项不能为空'); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
if ( |
||||
this.listOfControl[this.listOfControl.length - 1].prizeId == null || |
||||
this.listOfControl[this.listOfControl.length - 1].prizeNum == null || |
||||
this.listOfControl[this.listOfControl.length - 1].agentId == null |
||||
) { |
||||
this.message.error('请填写必填项!'); |
||||
return; |
||||
} |
||||
|
||||
this.validateFormAward.value.activityPrizes = this.listOfControl; |
||||
this.validateFormAward.value.activityInfoId = this.id; |
||||
if (this.logoFile.length !== 0) { |
||||
if (this.logoFile[0]['response'] != null) { |
||||
this.validateFormAward.value.img = this.logoFile[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateFormAward.value.img = this.logoFile[0].name; |
||||
} |
||||
} |
||||
this.message.loading('生成奖品中!'); |
||||
this.activate.editActivityAward(this.validateFormAward.value , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.isVisible = false; |
||||
this.getListByActivityId(this.id); |
||||
this.message.success('编辑成功'); |
||||
} else { |
||||
this.message.create('error', '编辑失败'); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
handleCancel(): void { |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
|
||||
deleteActivateAward(id: number) { |
||||
this.activate.deleteActivateAward(id , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getListByActivityId(this.id); |
||||
this.message.success('成功'); |
||||
} else { |
||||
this.message.create('error', '编辑失败'); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,118 @@ |
||||
<!-- 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">优惠券包名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="title"/> |
||||
</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 nzShowSearch nzAllowClear formControlName="salesType" nzPlaceHolder="请选择类型"> |
||||
<nz-option nzLabel="售卖" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="赠送" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</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="usingAttribution" nzAllowClear nzPlaceHolder="选择类型"> |
||||
<nz-option *ngFor="let item of usingAttribution" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</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 nzShowSearch nzAllowClear formControlName="status" nzPlaceHolder="请选择优惠券包状态"> |
||||
<nz-option nzLabel="上架中" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="下架中" nzValue="2"></nz-option> |
||||
<nz-option nzLabel="编辑中" nzValue="3"></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> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/discount-package/discount-package-edit']" ><i nz-icon nzType="plus" 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="50px">编号</th> |
||||
<th nzWidth="150px">活动标题</th> |
||||
<th nzWidth="70px">活动类型</th> |
||||
<th nzWidth="100px">开始时间</th> |
||||
<th nzWidth="100px">结束时间</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="80px" nzRight>活动状态</th> |
||||
<th nzWidth="120px" nzRight>操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.title}}</td> |
||||
<td>{{data.type | type}}</td> |
||||
<td>{{data.startTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.endTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight>{{data.status | status}}</td> |
||||
<td nzRight class="table-td-operation"> |
||||
<a *ngIf="data.status == 1" (click)="getEdit(data.id)">编辑</a> |
||||
<a (click)="startActivity(data.id)" *ngIf="data.status == 1">发布</a> |
||||
<a (click)="endActivity(data.id)" *ngIf="data.status == 2">结束</a> |
||||
<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><a (click)='jumpLotteryRecord(data.id )'>中奖记录</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
|
@ -0,0 +1,3 @@ |
||||
.table-td-operation a { |
||||
margin-right: 8px; |
||||
} |
@ -0,0 +1,125 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {FormBuilder, FormGroup} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {CompanyService} from '../../../services/company.service'; |
||||
import {ActivateService} from '../../../services/activate.service'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {Router} from '_@angular_router@9.0.7@@angular/router'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {DiscountPackageService} from '../../../services/discount-package.service'; |
||||
|
||||
@Component({ |
||||
selector: 'app-discount-package-list', |
||||
templateUrl: './discount-package-list.component.html', |
||||
styleUrls: ['./discount-package-list.component.scss'] |
||||
}) |
||||
export class DiscountPackageListComponent implements OnInit { |
||||
|
||||
WEB_SERVE_URL = environment.imageUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
usingAttribution = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private company: CompanyService, |
||||
private activate: ActivateService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private router: Router, |
||||
private discountPackage: DiscountPackageService, |
||||
private commonsService: CommonsService, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
} |
||||
|
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
title: [null], |
||||
salesType: [null], |
||||
usingAttribution: [null], |
||||
status: [null], |
||||
}); |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.commonsService.getDictionary('USING_ATTRIBUTION ', data => { |
||||
this.usingAttribution = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.discountPackage.getDiscountPackageList(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(); |
||||
} |
||||
|
||||
// 活动开始
|
||||
public startActivity(id: number): void { |
||||
this.activate.startActivity({activityId : id}, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.message.success(data['return_msg']); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 活动结束
|
||||
public endActivity(id: number): void { |
||||
this.activate.endActivity({activityId : id}, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.message.success(data['return_msg']); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 修改
|
||||
public getEdit(id: number): void { |
||||
this.router.navigate(['/admin/discount-package/discount-package-edit'], { |
||||
queryParams: { |
||||
id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 跳转中奖记录
|
||||
public jumpLotteryRecord(id: number): void { |
||||
this.router.navigate(['/admin/activate/activate-lottery-record'], { |
||||
queryParams: { |
||||
activityId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,16 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {DiscountPackageListComponent} from './discount-package-list/discount-package-list.component'; |
||||
import {DiscountPackageEditComponent} from './discount-package-edit/discount-package-edit.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'discount-package-list', component: DiscountPackageListComponent }, |
||||
{ path: 'discount-package-edit', component: DiscountPackageEditComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class DiscountPackageRoutingModule { } |
@ -0,0 +1,29 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { DiscountPackageRoutingModule } from './discount-package-routing.module'; |
||||
import { DiscountPackageListComponent } from './discount-package-list/discount-package-list.component'; |
||||
import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; |
||||
import {AppCommonModule} from '../../app-common.module'; |
||||
import { DiscountPackageEditComponent } from './discount-package-edit/discount-package-edit.component'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [DiscountPackageListComponent, DiscountPackageEditComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
DiscountPackageRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
RegionSelectorModule, |
||||
AppCommonModule |
||||
] |
||||
}) |
||||
export class DiscountPackageModule { } |
@ -0,0 +1,49 @@ |
||||
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 DiscountPackageService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @methodName getDiscountPackageList |
||||
* @Description // 查询优惠券包列表
|
||||
* @Date 3:16 下午 2021/11/29 |
||||
* @Param [paramsObject , callBack] |
||||
*/ |
||||
public getDiscountPackageList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'highDiscountPackage/getDiscountPackageList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @methodName insertCouponPackageInfo |
||||
* @Description // 配置优惠券包基本信息
|
||||
* @Date 5:18 下午 2021/11/29 |
||||
* @Param [params: object, callBack] |
||||
*/ |
||||
public insertCouponPackageInfo(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highDiscountPackage/insertCouponPackageInfo', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
public updateCouponPackageInfo(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highDiscountPackage/updateCouponPackageInfo', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue