From 17a6c374204147e4fa1c8615f34911287b6e9244 Mon Sep 17 00:00:00 2001
From: YuanYe <418471657@qq.com>
Date: Mon, 27 Oct 2025 16:45:57 +0800
Subject: [PATCH] 1
---
.../goods-auto/goods-auto.component.html | 244 +++++++++++++
.../goods-auto/goods-auto.component.less | 19 +
.../goods/goods-auto/goods-auto.component.ts | 335 ++++++++++++++++++
.../goods-list/goods-list.component.html | 2 +-
src/app/pages/goods/goods.routes.ts | 2 +
src/app/pages/login/login/login.component.ts | 1 -
src/app/pipes/goods/auto-goods-status.pipe.ts | 24 ++
src/app/services/goods/goods.service.ts | 46 +++
src/app/utils/dateUtils.service.ts | 10 +
9 files changed, 681 insertions(+), 2 deletions(-)
create mode 100644 src/app/pages/goods/goods-auto/goods-auto.component.html
create mode 100644 src/app/pages/goods/goods-auto/goods-auto.component.less
create mode 100644 src/app/pages/goods/goods-auto/goods-auto.component.ts
create mode 100644 src/app/pipes/goods/auto-goods-status.pipe.ts
diff --git a/src/app/pages/goods/goods-auto/goods-auto.component.html b/src/app/pages/goods/goods-auto/goods-auto.component.html
new file mode 100644
index 0000000..fc5026d
--- /dev/null
+++ b/src/app/pages/goods/goods-auto/goods-auto.component.html
@@ -0,0 +1,244 @@
+
+
+
+
+
+ | 任务名称 |
+ 任务类型 |
+ 更新库存数量 |
+ 状态 |
+ 上架时间 |
+ 下架时间 |
+ 创建时间 |
+ 操作 |
+
+
+
+
+ | {{data.taskTitle}} |
+ {{data.type == 1 ? '上架' : '下架'}} |
+ {{data.inventory}} |
+ {{data.status | autoGoodsStatus}} |
+ {{ data.listingTime | date: 'yyyy-MM-dd HH:mm:ss'}} |
+ {{ data.removalTime | date: 'yyyy-MM-dd HH:mm:ss'}} |
+ {{ data.createTime | date: 'yyyy-MM-dd HH:mm:ss'}} |
+
+ 关联商品
+
+
+ 更多
+
+
+
+
+
+ |
+
+
+ 总计 {{ total }} 条
+
+
+
+
+
+
+
+
+
+
+
+
+ 已选择 {{ setOfCheckedId.size }} 件商品
+
+
+
+
+ |
+ 商户 |
+ 商品名称 |
+ 商品类型 |
+ 商品分类 |
+ 商品品牌 |
+
+
+
+
+ |
+ {{ data.merName }} |
+ {{ data.title }} |
+ {{data.type == 1 ? '实物商品' : '虚拟商品'}} |
+ {{data.goodsTypeName}} |
+ {{data.goodsBrandName}} |
+
+
+
+
+
+
+
+
+
+
+
+ | 商品名称 |
+ 状态 |
+ 操作 |
+
+
+
+
+ | {{ data.goodsName }} |
+ {{data.status | autoGoodsStatus}} |
+
+ 删除
+ |
+
+
+
+
+
diff --git a/src/app/pages/goods/goods-auto/goods-auto.component.less b/src/app/pages/goods/goods-auto/goods-auto.component.less
new file mode 100644
index 0000000..6c41796
--- /dev/null
+++ b/src/app/pages/goods/goods-auto/goods-auto.component.less
@@ -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;
+}
diff --git a/src/app/pages/goods/goods-auto/goods-auto.component.ts b/src/app/pages/goods/goods-auto/goods-auto.component.ts
new file mode 100644
index 0000000..23d0bef
--- /dev/null
+++ b/src/app/pages/goods/goods-auto/goods-auto.component.ts
@@ -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();
+
+ 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;
+}
diff --git a/src/app/pages/goods/goods-list/goods-list.component.html b/src/app/pages/goods/goods-list/goods-list.component.html
index c16767c..c02b3e5 100644
--- a/src/app/pages/goods/goods-list/goods-list.component.html
+++ b/src/app/pages/goods/goods-list/goods-list.component.html
@@ -356,7 +356,7 @@
删除
- 赠送列表
+ 赠送列表
diff --git a/src/app/pages/goods/goods.routes.ts b/src/app/pages/goods/goods.routes.ts
index aa82294..02027a6 100644
--- a/src/app/pages/goods/goods.routes.ts
+++ b/src/app/pages/goods/goods.routes.ts
@@ -4,12 +4,14 @@ import {GoodsBrandComponent} from "./goods-brand/goods-brand.component";
import {GoodsListComponent} from "./goods-list/goods-list.component";
import {PriceListComponent} from "./recharge/price-list/price-list.component";
import {JdGoodsListComponent} from "./jd-goods-list/jd-goods-list.component";
+import {GoodsAutoComponent} from "./goods-auto/goods-auto.component";
export const GOODS_ROUTES: Routes = [
{ path: 'goods_type', component: GoodsTypeComponent},
{ path: 'goods_brand', component: GoodsBrandComponent},
{ path: 'goods-list', component: GoodsListComponent},
+ { path: 'goods-auto', component: GoodsAutoComponent},
{ path: 'jd-goods-list', component: JdGoodsListComponent},
{ path: 'recharge-price', component: PriceListComponent},
diff --git a/src/app/pages/login/login/login.component.ts b/src/app/pages/login/login/login.component.ts
index df0fd77..d428872 100644
--- a/src/app/pages/login/login/login.component.ts
+++ b/src/app/pages/login/login/login.component.ts
@@ -96,7 +96,6 @@ export class LoginComponent {
// 发起登录
this.login.userLogin(this.validateForm.value , (data: any) => {
if (data['return_code'] === '000000') {
- debugger
this.storage.set(LOGIN_DATA, this.validateForm.value);
this.storage.set(DATA, data['return_data']['object']);
this.storage.set(USER_TOKEN, data['return_data']['token']);
diff --git a/src/app/pipes/goods/auto-goods-status.pipe.ts b/src/app/pipes/goods/auto-goods-status.pipe.ts
new file mode 100644
index 0000000..88327a7
--- /dev/null
+++ b/src/app/pipes/goods/auto-goods-status.pipe.ts
@@ -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 '未知状态'
+ }
+ }
+
+
+
+}
diff --git a/src/app/services/goods/goods.service.ts b/src/app/services/goods/goods.service.ts
index 80c2602..db2bfe3 100644
--- a/src/app/services/goods/goods.service.ts
+++ b/src/app/services/goods/goods.service.ts
@@ -22,6 +22,12 @@ export class GoodsService {
});
}
+ public goodsTaskRel(params: object, callBack:any) {
+ this.http.post(environment.baseUrl + 'goodsAuto/goodsTaskRel', params).subscribe(data => {
+ callBack(data);
+ });
+ }
+
/**
* 查询列表
* @param params
@@ -55,6 +61,17 @@ export class GoodsService {
});
}
+ /**
+ * 创建商品自动上架任务
+ * @param params
+ * @param callBack
+ */
+ public goodsAutoTask(params: object, callBack:any) {
+ this.http.post(environment.baseUrl + 'goodsAuto/goodsAutoTask', params).subscribe(data => {
+ callBack(data);
+ });
+ }
+
/**
* 查询品牌列表
* @param params
@@ -83,6 +100,24 @@ export class GoodsService {
});
}
+ public deleteGoodsAuto(id: number, callBack:any) {
+ this.http.get(environment.baseUrl + 'goodsAuto/delete?id=' + id ).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ public deleteRel(id: number, callBack:any) {
+ this.http.get(environment.baseUrl + 'goodsAuto/deleteRel?id=' + id ).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ public queryListTaskGoodsRel(taskId: number, callBack:any) {
+ this.http.get(environment.baseUrl + 'goodsAuto/queryListTaskGoodsRel?taskId=' + taskId + "&time=" + new Date().getTime()).subscribe(data => {
+ callBack(data);
+ });
+ }
+
/**
* 获取商品列表
* @param params
@@ -94,6 +129,17 @@ export class GoodsService {
});
}
+ /**
+ * 获取商品自动上下架列表
+ * @param params
+ * @param callBack
+ */
+ public queryList(params: object, callBack:any) {
+ this.http.get(environment.baseUrl + 'goodsAuto/queryList?' + ObjectData.objectByString(params)).subscribe(data => {
+ callBack(data);
+ });
+ }
+
public getJdGoodsList(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'goods/getJdGoodsList?' + ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
diff --git a/src/app/utils/dateUtils.service.ts b/src/app/utils/dateUtils.service.ts
index 05bbb81..65e90d5 100644
--- a/src/app/utils/dateUtils.service.ts
+++ b/src/app/utils/dateUtils.service.ts
@@ -138,4 +138,14 @@ export class DateUtils {
}
return currentDate;
}
+
+ public static getDateHMShm(currentDate: Date , type: number): any {
+ if (type == 1) {
+ currentDate.setSeconds(0);
+ }
+ if (type == 2) {
+ currentDate.setSeconds(59);
+ }
+ return currentDate;
+ }
}