master
parent
0c13b49c35
commit
17a6c37420
@ -0,0 +1,244 @@ |
||||
<form nz-form [formGroup]="searchForm" class="search_form" [nzLayout]="'vertical'"> |
||||
<div nz-row [nzGutter]="24"> |
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>任务名称</nz-form-label> |
||||
<nz-form-control> |
||||
<input nzSize="large" nz-input formControlName="taskTitle" placeholder="请输入" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>任务名称</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="type"> |
||||
<nz-option nzLabel="上架" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="下架" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>上下架时间区间</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-range-picker nzSize="large" formControlName="timeArray" |
||||
[nzShowTime]="{ nzFormat: 'HH:mm' }" |
||||
nzFormat="yyyy-MM-dd HH:mm" |
||||
></nz-range-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="6" class="search-area"> |
||||
<button nz-button [nzType]="'primary'" (click)="getRequest(true)">查询</button> |
||||
<button nz-button (click)="searchForm.reset()">重置</button> |
||||
<button nz-button [nzType]="'primary'" (click)="showEdit()">创建</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
<nz-table #basicTable |
||||
[nzBordered]="true" |
||||
[nzFrontPagination]="false" |
||||
[nzShowQuickJumper]="true" |
||||
[nzShowTotal]="totalTemplate" |
||||
[(nzPageIndex)]="tablePageNum" |
||||
(nzPageIndexChange)="getRequest(false)" |
||||
[nzTotal]="tableData.total" |
||||
[nzData]="tableData.list" > |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px">任务名称</th> |
||||
<th nzWidth="80px">任务类型</th> |
||||
<th nzWidth="100px">更新库存数量</th> |
||||
<th nzWidth="100px">状态</th> |
||||
<th nzWidth="100px">上架时间</th> |
||||
<th nzWidth="100px">下架时间</th> |
||||
<th nzWidth="50px">创建时间</th> |
||||
<th nzWidth="70px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data"> |
||||
<td>{{data.taskTitle}}</td> |
||||
<td>{{data.type == 1 ? '上架' : '下架'}}</td> |
||||
<td>{{data.inventory}}</td> |
||||
<td>{{data.status | autoGoodsStatus}}</td> |
||||
<td>{{ data.listingTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td>{{ data.removalTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td> |
||||
<a (click)="goodsRel(data.id)">关联商品</a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a nz-dropdown [nzDropdownMenu]="menu"> |
||||
更多 |
||||
<span nz-icon nzType="down"></span> |
||||
</a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item><a (click)="showTaskGoodsRel(data.id)">商品列表</a></li> |
||||
<li nz-menu-item><a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template> |
||||
<nz-modal [(nzVisible)]="isVisibleEdit" [nzMaskClosable] = false nzTitle="创建任务" (nzOnCancel)="isVisibleEdit = false" (nzOnOk)="handleEdit()"> |
||||
<ng-container *nzModalContent> |
||||
<form nz-form [formGroup]="editForm"> |
||||
<nz-form-item > |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>任务标题</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入标题!"> |
||||
<input nzSize="large" nz-input formControlName="taskTitle" placeholder="请输入" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item > |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>任务类型</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请选择任务类型!"> |
||||
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="type"> |
||||
<nz-option nzLabel="上架" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="下架" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item *ngIf="editForm.value['type'] == 1"> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>更新库存</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入更新库存!"> |
||||
<nz-input-number formControlName="inventory" [nzStep]="1" ></nz-input-number> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item *ngIf="editForm.value['type'] == 1"> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>上架时间</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入上架时间!"> |
||||
<nz-date-picker nzShowTime formControlName="listingTime" [nzShowTime]="{ nzFormat: 'HH:mm' }" nzFormat="yyyy-MM-dd HH:mm"></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item *ngIf="editForm.value['type'] == 2" > |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>下架时间</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入下架时间!"> |
||||
<nz-date-picker nzShowTime formControlName="removalTime" [nzShowTime]="{ nzFormat: 'HH:mm' }" nzFormat="yyyy-MM-dd HH:mm"></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
</form> |
||||
</ng-container> |
||||
</nz-modal> |
||||
|
||||
<nz-modal [nzWidth]="1000" [(nzVisible)]="isVisible" nzTitle="绑定商品" (nzOnCancel)="isVisible = false" (nzOnOk)="handleOk()"> |
||||
<ng-container *nzModalContent> |
||||
|
||||
<form nz-form [formGroup]="searchFormGoods" class="search_form" [nzLayout]="'vertical'"> |
||||
<div nz-row [nzGutter]="24"> |
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>商品名称</nz-form-label> |
||||
<nz-form-control> |
||||
<input nzSize="large" nz-input formControlName="title" placeholder="请输入" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>商品类型</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="type"> |
||||
<nz-option nzLabel="实物商品" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="虚拟商品商品" nzValue="2"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>商品状态</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-select nzSize="large" nzShowSearch nzAllowClear nzPlaceHolder="请选择" formControlName="status"> |
||||
<nz-option nzLabel="上线中" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="编辑中" nzValue="2"></nz-option> |
||||
<nz-option nzLabel="审核中" nzValue="3"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
|
||||
<div nz-col [nzSpan]="6" class="search-area"> |
||||
<button nz-button [nzType]="'primary'" (click)="getRequestGoods(true)">查询</button> |
||||
<button nz-button (click)="searchFormGoods.reset()">重置</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
<div class="send-request"> |
||||
|
||||
<span>已选择 {{ setOfCheckedId.size }} 件商品</span> |
||||
</div> |
||||
<nz-table |
||||
#rowSelectionTable |
||||
nzShowSizeChanger |
||||
[nzLoading]="loading" |
||||
[nzBordered]="true" |
||||
[nzFrontPagination]="false" |
||||
[nzShowQuickJumper]="true" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzData]="listOfData" |
||||
(nzPageIndexChange)="getRequestGoods(false)" |
||||
(nzPageSizeChange)="getRequestGoods(false)" |
||||
(nzCurrentPageDataChange)="onCurrentPageDataChange($event)" |
||||
> |
||||
<thead> |
||||
<tr> |
||||
<th |
||||
[(nzChecked)]="checked" |
||||
[nzIndeterminate]="indeterminate" |
||||
(nzCheckedChange)="onAllChecked($event)" |
||||
></th> |
||||
<th>商户</th> |
||||
<th>商品名称</th> |
||||
<th>商品类型</th> |
||||
<th>商品分类</th> |
||||
<th>商品品牌</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of rowSelectionTable.data"> |
||||
<td [nzChecked]="setOfCheckedId.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td> |
||||
<td>{{ data.merName }}</td> |
||||
<td>{{ data.title }}</td> |
||||
<td>{{data.type == 1 ? '实物商品' : '虚拟商品'}}</td> |
||||
<td>{{data.goodsTypeName}}</td> |
||||
<td>{{data.goodsBrandName}}</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</ng-container> |
||||
</nz-modal> |
||||
|
||||
<nz-modal [nzWidth]="1000" [(nzVisible)]="isVisibleRel" nzTitle="绑定商品列表" (nzOnCancel)="isVisibleRel = false" > |
||||
<ng-container *nzModalContent> |
||||
<nz-table #basicTable [nzData]="taskGoodsRelData" [nzBordered]="true"> |
||||
<thead> |
||||
<tr> |
||||
<th>商品名称</th> |
||||
<th>状态</th> |
||||
<th>操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data"> |
||||
<td>{{ data.goodsName }}</td> |
||||
<td>{{data.status | autoGoodsStatus}}</td> |
||||
<td> |
||||
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="deleteRel(data.id)">删除</a> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</ng-container> |
||||
</nz-modal> |
||||
@ -0,0 +1,19 @@ |
||||
[nz-form-label] { |
||||
overflow: visible; |
||||
} |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
.submit-btn { |
||||
width: 150px; |
||||
} |
||||
.search-area { |
||||
margin-top: 30px; |
||||
} |
||||
.send-request { |
||||
margin-bottom: 16px; |
||||
} |
||||
|
||||
.send-request span { |
||||
margin-left: 8px; |
||||
} |
||||
@ -0,0 +1,335 @@ |
||||
import { Component } from '@angular/core'; |
||||
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
||||
import {DatePipe, NgForOf, NgIf} from "@angular/common"; |
||||
import {NzButtonComponent} from "ng-zorro-antd/button"; |
||||
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; |
||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; |
||||
import {NzInputDirective} from "ng-zorro-antd/input"; |
||||
import {NzMessageService} from "ng-zorro-antd/message"; |
||||
import {GoodsService} from "../../../services/goods/goods.service"; |
||||
import {NzDatePickerComponent, NzRangePickerComponent} from "ng-zorro-antd/date-picker"; |
||||
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm"; |
||||
import { |
||||
NzTableCellDirective, |
||||
NzTableComponent, |
||||
NzTbodyComponent, NzTdAddOnComponent, |
||||
NzTheadComponent, |
||||
NzThMeasureDirective, NzThSelectionComponent, NzTrDirective |
||||
} from "ng-zorro-antd/table"; |
||||
import {NzModalComponent, NzModalContentDirective} from "ng-zorro-antd/modal"; |
||||
import {NzInputNumberComponent} from "ng-zorro-antd/input-number"; |
||||
import {DateUtils} from "../../../utils/dateUtils.service"; |
||||
import {NzDividerComponent} from "ng-zorro-antd/divider"; |
||||
import {NzImageDirective} from "ng-zorro-antd/image"; |
||||
import {fallbackImg} from "../../../data/goods/goods.namespace"; |
||||
import {environment} from "../../../../environments/environment"; |
||||
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; |
||||
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; |
||||
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
||||
import {NzIconDirective} from "ng-zorro-antd/icon"; |
||||
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu"; |
||||
import {AutoGoodsStatusPipe} from "../../../pipes/goods/auto-goods-status.pipe"; |
||||
|
||||
interface ItemData { |
||||
id: number; |
||||
title: string; |
||||
merName: string; |
||||
thirdId: string; |
||||
goodsTypeName: string; |
||||
goodsBrandName: string; |
||||
type: number; |
||||
} |
||||
|
||||
@Component({ |
||||
selector: 'app-goods-auto', |
||||
standalone: true, |
||||
imports: [ |
||||
FormsModule, |
||||
NzButtonComponent, |
||||
NzColDirective, |
||||
NzFormControlComponent, |
||||
NzFormDirective, |
||||
NzFormItemComponent, |
||||
NzFormLabelComponent, |
||||
NzInputDirective, |
||||
NzRowDirective, |
||||
ReactiveFormsModule, |
||||
NzDatePickerComponent, |
||||
NzRangePickerComponent, |
||||
DatePipe, |
||||
NgForOf, |
||||
NzPopconfirmDirective, |
||||
NzTableCellDirective, |
||||
NzTableComponent, |
||||
NzTbodyComponent, |
||||
NzThMeasureDirective, |
||||
NzTheadComponent, |
||||
NzTrDirective, |
||||
NzModalComponent, |
||||
NzModalContentDirective, |
||||
NzInputNumberComponent, |
||||
|
||||
NzDividerComponent, |
||||
NzThSelectionComponent, |
||||
NzTdAddOnComponent, |
||||
|
||||
NzOptionComponent, |
||||
NzSelectComponent, |
||||
NgIf, |
||||
NzDropDownADirective, |
||||
NzDropDownDirective, |
||||
NzDropdownMenuComponent, |
||||
NzIconDirective, |
||||
NzMenuDirective, |
||||
NzMenuItemComponent, |
||||
AutoGoodsStatusPipe, |
||||
|
||||
], |
||||
templateUrl: './goods-auto.component.html', |
||||
styleUrl: './goods-auto.component.less' |
||||
}) |
||||
export class GoodsAutoComponent { |
||||
// 表单页数
|
||||
tablePageNum = 1; |
||||
// 表单数据
|
||||
tableData: any = { |
||||
total: 0, |
||||
loading: false, |
||||
list: [], |
||||
}; |
||||
imageUrl = environment.imageUrl; |
||||
// 搜索表单
|
||||
searchForm: FormGroup; |
||||
editForm: FormGroup; |
||||
searchFormGoods: FormGroup; |
||||
isVisibleEdit = false; |
||||
isVisible = false; |
||||
isVisibleRel = false; |
||||
// 多选表单
|
||||
|
||||
|
||||
checked = false; |
||||
indeterminate = false; |
||||
listOfCurrentPageData: readonly ItemData[] = []; |
||||
listOfData: readonly ItemData[] = []; |
||||
taskGoodsRelData: any = []; |
||||
loading = false; |
||||
total = 1; |
||||
// 页码
|
||||
pageNum = 1; |
||||
// 条码
|
||||
pageSize = 10; |
||||
|
||||
setOfCheckedId = new Set<number>(); |
||||
|
||||
taskId: any; |
||||
constructor( |
||||
private fb: NonNullableFormBuilder, |
||||
private msg: NzMessageService, |
||||
private goodsService: GoodsService |
||||
) { |
||||
// 初始化搜索框
|
||||
this.searchForm = this.fb.group({ |
||||
taskTitle: [''], |
||||
type: [''], |
||||
timeArray: [[]], |
||||
listingTime: [''], |
||||
removalTime: [''], |
||||
}); |
||||
this.editForm = this.fb.group({ |
||||
taskTitle: ['', [Validators.required]], |
||||
type: ['', [Validators.required]], |
||||
listingTime: [''], |
||||
removalTime: [''], |
||||
inventory: [''], |
||||
}); |
||||
|
||||
this.searchFormGoods = this.fb.group({ |
||||
title: [''], |
||||
type: [''], |
||||
status: [''], |
||||
}); |
||||
this.getRequest(); |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
public getRequest(reset: boolean = false) { |
||||
if (this.searchForm.controls['timeArray'].value != null |
||||
&& this.searchForm.controls['timeArray'].value.length > 0) { |
||||
this.searchForm.controls['listingTime'].setValue(DateUtils.getDateHMShm(new Date(this.searchForm.controls['timeArray'].value[0]) , 1).getTime()); |
||||
this.searchForm.controls['removalTime'].setValue(DateUtils.getDateHMShm(new Date(this.searchForm.controls['timeArray'].value[1]) , 2).getTime()); |
||||
} else { |
||||
this.searchForm.controls['listingTime'].setValue(null) |
||||
this.searchForm.controls['removalTime'].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.goodsService.queryList(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; |
||||
}); |
||||
} |
||||
showEdit() { |
||||
this.editForm.reset() |
||||
this.isVisibleEdit = true; |
||||
} |
||||
|
||||
handleEdit(): void { |
||||
|
||||
if (this.editForm.valid) { |
||||
this.editForm.value.listingTime = DateUtils.getDateHMShm(new Date(this.editForm.value.listingTime) , 1); |
||||
this.editForm.value.removalTime = DateUtils.getDateHMShm(new Date(this.editForm.value.removalTime) , 1); |
||||
this.goodsService.goodsAutoTask(this.editForm.value , (data: any) => { |
||||
if (data['return_code'] === '000000') { |
||||
this.msg.success("成功!"); |
||||
this.isVisibleEdit = false; |
||||
this.getRequest(); |
||||
} else { |
||||
this.msg.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} else { |
||||
Object.values(this.editForm.controls).forEach(control => { |
||||
if (control.invalid) { |
||||
control.markAsDirty(); |
||||
control.updateValueAndValidity({ onlySelf: true }); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
goodsRel(taskId: number) { |
||||
this.taskId = taskId; |
||||
this.isVisible = true; |
||||
this.getRequestGoods(false) |
||||
} |
||||
|
||||
showTaskGoodsRel (taskId: number) { |
||||
this.taskId = taskId; |
||||
this.isVisibleRel = true; |
||||
this.queryListTaskGoodsRel(taskId); |
||||
} |
||||
|
||||
queryListTaskGoodsRel (taskId: number) { |
||||
this.goodsService.queryListTaskGoodsRel(taskId , (data: any) => { |
||||
if (data['return_code'] === '000000') { |
||||
this.taskGoodsRelData = data['return_data']; |
||||
} else { |
||||
this.msg.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
delete(id: number): void { |
||||
this.goodsService.deleteGoodsAuto(id , (data: any) => { |
||||
if (data['return_code'] === '000000') { |
||||
this.msg.success("成功!"); |
||||
this.getRequest(); |
||||
} else { |
||||
this.msg.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
deleteRel(id: number): void { |
||||
this.goodsService.deleteRel(id , (data: any) => { |
||||
if (data['return_code'] === '000000') { |
||||
this.queryListTaskGoodsRel(this.taskId); |
||||
this.msg.success("成功!"); |
||||
} else { |
||||
this.msg.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
handleOk() { |
||||
const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id)); |
||||
let goodsIds = ''; |
||||
for (const i of requestData) { |
||||
goodsIds += i['id'] + ','; |
||||
} |
||||
|
||||
goodsIds = goodsIds.substring(0, goodsIds.length - 1); |
||||
|
||||
this.goodsService.goodsTaskRel({ |
||||
taskId: this.taskId, |
||||
goodsIds: goodsIds |
||||
} , (data: any) => { |
||||
if (data['return_code'] === '000000') |
||||
this.msg.success("成功!"); |
||||
this.isVisible = false; |
||||
this.getRequest(); |
||||
}); |
||||
|
||||
} |
||||
|
||||
getRequestGoods(reset: boolean = false) { |
||||
|
||||
this.loading = true; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
this.searchFormGoods.value.pageNum = this.pageNum; |
||||
this.searchFormGoods.value.pageSize = this.pageSize; |
||||
this.searchFormGoods.value.time = new Date().getTime(); |
||||
|
||||
this.goodsService.getListGoods(this.searchFormGoods.value, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
this.listOfData = data['return_data'].list; |
||||
this.total = data['return_data'].total; |
||||
} else { |
||||
this.msg.error(data['return_msg']); |
||||
} |
||||
this.loading = false; |
||||
}); |
||||
|
||||
} |
||||
|
||||
|
||||
updateCheckedSet(id: number, checked: boolean): void { |
||||
if (checked) { |
||||
this.setOfCheckedId.add(id); |
||||
} else { |
||||
this.setOfCheckedId.delete(id); |
||||
} |
||||
} |
||||
|
||||
onItemChecked(id: number, checked: boolean): void { |
||||
this.updateCheckedSet(id, checked); |
||||
this.refreshCheckedStatus(); |
||||
} |
||||
|
||||
onAllChecked(value: boolean): void { |
||||
this.listOfCurrentPageData.forEach(item => this.updateCheckedSet(item.id, value)); |
||||
this.refreshCheckedStatus(); |
||||
} |
||||
|
||||
onCurrentPageDataChange($event: readonly ItemData[]): void { |
||||
this.listOfCurrentPageData = $event; |
||||
this.refreshCheckedStatus(); |
||||
} |
||||
|
||||
refreshCheckedStatus(): void { |
||||
this.checked = this.listOfCurrentPageData.every(item => this.setOfCheckedId.has(item.id)); |
||||
this.indeterminate = this.listOfCurrentPageData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked; |
||||
} |
||||
|
||||
protected readonly fallbackImg = fallbackImg; |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'autoGoodsStatus', |
||||
standalone: true |
||||
}) |
||||
export class AutoGoodsStatusPipe implements PipeTransform { |
||||
|
||||
transform(value: number): any { |
||||
switch (value) { |
||||
case 1: |
||||
return '启动'; |
||||
case 2: |
||||
return '成功'; |
||||
case 3: |
||||
return '失败'; |
||||
default: |
||||
return '未知状态' |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
Loading…
Reference in new issue