pull/1/head
parent
6c0b1e5bf0
commit
a0ec5888da
@ -0,0 +1,79 @@ |
||||
<!-- 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-step nzTitle="Waiting"></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 |
||||
nzMode="multiple" |
||||
nzShowSearch |
||||
formControlName="productIdArray" |
||||
nzPlaceHolder="请选择有抽奖资格的产品" |
||||
> |
||||
<nz-option *ngFor="let item of listOfOption" [nzLabel]="item.couponName" [nzValue]="item.id"></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="type" nzPlaceHolder="请选择活动类型"> |
||||
<nz-option nzLabel="大转盘" nzValue="1"></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-range-picker [nzShowTime]="true" formControlName="time"></nz-range-picker> |
||||
</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="请输入活动内容"> |
||||
<textarea rows="6" nz-input formControlName="content" placeholder="请输入活动内容" ></textarea> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
|
||||
</form> |
||||
<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> |
@ -0,0 +1,14 @@ |
||||
.main { |
||||
width: 90%; |
||||
margin-left: 5%; |
||||
.title { |
||||
width: 100%; |
||||
height: 46px; |
||||
line-height: 46px; |
||||
font-size: 16px; |
||||
text-align: center; |
||||
color: #1890ff; |
||||
background-color: #f3f9ff; |
||||
margin-bottom: 20px; |
||||
} |
||||
} |
@ -0,0 +1,134 @@ |
||||
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'; |
||||
|
||||
@Component({ |
||||
selector: 'app-activate-edit', |
||||
templateUrl: './activate-edit.component.html', |
||||
styleUrls: ['./activate-edit.component.scss'] |
||||
}) |
||||
export class ActivateEditComponent implements OnInit { |
||||
|
||||
validateForm!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
listOfOption: string[] = []; |
||||
current = 0; |
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private coupon: CouponService, |
||||
private activate: ActivateService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { } |
||||
|
||||
ngOnInit(): void { |
||||
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]], |
||||
productIdArray: [null, [Validators.required]], |
||||
type: [null, [Validators.required]], |
||||
content: [null, [Validators.required]], |
||||
time: [null, [Validators.required]], |
||||
|
||||
}); |
||||
|
||||
const whereObject = { |
||||
pageNum: 1 , |
||||
pageSize: 200 , |
||||
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']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 返回
|
||||
getBack() { |
||||
history.back(); |
||||
} |
||||
|
||||
// 重置
|
||||
public resetForm(): void { |
||||
this.validateForm.reset(); |
||||
} |
||||
|
||||
// 基本信息提交
|
||||
public editActivityInfo(): 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.validateForm.value.ruleArray = [{ |
||||
partakeMode: 1, |
||||
productType: 1 , |
||||
productIdArray: this.validateForm.value.productIdArray |
||||
}]; |
||||
this.validateForm.value.startTime = this.validateForm.value.time[0].getTime(); |
||||
this.validateForm.value.endTime = this.validateForm.value.time[1].getTime(); |
||||
|
||||
if (this.editFlag) { |
||||
this.validateForm.value.id = this.id; |
||||
} |
||||
this.activate.editActivityInfo(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.current += 1; |
||||
this.message.success('编辑成功'); |
||||
} else { |
||||
this.message.create('error', '编辑失败'); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 查询详情
|
||||
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']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 上一步
|
||||
pre(): void { |
||||
this.current -= 1; |
||||
} |
||||
|
||||
// 下一步
|
||||
getNest(): void { |
||||
|
||||
this.editActivityInfo(); |
||||
} |
||||
|
||||
// 完成
|
||||
done(): void { |
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,99 @@ |
||||
<!-- 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="type" nzPlaceHolder="请选择代理商状态"> |
||||
<nz-option nzLabel="大转盘" nzValue="1"></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/activate/activate-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="80px">活动标题</th> |
||||
<th nzWidth="80px">活动类型</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="100px">更新时间</th> |
||||
<th nzWidth="70px" nzRight>活动状态</th> |
||||
<th nzWidth="80px" 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.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight>{{data.status | status}}</td> |
||||
<td nzRight class="table-td-operation"> |
||||
<a (click)="getEdit(data.id)">编辑</a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)='getForbiddenUser(data.id , data.status)'>{{data.status === 1 ? '禁用': '启用'}}</a> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
|
@ -0,0 +1,102 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {CompanyService} from '../../../services/company.service'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {Router} from '@angular/router'; |
||||
import {ActivateService} from "../../../services/activate.service"; |
||||
|
||||
@Component({ |
||||
selector: 'app-activate-list', |
||||
templateUrl: './activate-list.component.html', |
||||
styleUrls: ['./activate-list.component.scss'] |
||||
}) |
||||
export class ActivateListComponent implements OnInit { |
||||
|
||||
WEB_SERVE_URL = environment.imageUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
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 common: CommonsService |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
} |
||||
|
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
title: [null], |
||||
type: [null], |
||||
status: [null], |
||||
}); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} |
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.activate.getList(whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
console.log(data); |
||||
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 getForbiddenUser(id, status: any): void { |
||||
const message = (status === 1 ? '是否禁用当前公司' : '是否启用当前公司'); |
||||
|
||||
const s = status === 1 ? 0 : 1; |
||||
|
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.company.editStatus(id, s , dataUser => { |
||||
this.getRequest(false , this.searchForm.value); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 修改
|
||||
public getEdit(id: number): void { |
||||
this.router.navigate(['/admin/activate/activate-edit'], { |
||||
queryParams: { |
||||
id: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,16 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {ActivateListComponent} from './activate-list/activate-list.component'; |
||||
import {ActivateEditComponent} from './activate-edit/activate-edit.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'activate-list', component: ActivateListComponent }, |
||||
{ path: 'activate-edit', component: ActivateEditComponent}, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class ActivateRoutingModule { } |
@ -0,0 +1,29 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { ActivateRoutingModule } from './activate-routing.module'; |
||||
import { ActivateListComponent } from './activate-list/activate-list.component'; |
||||
import { ActivateEditComponent } from './activate-edit/activate-edit.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"; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [ActivateListComponent, ActivateEditComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
ActivateRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
RegionSelectorModule, |
||||
AppCommonModule |
||||
] |
||||
}) |
||||
export class ActivateModule { } |
@ -0,0 +1,19 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'status' |
||||
}) |
||||
export class StatusPipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '编辑中'; |
||||
case 2: |
||||
return '已发布'; |
||||
case 3: |
||||
return '已结束'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'type' |
||||
}) |
||||
export class TypePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '大转盘'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class ActivateService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* @params paramsObject |
||||
* @params callBack |
||||
* @return ArrayList |
||||
* @author sum1dream |
||||
* @description 查询活动列表 |
||||
* @date 2021/9/27 5:53 下午 |
||||
* @version: 1.0.0 |
||||
*/ |
||||
public getList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'activity/getList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* @params params |
||||
* @author sum1dream |
||||
* @description 编辑活动基本信息 |
||||
* @date 2021/9/28 2:37 下午 |
||||
* @version: 1.0.0 |
||||
*/ |
||||
public editActivityInfo(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'activity/editActivityInfo', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* @params id |
||||
* @author sum1dream |
||||
* @description 根据id查询活动基本信息详情 |
||||
* @date 2021/9/28 2:39 下午 |
||||
* @version: 1.0.0 |
||||
*/ |
||||
public getDetailById(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'activity/getDetailById?activityId=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue