|
|
@ -5,6 +5,7 @@ import {IconService} from '../../../services/icon.service'; |
|
|
|
import {NzMessageService, NzModalService, NzUploadFile} from 'ng-zorro-antd'; |
|
|
|
import {NzMessageService, NzModalService, NzUploadFile} from 'ng-zorro-antd'; |
|
|
|
import {ConfigService} from '../../../services/config.service'; |
|
|
|
import {ConfigService} from '../../../services/config.service'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
|
|
|
|
import {CommonsService} from "../../../services/commons.service"; |
|
|
|
|
|
|
|
|
|
|
|
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
|
|
|
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
@ -37,7 +38,14 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
imgFile = []; |
|
|
|
imgFile = []; |
|
|
|
previewImage: string | undefined = ''; |
|
|
|
previewImage: string | undefined = ''; |
|
|
|
previewVisible = false; |
|
|
|
previewVisible = false; |
|
|
|
|
|
|
|
businessTypeS; |
|
|
|
|
|
|
|
goodsTypeData; |
|
|
|
|
|
|
|
goodsTypeDataChild; |
|
|
|
|
|
|
|
parentIdIsShow = false; |
|
|
|
|
|
|
|
listModal = false; |
|
|
|
|
|
|
|
listModalLoading = false; |
|
|
|
|
|
|
|
editTitle = '编辑'; |
|
|
|
|
|
|
|
parentId; |
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private form: FormBuilder, |
|
|
|
private form: FormBuilder, |
|
|
|
private config: ConfigService, |
|
|
|
private config: ConfigService, |
|
|
@ -45,6 +53,7 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
private message: NzMessageService, |
|
|
|
private message: NzMessageService, |
|
|
|
private router: Router, |
|
|
|
private router: Router, |
|
|
|
private modalService: NzModalService, |
|
|
|
private modalService: NzModalService, |
|
|
|
|
|
|
|
private commonsService: CommonsService, |
|
|
|
private fb: FormBuilder, |
|
|
|
private fb: FormBuilder, |
|
|
|
) { |
|
|
|
) { |
|
|
|
} |
|
|
|
} |
|
|
@ -56,12 +65,20 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
public init(): void { |
|
|
|
public init(): void { |
|
|
|
this.searchForm = this.form.group({ |
|
|
|
this.searchForm = this.form.group({ |
|
|
|
title: [null], |
|
|
|
title: [null], |
|
|
|
|
|
|
|
businessType: [null], |
|
|
|
|
|
|
|
parentId: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
title: [null, [Validators.required]], |
|
|
|
title: [null, [Validators.required]], |
|
|
|
userService: [null], |
|
|
|
businessType: [null , [Validators.required]], |
|
|
|
|
|
|
|
parentId: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.getListGoodsTypeByParentId(); |
|
|
|
|
|
|
|
this.commonsService.getDictionary('BUSINESS_TYPE', data => { |
|
|
|
|
|
|
|
this.businessTypeS = data['return_data']; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 图片查看
|
|
|
|
// 图片查看
|
|
|
@ -74,6 +91,16 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
this.previewVisible = true; |
|
|
|
this.previewVisible = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getListGoodsTypeByParentId(parentId?: number): void { |
|
|
|
|
|
|
|
this.config.getListGoodsTypeByParentId(parentId , data => { |
|
|
|
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
parentId == null ? this.goodsTypeData = data['return_data'] : this.goodsTypeDataChild = data['return_data']; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(data['return_msg']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询列表
|
|
|
|
// 查询列表
|
|
|
|
public getRequest(reset: boolean = false, whereObject: object) { |
|
|
|
public getRequest(reset: boolean = false, whereObject: object) { |
|
|
|
|
|
|
|
|
|
|
@ -100,23 +127,20 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 修改
|
|
|
|
// 修改
|
|
|
|
public getEdit(id?: number): void { |
|
|
|
public getEdit(id?: number , parentId?: number , title?: string): void { |
|
|
|
this.id = id; |
|
|
|
this.id = id; |
|
|
|
if (id != null) { |
|
|
|
this.parentId = parentId; |
|
|
|
|
|
|
|
if (title != null) { |
|
|
|
|
|
|
|
this.editTitle = title + '添加子类'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (id != null && parentId == null) { |
|
|
|
this.editFlag = true; |
|
|
|
this.editFlag = true; |
|
|
|
this.config.getGoodsTypeById(id, data => { |
|
|
|
this.config.getGoodsTypeById(id, data => { |
|
|
|
if (data['return_data']['img'] != null && data['return_data']['img'] !== '') { |
|
|
|
if (!this.commonsService.whetherStringIsNull(data['return_data']['img'])) { |
|
|
|
const img = String(data['return_data']['img']); |
|
|
|
this.imgFile = this.commonsService.stitchImg(data['return_data']['img']); |
|
|
|
const imgArray = []; |
|
|
|
|
|
|
|
imgArray.push( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uid: 1, |
|
|
|
|
|
|
|
name: img, |
|
|
|
|
|
|
|
status: 'done', |
|
|
|
|
|
|
|
url: environment.imageUrl + img |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.imgFile = imgArray; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data['return_data']['businessType'] = String(data['return_data']['businessType']); |
|
|
|
this.validateForm.patchValue(data['return_data']); |
|
|
|
this.validateForm.patchValue(data['return_data']); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -137,12 +161,10 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleOk(): void { |
|
|
|
handleOk(): void { |
|
|
|
// tslint:disable-next-line:forin
|
|
|
|
|
|
|
|
for (const i in this.validateForm.controls) { |
|
|
|
for (const i in this.validateForm.controls) { |
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
if (this.validateForm.controls[i].errors != null) { |
|
|
|
if (this.validateForm.controls[i].errors != null) { |
|
|
|
this.message.error('必填项不能为空'); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -154,13 +176,20 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
this.validateForm.value.img = this.imgFile[0].name; |
|
|
|
this.validateForm.value.img = this.imgFile[0].name; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.validateForm.value['parentId'] == null) { |
|
|
|
|
|
|
|
this.validateForm.value['parentId'] = this.parentId; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.editFlag) { |
|
|
|
if (this.editFlag) { |
|
|
|
this.validateForm.value.id = this.id; |
|
|
|
this.validateForm.value.id = this.id; |
|
|
|
|
|
|
|
|
|
|
|
this.config.updateGoodsType(this.validateForm.value, data => { |
|
|
|
this.config.updateGoodsType(this.validateForm.value, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
this.message.success('修改成功'); |
|
|
|
this.message.success('修改成功'); |
|
|
|
this.isVisible = false; |
|
|
|
this.isVisible = false; |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
|
|
|
this.getListGoodsTypeByParentId(this.validateForm.value['parentId']); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
} |
|
|
|
} |
|
|
@ -171,39 +200,47 @@ export class GoodsTypeComponent implements OnInit { |
|
|
|
this.message.success('添加成功'); |
|
|
|
this.message.success('添加成功'); |
|
|
|
this.isVisible = false; |
|
|
|
this.isVisible = false; |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
|
|
|
this.getListGoodsTypeByParentId(this.validateForm.value['parentId']); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleCancel(): void { |
|
|
|
handleCancel(): void { |
|
|
|
this.isVisible = false; |
|
|
|
this.isVisible = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查看子类列表
|
|
|
|
|
|
|
|
public getGoodsTypesChild(parentId: number) { |
|
|
|
|
|
|
|
this.listModal = true; |
|
|
|
|
|
|
|
this.getListGoodsTypeByParentId(parentId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 對話框删除
|
|
|
|
// 對話框删除
|
|
|
|
showDeleteConfirm(id): void { |
|
|
|
showDeleteConfirm(id): void { |
|
|
|
this.modalService.confirm({ |
|
|
|
this.modalService.confirm({ |
|
|
|
nzTitle: '确定删除', |
|
|
|
nzTitle: '确定删除', |
|
|
|
nzOkText: '是', |
|
|
|
nzOkText: '是', |
|
|
|
nzOnOk: () => this.onDelete(id), |
|
|
|
nzOnOk: () => { |
|
|
|
nzCancelText: '否', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onDelete(ids) { |
|
|
|
|
|
|
|
this.config.getGoodsTypeByDelete({ |
|
|
|
this.config.getGoodsTypeByDelete({ |
|
|
|
id: ids |
|
|
|
id: id |
|
|
|
}, data => { |
|
|
|
}, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
this.message.create('success', `删除成功!`); |
|
|
|
this.message.create('success', `删除成功!`); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
this.getRequest(true, this.searchForm.value); |
|
|
|
|
|
|
|
this.getListGoodsTypeByParentId(this.parentId); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
this.message.create('error', data['return_msg']); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
nzCancelText: '否', |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|