提交膝蓋

pull/1/head
yuanye 4 years ago
commit 87095cc97a
  1. 1
      src/app/admin/company/company-detail/company-detail.component.html
  2. 0
      src/app/admin/company/company-detail/company-detail.component.scss
  3. 25
      src/app/admin/company/company-detail/company-detail.component.spec.ts
  4. 15
      src/app/admin/company/company-detail/company-detail.component.ts
  5. 109
      src/app/admin/company/company-edit/company-edit.component.html
  6. 6
      src/app/admin/company/company-edit/company-edit.component.scss
  7. 168
      src/app/admin/company/company-edit/company-edit.component.ts
  8. 85
      src/app/admin/company/company-list/company-list.component.html
  9. 4
      src/app/admin/company/company-list/company-list.component.scss
  10. 135
      src/app/admin/company/company-list/company-list.component.ts
  11. 18
      src/app/admin/company/company-routing.module.ts
  12. 28
      src/app/admin/company/company.module.ts
  13. 154
      src/app/admin/coupon/coupon-edit/coupon-edit.component.html
  14. 160
      src/app/admin/coupon/coupon-edit/coupon-edit.component.ts
  15. 20
      src/app/admin/coupon/coupon.module.ts
  16. 5
      src/app/app-routing.module.ts
  17. 92
      src/app/services/company.service.ts
  18. 91
      src/app/services/coupon.service.ts
  19. 2
      src/app/services/icon.service.ts

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CompanyDetailComponent } from './company-detail.component';
describe('CompanyDetailComponent', () => {
let component: CompanyDetailComponent;
let fixture: ComponentFixture<CompanyDetailComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CompanyDetailComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CompanyDetailComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-company-detail',
templateUrl: './company-detail.component.html',
styleUrls: ['./company-detail.component.scss']
})
export class CompanyDetailComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

@ -0,0 +1,109 @@
<!-- start 面包屑 -->
<nz-breadcrumb>
<nz-breadcrumb-item>
系统管理
</nz-breadcrumb-item>
<nz-breadcrumb-item>
增加单位
</nz-breadcrumb-item>
</nz-breadcrumb>
<!-- end 面包屑 -->
<div class="inner-content">
<div nz-row>
<div nz-col nzSpan="2"></div>
<div nz-col nzSpan="20">
<form nz-form [formGroup]="validateForm" >
<div nz-row [nzGutter]="24">
<nz-divider nzText="账号信息"></nz-divider>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'loginName'" nzRequired>用户名</nz-form-label>
<nz-form-control nzErrorTip="请输入用户名!">
<input nz-input placeholder="请输入用户名..." [formControlName]="'loginName'" id="'loginName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label>
<nz-form-control nzErrorTip="请输入登录密码!">
<nz-input-group [nzSuffix]="suffixTemplate">
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" />
</nz-input-group>
<ng-template #suffixTemplate>
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i>
</ng-template>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'phone'" nzRequired>联系电话</nz-form-label>
<nz-form-control nzErrorTip="请输入联系电话!">
<input nz-input placeholder="请输入联系电话..." [formControlName]="'phone'" id="'phone'" />
</nz-form-control>
</nz-form-item>
</div>
<nz-divider nzText="单位信息"></nz-divider>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'telephone'" nzRequired>所属地区</nz-form-label>
<nz-form-control nzErrorTip="请输入所属地区!">
<app-region-selector *ngIf="!editFlag" [selectLevel]="2" (selectedRegionIdChange)="regionChange($event)"></app-region-selector>
<input *ngIf="editFlag" nz-input [formControlName]="'regionName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'name'" nzRequired>单位名称</nz-form-label>
<nz-form-control nzErrorTip="请输入单位名称!">
<input nz-input placeholder="请输入单位名称..." [formControlName]="'name'" id="'name'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'address'" nzRequired>单位地址</nz-form-label>
<nz-form-control nzErrorTip="请输入单位地址!">
<input nz-input placeholder="请输入单位地址..." [formControlName]="'address'" id="'address'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="20">
<nz-form-item>
<nz-form-label>单位LOGO</nz-form-label>
<nz-form-control>
<nz-upload
nzAction="{{WEB_SERVE_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">上传LOGO</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>
<div nz-row>
<div nz-col [nzSpan]="24" class="search-area">
<button nz-button (click)="resetForm()">重置</button>
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button>
</div>
</div>
</form>
</div>
<div nz-col nzSpan="2"></div>
</div>
</div>

@ -0,0 +1,6 @@
button {
margin-left: 8px;
}
:host ::ng-deep .ant-upload {
background-color: #ffffff;
}

@ -0,0 +1,168 @@
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {environment} from '../../../../environments/environment';
import {MerchantService} from '../../../services/merchant.service';
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {ValidatorsService} from '../../../services/validators.service';
import {CompanyService} from '../../../services/company.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-company-edit',
templateUrl: './company-edit.component.html',
styleUrls: ['./company-edit.component.scss']
})
export class CompanyEditComponent implements OnInit {
validateForm!: FormGroup;
data: any;
editFlag = false;
id: number;
passwordVisible = false;
logoFile = [];
WEB_SERVE_URL = environment.baseUrl;
previewImage: string | undefined = '';
previewVisible = false;
regionId;
constructor(
private fb: FormBuilder,
private company: CompanyService,
private message: NzMessageService, // 信息提示
private activatedRoute: ActivatedRoute,
) {
}
ngOnInit(): void {
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.companyId != null) {
this.editFlag = true;
this.id = queryParams.companyId;
this.getDetails(queryParams.companyId);
}
});
this.validateForm = this.fb.group({
loginName: [null, [Validators.required, ValidatorsService.maxLength(20)]],
password: [null, [Validators.required, ValidatorsService.maxLength(20)]],
phone: [null, [Validators.required, ValidatorsService.mobile]],
regionId: [null],
name: [null, [Validators.required, ValidatorsService.maxLength(50)]],
address: [null, [Validators.required, ValidatorsService.maxLength(80)]],
logo: [null],
status: [null],
createTime: [null],
regionName: [null],
company: {},
user: {},
});
}
// 返回
getBack() {
history.back();
}
// 重置
public resetForm(): void {
this.validateForm.reset();
}
// 课程保存
public getSave(): 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;
}
}
if (this.logoFile.length !== 0) {
if (this.logoFile[0]['response'] != null) {
this.validateForm.value.logo = this.logoFile[0]['response']['return_data'][0];
} else {
this.validateForm.value.logo = this.logoFile[0].name;
}
}
this.validateForm.value['company']['name'] = this.validateForm.value.name;
this.validateForm.value['company']['regionId'] = this.regionId;
this.validateForm.value['company']['address'] = this.validateForm.value.address;
this.validateForm.value['company']['phone'] = this.validateForm.value.phone;
this.validateForm.value['company']['logo'] = this.validateForm.value.logo;
this.validateForm.value['user']['loginName'] = this.validateForm.value.loginName;
this.validateForm.value['user']['password'] = this.validateForm.value.password;
console.log(this.validateForm.value);
if (this.editFlag) {
this.validateForm.value.id = this.id;
this.company.updateCompany(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功');
} else {
this.message.create('error', '修改失败');
}
});
} else {
this.company.addCompanyAndUser(this.validateForm.value, data => {
console.log(data);
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('添加成功');
} else {
this.message.create('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;
}
public getDetails(id) {
this.company.getMerchantById(id, data => {
if (data['return_code'] === '000000') {
console.log(data);
data['return_data']['company'].loginName = data['return_data'].user.loginName;
data['return_data']['company'].password = data['return_data'].user.password;
if (data['return_data']['company']['logo'] != null && data['return_data']['company']['logo'] !== '') {
const logo = String(data['return_data']['company']['logo']);
const logoArray = [];
logoArray.push(
{
uid: 1,
name: logo,
status: 'done',
url: environment.imageUrl + logo
});
this.logoFile = logoArray;
}
this.validateForm.patchValue(data['return_data']['company']);
console.log(this.validateForm.value);
} else {
this.message.create('error', data['return_msg']);
}
});
}
regionChange(regionId) {
this.regionId = regionId;
}
}

@ -0,0 +1,85 @@
<!-- 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="6">
<nz-form-item>
<nz-form-label [nzSpan]="6">单位名称</nz-form-label>
<nz-form-control [nzSpan]="16">
<input nz-input formControlName="name"/>
</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/company/company-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="70px">联系方式</th>
<th nzWidth="100px">地址</th>
<th nzWidth="100px">创建时间</th>
<th nzWidth="100px">更新时间</th>
<th nzWidth="80px" nzRight="0px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of ajaxTable.data; let i = index">
<td>{{i+1}}</td>
<td>{{data.regionName}}</td>
<td>{{data.name}}</td>
<td>{{data.phone}}</td>
<td>{{data.address}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight="0px" class="table-td-operation">
<a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="商户详情"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getList(data.id , data.merchantName)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="门店列表"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a *ngIf="data.status === 1" (click)='disableMerchant(data.id)'><i nz-icon nzType="stop" nzTheme="outline" nz-tooltip="禁用"></i></a>
<a *ngIf="data.status !== 1" (click)='enableMerchant(data.id)'><i nz-icon nzType="check-circle" nzTheme="outline" nz-tooltip="启用"></i></a>
</td>
</tbody>
</nz-table>
</div>

@ -0,0 +1,4 @@
.head_img {
height: 60px;
width: 60px;
}

@ -0,0 +1,135 @@
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {MerchantService} from '../../../services/merchant.service';
import {IconService} from '../../../services/icon.service';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {CommonsService} from '../../../services/commons.service';
import {CompanyService} from '../../../services/company.service';
@Component({
selector: 'app-company-list',
templateUrl: './company-list.component.html',
styleUrls: ['./company-list.component.scss']
})
export class CompanyListComponent implements OnInit {
searchForm: FormGroup; // 搜索框
requestData = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
constructor(
private form: FormBuilder,
private company: CompanyService,
private iconService: IconService,
private message: NzMessageService,
private router: Router,
private common: CommonsService
) {
}
ngOnInit(): void {
this.init();
}
public init(): void {
this.searchForm = this.form.group({
merchantKey: [null],
merchantName: [null],
telephone: [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.company.selectCompanyList(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 disableMerchant(id): void {
const message = '是否禁用商户';
this.common.showConfirm(message, data => {
if (data) {
this.company.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 enableMerchant(id): void {
const message = '是否启用商户';
this.common.showConfirm(message, data => {
if (data) {
this.company.enableMerchant(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/company/company-edit'], {
queryParams: {
companyId: id
}
}).then(r => console.log(r));
}
// 查看详情
public getDetail(id: number): void {
this.router.navigate(['/admin/merchant/merchant-detail'], {
queryParams: {
merchantId: id
}
}).then(r => console.log(r));
}
// 查看门店列表
public getList(id: number , merchantName: string): void {
this.router.navigate(['/admin/merchantStore/store-list'], {
queryParams: {
merchantId: id,
name: merchantName,
}
}).then(r => console.log(r));
}
}

@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {CompanyEditComponent} from './company-edit/company-edit.component';
import {CompanyDetailComponent} from './company-detail/company-detail.component';
import {CompanyListComponent} from './company-list/company-list.component';
const routes: Routes = [
{ path: 'company-list', component: CompanyListComponent },
{ path: 'company-edit', component: CompanyEditComponent},
{ path: 'company-detail', component: CompanyDetailComponent}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class CompanyRoutingModule { }

@ -0,0 +1,28 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CompanyRoutingModule } from './company-routing.module';
import { CompanyListComponent } from './company-list/company-list.component';
import { CompanyEditComponent } from './company-edit/company-edit.component';
import { CompanyDetailComponent } from './company-detail/company-detail.component';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {SeparateModule} from '../../common/separate/separate.module';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module';
import {RegionSelectorModule} from '../../common/region-selector/region-selector.module';
@NgModule({
declarations: [CompanyListComponent, CompanyEditComponent, CompanyDetailComponent],
imports: [
CommonModule,
CompanyRoutingModule,
NgZorroAntdModule,
SeparateModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule,
RegionSelectorModule
]
})
export class CompanyModule { }

@ -9,100 +9,172 @@
</nz-breadcrumb>
<!-- end 面包屑 -->
<nz-content class="inner-content">
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'loginTelephone'" nzRequired>登录手机号</nz-form-label>
<nz-form-control nzErrorTip="请输入登录手机号!">
<input nz-input placeholder="请输入登录手机号..." [formControlName]="'loginTelephone'" id="'loginTelephone'" />
<nz-form-label [nzFor]="'couponName'" nzRequired>卡券名称</nz-form-label>
<nz-form-control nzErrorTip="请输入卡券名称!">
<input nz-input placeholder="请输入卡券名称..." [formControlName]="'couponName'" id="'couponName'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label>
<nz-form-control nzErrorTip="请输入登录密码!">
<nz-input-group [nzSuffix]="suffixTemplate">
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" />
</nz-input-group>
<ng-template #suffixTemplate>
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i>
</ng-template>
<nz-form-label [nzFor]="'couponType'" nzRequired>卡券类型</nz-form-label>
<nz-form-control nzErrorTip="请选择卡券类型!">
<nz-select nzPlaceHolder="请选择卡券类型" [formControlName]="'couponType'">
<nz-option nzValue="1" nzLabel="内部卷"></nz-option>
<nz-option nzValue="2" nzLabel="外部卷"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'merchantKey'" nzRequired>商户编号</nz-form-label>
<nz-form-control nzErrorTip="请输入商户编号!">
<input nz-input placeholder="请输入商户编号..." [formControlName]="'merchantKey'" id="'merchantKey'" />
<nz-form-label [nzFor]="'couponPrice'" nzRequired>卡券面值</nz-form-label>
<nz-form-control nzErrorTip="请输入卡券面值!">
<input nz-input placeholder="请输入卡券面值..." [formControlName]="'couponPrice'" id="'couponPrice'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'merchantName'" nzRequired>商户名称</nz-form-label>
<nz-form-control nzErrorTip="请输入商户名称!">
<input nz-input placeholder="请输入商户名称..." [formControlName]="'merchantName'" id="'merchantName'" />
<nz-form-label [nzFor]="'salesPrice'" nzRequired>销售价格</nz-form-label>
<nz-form-control nzErrorTip="请输入销售价格!">
<input nz-input placeholder="请输入销售价格..." [formControlName]="'salesPrice'" id="'salesPrice'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'telephone'" nzRequired>联系电话</nz-form-label>
<nz-form-control nzErrorTip="请输入联系电话!">
<input nz-input placeholder="请输入联系电话..." [formControlName]="'telephone'" id="'telephone'" />
<nz-form-label [nzFor]="'salesCount'" nzRequired>销售数量</nz-form-label>
<nz-form-control nzErrorTip="请输入销售数量!">
<input nz-input placeholder="请输入销售数量 ..." [formControlName]="'salesCount'" id="'salesCount'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'address'" nzRequired>商户地址</nz-form-label>
<nz-form-control nzErrorTip="请输入商户地址!">
<input nz-input placeholder="请输入商户地址..." [formControlName]="'address'" id="'address'" />
<nz-form-label [nzFor]="'limitNumber'" nzRequired>限购数量</nz-form-label>
<nz-form-control nzErrorTip="请输入限购数量!">
<input nz-input placeholder="请输入限购数量 ..." [formControlName]="'limitNumber'" id="'limitNumber'" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'bankName'" >银行名称</nz-form-label>
<nz-form-control nzErrorTip="请输入银行名称!">
<input nz-input placeholder="请输入银行名称..." [formControlName]="'bankName'" id="'bankName'" />
<nz-form-label [nzFor]="'merchantId'" nzRequired>选择商户</nz-form-label>
<nz-form-control nzErrorTip="请选择商户!">
<nz-select
(nzScrollToBottom)="loadMore()"
(nzOnSearch)="search($event)"
nzShowSearch
[formControlName]="'merchantId'"
nzServerSearch
nzPlaceHolder="请选择商户"
nzAllowClear
[nzDropdownRender]="renderTemplate"
>
<nz-option *ngFor="let o of optionList" [nzValue]="o.id" [nzLabel]="o.merchantName"></nz-option>
</nz-select>
<ng-template #renderTemplate>
<nz-spin *ngIf="isLoading"></nz-spin>
</ng-template>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'bankAccount'" >银行账号</nz-form-label>
<nz-form-control nzErrorTip="请输入银行账号!">
<input nz-input placeholder="请输入银行账号..." [formControlName]="'bankAccount'" id="'bankAccount'" />
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>截止日期</nz-form-label>
<nz-form-control nzErrorTip="请选择销售截止日期!">
<nz-date-picker
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
[formControlName]="'salesEndTime'"
></nz-date-picker>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'bankHolder'" >开户人</nz-form-label>
<nz-form-control nzErrorTip="请输入开户人!">
<input nz-input placeholder="请输入开户人..." [formControlName]="'bankHolder'" id="'bankHolder'" />
<nz-form-label [nzFor]="'recycleDay'" nzRequired>归库天数</nz-form-label>
<nz-form-control nzErrorTip="请输入归库天数!">
<nz-input-number [formControlName]="'recycleDay'" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8">
<nz-form-item>
<nz-form-label [nzFor]="'isPresent'" nzRequired>是否赠送卡券</nz-form-label>
<nz-form-control nzErrorTip="请选择是否赠送卡券!">
<nz-switch [formControlName]="'isPresent'" ></nz-switch>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="8" *ngIf="validateForm.value.isPresent">
<nz-form-item>
<nz-form-label [nzFor]="'handselCouponList'" nzRequired>选择卡券</nz-form-label>
<nz-form-control nzErrorTip="请选择卡券!">
<nz-select
[formControlName]="'handselCouponList'"
(nzScrollToBottom)="loadMoreCoupon()"
(nzOnSearch)="searchCoupon($event)"
nzShowSearch
nzServerSearch
nzPlaceHolder="请选择卡券"
nzAllowClear
[nzDropdownRender]="renderTemplateCoupon"
>
<nz-option *ngFor="let o of optionListCoupon" [nzValue]="o.id" [nzLabel]="o.merchantName"></nz-option>
</nz-select>
<ng-template #renderTemplateCoupon>
<nz-spin *ngIf="isLoading"></nz-spin>
</ng-template>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="16">
<div nz-col [nzSpan]="24">
<nz-form-item>
<nz-form-label nzRequired>卡券图片</nz-form-label>
<nz-form-control>
<nz-upload
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile"
nzListType="picture-card"
[(nzFileList)]="couponImg"
[nzShowButton]="couponImg.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>商户LOGO</nz-form-label>
<nz-form-label nzRequired>卡卷轮播图</nz-form-label>
<nz-form-control>
<nz-upload
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile"
nzListType="picture-card"
[(nzFileList)]="logoFile"
[nzShowButton]="logoFile.length < 1"
[(nzFileList)]="couponCarouselImg"
[nzShowButton]="couponCarouselImg.length < 5"
[nzPreview]="handlePreview"
>
<i nz-icon nzType="plus"></i>
<div class="ant-upload-text">上传LOGO</div>
<div class="ant-upload-text">上传图片</div>
</nz-upload>
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false">
<ng-template #modalContent>
@ -112,11 +184,11 @@
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="16">
<div nz-col [nzSpan]="20">
<nz-form-item>
<nz-form-label>商户简介</nz-form-label>
<nz-form-label nzRequired>卡券介紹</nz-form-label>
<nz-form-control>
<textarea formControlName="merchantDesc" nz-input rows="2" placeholder="请输入商户简介"></textarea>
<app-richtext [content]='content' (newTextEvent)="textData($event)"></app-richtext>
</nz-form-control>
</nz-form-item>
</div>

@ -4,8 +4,8 @@ import {environment} from '../../../../environments/environment';
import {MerchantService} from '../../../services/merchant.service';
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {ValidatorsService} from '../../../services/validators.service';
import {CouponService} from '../../../services/coupon.service';
import {forEachToken} from 'tslint';
function getBase64(file: File): Promise<string | ArrayBuffer | null> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -22,24 +22,39 @@ function getBase64(file: File): Promise<string | ArrayBuffer | null> {
})
export class CouponEditComponent implements OnInit {
validateForm!: FormGroup;
data: any;
editFlag = false;
id: number;
passwordVisible = false;
logoFile = [];
couponImg = [];
couponCarouselImg = [];
WEB_SERVE_URL = environment.baseUrl;
previewImage: string | undefined = '';
previewVisible = false;
optionList: string[] = [];
isLoading = false;
pageNum = 1;
merchantName: string;
optionListCoupon: string[] = [];
isLoadingCoupon = false;
pageNumCoupon = 1;
couponName: string;
content: string;
constructor(
private fb: FormBuilder,
private merchant: MerchantService,
private coupon: CouponService,
private message: NzMessageService, // 信息提示
private activatedRoute: ActivatedRoute,
) {
}
ngOnInit(): void {
this.activatedRoute.queryParams.subscribe(queryParams => {
if (queryParams.merchantId != null) {
@ -49,15 +64,102 @@ export class CouponEditComponent implements OnInit {
}
});
this.validateForm = this.fb.group({
couponName: [null, [Validators.required, ValidatorsService.minLength(2)]],
couponName: [null, [Validators.required]],
couponPrice: [null, [Validators.required]],
couponDesc: [null],
couponType: [null, [Validators.required]],
salesEndTime: [null, [Validators.required]],
recycleDay: [1, [Validators.required]],
limitNumber: [null, [Validators.required]],
salesPrice: [null, [Validators.required]],
salesCount: [null, [Validators.required]],
merchantId: [null, [Validators.required]],
isPresent: [false, [Validators.required]],
handselCouponList: [null],
status: [null],
createTime: [null],
secUser: {},
});
}
// 查询商户
loadMore(): void {
this.isLoading = true;
const paramsObject = {
pageNum: this.pageNum,
pageSize: 10,
merchantName: this.merchantName,
};
this.getMerchantList(paramsObject);
}
// 搜索商户
search(e): void {
this.optionList = [];
this.isLoading = true;
this.merchantName = e;
this.pageNum = 1;
const paramsObject = {
pageNum: this.pageNum,
pageSize: 10,
merchantName: e,
};
this.getMerchantList(paramsObject);
}
// 查询商户
public getMerchantList(paramsObject): void {
this.merchant.getMerchantList(paramsObject , 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];
} else {
this.isLoading = false;
}
});
}
// 查询卡券
loadMoreCoupon(): void {
this.isLoadingCoupon = true;
const paramsObject = {
pageNum: this.pageNumCoupon,
pageSize: 10,
merchantName: this.merchantName,
};
this.getCouponList(paramsObject);
}
// 搜索卡券
searchCoupon(e): void {
this.optionListCoupon = [];
this.isLoadingCoupon = true;
this.merchantName = e;
this.pageNumCoupon = 1;
const paramsObject = {
pageNum: this.pageNumCoupon,
pageSize: 10,
merchantName: e,
};
this.getCouponList(paramsObject);
}
// 查询卡券
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];
} else {
this.isLoading = false;
}
});
}
// 返回
getBack() {
history.back();
@ -68,7 +170,8 @@ export class CouponEditComponent implements OnInit {
this.validateForm.reset();
}
// 课程保存
// 保存
public getSave(): void {
// tslint:disable-next-line:forin
for (const i in this.validateForm.controls) {
@ -80,19 +183,36 @@ export class CouponEditComponent implements OnInit {
}
}
this.validateForm.value['secUser']['telephone'] = this.validateForm.value.loginTelephone;
this.validateForm.value['secUser']['password'] = this.validateForm.value.password;
if (this.logoFile.length !== 0) {
if (this.logoFile[0]['response'] != null) {
this.validateForm.value.merchantLogo = this.logoFile[0]['response']['return_data'][0];
if (this.couponImg.length !== 0) {
if (this.couponImg[0]['response'] != null) {
this.validateForm.value.couponImg = this.couponImg[0]['response']['return_data'][0];
} else {
this.validateForm.value.merchantLogo = this.logoFile[0].name;
this.validateForm.value.couponImg = this.couponImg[0].name;
}
} else {
this.message.error('请上传卡券图片');
return;
}
const couponCarouselImg = [];
if (this.couponCarouselImg.length !== 0) {
for (const i of this.couponCarouselImg) {
if (i['response'] != null) {
couponCarouselImg.push(i['response']['return_data'][0]);
} else {
this.validateForm.value.couponCarouselImg = i.name;
}
}
} else {
this.message.error('请上传卡券轮播图');
return;
}
this.validateForm.value.couponCarouselImg = couponCarouselImg.join(',');
this.validateForm.value.couponDesc = this.content;
if (this.editFlag) {
this.validateForm.value.id = this.id;
this.merchant.updateMerchant(this.validateForm.value, data => {
this.coupon.updateCoupon(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('修改成功');
@ -102,8 +222,7 @@ export class CouponEditComponent implements OnInit {
});
} else {
this.merchant.insertMerchant(this.validateForm.value, data => {
console.log(data);
this.coupon.insertCoupon(this.validateForm.value, data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.success('添加成功');
@ -127,8 +246,6 @@ export class CouponEditComponent implements OnInit {
public getDetails(id) {
this.merchant.getMerchantById(id, data => {
if (data['return_code'] === '000000') {
data['return_data'].loginTelephone = data['return_data'].secUser.loginName;
data['return_data'].password = data['return_data'].secUser.password;
if (data['return_data']['merchantLogo'] != null && data['return_data']['merchantLogo'] !== '') {
const logo = String(data['return_data']['merchantLogo']);
const logoArray = [];
@ -139,7 +256,7 @@ export class CouponEditComponent implements OnInit {
status: 'done',
url: environment.imageUrl + logo
});
this.logoFile = logoArray;
// this.logoFile = logoArray;
}
this.validateForm.patchValue(data['return_data']);
} else {
@ -147,4 +264,9 @@ export class CouponEditComponent implements OnInit {
}
});
}
// 富文本内容
textData(content) {
this.content = content;
}
}

@ -9,17 +9,19 @@ import {NgZorroAntdModule} from 'ng-zorro-antd';
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';
@NgModule({
declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent],
imports: [
CommonModule,
CouponRoutingModule,
NgZorroAntdModule,
SeparateModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule
]
imports: [
CommonModule,
CouponRoutingModule,
NgZorroAntdModule,
SeparateModule,
ReactiveFormsModule,
FormsModule,
BreadcrumbModule,
RichtextModule
]
})
export class CouponModule { }

@ -41,6 +41,11 @@ const routes: Routes = [
loadChildren: () => import('./admin/coupon/coupon.module').then(m => m.CouponModule),
canActivate: [InitGuardService]
},
{
path: 'company',
loadChildren: () => import('./admin/company/company.module').then(m => m.CompanyModule),
canActivate: [InitGuardService]
},
{
path: 'system',
loadChildren: () => import('./admin/system/system.module').then(m => m.SystemModule),

@ -0,0 +1,92 @@
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 CompanyService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param paramsObject
* @param callBack
*/
public selectCompanyList(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'bsCompany/selectCompanyList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public addCompanyAndUser(params: object, callBack) {
this.http.post(environment.baseUrl + 'bsCompany/addCompanyAndUser', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public updateCompany(params: object, callBack) {
this.http.post(environment.baseUrl + 'bsCompany/updateCompany', params).subscribe(data => {
callBack(data);
});
}
/**
* id查询详情
*
* @param companyId id
* @param callBack
*/
public getMerchantById(companyId: number, callBack) {
this.http.get(environment.baseUrl + 'bsCompany/companyView?companyId=' + companyId).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 => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param callBack
*/
public enableMerchant(id: number, callBack) {
this.http.get(environment.baseUrl + 'highMerchant/enableMerchant?id=' + id).subscribe(data => {
callBack(data);
});
}
}

@ -0,0 +1,91 @@
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 CouponService {
constructor(
private http: HttpClient,
private common: CommonsService
) { }
/**
*
*
* @param paramsObject
* @param callBack
*/
public getCouponList(paramsObject: object, callBack) {
this.http.get(environment.baseUrl + 'coupon/getCouponList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public insertCoupon(params: object, callBack) {
this.http.post(environment.baseUrl + 'coupon/insertCoupon', params).subscribe(data => {
callBack(data);
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public updateCoupon(params: object, callBack) {
this.http.post(environment.baseUrl + 'coupon/updateCoupon', params).subscribe(data => {
callBack(data);
});
}
/**
* id查询详情
*
* @param merchantId id
* @param callBack
*/
public getMerchantById(merchantId: number, callBack) {
this.http.get(environment.baseUrl + 'highMerchant/getMerchantById?id=' + merchantId).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 => {
callBack(data);
});
}
/**
*
*
* @param id id
* @param callBack
*/
public enableMerchant(id: number, callBack) {
this.http.get(environment.baseUrl + 'highMerchant/enableMerchant?id=' + id).subscribe(data => {
callBack(data);
});
}
}

@ -12,7 +12,7 @@ export class IconService {
constructor(private iconService: NzIconService) {
this.iconService.fetchFromIconfont({
scriptUrl: 'https://at.alicdn.com/t/font_2424521_y0mw6uv5r2.js'
scriptUrl: 'https://at.alicdn.com/t/font_2424521_5ot4v5e6dp.js'
});
}
}

Loading…
Cancel
Save