pull/1/head
袁野 3 years ago
parent be6cff36c4
commit dd8e297741
  1. 71
      src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.html
  2. 72
      src/app/admin/discount-package/discount-package-edit/discount-package-edit.component.ts
  3. 31
      src/app/admin/discount-package/discount-package-list/discount-package-list.component.html
  4. 6
      src/app/admin/discount/discount-edit/discount-edit.component.html
  5. 5
      src/app/admin/discount/discount-edit/discount-edit.component.ts
  6. 2
      src/app/app-common.module.ts
  7. 19
      src/app/pipes/discount-package-status.pipe.ts
  8. 1
      src/app/pipes/index.ts
  9. 1
      src/app/services/discount-package.service.ts

@ -175,9 +175,17 @@
<nz-modal [(nzVisible)]="isVisible" nzTitle="配置奖励" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<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="请选择优惠券范围">
<nz-select formControlName="usingScope" (ngModelChange)="getDiscountPackageByList($event)" nzAllowClear nzPlaceHolder="请选择优惠券使用范围">
<nz-option *ngFor="let item of usingScope" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></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]="16" nzErrorTip="请输入奖励名称">
@ -190,66 +198,5 @@
<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>

@ -9,6 +9,7 @@ import {environment} from '../../../../environments/environment';
import {AgentService} from '../../../services/agent.service';
import {CommonsService} from "../../../services/commons.service";
import {DiscountPackageService} from "../../../services/discount-package.service";
import {DiscountService} from "../../../services/discount.service";
function getBase64(file: File): Promise<string | ArrayBuffer | null> {
return new Promise((resolve, reject) => {
@ -53,10 +54,13 @@ export class DiscountPackageEditComponent implements OnInit {
previewImage: string | undefined = '';
previewVisible = false;
discountList = []; // 列表数据
usingScope = []; // 列表数据
listImg = [];
bannerImg = [];
detailsImg = [];
constructor(
private fb: FormBuilder,
private coupon: CouponService,
@ -66,12 +70,16 @@ export class DiscountPackageEditComponent implements OnInit {
private agent: AgentService,
private commonsService: CommonsService,
private disCountPackage: DiscountPackageService,
private discount: DiscountService
) { }
ngOnInit(): void {
this.commonsService.getDictionary('USING_ATTRIBUTION', data => {
this.usingAttribution = data['return_data'];
});
this.commonsService.getDictionary('USING_RANGE', data => {
this.usingScope = data['return_data'];
});
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.id != null) {
this.editFlag = true;
@ -88,8 +96,9 @@ export class DiscountPackageEditComponent implements OnInit {
});
this.validateFormAward = this.fb.group({
name: [null, [Validators.required]],
getDiscountId: [null, [Validators.required]],
num: [null, [Validators.required]],
useScope: [null, [Validators.required]],
});
const whereObject = {
@ -103,50 +112,11 @@ export class DiscountPackageEditComponent implements OnInit {
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') {
@ -223,9 +193,9 @@ export class DiscountPackageEditComponent implements OnInit {
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];
this.validateForm.value.listImg = this.listImg[0]['response']['return_data'][0];
} else {
this.validateForm.value.couponImg = this.listImg[0].name;
this.validateForm.value.listImg= this.listImg[0].name;
}
} else {
this.message.error('请上传列表图片');
@ -260,11 +230,13 @@ export class DiscountPackageEditComponent implements OnInit {
this.message.error('请上传详情展示图');
return false;
}
this.validateForm.value.bannerImg = bannerImg.join(',');
this.validateForm.value.detailsImg = detailsImg.join(',');
}
// 查询详情
public getDetails(id) {
this.activate.getDetailById(id, data => {
this.disCountPackage.getDiscountPackageList(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);
@ -406,4 +378,18 @@ export class DiscountPackageEditComponent implements OnInit {
}
});
}
public getDiscountPackageByList(e): void {
const params = {
pageNum: 1,
pageSize: 10000,
useScope: e
};
this.discount.getDiscountList(params , data => {
this.discountList = data['return_data'].list;
console.log(data);
});
}
}

@ -81,10 +81,10 @@
<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="150px">优惠券标题</th>
<th nzWidth="70px">销售类型</th>
<th nzWidth="70px">销售价格</th>
<th nzWidth="70px">限购数量</th>
<th nzWidth="100px">创建时间</th>
<th nzWidth="80px" nzRight>活动状态</th>
<th nzWidth="120px" nzRight>操作</th>
@ -94,21 +94,16 @@
<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>{{data.salesType === 1 ? '售卖' : '赠送'}}</td>
<td>{{data.price === null ? '暂无': data.price}}</td>
<td>{{data.purchaseNum === null? '暂无': data.purchaseNum}}</td>
<td>{{data.createdTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight>{{data.status | discountPackageStatus}}</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>
<a *ngIf="data.status == 3" (click)="getEdit(data.id)">编辑</a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="startActivity(data.id)" *ngIf="data.status == 2 || data.status == 3">上架</a>
<a (click)="endActivity(data.id)" *ngIf="data.status == 1">下架</a>
</td>
</tbody>
</nz-table>

@ -34,10 +34,10 @@
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'usingRange'" nzRequired>优惠券使用范围</nz-form-label>
<nz-form-label [nzFor]="'usingScope'" nzRequired>优惠券使用范围</nz-form-label>
<nz-form-control nzErrorTip="请选择优惠券使用范围!">
<nz-select formControlName="usingRange" nzAllowClear nzPlaceHolder="请选择优惠券使用范围">
<nz-option *ngFor="let item of usingRange" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
<nz-select formControlName="usingScope" nzAllowClear nzPlaceHolder="请选择优惠券使用范围">
<nz-option *ngFor="let item of usingScope" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>

@ -29,6 +29,7 @@ export class DiscountEditComponent implements OnInit {
id: number;
discountImg = [];
usingRange = [];
usingScope = [];
WEB_SERVE_URL = environment.baseUrl;
previewImage: string | undefined = '';
previewVisible = false;
@ -57,7 +58,7 @@ export class DiscountEditComponent implements OnInit {
discountType: [null, [Validators.required]],
discountPrice: [null, [Validators.required]],
salesEndTime: [null, [Validators.required]],
usingRange: [null, [Validators.required]],
usingScope: [null, [Validators.required]],
effectiveDay: [1, [Validators.required]],
status: [null],
createTime: [null],
@ -65,7 +66,7 @@ export class DiscountEditComponent implements OnInit {
});
this.commonsService.getDictionary('USING_RANGE', data => {
this.usingRange = data['return_data'];
this.usingScope = data['return_data'];
});
}

@ -35,6 +35,7 @@ import {
} from './pipes';
import { PreOrderStatusPipe } from './pipes/order/pre-order-status.pipe';
import { ButtonPipe } from './pipes/commons/button.pipe';
import { DiscountPackageStatusPipe } from './pipes/discount-package-status.pipe';
@ -64,6 +65,7 @@ const PIPES = [
RefundStatusPipe,
PreOrderStatusPipe,
ButtonPipe,
DiscountPackageStatusPipe,
];

@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'discountPackageStatus'
})
export class DiscountPackageStatusPipe implements PipeTransform {
transform(value: number): string {
switch (value) {
case 1:
return '上架中';
case 2:
return '下架中';
case 3:
return '编辑中';
}
}
}

@ -22,3 +22,4 @@ export * from './audit/refund-source.pipe';
export * from './audit/refund-status.pipe';
export * from './order/pre-order-status.pipe';
export * from './commons/button.pipe';
export * from './discount-package-status.pipe';

@ -28,6 +28,7 @@ export class DiscountPackageService {
}
/**
* @Author Sum1Dream
* @methodName insertCouponPackageInfo

Loading…
Cancel
Save