袁野 6 months ago
parent 0011f75a51
commit 00831186a5
  1. 25
      src/app/model/discount.interface.ts
  2. 4
      src/app/pages/goods/goods-brand/goods-brand.component.ts
  3. 177
      src/app/pages/marketing/discount-list/discount-list.component.html
  4. 3
      src/app/pages/marketing/discount-list/discount-list.component.less
  5. 170
      src/app/pages/marketing/discount-list/discount-list.component.ts
  6. 13
      src/app/services/goods/goods.service.ts
  7. 69
      src/app/services/marketing/discount.service.ts

@ -0,0 +1,25 @@
export interface DiscountData {
id: number;
name: string;
img: string;
type: number;
condition: string;
price: string;
percentage: string;
effectiveDay: number;
effectiveNum: number;
createTime: string;
updateTime: string;
salesEndTime: string,
}
export interface NodesDiscountGoods {
id: number;
discountId: number;
specsId: String;
specsName: String;
createTime: string;
goodsName: string;
SpecsName: string;
salePrice: string;
}

@ -150,6 +150,8 @@ export class GoodsBrandComponent {
if (!this.commonService.whetherStringIsNull(item.imgUrl)) { if (!this.commonService.whetherStringIsNull(item.imgUrl)) {
this.imgUrl = this.commonService.stitchImg(item.imgUrl); this.imgUrl = this.commonService.stitchImg(item.imgUrl);
} }
} else {
this.editForm.reset();
} }
this.isVisibleEdit = true; this.isVisibleEdit = true;
} }
@ -191,7 +193,7 @@ export class GoodsBrandComponent {
// 删除 // 删除
delete(id: number): void { delete(id: number): void {
this.goodsService.deleteBran(id , (data: any) => { this.goodsService.deleteBrand(id , (data: any) => {
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.msg.success("成功!"); this.msg.success("成功!");
this.getRequest(); this.getRequest();

@ -2,13 +2,33 @@
<div nz-row [nzGutter]="24"> <div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="6"> <div nz-col [nzSpan]="6">
<nz-form-item> <nz-form-item>
<nz-form-label>品牌名称</nz-form-label> <nz-form-label>名称</nz-form-label>
<nz-form-control> <nz-form-control>
<input nzSize="large" nz-input formControlName="title" placeholder="请输入" /> <input nzSize="large" nz-input formControlName="name" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>优惠券类型</nz-form-label>
<nz-form-control>
<nz-select nzSize="large" nzShowSearch nzAllowClear formControlName="type" nzPlaceHolder="请选择">
<nz-option *ngFor="let item of discountType" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>优惠券状态</nz-form-label>
<nz-form-control>
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="status">
<nz-option nzLabel="编辑中" nzValue="1"></nz-option>
<nz-option nzLabel="上线中" nzValue="2"></nz-option>
</nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
<div nz-col [nzSpan]="6" class="search-area"> <div nz-col [nzSpan]="6" class="search-area">
<button nz-button [nzType]="'primary'" (click)="getRequest(true)">查询</button> <button nz-button [nzType]="'primary'" (click)="getRequest(true)">查询</button>
<button nz-button (click)="searchForm.reset()">重置</button> <button nz-button (click)="searchForm.reset()">重置</button>
@ -21,6 +41,7 @@
[nzBordered]="true" [nzBordered]="true"
[nzFrontPagination]="false" [nzFrontPagination]="false"
[nzShowQuickJumper]="true" [nzShowQuickJumper]="true"
[nzScroll]="{ x: '1980px' }"
[nzShowTotal]="totalTemplate" [nzShowTotal]="totalTemplate"
[(nzPageIndex)]="tablePageNum" [(nzPageIndex)]="tablePageNum"
(nzPageIndexChange)="getRequest(false)" (nzPageIndexChange)="getRequest(false)"
@ -28,25 +49,51 @@
[nzData]="tableData.list" > [nzData]="tableData.list" >
<thead> <thead>
<tr> <tr>
<th nzWidth="80px">品牌名称</th> <th nzLeft nzWidth="80px">优惠券名称</th>
<th nzWidth="100px">品牌图片</th> <th nzWidth="80px">优惠券图片</th>
<th nzWidth="50px">创建时间</th> <th nzWidth="100px">优惠券类型</th>
<th nzWidth="50px">更新时间</th> <th nzWidth="160px">优惠内容</th>
<th nzWidth="70px">操作</th> <th nzWidth="70px">有效天数</th>
<th nzWidth="70px">领取数量(个)</th>
<th nzWidth="100px">使用截止日期</th>
<th nzWidth="100px">创建时间</th>
<th nzWidth="100px">更新时间</th>
<th nzRight nzWidth="70px">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of basicTable.data"> <tr *ngFor="let data of basicTable.data">
<td>{{data.title}}</td> <td nzLeft>{{data.name}}</td>
<td>
<img nz-image width="60px" height="60px" nzSrc="{{imageUrl + data.img }}" [nzFallback]="fallbackImg" alt="" />
</td>
<td>{{data.type | dictionary: 'DISCOUNT_TYPE'}}</td>
<td> <td>
<img nz-image width="60px" height="60px" nzSrc="{{imageUrl + data.imgUrl }}" [nzFallback]="fallbackImg" alt="" /> <span *ngIf="data.type == 1" nzType="danger">满{{data.condition}}直减{{data.price}}</span>
<span *ngIf="data.type == 2" nzType="danger">直减{{data.price}}</span>
<span *ngIf="data.type == 3" nzType="danger">优惠{{100 - data.percentage}}%</span>
</td> </td>
<td>{{data.effectiveDay}}天</td>
<td>{{data.effectiveNum}}</td>
<td>{{ data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> <td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{ data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td> <td>{{ data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td> <td nzRight>
<a (click)="showEdit(data)">修改</a> <a (click)="showEdit(data)">修改</a>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a> <a nz-dropdown [nzDropdownMenu]="menu">
更多
<span nz-icon nzType="down"></span>
</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item><a (click)="showDiscountSpecsList(data)">绑定规格</a></li>
<li nz-menu-item nzDanger>
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a>
</li>
</ul>
</nz-dropdown-menu>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -54,24 +101,79 @@
<!--添加弹出框--> <!--添加弹出框-->
<nz-modal [(nzVisible)]="isVisibleEdit" [nzMaskClosable] = false nzTitle="编辑类目" (nzOnCancel)="isVisibleEdit = false" (nzOnOk)="handleEdit()"> <nz-modal [(nzVisible)]="isVisibleEdit" [nzMaskClosable] = false nzTitle="编辑优惠券" (nzOnCancel)="isVisibleEdit = false" (nzOnOk)="handleEdit()">
<ng-container *nzModalContent> <ng-container *nzModalContent>
<form nz-form [formGroup]="editForm"> <form nz-form [formGroup]="editForm">
<nz-form-item > <nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>标题</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>标题</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入标题!"> <nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入标题!">
<input nzSize="large" nz-input formControlName="title" placeholder="请输入" /> <input nzSize="large" nz-input formControlName="name" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>优惠券类型</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请选择优惠券类型!">
<nz-select nzSize="large" nzShowSearch nzAllowClear formControlName="type" nzPlaceHolder="请选择" (ngModelChange)="typeChange($event)">
<nz-option *ngFor="let item of discountType" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editForm.value.type == 1">
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>满减条件</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入满减条件!">
<nz-input-number-group nzPrefix="¥" nzSuffix="RMB" style="width: 100%">
<nz-input-number formControlName="condition" [nzPrecision]="2" ></nz-input-number>
</nz-input-number-group>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editForm.value.type == 1 ||editForm.value.type == 2 ">
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>优惠金额</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入优惠金额!">
<nz-input-number-group nzPrefix="¥" nzSuffix="RMB" style="width: 100%">
<nz-input-number formControlName="price" [nzPrecision]="2" ></nz-input-number>
</nz-input-number-group>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editForm.value.type == 3 ">
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>优惠折扣</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入优惠折扣!">
<nz-input-number-group nzSuffix="%" style="width: 100%">
<nz-input-number formControlName="percentage" [nzPrecision]="2" ></nz-input-number>
</nz-input-number-group>
</nz-form-control>
</nz-form-item>
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>最大领取数量</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入最大领取数量!">
<nz-input-number style="width: 100%" formControlName="effectiveNum" [nzSize]="'large'" [nzMin]="1" [nzMax]="99999" [nzStep]="1" ></nz-input-number>
</nz-form-control>
</nz-form-item>
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>有效天数</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入有效天数!">
<nz-input-number style="width: 100%" formControlName="effectiveDay" [nzSize]="'large'" [nzMin]="1" [nzMax]="99999" [nzStep]="1" ></nz-input-number>
</nz-form-control>
</nz-form-item>
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>领取最终时间</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请选择领取最终时间!">
<nz-date-picker
nzSize="large"
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
formControlName="salesEndTime"
nzPlaceHolder="请选择领取最终时间"
></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item > <nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" >上传图片</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" >上传图片</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-form-control [nzSm]="14" [nzXs]="24">
<nz-upload <nz-upload
nzAction="{{baseUrl}}fileUpload/fileUpload" nzAction="{{baseUrl}}fileUpload/fileUpload"
nzListType="picture-card" nzListType="picture-card"
[(nzFileList)]="imgUrl" [(nzFileList)]="img"
[nzShowButton]="imgUrl.length < 1" [nzShowButton]="img.length < 1"
[nzPreview]="handlePreview" [nzPreview]="handlePreview"
nzAccept="image/*" nzAccept="image/*"
> >
@ -96,3 +198,44 @@
</form> </form>
</ng-container> </ng-container>
</nz-modal> </nz-modal>
<nz-modal [nzWidth]="1400" [(nzVisible)]="isVisibleSpecsDiscount" nzTitle="{{discount?.name}}-绑定商品列表" [nzFooter]="null" (nzOnCancel)="isVisibleSpecsDiscount= false">
<!--列表-->
<ng-container *nzModalContent>
<button nz-button (click)="bindDiscountSpecs()" nzType="primary">绑定商品</button>
<button nz-button [nzType]="'default'" (click)="getSpecsDiscountList()">查询</button>
<br />
<br />
<nz-table #basicTable [nzData]="nodesDiscountGoods">
<thead>
<tr>
<th>商品名称</th>
<th>规格</th>
<th>售价(RMB)</th>
<th>创建时间</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{data.goodsName}}</td>
<td>{{data.specsName}}</td>
<td>¥{{data.salePrice}}</td>
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
</tr>
</tbody>
</nz-table>
</ng-container>
</nz-modal>
<nz-modal [(nzVisible)]="isVisibleBind" nzTitle="绑定商品" (nzOnCancel)="isVisibleBind= false" (nzOnOk)="handleOk()">
<!--列表-->
<ng-container *nzModalContent>
<nz-select
nzMode="multiple"
nzPlaceHolder="请选择绑定商品规格"
[(ngModel)]="listOfSelectBind"
>
<nz-option *ngFor="let item of goodsSpecs" [nzLabel]="item.goodsName + '-' + item.name + '-'+item.salePrice + ''" [nzValue]="item.id"></nz-option>
</nz-select>
</ng-container>
</nz-modal>

@ -10,3 +10,6 @@ button {
.search-area { .search-area {
margin-top: 30px; margin-top: 30px;
} }
nz-select {
width: 100%;
}

@ -1,17 +1,18 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import {DatePipe, NgForOf, NgOptimizedImage, NgStyle} from "@angular/common"; import {DatePipe, NgForOf, NgIf, NgOptimizedImage, NgStyle} from "@angular/common";
import {NzButtonComponent} from "ng-zorro-antd/button"; import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input"; import {NzInputDirective} from "ng-zorro-antd/input";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal"; import {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal";
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzIconDirective} from "ng-zorro-antd/icon"; import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select";
import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload"; import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload";
import {NzDividerComponent} from "ng-zorro-antd/divider"; import {NzDividerComponent} from "ng-zorro-antd/divider";
import { import {
NzCellFixedDirective,
NzTableCellDirective, NzTableCellDirective,
NzTableComponent, NzTableComponent,
NzTbodyComponent, NzTbodyComponent,
@ -23,9 +24,20 @@ import {NzImageModule} from "ng-zorro-antd/image";
import {environment} from "../../../../environments/environment"; import {environment} from "../../../../environments/environment";
import {NzMessageService} from "ng-zorro-antd/message"; import {NzMessageService} from "ng-zorro-antd/message";
import {CommonService} from "../../../services/common/common.service"; import {CommonService} from "../../../services/common/common.service";
import {GoodsService} from "../../../services/goods/goods.service";
import {GoodsTypeData} from "../../../model/goods.interface";
import { fallbackImg } from '../../../data/goods/goods.namespace'; import { fallbackImg } from '../../../data/goods/goods.namespace';
import {DiscountService} from "../../../services/marketing/discount.service";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
import {
NzInputNumberComponent,
NzInputNumberGroupComponent,
NzInputNumberGroupWhitSuffixOrPrefixDirective
} from "ng-zorro-antd/input-number";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {NzTypographyComponent} from "ng-zorro-antd/typography";
import {DiscountData, NodesDiscountGoods} from "../../../model/discount.interface";
import {GoodsService} from "../../../services/goods/goods.service";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
const getBase64 = (file: File): Promise<string | ArrayBuffer | null> => const getBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
@ -68,7 +80,21 @@ const getBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
NzTrDirective, NzTrDirective,
NzPopconfirmDirective, NzPopconfirmDirective,
NzImageModule, NzImageModule,
NgOptimizedImage NgOptimizedImage,
DictionaryPipe,
NzCellFixedDirective,
NgIf,
NzInputNumberComponent,
NzInputNumberGroupComponent,
NzInputNumberGroupWhitSuffixOrPrefixDirective,
NzDatePickerComponent,
NzTypographyComponent,
FormsModule,
NzDropDownADirective,
NzDropDownDirective,
NzDropdownMenuComponent,
NzMenuDirective,
NzMenuItemComponent
], ],
templateUrl: './discount-list.component.html', templateUrl: './discount-list.component.html',
styleUrl: './discount-list.component.less' styleUrl: './discount-list.component.less'
@ -86,7 +112,7 @@ export class DiscountListComponent {
searchForm: FormGroup; searchForm: FormGroup;
// 图片 // 图片
imgUrl: NzUploadFile[] = [] img: NzUploadFile[] = []
baseUrl = environment.baseUrl; baseUrl = environment.baseUrl;
imageUrl = environment.imageUrl; imageUrl = environment.imageUrl;
@ -94,30 +120,50 @@ export class DiscountListComponent {
previewImage: string | undefined = ''; previewImage: string | undefined = '';
// 上传是否展示 // 上传是否展示
previewVisible = false; previewVisible = false;
isVisibleSpecsDiscount = false;
// 编辑产品类型表单 // 编辑产品类型表单
editForm: FormGroup; editForm: FormGroup;
// 编辑弹出框 // 编辑弹出框
isVisibleEdit = false; isVisibleEdit = false;
isVisibleBind = false;
discountType;
discount?: DiscountData;
nodesDiscountGoods:NodesDiscountGoods[] = [];
listOfSelectBind: any = []
goodsSpecs:any = [];
protected readonly fallbackImg = fallbackImg; protected readonly fallbackImg = fallbackImg;
constructor(private fb: NonNullableFormBuilder, constructor(private fb: NonNullableFormBuilder,
private msg: NzMessageService, private msg: NzMessageService,
private commonService: CommonService, private commonService: CommonService,
private goodsService: GoodsService) { private goodsService: GoodsService,
private discountService: DiscountService) {
this.discountType = new DictionaryPipe().getDictionaryList('DISCOUNT_TYPE');
// 初始化搜索框 // 初始化搜索框
this.searchForm = this.fb.group({ this.searchForm = this.fb.group({
title: [''], name: [''],
type: [''],
status: [''],
}); });
// 初始化 // 初始化
this.editForm = this.fb.group({ this.editForm = this.fb.group({
title: ['' , [Validators.required]], name: ['' , [Validators.required]],
type: ['' , [Validators.required]],
effectiveNum: ['' , [Validators.required]],
effectiveDay: ['' , [Validators.required]],
salesEndTime: ['' , [Validators.required]],
condition: ['' , [Validators.required]],
price: ['' , [Validators.required]],
percentage: ['' , [Validators.required]],
img: [''],
id: [null], id: [null],
imgUrl: [''],
}); });
this.getRequest(); this.getRequest();
this.getGoodsSpecsListAll();
} }
@ -131,7 +177,7 @@ export class DiscountListComponent {
this.searchForm.value.pageSize = 10; this.searchForm.value.pageSize = 10;
this.searchForm.value.time = new Date().getTime(); this.searchForm.value.time = new Date().getTime();
this.goodsService.getListBrand(this.searchForm.value , (data: any) => { this.discountService.getListDiscount(this.searchForm.value , (data: any) => {
if (data['return_code'] == '000000') { if (data['return_code'] == '000000') {
this.tableData = data['return_data']; this.tableData = data['return_data'];
} else { } else {
@ -143,24 +189,26 @@ export class DiscountListComponent {
// 唤醒编辑表单 // 唤醒编辑表单
showEdit(item?: GoodsTypeData) { showEdit(item?: any) {
if (item != null) { if (item != null) {
item.businessType = String(item.businessType); item.type = String(item.type);
this.typeChange(item.type)
this.editForm.patchValue(item); this.editForm.patchValue(item);
if (!this.commonService.whetherStringIsNull(item.imgUrl)) { if (!this.commonService.whetherStringIsNull(item.img)) {
this.imgUrl = this.commonService.stitchImg(item.imgUrl); this.img = this.commonService.stitchImg(item.img);
} }
} else {
this.editForm.reset();
} }
this.isVisibleEdit = true; this.isVisibleEdit = true;
} }
// 编辑表单提交 // 编辑表单提交
handleEdit(): void { handleEdit(): void {
if (this.editForm.valid) { if (this.editForm.valid) {
if (this.imgUrl.length !== 0) { if (this.img.length !== 0) {
this.editForm.value.imgUrl = this.commonService.imgList(this.imgUrl); this.editForm.value.img = this.commonService.imgList(this.img);
} }
this.goodsService.editGoodsBrand(this.editForm.value , (data: any) => { this.discountService.editDiscount(this.editForm.value , (data: any) => {
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.msg.success("成功!"); this.msg.success("成功!");
this.isVisibleEdit = false; this.isVisibleEdit = false;
@ -191,7 +239,7 @@ export class DiscountListComponent {
// 删除 // 删除
delete(id: number): void { delete(id: number): void {
this.goodsService.deleteBran(id , (data: any) => { this.discountService.deleteDiscount(id , (data: any) => {
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.msg.success("成功!"); this.msg.success("成功!");
this.getRequest(); this.getRequest();
@ -200,4 +248,84 @@ export class DiscountListComponent {
} }
}); });
} }
typeChange(type: string): void {
if (type == "1") {
this.editForm.controls['percentage'].clearValidators();
this.editForm.controls['percentage'].markAsPristine();
} else if (type == "2") {
this.editForm.controls['percentage'].clearValidators();
this.editForm.controls['percentage'].markAsPristine();
this.editForm.controls['condition'].clearValidators();
this.editForm.controls['condition'].markAsPristine();
} else if (type == "3") {
this.editForm.controls['price'].clearValidators();
this.editForm.controls['price'].markAsPristine();
this.editForm.controls['condition'].clearValidators();
this.editForm.controls['condition'].markAsPristine();
}
this.editForm.controls['percentage'].updateValueAndValidity();
this.editForm.controls['condition'].updateValueAndValidity();
this.editForm.controls['price'].updateValueAndValidity();
}
showDiscountSpecsList(item: DiscountData):void {
this.listOfSelectBind = [];
this.discount = item;
this.getSpecsDiscountList();
this.isVisibleSpecsDiscount = true;
}
bindDiscountSpecs():void {
this.isVisibleBind = true;
}
// 查询绑定商品列表
getSpecsDiscountList(): void {
let params = {
discountId: this.discount?.id,
time: new Date().getTime()
}
this.discountService.getListDiscountGoodsRel(params , (data: any) => {
if (data['return_code'] == '000000') {
console.log("data" , data);
this.nodesDiscountGoods = data['return_data'];
for (const dataKey of this.nodesDiscountGoods) {
this.listOfSelectBind.push(dataKey['specsId'])
}
}
});
}
// 查询所有商品规格
getGoodsSpecsListAll(): void {
this.goodsService.getGoodsSpecsListAll( (data: any) => {
if (data['return_code'] == '000000') {
this.goodsSpecs = data['return_data'];
}
});
}
handleOk(): void {
let params = {
discountId: this.discount?.id,
specsIds: this.listOfSelectBind.join(",")
}
this.discountService.bindDiscountSpecs(params , (data: any) => {
if (data['return_code'] == '000000') {
this.msg.success("绑定成功");
this.getSpecsDiscountList();
this.isVisibleBind = false;
}
});
}
} }

@ -77,7 +77,7 @@ export class GoodsService {
* @param id * @param id
* @param callBack * @param callBack
*/ */
public deleteBran(id: number, callBack:any) { public deleteBrand(id: number, callBack:any) {
this.http.get(environment.baseUrl + 'goodsBrand/delete?id=' + id ).subscribe(data => { this.http.get(environment.baseUrl + 'goodsBrand/delete?id=' + id ).subscribe(data => {
callBack(data); callBack(data);
}); });
@ -149,4 +149,15 @@ export class GoodsService {
}); });
} }
/**
* 线
* @param callBack
*/
public getGoodsSpecsListAll(callBack:any) {
this.http.get(environment.baseUrl + 'goods/getGoodsSpecsListAll?time=' + new Date().getTime()).subscribe(data => {
callBack(data);
});
}
} }

@ -0,0 +1,69 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {environment} from "../../../environments/environment";
import {ObjectData} from "../../utils/objectData.service";
@Injectable({
providedIn: 'root'
})
export class DiscountService {
constructor(private http: HttpClient) { }
/**
*
* @param params
* @param callBack
*/
public getListDiscount(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'discount/getListDiscount?' + ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public editDiscount(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'discount/editDiscount', params).subscribe(data => {
callBack(data);
});
}
/**
*
* @param id
* @param callBack
*/
public deleteDiscount(id: number, callBack:any) {
this.http.get(environment.baseUrl + 'discount/delete?id=' + id ).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public getListDiscountGoodsRel(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'discount/getListDiscountGoodsRel?' + ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public bindDiscountSpecs(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'discount/bindDiscountSpecs', params).subscribe(data => {
callBack(data);
});
}
}
Loading…
Cancel
Save