master
parent
952f12f281
commit
28f93f9a92
@ -0,0 +1,93 @@ |
|||||||
|
<form nz-form [formGroup]="searchForm" class="search_form" [nzLayout]="'vertical'"> |
||||||
|
<div nz-row [nzGutter]="24"> |
||||||
|
<div nz-col [nzSpan]="8"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label>商品名称</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<input nzSize="large" nz-input formControlName="title" placeholder="请输入" /> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
<div nz-col [nzSpan]="8"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label>商品分类</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<nz-tree-select |
||||||
|
nzPlaceHolder="请选择" |
||||||
|
formControlName="goodsType" |
||||||
|
[nzNodes]="nodes" |
||||||
|
nzShowSearch |
||||||
|
></nz-tree-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
<div nz-col [nzSpan]="8"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label>商品品牌</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="goodsBrand"> |
||||||
|
<nz-option *ngFor="let item of nodesBrand" nzLabel="{{item['title']}}" nzValue="{{item['id']}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
<div nz-col [nzSpan]="8"> |
||||||
|
<nz-form-item> |
||||||
|
<nz-form-label>价格区间</nz-form-label> |
||||||
|
<nz-form-control> |
||||||
|
<nz-space nzDirection="vertical" style="width: 100%"> |
||||||
|
<nz-input-number-group *nzSpaceItem nzCompact> |
||||||
|
<nz-input-number formControlName="salePriceS" [nzPrecision]="2" style="width: 50%"></nz-input-number> |
||||||
|
<nz-input-number formControlName="salePriceE" [nzPrecision]="2" style="width: 50%"></nz-input-number> |
||||||
|
</nz-input-number-group> |
||||||
|
</nz-space> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div nz-col [nzSpan]="6" class="search-area"> |
||||||
|
<button nz-button [nzType]="'primary'" (click)="getRequest(true)">查询</button> |
||||||
|
<button nz-button (click)="searchForm.reset()">重置</button> |
||||||
|
<button nz-button [nzType]="'primary'" (click)="getExport()">导出</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
|
||||||
|
<nz-table #basicTable |
||||||
|
[nzBordered]="true" |
||||||
|
[nzFrontPagination]="false" |
||||||
|
[nzShowQuickJumper]="true" |
||||||
|
[nzShowTotal]="totalTemplate" |
||||||
|
[(nzPageIndex)]="tablePageNum" |
||||||
|
(nzPageIndexChange)="getRequest(false)" |
||||||
|
[nzTotal]="tableData.total" |
||||||
|
[nzData]="tableData.list" > |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th nzWidth="80px">一级分类</th> |
||||||
|
<th nzWidth="100px">二级分类</th> |
||||||
|
<th nzWidth="100px">品牌名称</th> |
||||||
|
<th nzWidth="100px">商品名称</th> |
||||||
|
<th nzWidth="100px">列表图</th> |
||||||
|
<th nzWidth="50px">售卖价格</th> |
||||||
|
<th nzWidth="50px">京东价</th> |
||||||
|
<th nzWidth="50px">原价</th> |
||||||
|
<th nzWidth="50px">sku编码</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr *ngFor="let data of basicTable.data"> |
||||||
|
<td>{{data.goodsTypeParentName}}</td> |
||||||
|
<td>{{data.goodsTypeName}}</td> |
||||||
|
<td>{{data.goodsBrandName}}</td> |
||||||
|
<td>{{data.title}}</td> |
||||||
|
<td> |
||||||
|
<img nz-image width="60px" height="60px" nzSrc="{{data.listImg }}" [nzFallback]="fallbackImg" alt="" /> |
||||||
|
</td> |
||||||
|
<td>¥{{data.salePrice}}</td> |
||||||
|
<td>¥{{data.thirdPrice}}</td> |
||||||
|
<td>¥{{data.originalPrice}}</td> |
||||||
|
<td>{{data.thirdId}}</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template> |
@ -0,0 +1,12 @@ |
|||||||
|
[nz-form-label] { |
||||||
|
overflow: visible; |
||||||
|
} |
||||||
|
button { |
||||||
|
margin-left: 8px; |
||||||
|
} |
||||||
|
.submit-btn { |
||||||
|
width: 150px; |
||||||
|
} |
||||||
|
.search-area { |
||||||
|
margin-top: 30px; |
||||||
|
} |
@ -0,0 +1,211 @@ |
|||||||
|
import {Component} from '@angular/core'; |
||||||
|
import {DatePipe, NgForOf, NgIf, NgStyle} from "@angular/common"; |
||||||
|
import {NzButtonComponent} from "ng-zorro-antd/button"; |
||||||
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; |
||||||
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; |
||||||
|
import {NzInputDirective} from "ng-zorro-antd/input"; |
||||||
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; |
||||||
|
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
||||||
|
import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload"; |
||||||
|
import {environment} from "../../../../environments/environment"; |
||||||
|
import {NzMessageService} from "ng-zorro-antd/message"; |
||||||
|
import {CommonService} from "../../../services/common/common.service"; |
||||||
|
import {GoodsService} from "../../../services/goods/goods.service"; |
||||||
|
import {fallbackImg} from '../../../data/goods/goods.namespace'; |
||||||
|
import {GoodsMsgData, SpecsData} from "../../../model/goods.interface"; |
||||||
|
import {NzDividerComponent} from "ng-zorro-antd/divider"; |
||||||
|
import {NzIconDirective} from "ng-zorro-antd/icon"; |
||||||
|
import {NzImageDirective, NzImageModule} from "ng-zorro-antd/image"; |
||||||
|
import {NzModalModule} from "ng-zorro-antd/modal"; |
||||||
|
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm"; |
||||||
|
import {NzTableComponent, NzTableModule, NzTdAddOnComponent,} from "ng-zorro-antd/table"; |
||||||
|
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; |
||||||
|
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; |
||||||
|
import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe"; |
||||||
|
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
||||||
|
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu"; |
||||||
|
import { |
||||||
|
NzInputNumberComponent, |
||||||
|
NzInputNumberGroupComponent, |
||||||
|
NzInputNumberGroupWhitSuffixOrPrefixDirective, NzInputNumberModule |
||||||
|
} from "ng-zorro-antd/input-number"; |
||||||
|
import {NzSpaceComponent, NzSpaceItemDirective} from "ng-zorro-antd/space"; |
||||||
|
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; |
||||||
|
import {NzTypographyComponent} from "ng-zorro-antd/typography"; |
||||||
|
import {Observable, Observer} from "rxjs"; |
||||||
|
import {BrowserStorageService} from "../../../utils/localStorage.service"; |
||||||
|
import {DATA} from "../../../data/login/localStorage.namespace"; |
||||||
|
import {MerService} from "../../../services/merchant/mer.service"; |
||||||
|
import {CommunicationService} from "../../../services/common/communication.service"; |
||||||
|
|
||||||
|
const getBase64 = (file: File): Promise<string | ArrayBuffer | null> => |
||||||
|
new Promise((resolve, reject) => { |
||||||
|
const reader = new FileReader(); |
||||||
|
reader.readAsDataURL(file); |
||||||
|
reader.onload = () => resolve(reader.result); |
||||||
|
reader.onerror = error => reject(error); |
||||||
|
}); |
||||||
|
|
||||||
|
@Component({ |
||||||
|
selector: 'app-goods-list', |
||||||
|
standalone: true, |
||||||
|
imports: [ |
||||||
|
FormsModule, |
||||||
|
NzButtonComponent, |
||||||
|
NzColDirective, |
||||||
|
NzFormControlComponent, |
||||||
|
NzFormDirective, |
||||||
|
NzFormItemComponent, |
||||||
|
NzFormLabelComponent, |
||||||
|
NzInputDirective, |
||||||
|
NzRowDirective, |
||||||
|
ReactiveFormsModule, |
||||||
|
NgForOf, |
||||||
|
NzOptionComponent, |
||||||
|
NzSelectComponent, |
||||||
|
NzModalModule, |
||||||
|
NgIf, |
||||||
|
NzUploadComponent, |
||||||
|
NzIconDirective, |
||||||
|
NzImageModule, |
||||||
|
NgStyle, |
||||||
|
NzTableComponent, |
||||||
|
NzTdAddOnComponent, |
||||||
|
NzTableModule, |
||||||
|
DictionaryPipe, |
||||||
|
DatePipe, |
||||||
|
NzImageDirective, |
||||||
|
NzTreeSelectComponent, |
||||||
|
NzDividerComponent, |
||||||
|
NzPopconfirmDirective, |
||||||
|
GoodsStatusPipe, |
||||||
|
NzDropDownADirective, |
||||||
|
NzDropDownDirective, |
||||||
|
NzInputNumberModule, |
||||||
|
NzDropdownMenuComponent, |
||||||
|
NzMenuDirective, |
||||||
|
NzMenuItemComponent, |
||||||
|
NzInputNumberComponent, |
||||||
|
NzInputNumberGroupWhitSuffixOrPrefixDirective, |
||||||
|
NzSpaceItemDirective, |
||||||
|
NzInputNumberGroupComponent, |
||||||
|
NzDatePickerComponent, |
||||||
|
NzTypographyComponent, |
||||||
|
NzSpaceComponent |
||||||
|
], |
||||||
|
templateUrl: './jd-goods-list.component.html', |
||||||
|
styleUrl: './jd-goods-list.component.less' |
||||||
|
}) |
||||||
|
export class JdGoodsListComponent { |
||||||
|
// 表单页数
|
||||||
|
tablePageNum = 1; |
||||||
|
// 表单数据
|
||||||
|
tableData: any = { |
||||||
|
total: 0, |
||||||
|
loading: false, |
||||||
|
list: [], |
||||||
|
}; |
||||||
|
// 搜索表单
|
||||||
|
searchForm: FormGroup; |
||||||
|
|
||||||
|
|
||||||
|
// 展示图片
|
||||||
|
previewImage: string | undefined = ''; |
||||||
|
// 上传是否展示
|
||||||
|
previewVisible = false; |
||||||
|
|
||||||
|
loadingSpecs = false; |
||||||
|
// 商品类型数据
|
||||||
|
nodes = []; |
||||||
|
nodesBrand = []; |
||||||
|
nodesSpecs: SpecsData[] = []; |
||||||
|
|
||||||
|
protected readonly fallbackImg = fallbackImg; |
||||||
|
|
||||||
|
constructor(private fb: NonNullableFormBuilder, |
||||||
|
private msg: NzMessageService, |
||||||
|
private communicationService: CommunicationService, |
||||||
|
private goodsService: GoodsService) { |
||||||
|
|
||||||
|
// 初始化搜索框
|
||||||
|
this.searchForm = this.fb.group({ |
||||||
|
title: [''], |
||||||
|
goodsType: [''], |
||||||
|
goodsBrand: [''], |
||||||
|
salePriceS: [''], |
||||||
|
salePriceE: [''], |
||||||
|
}); |
||||||
|
|
||||||
|
this.getRequest(); |
||||||
|
this.getGoodsTypeNode(); |
||||||
|
this.getGoodsBrandNode(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// 查询列表
|
||||||
|
public getRequest(reset: boolean = false) { |
||||||
|
this.tableData.loading = true; |
||||||
|
if (reset) { |
||||||
|
this.tablePageNum = 1; |
||||||
|
} |
||||||
|
this.searchForm.value.pageNum = this.tablePageNum; |
||||||
|
this.searchForm.value.pageSize = 10; |
||||||
|
this.searchForm.value.time = new Date().getTime(); |
||||||
|
|
||||||
|
this.goodsService.getJdGoodsList(this.searchForm.value, (data: any) => { |
||||||
|
if (data['return_code'] == '000000') { |
||||||
|
this.tableData = data['return_data']; |
||||||
|
} else { |
||||||
|
this.msg.error(data['return_msg']); |
||||||
|
} |
||||||
|
this.tableData.loading = false; |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// 获取商品分类
|
||||||
|
getGoodsTypeNode() { |
||||||
|
this.goodsService.getList({time: new Date().getTime()}, (data: any) => { |
||||||
|
if (data['return_code'] === '000000') { |
||||||
|
this.getNode(data['return_data']); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
// 配置数据
|
||||||
|
getNode(array: any): any { |
||||||
|
array.forEach((item: any) => { |
||||||
|
if (item.children) { |
||||||
|
this.getNode(item.children); |
||||||
|
} else { |
||||||
|
item["isLeaf"] = true; |
||||||
|
} |
||||||
|
item["key"] = item.id; |
||||||
|
|
||||||
|
}); |
||||||
|
this.nodes = array; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取商品品牌
|
||||||
|
getGoodsBrandNode() { |
||||||
|
this.goodsService.getListBrandAll((data: any) => { |
||||||
|
if (data['return_code'] == '000000') { |
||||||
|
this.nodesBrand = data['return_data']; |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
// 订单导出
|
||||||
|
public getExport() { |
||||||
|
this.searchForm.value.time = new Date().getTime(); |
||||||
|
this.goodsService.exportJdGoods(this.searchForm.value , (data: any) => { |
||||||
|
if (data['return_code'] == '000000') { |
||||||
|
this.communicationService.sendMessage(data['return_data']); |
||||||
|
} else { |
||||||
|
this.msg.error(data['return_msg']); |
||||||
|
} |
||||||
|
this.tableData.loading = false; |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue