You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
puhui-go-web/src/app/pages/trade/goods-list/goods-list.component.ts

318 lines
10 KiB

import {Component, Output} from '@angular/core';
import {DatePipe, NgClass, NgForOf, NgIf} from "@angular/common";
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule} from "@angular/forms";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {
NzTableComponent, NzTableModule,
NzThMeasureDirective
} from "ng-zorro-antd/table";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormDirective, NzFormModule} from "ng-zorro-antd/form";
import {NzImageDirective, NzImageModule,} from "ng-zorro-antd/image";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select";
import {environment} from "../../../../environments/environment";
import {NzMessageService} from "ng-zorro-antd/message";
import {GoodsService} from "../../../services/goods/goods.service";
import {fallbackImg, logisticsStatus, orderGoodsChild, orderPayType} from '../../../data/goods/goods.namespace';
import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe";
import {NzModalModule} from "ng-zorro-antd/modal";
import {OrderGoodsService} from "../../../services/trade/order-goods.service";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm";
import {OrderGoodsData} from "../../../model/order.interface";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
import {NzBadgeComponent} from "ng-zorro-antd/badge";
import {AuditStatusPipe} from "../../../pipes/audit/audit-status.pipe";
import {NzTabSetComponent, NzTabsModule} from "ng-zorro-antd/tabs";
import {NzSpinComponent} from "ng-zorro-antd/spin";
import {NzTimelineComponent, NzTimelineItemComponent} from "ng-zorro-antd/timeline";
import {NzResultComponent} from "ng-zorro-antd/result";
import {DateUtils} from "../../../utils/dateUtils.service";
import {NzDatePickerComponent, NzRangePickerComponent} from "ng-zorro-antd/date-picker";
import {NzRadioButtonDirective, NzRadioComponent, NzRadioGroupComponent} from "ng-zorro-antd/radio";
import {PayTypePipe} from "../../../pipes/goods/pay-type.pipe";
import {IconService} from "../../../services/common/icon.service";
import {OrderChildStatusPipe} from "../../../pipes/goods/order-child-status.pipe";
import {DATA} from "../../../data/login/localStorage.namespace";
import {BrowserStorageService} from "../../../utils/localStorage.service";
import {MerService} from "../../../services/merchant/mer.service";
import {CommunicationService} from "../../../services/common/communication.service";
@Component({
selector: 'app-goods-list',
standalone: true,
imports: [
NzColDirective,
NzRowDirective,
NzFormDirective,
ReactiveFormsModule,
NzTreeSelectComponent,
NzInputDirective,
NzSelectComponent,
NzOptionComponent,
NzButtonComponent,
NzTableComponent,
NzImageModule,
NzModalModule,
NzTableModule,
NzFormModule,
NzThMeasureDirective,
NgForOf,
NzImageDirective,
GoodsStatusPipe,
DatePipe,
NzDropdownMenuComponent,
NgIf,
NzMenuDirective,
NzDescriptionsModule,
NzMenuItemComponent,
NzPopconfirmDirective,
NzDividerComponent,
NzDropDownADirective,
NzDropDownDirective,
NzTabsModule,
NzIconDirective,
NzBadgeComponent,
AuditStatusPipe,
NzTabSetComponent,
FormsModule,
NzSpinComponent,
NzTimelineItemComponent,
NgClass,
NzResultComponent,
NzTimelineComponent,
NzDatePickerComponent,
NzRadioButtonDirective,
NzRadioComponent,
NzRadioGroupComponent,
NzRangePickerComponent,
PayTypePipe,
OrderChildStatusPipe,
],
templateUrl: './goods-list.component.html',
styleUrl: './goods-list.component.less'
})
export class GoodsListComponent {
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any = {
total: 0,
loading: false,
list: [],
};
// 搜索表单
searchForm: FormGroup;
baseUrl = environment.baseUrl;
imageUrl = environment.imageUrl;
// 商品类型数据
nodes = [];
nodesBrand = [];
orderGoodsData: any;
orderDetailModal = false;
orderDetailModalChild = false;
orderDetailModalLoading = false;
logisticsTraceDetails: any;
deliveryAddress: any;
// 更多查询条件
isCollapse = false;
merData: any;
objectType: any;
protected readonly fallbackImg = fallbackImg;
protected readonly logisticsStatus = logisticsStatus;
protected readonly orderGoodsChild = orderGoodsChild;
protected readonly orderPayType = orderPayType;
constructor(private fb: NonNullableFormBuilder,
private msg: NzMessageService,
private storage: BrowserStorageService,
private communicationService: CommunicationService,
private merService: MerService,
private iconService: IconService,
private orderGoodsService: OrderGoodsService,
private goodsService: GoodsService) {
// 初始化搜索框
this.searchForm = this.fb.group({
logisticsNo: [''],
orderNo: [''],
childOrderNo: [''],
logisticsStatus: [''],
goodsType: [''],
goodsBrand: [''],
merId: [''],
goodsSpecsId: [''],
userPhone: [''],
goodsSpecsName: [''],
createTimeArray: [[]],
finishTimeArray: [[]],
createTimeS: [''],
createTimeE: [''],
finishTimeS: [''],
finishTimeE: [''],
goodsName: [''],
status: [''],
payType: [''],
});
this.getRequest();
this.getGoodsTypeNode();
this.getGoodsBrandNode();
this.merList();
this.objectType = this.storage.get(DATA)['account']['objectType'];
}
// 查询商户
public merList() {
let params: any = {
pageNum: 1,
pageSize: 1000,
time: new Date().getTime(),
}
this.merService.queryList(params, (data: any) => {
if (data['return_code'] == '000000') {
this.merData = data['return_data']['list'];
}
});
}
// 查询列表
public getRequest(reset: boolean = false) {
if (this.searchForm.controls['createTimeArray'].value != null
&& this.searchForm.controls['createTimeArray'].value.length > 0) {
this.searchForm.controls['createTimeS'].setValue(DateUtils.getDateHMS(new Date(this.searchForm.controls['createTimeArray'].value[0]) , 1).getTime());
this.searchForm.controls['createTimeE'].setValue(DateUtils.getDateHMS(new Date(this.searchForm.controls['createTimeArray'].value[1]) , 2).getTime());
} else {
this.searchForm.controls['createTimeS'].setValue(null)
this.searchForm.controls['createTimeE'].setValue(null)
}
if (this.searchForm.controls['finishTimeArray'].value != null
&& this.searchForm.controls['finishTimeArray'].value.length > 0) {
this.searchForm.controls['finishTimeS'].setValue(DateUtils.getDateHMS(new Date(this.searchForm.controls['finishTimeArray'].value[0]) , 1).getTime());
this.searchForm.controls['finishTimeE'].setValue(DateUtils.getDateHMS(new Date(this.searchForm.controls['finishTimeArray'].value[1]) , 2).getTime());
} else {
this.searchForm.controls['finishTimeS'].setValue(null)
this.searchForm.controls['finishTimeE'].setValue(null)
}
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.orderGoodsService.getListGoods(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;
});
}
// 重制
public reset() {
this.searchForm.reset();
this.getRequest();
}
// 获取商品分类
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'];
}
});
}
showDetail(data: OrderGoodsData): void {
this.orderGoodsData = data;
// this.findDeliveryAddressById(data.deliveryAddressId);
this.orderDetailModal = true;
}
showLogisticsNo(id: number): void {
let params = {
id:id,
time: new Date().getTime()
}
this.orderGoodsService.getLogisticsMsg(params , (data: any) => {
if (data['return_code'] == '000000') {
this.orderDetailModalChild = true;
this.getRequest(false);
this.logisticsTraceDetails = data['return_data']['logisticsTraceDetails'];
} else {
this.msg.error(data['return_msg']);
}
});
}
findDeliveryAddressById(id: number): void {
this.goodsService.findDeliveryAddressById(id, (data: any) => {
if (data['return_code'] == '000000') {
this.deliveryAddress = data['return_data'];
} else {
this.msg.error(data['return_msg']);
}
});
}
// 订单导出
public getExport() {
this.searchForm.value.time = new Date().getTime();
this.orderGoodsService.exportGoodsOrder(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;
});
}
}