From a0ec5888da1c323275ab89b5167b713daed58746 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Wed, 29 Sep 2021 16:09:58 +0800 Subject: [PATCH] 1 --- .../activate-edit.component.html | 79 +++++++++++ .../activate-edit.component.scss | 14 ++ .../activate-edit/activate-edit.component.ts | 134 ++++++++++++++++++ .../activate-list.component.html | 99 +++++++++++++ .../activate-list.component.scss | 0 .../activate-list/activate-list.component.ts | 102 +++++++++++++ .../admin/activate/activate-routing.module.ts | 16 +++ src/app/admin/activate/activate.module.ts | 29 ++++ src/app/pipes/activate/status.pipe.ts | 19 +++ src/app/pipes/activate/type.pipe.ts | 15 ++ src/app/services/activate.service.ts | 56 ++++++++ 11 files changed, 563 insertions(+) create mode 100644 src/app/admin/activate/activate-edit/activate-edit.component.html create mode 100644 src/app/admin/activate/activate-edit/activate-edit.component.scss create mode 100644 src/app/admin/activate/activate-edit/activate-edit.component.ts create mode 100644 src/app/admin/activate/activate-list/activate-list.component.html create mode 100644 src/app/admin/activate/activate-list/activate-list.component.scss create mode 100644 src/app/admin/activate/activate-list/activate-list.component.ts create mode 100644 src/app/admin/activate/activate-routing.module.ts create mode 100644 src/app/admin/activate/activate.module.ts create mode 100644 src/app/pipes/activate/status.pipe.ts create mode 100644 src/app/pipes/activate/type.pipe.ts create mode 100644 src/app/services/activate.service.ts diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.html b/src/app/admin/activate/activate-edit/activate-edit.component.html new file mode 100644 index 0000000..656ac0c --- /dev/null +++ b/src/app/admin/activate/activate-edit/activate-edit.component.html @@ -0,0 +1,79 @@ + + + + 活动管理 + + + 编辑活动 + + + +
+
+ + + + + +
+
+
+ + 活动标题 + + + + +
+
+ + 抽奖资格 + + + + + + +
+
+ + 活动类型 + + + + + + +
+
+ + 活动时间 + + + + +
+
+ + 活动内容 + + + + +
+
+ +
+
+
+ + +
+
+
+
diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.scss b/src/app/admin/activate/activate-edit/activate-edit.component.scss new file mode 100644 index 0000000..60ffd9a --- /dev/null +++ b/src/app/admin/activate/activate-edit/activate-edit.component.scss @@ -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; + } +} diff --git a/src/app/admin/activate/activate-edit/activate-edit.component.ts b/src/app/admin/activate/activate-edit/activate-edit.component.ts new file mode 100644 index 0000000..01104e8 --- /dev/null +++ b/src/app/admin/activate/activate-edit/activate-edit.component.ts @@ -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 { + + } + + +} diff --git a/src/app/admin/activate/activate-list/activate-list.component.html b/src/app/admin/activate/activate-list/activate-list.component.html new file mode 100644 index 0000000..10cc440 --- /dev/null +++ b/src/app/admin/activate/activate-list/activate-list.component.html @@ -0,0 +1,99 @@ + + + + + +
+
+
+
+ + 活动名称 + + + + +
+
+ + 活动类型 + + + + + + +
+
+ + 活动名称 + + + + + + + + +
+ +
+ +
+
+ + +
+
+
+
+ + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 活动标题 + 活动类型 + 创建时间 + 更新时间 + 活动状态 + 操作 + + + + + {{i+1}} + {{data.title}} + {{data.type | type}} + {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.updateTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.status | status}} + + 编辑 + + {{data.status === 1 ? '禁用': '启用'}} + + + +
+ + + diff --git a/src/app/admin/activate/activate-list/activate-list.component.scss b/src/app/admin/activate/activate-list/activate-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/activate/activate-list/activate-list.component.ts b/src/app/admin/activate/activate-list/activate-list.component.ts new file mode 100644 index 0000000..0bd1752 --- /dev/null +++ b/src/app/admin/activate/activate-list/activate-list.component.ts @@ -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)); + } + + + +} + diff --git a/src/app/admin/activate/activate-routing.module.ts b/src/app/admin/activate/activate-routing.module.ts new file mode 100644 index 0000000..d43caee --- /dev/null +++ b/src/app/admin/activate/activate-routing.module.ts @@ -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 { } diff --git a/src/app/admin/activate/activate.module.ts b/src/app/admin/activate/activate.module.ts new file mode 100644 index 0000000..810b342 --- /dev/null +++ b/src/app/admin/activate/activate.module.ts @@ -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 { } diff --git a/src/app/pipes/activate/status.pipe.ts b/src/app/pipes/activate/status.pipe.ts new file mode 100644 index 0000000..1c39464 --- /dev/null +++ b/src/app/pipes/activate/status.pipe.ts @@ -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 '已结束'; + } + } + +} diff --git a/src/app/pipes/activate/type.pipe.ts b/src/app/pipes/activate/type.pipe.ts new file mode 100644 index 0000000..87da07e --- /dev/null +++ b/src/app/pipes/activate/type.pipe.ts @@ -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 '大转盘'; + } + } + +} diff --git a/src/app/services/activate.service.ts b/src/app/services/activate.service.ts new file mode 100644 index 0000000..665652c --- /dev/null +++ b/src/app/services/activate.service.ts @@ -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); + }); + } +}