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-logistics-list/goods-logistics-list.compon...

284 lines
8.6 KiB

import { Component } from '@angular/core';
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule} from "@angular/forms";
import {NzMessageService} from "ng-zorro-antd/message";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import { NzFormDirective, NzFormModule} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzDatePickerComponent, NzRangePickerComponent} from "ng-zorro-antd/date-picker";
import {NzRadioButtonDirective, NzRadioComponent, NzRadioGroupComponent} from "ng-zorro-antd/radio";
import {NzCellFixedDirective, NzTableComponent, NzTableModule, NzThMeasureDirective} from "ng-zorro-antd/table";
import {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal";
import {DatePipe, NgClass, NgForOf, NgIf, NgOptimizedImage} from "@angular/common";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzTabSetComponent, NzTabsModule} from "ng-zorro-antd/tabs";
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
import {NzImageDirective, NzImageModule} from "ng-zorro-antd/image";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzBadgeComponent} from "ng-zorro-antd/badge";
import {fallbackImg, logisticsStatus, orderPayType} from '../../../data/goods/goods.namespace';
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {NzResultComponent} from "ng-zorro-antd/result";
import {NzSpinComponent} from "ng-zorro-antd/spin";
import {NzTimelineComponent, NzTimelineItemComponent} from "ng-zorro-antd/timeline";
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select";
import {environment} from "../../../../environments/environment";
import {OrderGoodsService} from "../../../services/trade/order-goods.service";
import {GoodsService} from "../../../services/goods/goods.service";
import {OrderGoodsData} from "../../../model/order.interface";
import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe";
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm";
import {AuditStatusPipe} from "../../../pipes/audit/audit-status.pipe";
import {IconService} from "../../../services/common/icon.service";
import {PayTypePipe} from "../../../pipes/goods/pay-type.pipe";
import {OrderChildStatusPipe} from "../../../pipes/goods/order-child-status.pipe";
@Component({
selector: 'app-goods-logistics-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-logistics-list.component.html',
styleUrl: './goods-logistics-list.component.less'
})
export class GoodsLogisticsListComponent {
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any = {
total: 0,
loading: false,
list: [],
};
// 搜索表单
searchForm: FormGroup;
baseUrl = environment.baseUrl;
imageUrl = environment.imageUrl;
// 商品类型数据
nodes = [];
nodesBrand = [];
orderGoodsData: any;
orderDetailModal = false;
isVisible = false;
orderDetailModalChild = false;
orderDetailModalLoading = false;
logisticsNo: any;
logisticsTraceDetails: any;
goodsOrderId: any;
deliveryAddress: any;
protected readonly fallbackImg = fallbackImg;
protected readonly orderPayType = orderPayType;
protected readonly logisticsStatus = logisticsStatus;
constructor(private fb: NonNullableFormBuilder,
private msg: NzMessageService,
private iconService: IconService,
private orderGoodsService: OrderGoodsService,
private goodsService: GoodsService) {
// 初始化搜索框
this.searchForm = this.fb.group({
logisticsNo: [''],
orderNo: [''],
childOrderNo: [''],
goodsType: [''],
goodsBrand: [''],
userPhone: [''],
goodsSpecsName: [''],
createTimeArray: [[]],
createTimeSelect: ['1'],
createTimeS: [''],
createTimeE: [''],
goodsName: [''],
payType: [''],
status: [''],
logisticsStatus: [''],
});
this.getRequest();
this.getGoodsTypeNode();
this.getGoodsBrandNode();
}
// 查询列表
public getRequest(reset: boolean = false) {
this.searchForm.controls['status'].setValue(2)
if (this.searchForm.controls['createTimeArray'].value != null
&& this.searchForm.controls['createTimeArray'].value.length > 0) {
this.searchForm.controls['createTimeS'].setValue(new Date(this.searchForm.controls['createTimeArray'].value[0]).getTime());
this.searchForm.controls['createTimeE'].setValue(new Date(this.searchForm.controls['createTimeArray'].value[1]).getTime());
} else {
this.searchForm.controls['createTimeS'].setValue(null)
this.searchForm.controls['createTimeE'].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;
});
}
// 获取商品分类
getGoodsTypeNode() {
this.goodsService.getList({time: new Date().getTime()}, (data: any) => {
if (data['return_code'] === '000000') {
this.getNode(data['return_data']);
}
});
}
// 重制
public reset() {
this.searchForm.reset();
this.getRequest();
}
// 配置数据
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'];
}
});
}
getLogisticsNo(id: number): void {
this.goodsOrderId = id;
this.isVisible = true;
}
showDetail(data: OrderGoodsData): void {
this.orderGoodsData = data;
this.findDeliveryAddressById(data.deliveryAddressId);
this.orderDetailModal = true;
}
handleOk(): void {
let params = {
id: this.goodsOrderId,
logisticsNo: this.logisticsNo,
time: new Date().getTime()
}
this.orderGoodsService.updateLogisticsNo(params , (data: any) => {
if (data['return_code'] == '000000') {
this.isVisible = false;
this.getRequest(false);
this.msg.success("成功")
} else {
this.msg.error(data['return_msg']);
}
});
}
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']);
}
});
}
}