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/comp-order/comp-order.component.ts

229 lines
7.1 KiB

import { Component } from '@angular/core';
import {DatePipe, NgForOf, NgIf, NgSwitch} from "@angular/common";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule} from "@angular/forms";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {
NzCellEllipsisDirective,
NzCellFixedDirective,
NzTableCellDirective,
NzTableComponent,
NzTbodyComponent, NzTheadComponent,
NzThMeasureDirective, NzTrDirective
} from "ng-zorro-antd/table";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {NzModalComponent, NzModalModule, NzModalService} from "ng-zorro-antd/modal";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzMessageService} from "ng-zorro-antd/message";
import {OrderCouponService} from "../../../services/trade/order-coupon.service";
import {NzDatePickerComponent, NzDatePickerModule, NzRangePickerComponent} from "ng-zorro-antd/date-picker";
import {NzRadioButtonDirective, NzRadioComponent, NzRadioGroupComponent} from "ng-zorro-antd/radio";
import {NzTooltipDirective} from "ng-zorro-antd/tooltip";
import {DateSelectType, DateUtils} from "../../../utils/dateUtils.service";
import {NzTreeComponent} from "ng-zorro-antd/tree";
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
import {NzTabComponent, NzTabSetComponent, NzTabsModule} from "ng-zorro-antd/tabs";
import {environment} from "../../../../environments/environment";
import {CommunicationService} from "../../../services/common/communication.service";
@Component({
selector: 'app-comp-order',
standalone: true,
imports: [
DatePipe,
DictionaryPipe,
FormsModule,
NgForOf,
NgIf,
NzButtonComponent,
NzCellFixedDirective,
NzColDirective,
NzDividerComponent,
NzDropDownADirective,
NzDropDownDirective,
NzDropdownMenuComponent,
NzFlexDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzIconDirective,
NzInputDirective,
NzMenuDirective,
NzMenuItemComponent,
NzModalComponent,
NzOptionComponent,
NzRowDirective,
NzSelectComponent,
NzTableCellDirective,
NzTableComponent,
NzTbodyComponent,
NzThMeasureDirective,
NzTheadComponent,
NzTrDirective,
ReactiveFormsModule,
NzModalModule,
NzRangePickerComponent,
NzDatePickerComponent,
NzDatePickerModule,
NzRadioButtonDirective,
NzRadioComponent,
NzRadioGroupComponent,
NgSwitch,
NzCellEllipsisDirective,
NzTooltipDirective,
NzTreeComponent,
NzDescriptionsModule,
NzTabSetComponent,
NzTabComponent,
NzTabsModule
],
templateUrl: './comp-order.component.html',
styleUrl: './comp-order.component.less'
})
export class CompOrderComponent {
imageUrl = environment.imageUrl;
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any = {
total: 0,
list: [],
};
// 搜索表单
searchForm: FormGroup;
// 更多查询条件
isCollapse = false;
// 时间类型选择
dateTypeSelect = DateSelectType;
// 订单支付类型
orderPayTypeArray = new DictionaryPipe().getDictionaryList('ORDER_PAY_TYPE');
// 订单状态
orderStatusArray = new DictionaryPipe().getDictionaryList('ORDER_STATUS');
// 卡密使用状态
orderCouponNoStatus = new DictionaryPipe().getDictionaryList('ORDER_COUPON_NO_STATUS');
// 订单详情模态框
orderDetailVisible = false;
// 订单详情数据
orderDetail: any = {
order: {},
goods: [],
};
constructor(private fb: NonNullableFormBuilder,
private orderService : OrderCouponService,
private communicationService: CommunicationService,
private message: NzMessageService,
private modal: NzModalService) {
// 初始化搜索框
this.searchForm = this.fb.group({
userPhone: [''],
orderNo: [''],
tradeStatus: [''],
payType: [''],
goodsName: [''],
channelOrderNo: [''],
couNo: [''],
couStatus: [''],
createTimeArray: [[]],
createTimeSelect: ['1'],
createTimeS: [''],
createTimeE: [''],
});
this.createTimeInit();
this.queryData();
}
/**
* 获取数据
*/
queryData() {
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.searchForm.value.pageNum = this.tablePageNum;
this.searchForm.value.pageSize = 10;
this.searchForm.value.time = new Date().getTime();
this.orderService.queryList(this.searchForm.value, (data: any) => {
if (data['return_code'] == '000000') {
this.tableData = data['return_data'];
for (let data of this.tableData.list) {
data['rowSpan'] = this.tableData.list.filter((s: { childOrderNo: any; }) => s.childOrderNo == data.childOrderNo).length;
}
}
});
}
/**
* 搜索表单提交
*/
searchFormSubmit(): void {
this.tablePageNum = 1;
this.queryData();
}
/**
* 搜索表单重置
*/
searchFormReset(): void {
this.searchForm.reset();
}
/**
* 创建时间初始化
*/
createTimeInit() {
let createTimeSelect = this.searchForm.controls['createTimeSelect'].value;
if (createTimeSelect != null) {
let timeObj = DateUtils.getDate(new Date(), Number(createTimeSelect));
this.searchForm.controls['createTimeArray'].setValue([timeObj.timeS, timeObj.timeE]);
}
}
/**
* 展示详情
* @param childOrderNo
*/
showDetail(childOrderNo: string) {
this.orderService.queryDetail(childOrderNo,(data: any) => {
if (data['return_code'] == '000000') {
this.orderDetail = data['return_data'];
}
});
this.orderDetailVisible = true;
}
/**
* 关闭详情
*/
closeDetail() {
this.orderDetail = {};
this.orderDetailVisible = false;
}
/**
* 导出订单
*/
export() {
this.orderService.export(this.searchForm.value, (data: any) => {
if (data['return_code'] == '000000') {
if (data['return_code'] == '000000') {
this.communicationService.sendMessage(data['return_data']);
} else {
this.message.error(data['return_msg']);
}
}
});
}
}