590 lines
16 KiB
TypeScript
590 lines
16 KiB
TypeScript
import { Component, OnInit, ViewChild } from '@angular/core';
|
||
import { Router } from '@angular/router';
|
||
import { STColumn, STComponent } from '@delon/abc/st';
|
||
import { SFComponent, SFDateWidgetSchema, SFSchema, SFSchemaEnum, SFSelectWidgetSchema, SFUISchema } from '@delon/form';
|
||
import { ModalHelper, _HttpClient } from '@delon/theme';
|
||
import { ShipperBaseService } from '@shared';
|
||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||
import { of } from 'rxjs';
|
||
import { map } from 'rxjs/operators';
|
||
import { SupplyManagementService } from '../../services/supply-management.service';
|
||
import { SupplyManagementBulkAssignedCarComponent } from '../assigned-car-bulk/assigned-car-bulk.component';
|
||
import { SupplyManagementQrcodePageComponent } from '../qrcode-page/qrcode-page.component';
|
||
import { SupplyManagementUpdatePriceComponent } from '../update-price/update-price.component';
|
||
|
||
@Component({
|
||
selector: 'app-supply-management-bulk',
|
||
templateUrl: './bulk.component.html',
|
||
})
|
||
export class SupplyManagementBulkComponent implements OnInit {
|
||
resourceStatus: any;
|
||
ui: SFUISchema = {};
|
||
ui2: SFUISchema = {};
|
||
schema: SFSchema = {};
|
||
auditMany = false;
|
||
isVisible = false;
|
||
auditID: any;
|
||
_$expand = false;
|
||
columns: STColumn[] = [];
|
||
freightSchema: SFSchema = {};
|
||
@ViewChild('st') private readonly st!: STComponent;
|
||
@ViewChild('sf', { static: false }) sf!: SFComponent;
|
||
@ViewChild('sfFre', { static: false }) sfFre!: SFComponent;
|
||
|
||
tabs = {
|
||
totalQuantity: 0,
|
||
cancelQuantity: 0,
|
||
receivedQuantity: 0,
|
||
stayQuantity: 0
|
||
};
|
||
constructor(
|
||
public service: SupplyManagementService,
|
||
private modal: NzModalService,
|
||
private router: Router,
|
||
public shipperservice: ShipperBaseService
|
||
) { }
|
||
|
||
ngOnInit(): void {
|
||
this.initSF();
|
||
this.initST();
|
||
this.initSFFre();
|
||
this.getGoodsSourceStatistical()
|
||
}
|
||
/**
|
||
* 查询参数
|
||
*/
|
||
get reqParams() {
|
||
const a:any = {};
|
||
if(this.resourceStatus) {
|
||
a.resourceStatus = this.resourceStatus
|
||
}
|
||
const params: any = Object.assign({}, this.sf?.value || {});
|
||
delete params._$expand;
|
||
return {
|
||
...a,
|
||
...params,
|
||
releaseTime: {
|
||
start: this.sf?.value?.releaseTime?.[0] || '',
|
||
end: this.sf?.value?.releaseTime?.[1] || '',
|
||
},
|
||
deadlineTime: {
|
||
start: this.sf?.value?.deadlineTime?.[0] || '',
|
||
end: this.sf?.value?.deadlineTime?.[1] || '',
|
||
},
|
||
};
|
||
|
||
// const a:any = {};
|
||
// if(this.resourceStatus) {
|
||
// a.resourceStatus = this.resourceStatus
|
||
// }
|
||
// return {
|
||
// ...a,
|
||
// ...this.sf?.value,
|
||
// createTime: {
|
||
// start: this.sf.value.createTime?.[0] || null,
|
||
// end: this.sf.value.createTime?.[1] || null,
|
||
// }
|
||
// };
|
||
}
|
||
search() {
|
||
this.st?.load(1);
|
||
this.getGoodsSourceStatistical()
|
||
}
|
||
/**
|
||
* 初始化查询表单
|
||
*/
|
||
initSF() {
|
||
this.schema = {
|
||
properties: {
|
||
_$expand: { type: 'boolean', ui: { hidden: true } },
|
||
resourceCode: {
|
||
type: 'string',
|
||
title: '货源编号'
|
||
},
|
||
loadingAddressArr: {
|
||
type: 'string',
|
||
title: '装货地'
|
||
},
|
||
unloadingAddressArr: {
|
||
type: 'string',
|
||
title: '卸货地'
|
||
},
|
||
serviceType: {
|
||
title: '服务类型',
|
||
type: 'string',
|
||
default: '',
|
||
ui: {
|
||
widget: 'dict-select',
|
||
containsAllLable: true,
|
||
params: { dictKey: 'service:type' },
|
||
containAllLable:true,
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value,
|
||
},
|
||
} as SFSelectWidgetSchema,
|
||
},
|
||
settlementBasis: {
|
||
title: '结算依据',
|
||
type: 'string',
|
||
ui: {
|
||
widget: 'dict-select',
|
||
containsAllLable: true,
|
||
params: { dictKey: 'goodresource:settlement:type' },
|
||
containAllLable:true,
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value,
|
||
},
|
||
} as SFSelectWidgetSchema,
|
||
},
|
||
releaseTime: {
|
||
title: '发布时间',
|
||
type: 'string',
|
||
ui: {
|
||
widget: 'date',
|
||
mode: 'range',
|
||
format: 'yyyy-MM-dd',
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value,
|
||
},
|
||
} as SFDateWidgetSchema,
|
||
},
|
||
deadlineTime: {
|
||
title: '截止时间',
|
||
type: 'string',
|
||
ui: {
|
||
widget: 'date',
|
||
mode: 'range',
|
||
format: 'yyyy-MM-dd',
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value,
|
||
},
|
||
} as SFDateWidgetSchema,
|
||
},
|
||
enterpriseInfoId: {
|
||
type: 'string',
|
||
title: '网络货运人',
|
||
ui: {
|
||
widget: 'select',
|
||
placeholder: '请选择',
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value,
|
||
},
|
||
allowClear: true,
|
||
asyncData: () => this.shipperservice.getNetworkFreightForwarder(),
|
||
},
|
||
},
|
||
shipperAppUserId: {
|
||
type: 'string',
|
||
title: '货主',
|
||
ui: {
|
||
widget: 'select',
|
||
serverSearch: true,
|
||
searchDebounceTime: 300,
|
||
searchLoadingText: '搜索中...',
|
||
visibleIf: {
|
||
_$expand: (value: boolean) => value
|
||
},
|
||
onSearch: (q: any) => {
|
||
console.log(q)
|
||
if (!!q) {
|
||
return this.service
|
||
.request(this.service.$api_enterpriceList, { enterpriseName: q})
|
||
.pipe(map((res: any) => (res as any[]).map((i) => ({ label: i.enterpriseName, value: i.id } as SFSchemaEnum))))
|
||
.toPromise();
|
||
} else {
|
||
return of([]);
|
||
}
|
||
},
|
||
} as SFSelectWidgetSchema,
|
||
},
|
||
},
|
||
type: 'object',
|
||
};
|
||
this.ui = { '*': { spanLabelFixed: 110, grid: { span: 8, gutter: 4 } } };
|
||
}
|
||
initSFFre() {
|
||
this.freightSchema = {
|
||
properties: {
|
||
remarks: {
|
||
title: '备注',
|
||
type: 'string',
|
||
maxLength: 50,
|
||
ui: {
|
||
placeholder: '请输入备注',
|
||
widget: 'textarea',
|
||
},
|
||
},
|
||
}
|
||
};
|
||
this.ui2 = { '*': { spanLabelFixed: 120, grid: { span: 24 } } };
|
||
}
|
||
/**
|
||
* 初始化数据列表
|
||
*/
|
||
initST() {
|
||
this.columns = [
|
||
{ title: '', type: 'checkbox', fixed: 'left', width: '50px', className: 'text-center' },
|
||
{
|
||
title: '货源编号',
|
||
width: '200px',
|
||
fixed: 'left',
|
||
className: 'text-left',
|
||
render: 'resourceCode'
|
||
},
|
||
{ title: '服务类型', index: 'serviceTypeLabel', width: '150px', className: 'text-left' },
|
||
{ title: '货主', index: 'shipperAppUserName', width: '220px', className: 'text-left' },
|
||
{ title: '项目名称', index: 'enterpriseProjectName', width: '220px', className: 'text-left' },
|
||
{ title: '关联订单', render: 'orderSn', width: '200px', className: 'text-left' },
|
||
{ title: '货物信息', render: 'goodsInfos', width: '280px', className: 'text-left' },
|
||
{
|
||
title: '装货地',
|
||
className: 'text-left',
|
||
index: 'loadingAddressArr',
|
||
width: '200px',
|
||
}, {
|
||
title: '卸货地',
|
||
className: 'text-left',
|
||
index: 'unloadingAddressArr',
|
||
width: '200px',
|
||
},
|
||
{
|
||
title: '用车需求',
|
||
className: 'text-left',
|
||
width: '200px',
|
||
render: 'useCarDemand'
|
||
},
|
||
{
|
||
title: '运费单价',
|
||
className: 'text-right',
|
||
width: '150px',
|
||
index: 'freightPrice',
|
||
render: 'freightPrice'
|
||
},
|
||
{
|
||
title: '结算依据',
|
||
className: 'text-left',
|
||
width: '200px',
|
||
index: 'settlementBasisLabel',
|
||
},
|
||
{
|
||
title: '货源状态',
|
||
className: 'text-left',
|
||
index: 'resourceStatus',
|
||
type: 'badge',
|
||
width: '120px',
|
||
badge: {
|
||
'1': { text: '待接单', color: 'success' },
|
||
'2': { text: '已接单', color: 'warning' },
|
||
},
|
||
},
|
||
{
|
||
title: '截止时间',
|
||
width: '170px',
|
||
className: 'text-left',
|
||
index: 'deadlineTime',
|
||
},
|
||
{
|
||
title: '发布时间',
|
||
width: '170px',
|
||
className: 'text-left',
|
||
index: 'createTime',
|
||
},
|
||
{
|
||
title: '审核状态',
|
||
className: 'text-left',
|
||
index: 'auditStatus',
|
||
type: 'badge',
|
||
width: '170px',
|
||
badge: {
|
||
'1': { text: '待审核', color: 'warning' },
|
||
'2': { text: '审核通过', color: 'success' },
|
||
'3': { text: '不通过', color: 'default' },
|
||
'4': { text: '已取消', color: 'default' },
|
||
},
|
||
},
|
||
{
|
||
title: '操作',
|
||
fixed: 'right',
|
||
width: '110px',
|
||
className: 'text-left',
|
||
buttons: [
|
||
{
|
||
text: '货源审核',
|
||
click: (_record) => this.audit(_record, 1),
|
||
iif: item => item.auditStatus == 1,
|
||
},
|
||
{
|
||
text: '二维码 ',
|
||
click: (_record) => this.assignedQrcode(_record),
|
||
iif: item => item.auditStatus == 1 || item.auditStatus == 2,
|
||
},
|
||
{
|
||
text: '修改单价',
|
||
click: (_record) => this.modification(_record),
|
||
iif: item => item.auditStatus == 1 || item.auditStatus == 2,
|
||
},
|
||
{
|
||
text: '取消货源',
|
||
click: (_record) => this.delOne(_record),
|
||
iif: item => item.auditStatus == 1 || item.auditStatus == 2,
|
||
},
|
||
{
|
||
text: '再下一单',
|
||
click: (_record) => this.nextOrder(_record),
|
||
},
|
||
{
|
||
text: '重新指派',
|
||
click: (_record) => this.assignedCar(_record),
|
||
iif: item => item.auditStatus == 2,
|
||
},
|
||
],
|
||
},
|
||
];
|
||
}
|
||
add(): void {
|
||
// this.modal
|
||
// .createStatic(FormEditComponent, { i: { id: 0 } })
|
||
// .subscribe(() => this.st.reload());
|
||
}
|
||
/**
|
||
* 重新指派
|
||
*/
|
||
assignedCar(item: any) {
|
||
const modalRef = this.modal.create({
|
||
nzTitle: '指派熟车',
|
||
nzWidth: '1500px',
|
||
nzContent: SupplyManagementBulkAssignedCarComponent,
|
||
nzComponentParams: {
|
||
i: item
|
||
},
|
||
nzFooter: null,
|
||
|
||
});
|
||
modalRef.afterClose.subscribe((result) => {
|
||
if (result) {
|
||
this.st.reload();
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* 查询字段个数
|
||
*/
|
||
get queryFieldCount(): number {
|
||
return Object.keys(this.schema?.properties || {}).length;
|
||
}
|
||
/**
|
||
* 伸缩查询条件
|
||
*/
|
||
expandToggle(): void {
|
||
this._$expand = !this._$expand;
|
||
this.sf?.setValue('/_$expand', this._$expand);
|
||
}
|
||
|
||
/**
|
||
* 重置表单
|
||
*/
|
||
resetSF(): void {
|
||
this.sf.reset();
|
||
this._$expand = false;
|
||
}
|
||
get selectedRows() {
|
||
return this.st?.list.filter((item) => item.checked) || [];
|
||
}
|
||
|
||
selectChange(e: number) {
|
||
console.log(e);
|
||
this.resourceStatus = e;
|
||
this.initST();
|
||
setTimeout(() => {
|
||
this.st.load();
|
||
this.getGoodsSourceStatistical();
|
||
}, 500);
|
||
}
|
||
|
||
/**
|
||
* 更新运费
|
||
*/
|
||
updatePrice(item: any) {
|
||
const modalRef = this.modal.create({
|
||
nzTitle: '修改单价',
|
||
nzWidth: '600px',
|
||
nzContent: SupplyManagementUpdatePriceComponent,
|
||
nzComponentParams: {
|
||
i: item,
|
||
},
|
||
nzFooter: null,
|
||
});
|
||
modalRef.afterClose.subscribe(res => {
|
||
if (res) {
|
||
this.st.reload();
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 二维码
|
||
*/
|
||
assignedQrcode(item: any) {
|
||
const modalRef = this.modal.create({
|
||
nzTitle: '二维码',
|
||
nzWidth: '600px',
|
||
nzContent: SupplyManagementQrcodePageComponent,
|
||
nzComponentParams: {
|
||
i: item,
|
||
},
|
||
nzFooter: null,
|
||
});
|
||
}
|
||
tabChange(item: any) {
|
||
console.log(item)
|
||
}
|
||
/**
|
||
* 审核
|
||
* status : 1 单个 2:批量
|
||
* value : 单个单条数据
|
||
*/
|
||
audit(value: any, status?: any) {
|
||
console.log(value)
|
||
console.log(status)
|
||
if(status === 2) {
|
||
if(this.selectedRows.length <= 0) {
|
||
this.service.msgSrv.error('未选择货源单!');
|
||
return
|
||
}
|
||
let list: any[] = [];
|
||
this.selectedRows.forEach(item => {
|
||
list.push(item.id);
|
||
});
|
||
this.auditID = list;
|
||
this.auditMany = true;
|
||
} else {
|
||
this.auditID = value.id
|
||
this.auditMany = false;
|
||
}
|
||
this.isVisible = true;
|
||
}
|
||
/**
|
||
* 审核关闭弹窗
|
||
*/
|
||
handleCancel(type: any) {
|
||
this.isVisible = false
|
||
}
|
||
/**
|
||
* 代发货源
|
||
*/
|
||
releaseGoods() {
|
||
this.router.navigate(['/supply-management/bulk-release']);
|
||
}
|
||
/**
|
||
* 审核通过按钮
|
||
*/
|
||
handleOK(value: any) {
|
||
if(this.selectedRows.length <= 0) {
|
||
const params: any = {
|
||
id: this.auditID,
|
||
remarks: this.sfFre.value.remarks,
|
||
}
|
||
if(value == 1) {
|
||
params.auditStatus = 2
|
||
} else {
|
||
params.auditStatus = 3
|
||
}
|
||
console.log(params)
|
||
this.service.request(this.service.$api_goodsResourceAudit, params).subscribe(res => {
|
||
if (res === true) {
|
||
this.service.msgSrv.success('审核成功!');
|
||
this.isVisible = false;
|
||
this.st?.reload();
|
||
this.getGoodsSourceStatistical();
|
||
}
|
||
})
|
||
} else {
|
||
const params: any = {
|
||
ids: this.auditID,
|
||
remarks: this.sfFre.value.remarks,
|
||
}
|
||
if(value == 1) {
|
||
params.auditStatus = 2
|
||
} else {
|
||
params.auditStatus = 3
|
||
}
|
||
console.log(params)
|
||
this.service.request(this.service.$api_batchGoodsResourceAudit, params).subscribe(res => {
|
||
if (res === true) {
|
||
this.service.msgSrv.success('审核成功!');
|
||
this.isVisible = false;
|
||
this.st?.reload();
|
||
this.getGoodsSourceStatistical();
|
||
}
|
||
})
|
||
}
|
||
}
|
||
// 修改单价
|
||
modification(item: any) {
|
||
const modalRef = this.modal.create({
|
||
nzTitle: '修改单价',
|
||
nzWidth: '600px',
|
||
nzContent: SupplyManagementUpdatePriceComponent,
|
||
nzComponentParams: {
|
||
record: item,
|
||
},
|
||
nzFooter: null,
|
||
});
|
||
modalRef.afterClose.subscribe(res => {
|
||
if (res) {
|
||
console.log(res)
|
||
// this.getGoodsSourceDetail();
|
||
}
|
||
})
|
||
}
|
||
// getGoodsSourceDetail() {
|
||
// this.service.request(this.service.$api_get_bulk_detail, { id: this.id }).subscribe(res => {
|
||
// this.i = res;
|
||
// this.currentStatus = +this.i?.resourceStatus - 1;
|
||
// })
|
||
// }
|
||
|
||
// 再下一单
|
||
nextOrder(item: any) {
|
||
this.router.navigate(['/supply-management/bulk-amend', item.id], {
|
||
queryParams: {
|
||
sta: 4
|
||
},
|
||
})
|
||
}
|
||
// 取消货源
|
||
delOne(item: any) {
|
||
this.modal.confirm({
|
||
nzTitle: '<b>确定取消货源吗?</b>',
|
||
nzContent: `<b>取消后不可恢复,谨慎操作</b>`,
|
||
nzOnOk: () =>
|
||
this.service.request(this.service.$api_cancelSource, {id: item.id}).subscribe((res) => {
|
||
if(res) {
|
||
this.service.msgSrv.success('已取消货源!')
|
||
this.st?.reload();
|
||
this.getGoodsSourceStatistical();
|
||
}
|
||
})
|
||
})
|
||
|
||
}
|
||
// 获取货源状态统计
|
||
getGoodsSourceStatistical() {
|
||
this.tabs = {
|
||
totalQuantity: 0,
|
||
cancelQuantity: 0,
|
||
receivedQuantity: 0,
|
||
stayQuantity: 0
|
||
};
|
||
this.service.request(this.service.$api_get_goods_resource_statistical, { resourceType: 2, ...this.reqParams }).subscribe(res => {
|
||
if (res) {
|
||
console.log(res)
|
||
this.tabs = res;
|
||
}
|
||
})
|
||
}
|
||
userAction() {
|
||
|
||
}
|
||
}
|