提交代码

pull/1/head
袁野 4 years ago
parent ecedf9c217
commit 151a8028f9
  1. 67
      src/app/admin/agent/agent-list/agent-list.component.html
  2. 8
      src/app/admin/agent/agent-list/agent-list.component.scss
  3. 61
      src/app/admin/agent/agent-list/agent-list.component.ts
  4. 13
      src/app/services/agent.service.ts

@ -7,7 +7,7 @@
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)">
<div nz-row>
<div nz-col nzSpan="6">
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">名称</nz-form-label>
<nz-form-control [nzSpan]="16">
@ -15,7 +15,7 @@
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">电话</nz-form-label>
<nz-form-control [nzSpan]="16">
@ -23,7 +23,7 @@
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzSpan="6">
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">代理商状态</nz-form-label>
<nz-form-control [nzSpan]="16">
@ -40,7 +40,9 @@
<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>
<button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload"
nzTheme="outline"></i>重置
</button>
</div>
</div>
</form>
@ -50,7 +52,10 @@
<div class="inner-content">
<span>共计 {{total}} 条数据</span>
<div class="operating-button">
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/agent/agent-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button>
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/agent/agent-edit']"><i nz-icon
nzType="plus"
nzTheme="outline"></i>添加
</button>
</div>
<nz-table
class="table"
@ -85,29 +90,29 @@
<td>{{data.agentPhone}}</td>
<td>{{data.createTime | 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)="getDiscount(data.id)"><i nz-icon nzType="api" nzTheme="outline" nz-tooltip="绑定优惠券"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="getDiscountList(data.id)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="优惠券列表"></i></a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)='getForbiddenUser(data.id , data.status)'><i nz-icon nzType="{{data.status === 1 ? 'stop': 'check-circle'}}" nzTheme="outline" nz-tooltip="{{data.status === 1 ? '禁用': '启用'}}"></i></a>
<a (click)="getEdit(data.id)">编辑</a>
<a nz-dropdown [nzDropdownMenu]="menu">更多</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li class="li-a" nz-menu-item><a (click)="getDistribution(data.id)">分发卡券</a></li>
<li class="li-a" nz-menu-item><a (click)="getDiscount(data.id)">绑定优惠券</a></li>
<li class="li-a" nz-menu-item><a (click)="getDiscountList(data.id)">优惠券列表</a></li>
<li class="li-a" nz-menu-item><a (click)='getForbiddenUser(data.id , data.status)'>{{data.status === 1 ? '禁用': '启用'}}</a></li>
</ul>
</nz-dropdown-menu>
</td>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isVisible" nzTitle="分配优惠券" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<nz-spin [nzSpinning]="isSpinning">
<form nz-form [formGroup]="validateForm" class="login-form">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>优惠券</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请选择优惠券!">
<nz-select nzShowSearch nzAllowClear formControlName="discountId" nzPlaceHolder="请选择优惠券">
<nz-option *ngFor="let item of discountList" nzLabel="{{item.discountName}}" nzValue="{{item.id}}"></nz-option>
<nz-option *ngFor="let item of discountList" nzLabel="{{item.discountName}}"
nzValue="{{item.id}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
@ -118,11 +123,10 @@
</nz-form-control>
</nz-form-item>
</form>
</nz-spin>
</nz-modal>
<nz-modal [(nzVisible)]="isVisibleDiscount" nzWidth="1000" nzTitle="分配优惠券列表" (nzOnCancel)="handleCancelDiscount()" (nzOnOk)="handleCancelDiscount()">
<nz-modal [(nzVisible)]="isVisibleDiscount" nzWidth="1000" nzTitle="分配优惠券列表" (nzOnCancel)="handleCancelDiscount()"
(nzOnOk)="handleCancelDiscount()">
<nz-table
class="table"
#ajaxTableDiscount
@ -169,3 +173,26 @@
</tbody>
</nz-table>
</nz-modal>
<nz-modal [(nzVisible)]="isVisibleDistribute" nzTitle="分发卡券" (nzOnCancel)="handleCancelDistribute()" (nzOnOk)="handleOkDistribute()">
<nz-spin [nzSpinning]="isSpinningDistribute">
<form nz-form [formGroup]="validateFormDistribute" class="login-form">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>卡券</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请选择卡券!">
<nz-select nzShowSearch nzAllowClear formControlName="couponId" nzPlaceHolder="请选择卡券">
<nz-option *ngFor="let item of distributeList" nzLabel="{{item.couponName + '-(有效库存:' + item.stockCount + ')'}}"
nzValue="{{item.id}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>分发卡券数量</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="分发卡券数量!">
<input [type]="'number'" nz-input formControlName="stockCount"/>
</nz-form-control>
</nz-form-item>
</form>
</nz-spin>
</nz-modal>

@ -2,3 +2,11 @@
height: 80px;
width: 80px;
}
.table-td-operation {
a {
margin-left: 8px;
}
}
.li-a :hover {
color: #1890ff;
}

@ -8,6 +8,7 @@ import {Router} from '@angular/router';
import {CommonsService} from '../../../services/commons.service';
import {AgentService} from '../../../services/agent.service';
import {DiscountService} from '../../../services/discount.service';
import {CouponService} from '../../../services/coupon.service';
@Component({
selector: 'app-agent-list',
@ -19,25 +20,32 @@ export class AgentListComponent implements OnInit {
WEB_SERVE_URL = environment.imageUrl;
searchForm: FormGroup; // 搜索框
validateForm: FormGroup; // 搜索框
validateFormDistribute: FormGroup; // 搜索框
requestData = []; // 列表数据
discountList = []; // 列表数据
distributeList = []; // 列表数据
total: number; // 页码
pageNum = 1; // 页码
pageSize = 10; // 条码
loading = true;
isVisible = false;
isVisibleDiscount = false;
isVisibleDistribute = false;
id: number;
isSpinning = false;
isSpinningDistribute = false;
requestDataDiscount = []; // 列表数据
totalDiscount: number; // 页码
pageNumDiscount = 1; // 页码
pageSizeDiscount = 10; // 条码
loadingDiscount = true;
agentId: number;
constructor(
private form: FormBuilder,
private agent: AgentService,
private discount: DiscountService,
private coupon: CouponService,
private iconService: IconService,
private message: NzMessageService,
private router: Router,
@ -59,6 +67,10 @@ export class AgentListComponent implements OnInit {
discountId: [null, [Validators.required]],
stockCount: [null, [Validators.required]],
});
this.validateFormDistribute = this.form.group({
couponId: [null, [Validators.required]],
stockCount: [null, [Validators.required]],
});
this.getRequest(true, this.searchForm.value);
}
@ -98,7 +110,6 @@ export class AgentListComponent implements OnInit {
});
}
// 修改
public getEdit(id: number): void {
this.router.navigate(['/admin/agent/agent-edit'], {
@ -143,10 +154,11 @@ export class AgentListComponent implements OnInit {
return;
}
}
this.isSpinning = true;
// this.isSpinning = true;
this.validateForm.value['agentId'] = this.id;
this.agent.insertDiscountAgent(this.validateForm.value , data => {
if (data['return_code'] === '000000') {
this.message.success('生成中,请耐心等待!');
this.isVisible = false;
} else {
this.message.error(data['return_msg']);
@ -168,7 +180,9 @@ export class AgentListComponent implements OnInit {
handleCancelDiscount() {
this.isVisibleDiscount = false;
}
handleCancelDistribute() {
this.isVisibleDistribute = false;
}
// 查询列表
public getRequestDiscount(reset: boolean = false) {
const whereObject = {};
@ -188,5 +202,46 @@ export class AgentListComponent implements OnInit {
}
});
}
// 分发卡券
public getDistribution(id: number): void {
this.isSpinningDistribute = true;
this.agentId = id;
const whereObject = {};
whereObject['pageNum'] = 1;
whereObject['pageSize'] = 10000;
this.coupon.getCouponList(whereObject, data => {
if (data['return_code'] === '000000') {
this.distributeList = data['return_data'].list;
} else {
this.message.error(data['return_msg']);
}
this.isSpinningDistribute = false;
});
this.isVisibleDistribute = true;
}
// 提交分发
public handleOkDistribute(): void {
// tslint:disable-next-line:forin
for (const i in this.validateFormDistribute.controls) {
this.validateFormDistribute.controls[i].markAsDirty();
this.validateFormDistribute.controls[i].updateValueAndValidity();
if (this.validateFormDistribute.controls[i].errors != null) {
this.message.error('必填项不能为空');
return;
}
}
this.validateFormDistribute.value['agentId'] = this.agentId;
this.agent.assignCouponAgent(this.validateFormDistribute.value , data => {
if (data['return_code'] === '000000') {
this.message.success('分发成功');
this.isVisibleDistribute = false;
} else {
this.message.error(data['return_msg']);
}
this.isSpinning = false;
});
}
}

@ -91,6 +91,19 @@ export class AgentService {
});
}
/**
*
*
* @param params
* @param callBack
* @return data
*/
public assignCouponAgent(params: object, callBack) {
this.http.post(environment.baseUrl + 'highCouponAgent/assignCouponAgent', params).subscribe(data => {
callBack(data);
});
}
/**
*
*

Loading…
Cancel
Save