|
|
|
@ -36,6 +36,7 @@ import {Observable, Observer} from "rxjs"; |
|
|
|
|
import {BrowserStorageService} from "../../../utils/localStorage.service"; |
|
|
|
|
import {DATA} from "../../../data/login/localStorage.namespace"; |
|
|
|
|
import {MerService} from "../../../services/merchant/mer.service"; |
|
|
|
|
import {DiscountService} from "../../../services/marketing/discount.service"; |
|
|
|
|
|
|
|
|
|
const getBase64 = (file: File): Promise<string | ArrayBuffer | null> => |
|
|
|
|
new Promise((resolve, reject) => { |
|
|
|
@ -121,20 +122,27 @@ export class GoodsListComponent { |
|
|
|
|
// 编辑产品类型表单
|
|
|
|
|
editForm: FormGroup; |
|
|
|
|
editSpecsForm: FormGroup; |
|
|
|
|
editPresentForm: FormGroup; |
|
|
|
|
// 编辑弹出框
|
|
|
|
|
isVisibleEdit = false; |
|
|
|
|
// 编辑商品规格弹出框
|
|
|
|
|
isVisibleSpecs = false; |
|
|
|
|
isVisiblePresent = false; |
|
|
|
|
editSpecs = false; |
|
|
|
|
editPresent = false; |
|
|
|
|
loadingSpecs = false; |
|
|
|
|
// 商品类型数据
|
|
|
|
|
dataSet: any = []; |
|
|
|
|
nodes = []; |
|
|
|
|
nodesBrand = []; |
|
|
|
|
nodesPresent: any = []; |
|
|
|
|
nodesSpecs: SpecsData[] = []; |
|
|
|
|
nodesVpdSource; |
|
|
|
|
merData: any; |
|
|
|
|
objectType: number; |
|
|
|
|
goodsMsg?: GoodsMsgData; |
|
|
|
|
specsName: string | undefined; |
|
|
|
|
specsId: number | undefined; |
|
|
|
|
|
|
|
|
|
protected readonly fallbackImg = fallbackImg; |
|
|
|
|
|
|
|
|
@ -142,11 +150,13 @@ export class GoodsListComponent { |
|
|
|
|
private msg: NzMessageService, |
|
|
|
|
private merService: MerService, |
|
|
|
|
private storage: BrowserStorageService, |
|
|
|
|
private discount: DiscountService, |
|
|
|
|
private commonService: CommonService, |
|
|
|
|
private goodsService: GoodsService) { |
|
|
|
|
|
|
|
|
|
this.nodesVpdSource = new DictionaryPipe().getDictionaryList('GOODS_VPD_SOURCE'); |
|
|
|
|
this.objectType = this.storage.get(DATA)['account']['objectType']; |
|
|
|
|
console.log("objectType", this.objectType); |
|
|
|
|
this.merList(); |
|
|
|
|
|
|
|
|
|
// 初始化搜索框
|
|
|
|
@ -158,7 +168,11 @@ export class GoodsListComponent { |
|
|
|
|
type: [''], |
|
|
|
|
status: [''], |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
this.editPresentForm = this.fb.group({ |
|
|
|
|
type: ['', [Validators.required]], |
|
|
|
|
key: ['', [Validators.required]], |
|
|
|
|
}); |
|
|
|
|
// 初始化
|
|
|
|
|
this.editForm = this.fb.group({ |
|
|
|
|
title: ['', [Validators.required]], |
|
|
|
@ -167,6 +181,8 @@ export class GoodsListComponent { |
|
|
|
|
goodsBrand: ['', [Validators.required]], |
|
|
|
|
id: [null], |
|
|
|
|
goodsLabel: [''], |
|
|
|
|
sort: [''], |
|
|
|
|
showType: [''], |
|
|
|
|
goodsExplain: [''], |
|
|
|
|
}); |
|
|
|
|
// 初始化
|
|
|
|
@ -178,7 +194,6 @@ export class GoodsListComponent { |
|
|
|
|
stock: ['', [Validators.required]], |
|
|
|
|
validDay: ['', [Validators.required]], |
|
|
|
|
salesEndTime: [new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDay(), 23, 59, 59), [Validators.required]], |
|
|
|
|
type: [''], |
|
|
|
|
source: [''], |
|
|
|
|
btnName: [''], |
|
|
|
|
id: [null], |
|
|
|
@ -308,6 +323,17 @@ export class GoodsListComponent { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
deletePresent(id: number): void { |
|
|
|
|
this.goodsService.deletePresent(id, (data: any) => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.msg.success("成功!"); |
|
|
|
|
this.getPresentList(); |
|
|
|
|
} else { |
|
|
|
|
this.msg.error(data['return_msg']); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取商品分类
|
|
|
|
|
getGoodsTypeNode() { |
|
|
|
|
this.goodsService.getList({time: new Date().getTime()}, (data: any) => { |
|
|
|
@ -346,17 +372,13 @@ export class GoodsListComponent { |
|
|
|
|
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(); |
|
|
|
@ -364,7 +386,6 @@ export class GoodsListComponent { |
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
@ -386,6 +407,26 @@ export class GoodsListComponent { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getPresentList(): void { |
|
|
|
|
let params = { |
|
|
|
|
specsId: this.specsId, |
|
|
|
|
time: new Date().getTime() |
|
|
|
|
} |
|
|
|
|
this.goodsService.getLisPresent(params, (data: any) => { |
|
|
|
|
if (data['return_code'] == '000000') { |
|
|
|
|
this.dataSet = data['return_data']; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showPresent(id: number , name: string): void { |
|
|
|
|
this.specsName = name; |
|
|
|
|
this.specsId = id; |
|
|
|
|
this.isVisiblePresent = true; |
|
|
|
|
this.getPresentList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 添加规格
|
|
|
|
|
showEditSpecs(item?: any): void { |
|
|
|
|
|
|
|
|
@ -404,6 +445,24 @@ export class GoodsListComponent { |
|
|
|
|
this.editSpecs = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showEditPresent(): void { |
|
|
|
|
this.editPresent = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleEditPresent(): void { |
|
|
|
|
this.editPresentForm.value.specsId = this.specsId; |
|
|
|
|
this.goodsService.createGoodPresent(this.editPresentForm.value, (data: any) => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.msg.success("成功!"); |
|
|
|
|
this.editPresent = false; |
|
|
|
|
this.getPresentList(); |
|
|
|
|
} else { |
|
|
|
|
this.msg.error(data['return_msg']); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleEditSpecs(): void { |
|
|
|
|
if (this.editSpecsForm.valid) { |
|
|
|
|
if (this.showImg.length !== 0) { |
|
|
|
@ -444,6 +503,24 @@ export class GoodsListComponent { |
|
|
|
|
this.editSpecsForm.controls['appid'].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
discountPackageList(type: string): void { |
|
|
|
|
console.log("type" , type); |
|
|
|
|
let params = { |
|
|
|
|
type: type, |
|
|
|
|
time: new Date().getTime() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.discount.discountPackageList(params , (data: any) => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.nodesPresent = data['return_data']; |
|
|
|
|
} else { |
|
|
|
|
this.msg.error(data['return_msg']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 上下线
|
|
|
|
|
goodsAudit(id: number): void { |
|
|
|
|
let params = { |
|
|
|
|