胡锐 6 months ago
commit 0f381c3f7d
  1. 41
      src/app/model/goods.interface.ts
  2. 229
      src/app/pages/goods/goods-list/goods-list.component.html
  3. 209
      src/app/pages/goods/goods-list/goods-list.component.ts
  4. 46
      src/app/services/goods/goods.service.ts
  5. 9
      src/environments/environment.ts

@ -12,3 +12,44 @@ export interface GoodsTypeData {
children?: GoodsTypeData[]; children?: GoodsTypeData[];
parent?: GoodsTypeData; parent?: GoodsTypeData;
} }
export interface GoodsMsgData {
id: number;
goodsTypeName: string;
goodsType: number;
type: number;
goodsBrandName: string;
goodsBrand: number;
goodsLabel: string;
title: string;
listImg: string;
bannerImg: string;
detailImg: string;
status: number;
createTime: string;
updateTime: string;
merId: string;
merName: string;
}
export interface SpecsData {
id: number;
goodsId: number;
name: string;
purLimit: number;
salePrice: number;
originalPrice: number;
stock: number;
showImg: string;
status: number;
createTime: string;
updateTime: string;
specsId: number;
key: string;
validDay: string;
salesEndTime: string,
type: number,
source: string,
jumpType: number,
jumpUrl: string,
appid: string
}

@ -100,13 +100,24 @@
<td> <td>
<a (click)="showEdit(data)">修改</a> <a (click)="showEdit(data)">修改</a>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<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)="showSpecsList(data)">规格列表</a></li>
<li nz-menu-item nzDanger>
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a> <a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a>
</li>
</ul>
</nz-dropdown-menu>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template> <ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>
<!--添加弹出框--> <!--添加弹出框-->
<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>
@ -117,6 +128,7 @@
<input nzSize="large" nz-input formControlName="title" placeholder="请输入" /> <input nzSize="large" nz-input formControlName="title" placeholder="请输入" />
</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">
@ -145,6 +157,18 @@
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24">商品标签</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入商品标签!">
<input nzSize="large" nz-input formControlName="goodsLabel" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24">商品说明</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入商品说明!">
<input nzSize="large" nz-input formControlName="goodsExplain" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
<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"> <nz-form-control [nzSm]="14" [nzXs]="24">
@ -171,7 +195,6 @@
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" alt=""/> <img [src]="previewImage" [ngStyle]="{ width: '100%' }" alt=""/>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item > <nz-form-item >
@ -235,3 +258,205 @@
</form> </form>
</ng-container> </ng-container>
</nz-modal> </nz-modal>
<nz-modal [nzWidth]="1400" [(nzVisible)]="isVisibleSpecs" nzTitle="{{goodsMsg?.title}}-规格列表" [nzFooter]="null" (nzOnCancel)="isVisibleSpecs= false">
<!--列表-->
<ng-container *nzModalContent>
<button nz-button (click)="showEditSpecs()" nzType="primary">创建</button>
<button nz-button [nzType]="'default'" (click)="getSpecsList()">查询</button>
<br />
<br />
<nz-table [nzScroll]="{ x: '1980px' }" [nzBordered]="true" #basicTable [nzData]="nodesSpecs">
<thead>
<tr>
<th nzLeft rowspan="2">规格名称</th>
<th colspan="2">价格(RMB)</th>
<th rowspan="2">图片</th>
<th rowspan="2">限购(个)</th>
<th rowspan="2">库存(个)</th>
<th colspan="2">时间</th>
<th colspan="7" *ngIf="goodsMsg?.type == 2">虚拟产品</th>
<th rowspan="2" nzRight>操作</th>
</tr>
<tr>
<th rowspan="1">售价</th>
<th rowspan="1">原价</th>
<th rowspan="1">销售截止时间</th>
<th rowspan="1">创建时间</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">卡密</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">归库天数</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">类型</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">产品来源</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">跳转类型</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">跳转地址</th>
<th *ngIf="goodsMsg?.type == 2" rowspan="1">应用ID</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td nzLeft>{{data.name}}</td>
<td>
<span style="font-size: 24px;" nz-typography nzType="danger">¥{{data.salePrice}}</span>
</td>
<td>
<span nz-typography nzType="secondary">¥{{data.originalPrice}}</span>
</td>
<td>
<img nz-image width="60px" height="60px" nzSrc="{{imageUrl + data.showImg }}" [nzFallback]="fallbackImg" alt="" />
</td>
<td>{{data.purLimit}}</td>
<td>{{data.stock}}</td>
<td>{{ data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.key}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.validDay}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.type == 1 ? '内部虚拟商品' : '外部虚拟产品'}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.source | dictionary: 'GOODS_VPD_SOURCE'}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.jumpType == 1 ? '小程序' : 'H5'}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.jumpUrl}}</td>
<td *ngIf="goodsMsg?.type == 2">{{data.appid}}</td>
<td nzRight>
<a (click)="showEditSpecs(data)">修改</a>
<nz-divider nzType="vertical"></nz-divider>
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="deleteGoodsSpecs(data.specsId)">删除</a>
</td>
</tr>
</tbody>
</nz-table>
</ng-container>
</nz-modal>
<!--添加弹出框-->
<nz-modal [(nzVisible)]="editSpecs" [nzMaskClosable] = false nzTitle="编辑规格" (nzOnCancel)="editSpecs = false" (nzOnOk)="handleEditSpecs()">
<ng-container *nzModalContent>
<form nz-form [formGroup]="editSpecsForm">
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>规格名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入规格名称!">
<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-input-number style="width: 100%" formControlName="purLimit" [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-group nzPrefix="¥" nzSuffix="RMB" style="width: 100%">
<nz-input-number formControlName="salePrice" [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-group nzPrefix="¥" nzSuffix="RMB" style="width: 100%">
<nz-input-number formControlName="originalPrice" [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="stock" [nzSize]="'large'" [nzMin]="1" [nzMax]="99999" [nzStep]="1" ></nz-input-number>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="goodsMsg?.type == 2">
<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="validDay" [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-item>
<nz-form-item *ngIf="goodsMsg?.type == 2">
<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="source" nzPlaceHolder="请选择">
<nz-option *ngFor="let item of nodesVpdSource" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="goodsMsg?.type == 2">
<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 nzPlaceHolder="请选择" formControlName="type" (ngModelChange)="typeChange($event)">
<nz-option nzLabel="内部虚拟商品" nzValue="1"></nz-option>
<nz-option nzLabel="外部虚拟产品" nzValue="2"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editSpecsForm.value.type == 2">
<nz-form-label [nzSm]="6" [nzXs]="24">卡密</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nzSize="large" nz-input formControlName="key" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editSpecsForm.value.type == 2">
<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 nzPlaceHolder="请选择" formControlName="jumpType" (ngModelChange)="jumpTypeChange($event)">
<nz-option nzLabel="小程序" nzValue="1"></nz-option>
<nz-option nzLabel="H5" nzValue="2"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editSpecsForm.value.type == 2">
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>跳转地址</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入跳转地址!">
<input nzSize="large" nz-input formControlName="jumpUrl" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="editSpecsForm.value['jumpType'] == 1">
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>应用ID</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入应用ID!">
<input nzSize="large" nz-input formControlName="appid" 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">
<nz-upload
nzAction="{{baseUrl}}fileUpload/fileUpload"
nzListType="picture-card"
[(nzFileList)]="showImg"
[nzShowButton]="showImg.length < 1"
[nzPreview]="handlePreview"
nzAccept="image/*"
>
<div>
<span nz-icon nzType="plus"></span>
<div style="margin-top: 8px">上传图片</div>
</div>
</nz-upload>
<nz-modal
[nzVisible]="previewVisible"
[nzContent]="modalContent"
[nzFooter]="null"
(nzOnCancel)="previewVisible = false"
>
<ng-template #modalContent>
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" alt=""/>
</ng-template>
</nz-modal>
</nz-form-control>
</nz-form-item>
</form>
</ng-container>
</nz-modal>

@ -12,7 +12,7 @@ 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 {GoodsService} from "../../../services/goods/goods.service";
import { fallbackImg } from '../../../data/goods/goods.namespace'; import { fallbackImg } from '../../../data/goods/goods.namespace';
import {GoodsTypeData} from "../../../model/goods.interface"; import {GoodsMsgData, GoodsTypeData, SpecsData} from "../../../model/goods.interface";
import {NzDividerComponent} from "ng-zorro-antd/divider"; import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzIconDirective} from "ng-zorro-antd/icon"; import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzImageDirective, NzImageModule} from "ng-zorro-antd/image"; import {NzImageDirective, NzImageModule} from "ng-zorro-antd/image";
@ -26,6 +26,16 @@ import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe"; import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe";
import {NzConfigService} from "ng-zorro-antd/core/config"; import {NzConfigService} from "ng-zorro-antd/core/config";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {
NzInputNumberComponent,
NzInputNumberGroupComponent,
NzInputNumberGroupWhitSuffixOrPrefixDirective
} from "ng-zorro-antd/input-number";
import {NzSpaceItemDirective} from "ng-zorro-antd/space";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {NzTypographyComponent} from "ng-zorro-antd/typography";
const getBase64 = (file: File): Promise<string | ArrayBuffer | null> => const getBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
@ -67,7 +77,18 @@ const getBase64 = (file: File): Promise<string | ArrayBuffer | null> =>
NzTreeSelectComponent, NzTreeSelectComponent,
NzDividerComponent, NzDividerComponent,
NzPopconfirmDirective, NzPopconfirmDirective,
GoodsStatusPipe GoodsStatusPipe,
NzDropDownADirective,
NzDropDownDirective,
NzDropdownMenuComponent,
NzMenuDirective,
NzMenuItemComponent,
NzInputNumberComponent,
NzInputNumberGroupWhitSuffixOrPrefixDirective,
NzSpaceItemDirective,
NzInputNumberGroupComponent,
NzDatePickerComponent,
NzTypographyComponent
], ],
templateUrl: './goods-list.component.html', templateUrl: './goods-list.component.html',
styleUrl: './goods-list.component.less' styleUrl: './goods-list.component.less'
@ -88,6 +109,7 @@ export class GoodsListComponent {
listImg: NzUploadFile[] = [] listImg: NzUploadFile[] = []
bannerImg: NzUploadFile[] = [] bannerImg: NzUploadFile[] = []
detailImg: NzUploadFile[] = [] detailImg: NzUploadFile[] = []
showImg: NzUploadFile[] = []
baseUrl = environment.baseUrl; baseUrl = environment.baseUrl;
imageUrl = environment.imageUrl; imageUrl = environment.imageUrl;
@ -98,11 +120,20 @@ export class GoodsListComponent {
// 编辑产品类型表单 // 编辑产品类型表单
editForm: FormGroup; editForm: FormGroup;
editSpecsForm: FormGroup;
// 编辑弹出框 // 编辑弹出框
isVisibleEdit = false; isVisibleEdit = false;
// 编辑商品规格弹出框
isVisibleSpecs = false;
editSpecs = false;
loadingSpecs = false;
// 商品类型数据 // 商品类型数据
nodes = []; nodes = [];
nodesBrand = []; nodesBrand = [];
nodesSpecs:SpecsData[] = [];
nodesVpdSource;
goodsMsg?: GoodsMsgData;
protected readonly fallbackImg = fallbackImg; protected readonly fallbackImg = fallbackImg;
@ -111,6 +142,9 @@ export class GoodsListComponent {
private commonService: CommonService, private commonService: CommonService,
private goodsService: GoodsService) { private goodsService: GoodsService) {
this.nodesVpdSource = new DictionaryPipe().getDictionaryList('GOODS_VPD_SOURCE');
// 初始化搜索框 // 初始化搜索框
this.searchForm = this.fb.group({ this.searchForm = this.fb.group({
title: [''], title: [''],
@ -130,6 +164,25 @@ export class GoodsListComponent {
goodsLabel: [''], goodsLabel: [''],
goodsExplain: [''], goodsExplain: [''],
}); });
// 初始化
this.editSpecsForm = this.fb.group({
name: ['' , [Validators.required]],
purLimit: ['' , [Validators.required]],
salePrice: ['' , [Validators.required]],
originalPrice: ['' , [Validators.required]],
stock: ['' , [Validators.required]],
validDay: ['' , [Validators.required]],
salesEndTime: ['' , [Validators.required]],
type: [''],
source: [''],
id: [null],
specsId: [null],
jumpType: [null],
jumpUrl: [null],
goodsId: [null],
appid: [null],
key: [''],
});
this.getRequest(); this.getRequest();
this.getGoodsTypeNode(); this.getGoodsTypeNode();
this.getGoodsBrandNode(); this.getGoodsBrandNode();
@ -160,7 +213,8 @@ export class GoodsListComponent {
// 唤醒编辑表单 // 唤醒编辑表单
showEdit(item?: any) { showEdit(item?: any) {
if (item != null) { if (item != null) {
item.businessType = String(item.businessType); item.goodsBrand = String(item.goodsBrand);
item.type = String(item.type);
this.editForm.patchValue(item); this.editForm.patchValue(item);
if (!this.commonService.whetherStringIsNull(item.listImg)) { if (!this.commonService.whetherStringIsNull(item.listImg)) {
this.listImg = this.commonService.stitchImg(item.listImg); this.listImg = this.commonService.stitchImg(item.listImg);
@ -171,6 +225,8 @@ export class GoodsListComponent {
if (!this.commonService.whetherStringIsNull(item.detailImg)) { if (!this.commonService.whetherStringIsNull(item.detailImg)) {
this.detailImg = this.commonService.stitchImg(item.detailImg); this.detailImg = this.commonService.stitchImg(item.detailImg);
} }
} else {
this.editForm.reset()
} }
this.isVisibleEdit = true; this.isVisibleEdit = true;
} }
@ -181,17 +237,20 @@ export class GoodsListComponent {
if (this.listImg.length !== 0) { if (this.listImg.length !== 0) {
this.editForm.value.listImg = this.commonService.imgList(this.listImg); this.editForm.value.listImg = this.commonService.imgList(this.listImg);
} else { } else {
this.msg.error("请上传列表图片") this.msg.error("请上传列表图片");
return;
} }
if (this.bannerImg.length !== 0) { if (this.bannerImg.length !== 0) {
this.editForm.value.bannerImg = this.commonService.imgList(this.bannerImg); this.editForm.value.bannerImg = this.commonService.imgList(this.bannerImg);
} else { } else {
this.msg.error("请上传轮播图片") this.msg.error("请上传轮播图片");
return;
} }
if (this.detailImg.length !== 0) { if (this.detailImg.length !== 0) {
this.editForm.value.detailImg = this.commonService.imgList(this.detailImg); this.editForm.value.detailImg = this.commonService.imgList(this.detailImg);
} else { } else {
this.msg.error("请上传详情图片") this.msg.error("请上传详情图片");
return;
} }
this.goodsService.editGoodsMsg(this.editForm.value , (data: any) => { this.goodsService.editGoodsMsg(this.editForm.value , (data: any) => {
@ -225,7 +284,7 @@ export class GoodsListComponent {
// 删除 // 删除
delete(id: number): void { delete(id: number): void {
this.goodsService.deleteBran(id , (data: any) => { this.goodsService.deleteGoodsMsg(id , (data: any) => {
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.msg.success("成功!"); this.msg.success("成功!");
this.getRequest(); this.getRequest();
@ -235,6 +294,18 @@ export class GoodsListComponent {
}); });
} }
// 删除
deleteGoodsSpecs(id: number): void {
this.goodsService.deleteGoodsSpecs(id , (data: any) => {
if (data['return_code'] === '000000') {
this.msg.success("成功!");
this.getSpecsList();
} else {
this.msg.error(data['return_msg']);
}
});
}
// 获取商品分类 // 获取商品分类
getGoodsTypeNode() { getGoodsTypeNode() {
this.goodsService.getList({time: new Date().getTime()}, (data: any) => { this.goodsService.getList({time: new Date().getTime()}, (data: any) => {
@ -267,4 +338,128 @@ export class GoodsListComponent {
}); });
} }
// 弹出
showSpecsList(data: any): void {
this.goodsMsg = data;
this.isVisibleSpecs = true;
if (data.type == "1") {
this.editSpecsForm.controls['type'].clearValidators();
this.editSpecsForm.controls['type'].markAsPristine();
this.editSpecsForm.controls['source'].clearValidators();
this.editSpecsForm.controls['source'].markAsPristine();
this.editSpecsForm.controls['validDay'].clearValidators();
this.editSpecsForm.controls['validDay'].markAsPristine();
} else {
this.editSpecsForm.controls['type'].setValidators(Validators.required);
this.editSpecsForm.controls['type'].markAsDirty();
this.editSpecsForm.controls['source'].setValidators(Validators.required);
this.editSpecsForm.controls['source'].markAsDirty();
this.editSpecsForm.controls['validDay'].setValidators(Validators.required);
this.editSpecsForm.controls['validDay'].markAsDirty();
}
this.editSpecsForm.controls['type'].updateValueAndValidity();
this.editSpecsForm.controls['validDay'].updateValueAndValidity();
this.editSpecsForm.controls['source'].updateValueAndValidity();
this.getSpecsList();
}
// 查询规格列表
getSpecsList(): void {
this.loadingSpecs = true;
let params = {
id: this.goodsMsg?.id,
time: new Date().getTime()
}
this.goodsService.getGoodsSpecsList(params , (data: any) => {
this.loadingSpecs = false;
if (data['return_code'] == '000000') {
this.nodesSpecs = data['return_data'];
}
});
}
// 添加规格
showEditSpecs(item?: any): void {
if (item != null) {
item.source = String(item.source);
item.type = String(item.type);
item.jumpType = String(item.jumpType);
this.editSpecsForm.patchValue(item);
if (!this.commonService.whetherStringIsNull(item.showImg)) {
this.showImg = this.commonService.stitchImg(item.showImg);
}
} else {
this.editSpecsForm.reset()
}
this.editSpecs = true;
}
handleEditSpecs(): void {
if (this.editSpecsForm.valid) {
if (this.showImg.length !== 0) {
this.editSpecsForm.value.showImg = this.commonService.imgList(this.showImg);
} else {
this.msg.error("请上传展示图片");
return;
}
this.editSpecsForm.value.goodsId = this.goodsMsg?.id;
this.goodsService.editGoodsSpecs(this.editSpecsForm.value , (data: any) => {
if (data['return_code'] === '000000') {
this.msg.success("成功!");
this.editSpecs = false;
this.getSpecsList();
} else {
this.msg.error(data['return_msg']);
}
});
} else {
Object.values(this.editSpecsForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
}
}
typeChange(type: string): void {
if (type == "1") {
this.editSpecsForm.controls['jumpType'].clearValidators();
this.editSpecsForm.controls['jumpType'].markAsPristine();
this.editSpecsForm.controls['jumpUrl'].clearValidators();
this.editSpecsForm.controls['jumpUrl'].markAsPristine();
} else {
this.editSpecsForm.controls['jumpType'].setValidators(Validators.required);
this.editSpecsForm.controls['jumpType'].markAsDirty();
this.editSpecsForm.controls['jumpUrl'].setValidators(Validators.required);
this.editSpecsForm.controls['jumpUrl'].markAsDirty();
}
this.editSpecsForm.controls['jumpUrl'].updateValueAndValidity();
this.editSpecsForm.controls['jumpType'].updateValueAndValidity();
}
jumpTypeChange(type: string): void {
console.log("type" , type);
if (type == "2") {
this.editSpecsForm.controls['appid'].clearValidators();
this.editSpecsForm.controls['appid'].markAsPristine();
} else {
this.editSpecsForm.controls['appid'].setValidators(Validators.required);
this.editSpecsForm.controls['appid'].markAsDirty();
}
this.editSpecsForm.controls['appid'].updateValueAndValidity();
}
} }

@ -67,7 +67,7 @@ export class GoodsService {
} }
public getListBrandAll(callBack:any) { public getListBrandAll(callBack:any) {
this.http.get(environment.baseUrl + 'goodsBrand/getListBrandAll').subscribe(data => { this.http.get(environment.baseUrl + 'goodsBrand/getListBrandAll?time=' + new Date().getTime()).subscribe(data => {
callBack(data); callBack(data);
}); });
} }
@ -105,4 +105,48 @@ export class GoodsService {
}); });
} }
/**
*
* @param params
* @param callBack
*/
public editGoodsSpecs(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'goods/editGoodsSpecs', params).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public getGoodsSpecsList(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'goods/getGoodsSpecsList?' + ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
});
}
/**
*
* @param id
* @param callBack
*/
public deleteGoodsMsg(id: number, callBack:any) {
this.http.get(environment.baseUrl + 'goods/deleteGoodsMsg?id=' + id ).subscribe(data => {
callBack(data);
});
}
/**
*
* @param id
* @param callBack
*/
public deleteGoodsSpecs(id: number, callBack:any) {
this.http.get(environment.baseUrl + 'goods/deleteGoodsSpecs?id=' + id ).subscribe(data => {
callBack(data);
});
}
} }

@ -4,10 +4,13 @@
export const environment = { export const environment = {
production: false, production: false,
baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) // baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址)
// orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) // orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址)
orderUrl: 'http://localhost:9703/order/', // 测试环境服务器地址(请求数据地址) // userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址)
userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) // imageUrl: 'https://phgcs.dctpay.com/filesystem/',
baseUrl: 'http://localhost:9702/brest/', // 测试环境服务器地址(请求数据地址)
orderUrl: 'http://localhost:9304/order/', // 测试环境服务器地址(请求数据地址)
userUrl: 'http://localhost:9704/user/', // 测试环境服务器地址(请求数据地址)
imageUrl: 'https://phgcs.dctpay.com/filesystem/', imageUrl: 'https://phgcs.dctpay.com/filesystem/',
}; };

Loading…
Cancel
Save