diff --git a/src/app/model/goods.interface.ts b/src/app/model/goods.interface.ts index a5c9e2d..4665c8d 100644 --- a/src/app/model/goods.interface.ts +++ b/src/app/model/goods.interface.ts @@ -12,3 +12,44 @@ export interface GoodsTypeData { children?: GoodsTypeData[]; parent?: GoodsTypeData; } +export interface GoodsMsgData { + id: number; + goodsTypeName: string; + goodsType: number; + type: number; + goodsBrandName: string; + goodsBrand: number; + goodsLabel: string; + title: string; + listImg: string; + bannerImg: string; + detailImg: string; + status: number; + createTime: string; + updateTime: string; + merId: string; + merName: string; +} + +export interface SpecsData { + id: number; + goodsId: number; + name: string; + purLimit: number; + salePrice: number; + originalPrice: number; + stock: number; + showImg: string; + status: number; + createTime: string; + updateTime: string; + specsId: number; + key: string; + validDay: string; + salesEndTime: string, + type: number, + source: string, + jumpType: number, + jumpUrl: string, + appid: string +} 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 483f14e..ec905b8 100644 --- a/src/app/pages/goods/goods-list/goods-list.component.html +++ b/src/app/pages/goods/goods-list/goods-list.component.html @@ -100,13 +100,24 @@ 修改 - 删除 + + 更多 + + + + + 总计 {{ total }} 条 - @@ -117,6 +128,7 @@ + 商品分类 @@ -145,6 +157,18 @@ + + 商品标签 + + + + + + 商品说明 + + + + 列表图片 @@ -171,7 +195,6 @@ - @@ -235,3 +258,205 @@ + + + + + + +
+
+ + + + 规格名称 + 价格(RMB) + 图片 + 限购(个) + 库存(个) + 时间 + 虚拟产品 + 操作 + + + 售价 + 原价 + 销售截止时间 + 创建时间 + 卡密 + 归库天数 + 类型 + 产品来源 + 跳转类型 + 跳转地址 + 应用ID + + + + + + {{data.name}} + + ¥{{data.salePrice}} + + + ¥{{data.originalPrice}} + + + + + {{data.purLimit}} + {{data.stock}} + {{ data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}} + {{ data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{data.key}} + {{data.validDay}} + {{data.type == 1 ? '内部虚拟商品' : '外部虚拟产品'}} + {{data.source | dictionary: 'GOODS_VPD_SOURCE'}} + {{data.jumpType == 1 ? '小程序' : 'H5'}} + {{data.jumpUrl}} + {{data.appid}} + + + 修改 + + 删除 + + + + +
+
+ + + + +
+ + 规格名称 + + + + + + 限购数量 + + + + + + 售卖价格 + + + + + + + + 原价 + + + + + + + + 库存 + + + + + + 有效天数 + + + + + + 售卖最终时间 + + + + + + 虚拟来源 + + + + + + + + 类型 + + + + + + + + + 卡密 + + + + + + 跳转类型 + + + + + + + + + 跳转地址 + + + + + + 应用ID + + + + + + 展示图片 + + +
+ +
上传图片
+
+
+ + + + + + +
+
+
+
+
diff --git a/src/app/pages/goods/goods-list/goods-list.component.ts b/src/app/pages/goods/goods-list/goods-list.component.ts index 07a30cf..9aee5ce 100644 --- a/src/app/pages/goods/goods-list/goods-list.component.ts +++ b/src/app/pages/goods/goods-list/goods-list.component.ts @@ -12,7 +12,7 @@ import {NzMessageService} from "ng-zorro-antd/message"; import {CommonService} from "../../../services/common/common.service"; import {GoodsService} from "../../../services/goods/goods.service"; import { fallbackImg } from '../../../data/goods/goods.namespace'; -import {GoodsTypeData} from "../../../model/goods.interface"; +import {GoodsMsgData, GoodsTypeData, SpecsData} from "../../../model/goods.interface"; import {NzDividerComponent} from "ng-zorro-antd/divider"; import {NzIconDirective} from "ng-zorro-antd/icon"; import {NzImageDirective, NzImageModule} from "ng-zorro-antd/image"; @@ -26,6 +26,16 @@ import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; import {GoodsStatusPipe} from "../../../pipes/goods/goods-status.pipe"; import {NzConfigService} from "ng-zorro-antd/core/config"; +import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; +import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu"; +import { + NzInputNumberComponent, + NzInputNumberGroupComponent, + NzInputNumberGroupWhitSuffixOrPrefixDirective +} from "ng-zorro-antd/input-number"; +import {NzSpaceItemDirective} from "ng-zorro-antd/space"; +import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; +import {NzTypographyComponent} from "ng-zorro-antd/typography"; const getBase64 = (file: File): Promise => new Promise((resolve, reject) => { @@ -67,7 +77,18 @@ const getBase64 = (file: File): Promise => NzTreeSelectComponent, NzDividerComponent, NzPopconfirmDirective, - GoodsStatusPipe + GoodsStatusPipe, + NzDropDownADirective, + NzDropDownDirective, + NzDropdownMenuComponent, + NzMenuDirective, + NzMenuItemComponent, + NzInputNumberComponent, + NzInputNumberGroupWhitSuffixOrPrefixDirective, + NzSpaceItemDirective, + NzInputNumberGroupComponent, + NzDatePickerComponent, + NzTypographyComponent ], templateUrl: './goods-list.component.html', styleUrl: './goods-list.component.less' @@ -88,6 +109,7 @@ export class GoodsListComponent { listImg: NzUploadFile[] = [] bannerImg: NzUploadFile[] = [] detailImg: NzUploadFile[] = [] + showImg: NzUploadFile[] = [] baseUrl = environment.baseUrl; imageUrl = environment.imageUrl; @@ -98,11 +120,20 @@ export class GoodsListComponent { // 编辑产品类型表单 editForm: FormGroup; + editSpecsForm: FormGroup; // 编辑弹出框 isVisibleEdit = false; + // 编辑商品规格弹出框 + isVisibleSpecs = false; + editSpecs = false; + loadingSpecs = false; // 商品类型数据 nodes = []; nodesBrand = []; + nodesSpecs:SpecsData[] = []; + nodesVpdSource; + goodsMsg?: GoodsMsgData; + protected readonly fallbackImg = fallbackImg; @@ -111,6 +142,9 @@ export class GoodsListComponent { private commonService: CommonService, private goodsService: GoodsService) { + + this.nodesVpdSource = new DictionaryPipe().getDictionaryList('GOODS_VPD_SOURCE'); + // 初始化搜索框 this.searchForm = this.fb.group({ title: [''], @@ -130,6 +164,25 @@ export class GoodsListComponent { goodsLabel: [''], goodsExplain: [''], }); + // 初始化 + this.editSpecsForm = this.fb.group({ + name: ['' , [Validators.required]], + purLimit: ['' , [Validators.required]], + salePrice: ['' , [Validators.required]], + originalPrice: ['' , [Validators.required]], + stock: ['' , [Validators.required]], + validDay: ['' , [Validators.required]], + salesEndTime: ['' , [Validators.required]], + type: [''], + source: [''], + id: [null], + specsId: [null], + jumpType: [null], + jumpUrl: [null], + goodsId: [null], + appid: [null], + key: [''], + }); this.getRequest(); this.getGoodsTypeNode(); this.getGoodsBrandNode(); @@ -160,7 +213,8 @@ export class GoodsListComponent { // 唤醒编辑表单 showEdit(item?: any) { if (item != null) { - item.businessType = String(item.businessType); + item.goodsBrand = String(item.goodsBrand); + item.type = String(item.type); this.editForm.patchValue(item); if (!this.commonService.whetherStringIsNull(item.listImg)) { this.listImg = this.commonService.stitchImg(item.listImg); @@ -171,6 +225,8 @@ export class GoodsListComponent { if (!this.commonService.whetherStringIsNull(item.detailImg)) { this.detailImg = this.commonService.stitchImg(item.detailImg); } + } else { + this.editForm.reset() } this.isVisibleEdit = true; } @@ -181,17 +237,20 @@ export class GoodsListComponent { if (this.listImg.length !== 0) { this.editForm.value.listImg = this.commonService.imgList(this.listImg); } else { - this.msg.error("请上传列表图片") + this.msg.error("请上传列表图片"); + return; } if (this.bannerImg.length !== 0) { this.editForm.value.bannerImg = this.commonService.imgList(this.bannerImg); } else { - this.msg.error("请上传轮播图片") + this.msg.error("请上传轮播图片"); + return; } if (this.detailImg.length !== 0) { this.editForm.value.detailImg = this.commonService.imgList(this.detailImg); } else { - this.msg.error("请上传详情图片") + this.msg.error("请上传详情图片"); + return; } this.goodsService.editGoodsMsg(this.editForm.value , (data: any) => { @@ -225,7 +284,7 @@ export class GoodsListComponent { // 删除 delete(id: number): void { - this.goodsService.deleteBran(id , (data: any) => { + this.goodsService.deleteGoodsMsg(id , (data: any) => { if (data['return_code'] === '000000') { this.msg.success("成功!"); this.getRequest(); @@ -235,6 +294,18 @@ export class GoodsListComponent { }); } + // 删除 + deleteGoodsSpecs(id: number): void { + this.goodsService.deleteGoodsSpecs(id , (data: any) => { + if (data['return_code'] === '000000') { + this.msg.success("成功!"); + this.getSpecsList(); + } else { + this.msg.error(data['return_msg']); + } + }); + } + // 获取商品分类 getGoodsTypeNode() { this.goodsService.getList({time: new Date().getTime()}, (data: any) => { @@ -267,4 +338,128 @@ export class GoodsListComponent { }); } + // 弹出 + showSpecsList(data: any): void { + this.goodsMsg = data; + this.isVisibleSpecs = true; + + if (data.type == "1") { + this.editSpecsForm.controls['type'].clearValidators(); + this.editSpecsForm.controls['type'].markAsPristine(); + + this.editSpecsForm.controls['source'].clearValidators(); + this.editSpecsForm.controls['source'].markAsPristine(); + + this.editSpecsForm.controls['validDay'].clearValidators(); + this.editSpecsForm.controls['validDay'].markAsPristine(); + } else { + this.editSpecsForm.controls['type'].setValidators(Validators.required); + this.editSpecsForm.controls['type'].markAsDirty(); + + this.editSpecsForm.controls['source'].setValidators(Validators.required); + this.editSpecsForm.controls['source'].markAsDirty(); + + this.editSpecsForm.controls['validDay'].setValidators(Validators.required); + this.editSpecsForm.controls['validDay'].markAsDirty(); + } + this.editSpecsForm.controls['type'].updateValueAndValidity(); + this.editSpecsForm.controls['validDay'].updateValueAndValidity(); + this.editSpecsForm.controls['source'].updateValueAndValidity(); + + this.getSpecsList(); + } + + // 查询规格列表 + getSpecsList(): void { + this.loadingSpecs = true; + let params = { + id: this.goodsMsg?.id, + time: new Date().getTime() + } + this.goodsService.getGoodsSpecsList(params , (data: any) => { + this.loadingSpecs = false; + if (data['return_code'] == '000000') { + this.nodesSpecs = data['return_data']; + } + }); + } + // 添加规格 + showEditSpecs(item?: any): void { + + if (item != null) { + item.source = String(item.source); + item.type = String(item.type); + item.jumpType = String(item.jumpType); + this.editSpecsForm.patchValue(item); + if (!this.commonService.whetherStringIsNull(item.showImg)) { + this.showImg = this.commonService.stitchImg(item.showImg); + } + } else { + this.editSpecsForm.reset() + } + this.editSpecs = true; + } + + handleEditSpecs(): void { + if (this.editSpecsForm.valid) { + if (this.showImg.length !== 0) { + this.editSpecsForm.value.showImg = this.commonService.imgList(this.showImg); + } else { + this.msg.error("请上传展示图片"); + return; + } + this.editSpecsForm.value.goodsId = this.goodsMsg?.id; + this.goodsService.editGoodsSpecs(this.editSpecsForm.value , (data: any) => { + if (data['return_code'] === '000000') { + this.msg.success("成功!"); + this.editSpecs = false; + this.getSpecsList(); + } else { + this.msg.error(data['return_msg']); + } + }); + } else { + Object.values(this.editSpecsForm.controls).forEach(control => { + if (control.invalid) { + control.markAsDirty(); + control.updateValueAndValidity({ onlySelf: true }); + } + }); + } + } + + typeChange(type: string): void { + if (type == "1") { + this.editSpecsForm.controls['jumpType'].clearValidators(); + this.editSpecsForm.controls['jumpType'].markAsPristine(); + + this.editSpecsForm.controls['jumpUrl'].clearValidators(); + this.editSpecsForm.controls['jumpUrl'].markAsPristine(); + + } else { + this.editSpecsForm.controls['jumpType'].setValidators(Validators.required); + this.editSpecsForm.controls['jumpType'].markAsDirty(); + + this.editSpecsForm.controls['jumpUrl'].setValidators(Validators.required); + this.editSpecsForm.controls['jumpUrl'].markAsDirty(); + + } + this.editSpecsForm.controls['jumpUrl'].updateValueAndValidity(); + this.editSpecsForm.controls['jumpType'].updateValueAndValidity(); + } + + jumpTypeChange(type: string): void { + console.log("type" , type); + if (type == "2") { + this.editSpecsForm.controls['appid'].clearValidators(); + this.editSpecsForm.controls['appid'].markAsPristine(); + } else { + this.editSpecsForm.controls['appid'].setValidators(Validators.required); + this.editSpecsForm.controls['appid'].markAsDirty(); + } + this.editSpecsForm.controls['appid'].updateValueAndValidity(); + } + + + } diff --git a/src/app/services/goods/goods.service.ts b/src/app/services/goods/goods.service.ts index 15b2ff1..7ab3965 100644 --- a/src/app/services/goods/goods.service.ts +++ b/src/app/services/goods/goods.service.ts @@ -67,7 +67,7 @@ export class GoodsService { } public getListBrandAll(callBack:any) { - this.http.get(environment.baseUrl + 'goodsBrand/getListBrandAll').subscribe(data => { + this.http.get(environment.baseUrl + 'goodsBrand/getListBrandAll?time=' + new Date().getTime()).subscribe(data => { callBack(data); }); } @@ -105,4 +105,48 @@ export class GoodsService { }); } + /** + * 编辑商品规格信息 + * @param params + * @param callBack + */ + public editGoodsSpecs(params: object, callBack:any) { + this.http.post(environment.baseUrl + 'goods/editGoodsSpecs', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 获取商品规格列表 + * @param params + * @param callBack + */ + public getGoodsSpecsList(params: object, callBack:any) { + this.http.get(environment.baseUrl + 'goods/getGoodsSpecsList?' + ObjectData.objectByString(params)).subscribe(data => { + callBack(data); + }); + } + + /** + * 删除商品 + * @param id + * @param callBack + */ + public deleteGoodsMsg(id: number, callBack:any) { + this.http.get(environment.baseUrl + 'goods/deleteGoodsMsg?id=' + id ).subscribe(data => { + callBack(data); + }); + } + + /** + * 删除商品规格 + * @param id + * @param callBack + */ + public deleteGoodsSpecs(id: number, callBack:any) { + this.http.get(environment.baseUrl + 'goods/deleteGoodsSpecs?id=' + id ).subscribe(data => { + callBack(data); + }); + } + } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index abca029..95f2f04 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,10 +4,13 @@ export const environment = { production: false, - baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) + // baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) // orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) - orderUrl: 'http://localhost:9703/order/', // 测试环境服务器地址(请求数据地址) - userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) + // userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) + // imageUrl: 'https://phgcs.dctpay.com/filesystem/', + baseUrl: 'http://localhost:9702/brest/', // 测试环境服务器地址(请求数据地址) + orderUrl: 'http://localhost:9304/order/', // 测试环境服务器地址(请求数据地址) + userUrl: 'http://localhost:9704/user/', // 测试环境服务器地址(请求数据地址) imageUrl: 'https://phgcs.dctpay.com/filesystem/', };