From 64d89bcde7a2385869032452686556f755ed9c76 Mon Sep 17 00:00:00 2001 From: yuanye Date: Mon, 22 Mar 2021 17:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../company-detail.component.html | 65 ++-- .../company-detail.component.scss | 4 + .../company-detail.component.ts | 4 +- .../coupon-edit/coupon-edit.component.html | 6 +- .../coupon-edit/coupon-edit.component.ts | 65 ++-- .../coupon-list/coupon-list.component.html | 83 +++-- .../coupon-list/coupon-list.component.ts | 286 +++++++++++------- src/app/admin/coupon/coupon.module.ts | 4 +- .../navigation/navigation.component.html | 6 +- src/app/app-common.module.ts | 2 + src/app/pipes/coupon-status.pipe.ts | 24 ++ src/app/pipes/index.ts | 1 + src/app/services/coupon.service.ts | 19 +- src/app/services/icon.service.ts | 2 +- 14 files changed, 369 insertions(+), 202 deletions(-) create mode 100644 src/app/pipes/coupon-status.pipe.ts diff --git a/src/app/admin/company/company-detail/company-detail.component.html b/src/app/admin/company/company-detail/company-detail.component.html index 1eeb1d1..48e3fa0 100644 --- a/src/app/admin/company/company-detail/company-detail.component.html +++ b/src/app/admin/company/company-detail/company-detail.component.html @@ -1,32 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + 系统管理 + + + 公司详情 + + + + +
+ + + + {{data.user.loginName}} + {{data.user.userName}} + + + + + {{data.company.regionName}} + + + + {{data.company.name}} + {{data.company.phone}} + {{data.company.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.company.updateTime | date: 'yyyy-MM-dd HH:mm'}} + + + +
diff --git a/src/app/admin/company/company-detail/company-detail.component.scss b/src/app/admin/company/company-detail/company-detail.component.scss index e69de29..8bee3fb 100644 --- a/src/app/admin/company/company-detail/company-detail.component.scss +++ b/src/app/admin/company/company-detail/company-detail.component.scss @@ -0,0 +1,4 @@ +.head_img { + height: 60px; + width: 60px; +} diff --git a/src/app/admin/company/company-detail/company-detail.component.ts b/src/app/admin/company/company-detail/company-detail.component.ts index 7631eda..1c08fdb 100644 --- a/src/app/admin/company/company-detail/company-detail.component.ts +++ b/src/app/admin/company/company-detail/company-detail.component.ts @@ -1,8 +1,8 @@ import { Component, OnInit } from '@angular/core'; -import {MerchantService} from '../../../services/merchant.service'; import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {CompanyService} from '../../../services/company.service'; +import {environment} from '../../../../environments/environment'; @Component({ selector: 'app-company-detail', @@ -10,7 +10,7 @@ import {CompanyService} from '../../../services/company.service'; styleUrls: ['./company-detail.component.scss'] }) export class CompanyDetailComponent implements OnInit { - + FILE_URL = environment.imageUrl; data: any = {}; id: number; constructor( diff --git a/src/app/admin/coupon/coupon-edit/coupon-edit.component.html b/src/app/admin/coupon/coupon-edit/coupon-edit.component.html index 3f640c6..3f817dd 100644 --- a/src/app/admin/coupon/coupon-edit/coupon-edit.component.html +++ b/src/app/admin/coupon/coupon-edit/coupon-edit.component.html @@ -22,7 +22,6 @@
- 卡券类型 @@ -117,7 +116,7 @@
-
+
选择卡券 @@ -126,12 +125,13 @@ (nzScrollToBottom)="loadMoreCoupon()" (nzOnSearch)="searchCoupon($event)" nzShowSearch + nzMode="multiple" nzServerSearch nzPlaceHolder="请选择卡券" nzAllowClear [nzDropdownRender]="renderTemplateCoupon" > - + diff --git a/src/app/admin/coupon/coupon-edit/coupon-edit.component.ts b/src/app/admin/coupon/coupon-edit/coupon-edit.component.ts index 721bb59..a636d4f 100644 --- a/src/app/admin/coupon/coupon-edit/coupon-edit.component.ts +++ b/src/app/admin/coupon/coupon-edit/coupon-edit.component.ts @@ -5,7 +5,7 @@ import {MerchantService} from '../../../services/merchant.service'; import {NzMessageService, NzUploadFile} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {CouponService} from '../../../services/coupon.service'; -import {forEachToken} from 'tslint'; +import {IconService} from '../../../services/icon.service'; function getBase64(file: File): Promise { return new Promise((resolve, reject) => { const reader = new FileReader(); @@ -36,6 +36,7 @@ export class CouponEditComponent implements OnInit { optionList: string[] = []; isLoading = false; pageNum = 1; + pageSize = 10; merchantName: string; optionListCoupon: string[] = []; isLoadingCoupon = false; @@ -51,16 +52,14 @@ export class CouponEditComponent implements OnInit { ) { } - - - - ngOnInit(): void { this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.merchantId != null) { + if (queryParams.couponId != null) { this.editFlag = true; - this.id = queryParams.merchantId; - this.getDetails(queryParams.merchantId); + this.id = queryParams.couponId; + this.getDetails(queryParams.couponId); + this.pageSize = 10000; + this.loadMore(); } }); this.validateForm = this.fb.group({ @@ -77,6 +76,7 @@ export class CouponEditComponent implements OnInit { isPresent: [false, [Validators.required]], handselCouponList: [null], status: [null], + couponKey: [null], createTime: [null], secUser: {}, }); @@ -88,7 +88,7 @@ export class CouponEditComponent implements OnInit { this.isLoading = true; const paramsObject = { pageNum: this.pageNum, - pageSize: 10, + pageSize: this.pageSize, merchantName: this.merchantName, }; this.getMerchantList(paramsObject); @@ -102,7 +102,7 @@ export class CouponEditComponent implements OnInit { this.pageNum = 1; const paramsObject = { pageNum: this.pageNum, - pageSize: 10, + pageSize: this.pageSize, merchantName: e, }; this.getMerchantList(paramsObject); @@ -149,13 +149,12 @@ export class CouponEditComponent implements OnInit { // 查询卡券 public getCouponList(paramsObject): void { this.coupon.getCouponList(paramsObject , data => { - console.log(data); - if (data['return_code'] === '000000' && this.pageNum <= data['return_data'].pages ) { - this.pageNum ++; - this.isLoading = false; - this.optionList = [...this.optionList, ...data['return_data'].list]; + if (data['return_code'] === '000000' && this.pageNumCoupon <= data['return_data'].pages ) { + this.pageNumCoupon ++; + this.isLoadingCoupon = false; + this.optionListCoupon = [...this.optionListCoupon, ...data['return_data'].list]; } else { - this.isLoading = false; + this.isLoadingCoupon = false; } }); } @@ -201,7 +200,7 @@ export class CouponEditComponent implements OnInit { if (i['response'] != null) { couponCarouselImg.push(i['response']['return_data'][0]); } else { - this.validateForm.value.couponCarouselImg = i.name; + couponCarouselImg.push(i.name); } } } else { @@ -244,19 +243,35 @@ export class CouponEditComponent implements OnInit { } public getDetails(id) { - this.merchant.getMerchantById(id, data => { + this.coupon.getCouponById(id, data => { if (data['return_code'] === '000000') { - if (data['return_data']['merchantLogo'] != null && data['return_data']['merchantLogo'] !== '') { - const logo = String(data['return_data']['merchantLogo']); - const logoArray = []; - logoArray.push( + data['return_data']['couponType'] = String(data['return_data']['couponType']); + this.content = data['return_data']['couponDesc']; + if (data['return_data']['couponImg'] != null && data['return_data']['couponImg'] !== '') { + const couponImg = String(data['return_data']['couponImg']); + const couponArray = []; + couponArray.push( { uid: 1, - name: logo, + name: couponImg, status: 'done', - url: environment.imageUrl + logo + url: environment.imageUrl + couponImg }); - // this.logoFile = logoArray; + this.couponImg = couponArray; + } + if (data['return_data']['couponCarouselImg'] != null && data['return_data']['couponCarouselImg'] !== '') { + const couponCarouselImg = data['return_data']['couponCarouselImg'].split(','); + const couponCarouselArray = []; + for (const i of couponCarouselImg) { + couponCarouselArray.push( + { + uid: 1, + name: i, + status: 'done', + url: environment.imageUrl + i + }); + } + this.couponCarouselImg = couponCarouselArray; } this.validateForm.patchValue(data['return_data']); } else { diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.html b/src/app/admin/coupon/coupon-list/coupon-list.component.html index f4975e3..eee1e56 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.html +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.html @@ -9,17 +9,56 @@
- 门店名称 + 卡券名称 - +
- 门店电话 + 商户 - + + + + + + + + +
+
+ + 卡券类型 + + + + + + + +
+
+ + 卡券状态 + + + + + + + +
@@ -60,26 +99,36 @@ 编号 - 门店编号 - 门店名称 - 门店电话 - 创建时间 - 操作 + 卡券编号 + 卡券名称 + 卡券面值 + 销售价格 + 卡券类型 + 卡券状态 + 销售截止时间 + 创建时间 + 操作 {{i+1}} - {{data.storeKey}} - {{data.storeName}} - {{data.telephone}} + {{data.couponKey}} + {{data.couponName}} + ¥{{data.couponPrice}} + ¥{{data.salesPrice}} + {{data.couponType === 1 ? '内部卷' : '外部卷'}} + {{data.status | couponStatus}} + {{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}} {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} - - - - - + + + + + + + diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.ts b/src/app/admin/coupon/coupon-list/coupon-list.component.ts index 45cb387..a9d3d9a 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.ts +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.ts @@ -1,128 +1,196 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {FormBuilder, FormGroup} from '@angular/forms'; import {MerchantStoreService} from '../../../services/merchant-store.service'; import {IconService} from '../../../services/icon.service'; import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute, Router} from '@angular/router'; import {CommonsService} from '../../../services/commons.service'; +import {CouponService} from '../../../services/coupon.service'; +import {MerchantService} from '../../../services/merchant.service'; @Component({ - selector: 'app-coupon-list', - templateUrl: './coupon-list.component.html', - styleUrls: ['./coupon-list.component.scss'] + selector: 'app-coupon-list', + templateUrl: './coupon-list.component.html', + styleUrls: ['./coupon-list.component.scss'] }) export class CouponListComponent implements OnInit { - searchForm: FormGroup; // 搜索框 - requestData = []; // 列表数据 - total: number; // 页码 - pageNum = 1; // 页码 - pageSize = 10; // 条码 - loading = true; - id = null; - name: string; - constructor( - private form: FormBuilder, - private merchantStore: MerchantStoreService, - private iconService: IconService, - private message: NzMessageService, - private router: Router, - private activatedRoute: ActivatedRoute, - private common: CommonsService - ) { - } - - ngOnInit(): void { - this.init(); - - } - - public init(): void { - this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.merchantId != null) { - this.id = queryParams.merchantId; - this.name = queryParams.name; - } - }); - this.searchForm = this.form.group({ - storeName: [null], - telephone: [null], - }); - this.getRequest(true, this.searchForm.value); - } - - - // 查询列表 - public getRequest(reset: boolean = false, whereObject: object) { - - this.loading = false; - if (reset) { - this.pageNum = 1; + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + id = null; + name: string; + merchantName: string; + optionList: string[] = []; + isLoading = false; + pageNumMer = 1; + constructor( + private form: FormBuilder, + private coupon: CouponService, + private merchant: MerchantService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + private activatedRoute: ActivatedRoute, + private common: CommonsService + ) { } - whereObject['pageNum'] = this.pageNum; - whereObject['pageSize'] = this.pageSize; - if (this.id == null) { - this.merchantStore.getStoreListByMerchant(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']); - } - }); - } else { - whereObject['merchantId'] = this.id; - this.merchantStore.getStoreListByCompany(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']); + + ngOnInit(): void { + this.init(); + + } + + public init(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.merchantId != null) { + this.id = queryParams.merchantId; + this.name = queryParams.name; + } + }); + this.searchForm = this.form.group({ + merchantId: [null], + couponName: [null], + couponType: [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.coupon.getCouponList(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 getDelete(id): void { + const message = '是否删除门店'; + this.common.showConfirm(message, data => { + if (data) { + // this.coupon.disableMerchant(id, dataReturn => { + // if (dataReturn['return_code'] === '000000') { + // this.message.success('操作成功'); + // this.getRequest(false, this.searchForm.value); + // } else { + // this.message.warning(dataReturn['return_msg']); + // } + // }); + } + }); + } + + // 修改 + public getEdit(id: number): void { + this.router.navigate(['/admin/coupon/coupon-edit'], { + queryParams: { + couponId: id + } + }).then(r => console.log(r)); + } + + // 查看详情 + public getDetail(id: number): void { + this.router.navigate(['/admin/merchantStore/store-detail'], { + queryParams: { + storeId: id + } + }).then(r => console.log(r)); + } + + // 查询商户 + loadMore(): void { + this.isLoading = true; + const paramsObject = { + pageNum: this.pageNumMer, + pageSize: 10, + merchantName: this.merchantName, + }; + this.getMerchantList(paramsObject); } + // 搜索商户 + search(e): void { + this.optionList = []; + this.isLoading = true; + this.merchantName = e; + this.pageNumMer = 1; + const paramsObject = { + pageNum: this.pageNumMer, + pageSize: 10, + merchantName: e, + }; + this.getMerchantList(paramsObject); + } + + // 查询商户 + public getMerchantList(paramsObject): void { + this.merchant.getMerchantList(paramsObject , data => { + if (data['return_code'] === '000000' && this.pageNumMer <= data['return_data'].pages ) { + this.pageNumMer ++; + this.isLoading = false; + this.optionList = [...this.optionList, ...data['return_data'].list]; + } else { + this.isLoading = false; + } + }); + } - } - - // 重置 - public resetForm(): void { - this.searchForm.reset(); - } - - // 禁用门店 - public getDelete(id): void { - const message = '是否删除门店'; - this.common.showConfirm(message, data => { - if (data) { - this.merchantStore.deleteMerchantStore(id, dataReturn => { - if (dataReturn['return_code'] === '000000') { - this.message.success('操作成功'); - this.getRequest(false , this.searchForm.value); - } else { - this.message.warning(dataReturn['return_msg']); - } + // 下架卡券 + public disableMerchant(id): void { + const message = '是否下架卡券'; + this.common.showConfirm(message, data => { + if (data) { + this.coupon.ofShelfApprove(id, dataReturn => { + if (dataReturn['return_code'] === '000000') { + this.message.success('操作成功'); + this.getRequest(false , this.searchForm.value); + } else { + this.message.warning(dataReturn['return_msg']); + } + }); + } }); - } - }); - } - - // 修改 - public getEdit(id: number): void { - this.router.navigate(['/admin/merchantStore/store-edit'], { - queryParams: { - storeId: id - } - }).then(r => console.log(r)); - } - - // 查看详情 - public getDetail(id: number): void { - this.router.navigate(['/admin/merchantStore/store-detail'], { - queryParams: { - storeId: id - } - }).then(r => console.log(r)); - } + } + + // 上架 + public enableMerchant(id): void { + const message = '是否上架审核卡券'; + this.common.showConfirm(message, data => { + if (data) { + this.coupon.upShelfApprove(id, dataReturn => { + if (dataReturn['return_code'] === '000000') { + this.message.success('操作成功'); + this.getRequest(false , this.searchForm.value); + } else { + this.message.warning(dataReturn['return_msg']); + } + }); + } + }); + } } diff --git a/src/app/admin/coupon/coupon.module.ts b/src/app/admin/coupon/coupon.module.ts index 6fb7dfc..a756a54 100644 --- a/src/app/admin/coupon/coupon.module.ts +++ b/src/app/admin/coupon/coupon.module.ts @@ -10,6 +10,7 @@ import {SeparateModule} from '../../common/separate/separate.module'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; import {RichtextModule} from '../../common/richtext/richtext.module'; +import {AppCommonModule} from '../../app-common.module'; @NgModule({ declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent], @@ -21,7 +22,8 @@ import {RichtextModule} from '../../common/richtext/richtext.module'; ReactiveFormsModule, FormsModule, BreadcrumbModule, - RichtextModule + RichtextModule, + AppCommonModule ] }) export class CouponModule { } diff --git a/src/app/admin/navigation/navigation.component.html b/src/app/admin/navigation/navigation.component.html index 4172931..c3c9d4c 100644 --- a/src/app/admin/navigation/navigation.component.html +++ b/src/app/admin/navigation/navigation.component.html @@ -1,8 +1,8 @@
  • @@ -30,7 +30,7 @@ - {{userInfo.secRole.roleName}} + {{userInfo.secUser.userName}} diff --git a/src/app/app-common.module.ts b/src/app/app-common.module.ts index 7bc6111..bfa16a1 100644 --- a/src/app/app-common.module.ts +++ b/src/app/app-common.module.ts @@ -11,6 +11,7 @@ import {NgxNeditorModule} from '@notadd/ngx-neditor'; // 管道 import {TimesPipe , TextareaPipe} from './pipes'; import { SystemPipe } from './pipes/system.pipe'; +import { CouponStatusPipe } from './pipes/coupon-status.pipe'; @@ -19,6 +20,7 @@ const PIPES = [ TimesPipe, TextareaPipe, SystemPipe, + CouponStatusPipe, ]; diff --git a/src/app/pipes/coupon-status.pipe.ts b/src/app/pipes/coupon-status.pipe.ts new file mode 100644 index 0000000..c428fca --- /dev/null +++ b/src/app/pipes/coupon-status.pipe.ts @@ -0,0 +1,24 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'couponStatus' +}) +export class CouponStatusPipe implements PipeTransform { + + transform(value: number): string { + switch (value) { + case 0: + return '删除'; + case 1: + return '编辑中'; + case 2: + return '已上架'; + case 3: + return '已下架'; + case 101: + return '上架审批中'; + case 102: + return '上架审批驳回'; + } + } +} diff --git a/src/app/pipes/index.ts b/src/app/pipes/index.ts index 138b16a..947e9d4 100644 --- a/src/app/pipes/index.ts +++ b/src/app/pipes/index.ts @@ -1,3 +1,4 @@ export * from './commons/times.pipe'; export * from './commons/textarea.pipe'; export * from './system.pipe'; +export * from './coupon-status.pipe'; diff --git a/src/app/services/coupon.service.ts b/src/app/services/coupon.service.ts index c379cff..60d06fb 100644 --- a/src/app/services/coupon.service.ts +++ b/src/app/services/coupon.service.ts @@ -53,39 +53,40 @@ export class CouponService { /** * 根据id查询详情 * - * @param merchantId 职位id + * @param couponId 卡券id * @param callBack 回调 */ - public getMerchantById(merchantId: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/getMerchantById?id=' + merchantId).subscribe(data => { + public getCouponById(couponId: number, callBack) { + this.http.get(environment.baseUrl + 'coupon/getCouponById?id=' + couponId).subscribe(data => { callBack(data); }); } /** - * 禁用商户 + * 下架卡券 * * @param id 用户id * @param callBack 返回参数 */ - public disableMerchant(id: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/disableMerchant?id=' + id).subscribe(data => { + public ofShelfApprove(id: number, callBack) { + this.http.get(environment.baseUrl + 'coupon/ofShelfApprove?id=' + id).subscribe(data => { callBack(data); }); } /** - * 启用商户 + * 上架卡券 * * @param id 用户id * @param callBack 返回参数 */ - public enableMerchant(id: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/enableMerchant?id=' + id).subscribe(data => { + public upShelfApprove(id: number, callBack) { + this.http.get(environment.baseUrl + 'coupon/upShelfApprove?id=' + id).subscribe(data => { callBack(data); }); } + } diff --git a/src/app/services/icon.service.ts b/src/app/services/icon.service.ts index 21bb46e..3ea594e 100644 --- a/src/app/services/icon.service.ts +++ b/src/app/services/icon.service.ts @@ -12,7 +12,7 @@ export class IconService { constructor(private iconService: NzIconService) { this.iconService.fetchFromIconfont({ - scriptUrl: 'https://at.alicdn.com/t/font_2424521_5ot4v5e6dp.js' + scriptUrl: 'https://at.alicdn.com/t/font_2424521_elodxcgd21v.js' }); } }