import { Component, OnInit } from '@angular/core'; import {environment} from '../../../../environments/environment'; import {LocalStorageService} from '../../../services/local-storage.service'; import {OrderThirdPartyService} from '../../../services/order/order-third-party.service'; import {GoodsService} from '../../../services/goods/goods.service'; import {CompanyService} from '../../../services/company.service'; import {CommonsService} from '../../../services/commons.service'; import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; import {FormBuilder, FormGroup} from '@angular/forms'; import {NzMessageService, NzNotificationService} from 'ng-zorro-antd'; @Component({ selector: 'app-goods-child-order', templateUrl: './goods-child-order.component.html', styleUrls: ['./goods-child-order.component.scss'] }) export class GoodsChildOrderComponent implements OnInit { // 搜索框 searchForm: FormGroup; // 搜索框折叠 isCollapse = false; // 订单状态数据 orderStatusArray = []; // 公司数据 companyArray = []; // 角色类型 roleType: number; // 列表相关参数 // 总条数 total: number; // 页码 pageNum = 1; // 条码 pageSize = 10; // 列表数据 requestData = []; // 列表加载 loading = true; isVisible = false; // 订单详情相关参数 // 详情模态框 orderDetailModal = false; // 详情模态框数据等待 orderDetailModalLoading = false; // 订单详情数据 orderDetailObject: any = { tradeOrder: {}, goodsOrder: { logisticsNo: null }, }; // 数据加载中参数 loadingObject = { title: '加载中...', status: false, }; // 请求地址参数 FILE_URL = environment.imageUrl; orderId: number; logisticsNo; logisticsTraceDetails; constructor( private form: FormBuilder, private store: LocalStorageService, private message: NzMessageService, private thirdPartyOrder: OrderThirdPartyService, private goods: GoodsService, private companyService: CompanyService, private commonsService: CommonsService, private notification: NzNotificationService, ) { } ngOnInit(): void { // 搜索表单初始化 this.searchForm = this.form.group({ orderNo: [null], memPhone: [null], status: [null], createTimeArray: [null], }); // 角色类型初始化 this.roleType = Number(this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType); // 查询公司列表 if (this.roleType === 0 || this.roleType === 1) { this.companyService.selectCompanyList({ pageNum: 1, pageSize: 999 }, data => { this.companyArray = data['return_data']['list']; }); } // 查询订单状态数据 this.commonsService.getDictionary('ORDER_STATUS', data => { this.orderStatusArray = data['return_data']; }); this.getRequest(true, this.searchForm.value); } // 查询列表 public getRequest(reset: boolean = false, whereObject: object) { this.loading = true; if (reset) { this.pageNum = 1; } whereObject['pageNum'] = this.pageNum; whereObject['pageSize'] = this.pageSize; if (whereObject['createTimeArray'] != null && whereObject['createTimeArray'].length !== 0) { whereObject['createTimeS'] = whereObject['createTimeArray'][0].getTime(); whereObject['createTimeE'] = whereObject['createTimeArray'][1].getTime(); } this.goods.getOrderChildList(whereObject, data => { this.loading = false; if (data['return_code'] === '000000') { this.requestData = data['return_data'].list; this.total = data['return_data'].total; } else { this.message.error(data['return_msg']); } }); } // 展示订单详情 public showOrderDetail(orderId: number ) { this.orderDetailModal = true; this.orderDetailModalLoading = true; this.goods.getLogisticsMsg(orderId, data => { this.logisticsTraceDetails = data['return_data']; this.orderDetailModalLoading = false; }); } // 更新运费单号 public updateLogisticsNo(orderId: number): void { this.orderId = orderId; this.isVisible = true; } public handleOk(): void { this.goods.editLogisticsNo({ orderId: this.orderId , logisticsNo: this.logisticsNo } , data => { if (data['return_code'] === '000000') { this.isVisible = false; this.getRequest(false, this.searchForm.value); this.notification.success('成功' , '更新成功'); } else { this.notification.error( '失败' , '更新成功'); } }); } }