master
parent
1923371f10
commit
361d2ce9dc
@ -1,5 +1,3 @@ |
|||||||
export const goodsTypeSearch = [ |
|
||||||
{title: "标题" , formControlName: "title"}, |
export const fallbackImg = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEg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ErkJggg=='; |
||||||
{title: "业务类型" , formControlName: "businessType"} , |
|
||||||
]; |
|
||||||
|
|
||||||
|
@ -1,10 +1,14 @@ |
|||||||
export interface GoodsTypeData { |
export interface GoodsTypeData { |
||||||
id: number; |
id: number; |
||||||
parentId: number; |
parentId?: number | undefined; |
||||||
title: string; |
title: string; |
||||||
businessType: number; |
businessType?: any; |
||||||
imgUrl: string; |
imgUrl?: any; |
||||||
createTime: string; |
createTime: string; |
||||||
updateTime: string; |
updateTime: string; |
||||||
status: number; |
status: string; |
||||||
|
level?: number; |
||||||
|
expand?: boolean; |
||||||
|
children?: GoodsTypeData[]; |
||||||
|
parent?: GoodsTypeData; |
||||||
} |
} |
||||||
|
@ -0,0 +1,98 @@ |
|||||||
|
<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 nz-input formControlName="title" placeholder="请输入" /> |
||||||
|
</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="100px">品牌图片</th> |
||||||
|
<th nzWidth="50px">创建时间</th> |
||||||
|
<th nzWidth="50px">更新时间</th> |
||||||
|
<th nzWidth="70px">操作</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr *ngFor="let data of basicTable.data"> |
||||||
|
<td>{{data.title}}</td> |
||||||
|
<td> |
||||||
|
<img nz-image width="60px" height="60px" nzSrc="{{imageUrl + data.imgUrl }}" [nzFallback]="fallbackImg" alt="" /> |
||||||
|
</td> |
||||||
|
<td>{{ data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||||
|
<td>{{ data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||||
|
<td> |
||||||
|
<a (click)="showEdit(data)">修改</a> |
||||||
|
<nz-divider nzType="vertical"></nz-divider> |
||||||
|
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(data.id)">删除</a> |
||||||
|
</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 nz-input formControlName="title" placeholder="请输入" /> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
|
||||||
|
<nz-form-item > |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24" >上传图片</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-upload |
||||||
|
nzAction="{{baseUrl}}fileUpload/fileUpload" |
||||||
|
nzListType="picture-card" |
||||||
|
[(nzFileList)]="imgUrl" |
||||||
|
[nzShowButton]="imgUrl.length < 1" |
||||||
|
[nzPreview]="handlePreview" |
||||||
|
nzAccept="image/*" |
||||||
|
> |
||||||
|
<div> |
||||||
|
<span nz-icon nzType="plus"></span> |
||||||
|
<div style="margin-top: 8px">上传图片</div> |
||||||
|
</div> |
||||||
|
</nz-upload> |
||||||
|
<nz-modal |
||||||
|
[nzVisible]="previewVisible" |
||||||
|
[nzContent]="modalContent" |
||||||
|
[nzFooter]="null" |
||||||
|
(nzOnCancel)="previewVisible = false" |
||||||
|
> |
||||||
|
<ng-template #modalContent> |
||||||
|
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" alt=""/> |
||||||
|
</ng-template> |
||||||
|
</nz-modal> |
||||||
|
|
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
</form> |
||||||
|
</ng-container> |
||||||
|
</nz-modal> |
@ -0,0 +1,12 @@ |
|||||||
|
[nz-form-label] { |
||||||
|
overflow: visible; |
||||||
|
} |
||||||
|
button { |
||||||
|
margin-left: 8px; |
||||||
|
} |
||||||
|
.submit-btn { |
||||||
|
width: 150px; |
||||||
|
} |
||||||
|
.search-area { |
||||||
|
margin-top: 30px; |
||||||
|
} |
@ -0,0 +1,203 @@ |
|||||||
|
import { Component } from '@angular/core'; |
||||||
|
import {DatePipe, NgForOf, NgOptimizedImage, NgStyle} 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 {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; |
||||||
|
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
||||||
|
import {NzMessageService} from "ng-zorro-antd/message"; |
||||||
|
import {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal"; |
||||||
|
import {GoodsService} from "../../../services/goods/goods.service"; |
||||||
|
import {NzIconDirective} from "ng-zorro-antd/icon"; |
||||||
|
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; |
||||||
|
import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload"; |
||||||
|
import {environment} from "../../../../environments/environment"; |
||||||
|
import {GoodsTypeData} from "../../../model/goods.interface"; |
||||||
|
import {CommonService} from "../../../services/common/common.service"; |
||||||
|
import {NzDividerComponent} from "ng-zorro-antd/divider"; |
||||||
|
import { |
||||||
|
NzTableCellDirective, |
||||||
|
NzTableComponent, |
||||||
|
NzTbodyComponent, |
||||||
|
NzTheadComponent, |
||||||
|
NzThMeasureDirective, NzTrDirective |
||||||
|
} from "ng-zorro-antd/table"; |
||||||
|
import {NzPopconfirmDirective} from "ng-zorro-antd/popconfirm"; |
||||||
|
import {fallbackImg} from "../../../data/goods/goods.namespace"; |
||||||
|
import {NzImageModule} from "ng-zorro-antd/image"; |
||||||
|
|
||||||
|
const getBase64 = (file: File): Promise<string | ArrayBuffer | null> => |
||||||
|
new Promise((resolve, reject) => { |
||||||
|
const reader = new FileReader(); |
||||||
|
reader.readAsDataURL(file); |
||||||
|
reader.onload = () => resolve(reader.result); |
||||||
|
reader.onerror = error => reject(error); |
||||||
|
}); |
||||||
|
|
||||||
|
@Component({ |
||||||
|
selector: 'app-goods-brand', |
||||||
|
standalone: true, |
||||||
|
imports: [ |
||||||
|
NgForOf, |
||||||
|
NzButtonComponent, |
||||||
|
NzColDirective, |
||||||
|
NzFormControlComponent, |
||||||
|
NzFormDirective, |
||||||
|
NzFormItemComponent, |
||||||
|
NzFormLabelComponent, |
||||||
|
NzInputDirective, |
||||||
|
NzOptionComponent, |
||||||
|
NzRowDirective, |
||||||
|
NzModalModule, |
||||||
|
NzSelectComponent, |
||||||
|
ReactiveFormsModule, |
||||||
|
NzIconDirective, |
||||||
|
NzModalComponent, |
||||||
|
NzTreeSelectComponent, |
||||||
|
NzUploadComponent, |
||||||
|
NzModalContentDirective, |
||||||
|
NgStyle, |
||||||
|
DatePipe, |
||||||
|
NzDividerComponent, |
||||||
|
NzTableCellDirective, |
||||||
|
NzTableComponent, |
||||||
|
NzTbodyComponent, |
||||||
|
NzThMeasureDirective, |
||||||
|
NzTheadComponent, |
||||||
|
NzTrDirective, |
||||||
|
NzPopconfirmDirective, |
||||||
|
NzImageModule, |
||||||
|
NgOptimizedImage |
||||||
|
], |
||||||
|
templateUrl: './goods-brand.component.html', |
||||||
|
styleUrl: './goods-brand.component.less' |
||||||
|
}) |
||||||
|
export class GoodsBrandComponent { |
||||||
|
// 表单页数
|
||||||
|
tablePageNum = 1; |
||||||
|
// 表单数据
|
||||||
|
tableData: any = { |
||||||
|
total: 0, |
||||||
|
loading: false, |
||||||
|
list: [], |
||||||
|
}; |
||||||
|
// 搜索表单
|
||||||
|
searchForm: FormGroup; |
||||||
|
|
||||||
|
// 图片
|
||||||
|
imgUrl: NzUploadFile[] = [] |
||||||
|
baseUrl = environment.baseUrl; |
||||||
|
imageUrl = environment.imageUrl; |
||||||
|
|
||||||
|
// 展示图片
|
||||||
|
previewImage: string | undefined = ''; |
||||||
|
// 上传是否展示
|
||||||
|
previewVisible = false; |
||||||
|
|
||||||
|
// 编辑产品类型表单
|
||||||
|
editForm: FormGroup; |
||||||
|
// 编辑弹出框
|
||||||
|
isVisibleEdit = false; |
||||||
|
|
||||||
|
constructor(private fb: NonNullableFormBuilder, |
||||||
|
private msg: NzMessageService, |
||||||
|
private commonService: CommonService, |
||||||
|
private goodsService: GoodsService) { |
||||||
|
// 初始化搜索框
|
||||||
|
this.searchForm = this.fb.group({ |
||||||
|
title: [''], |
||||||
|
}); |
||||||
|
|
||||||
|
// 初始化
|
||||||
|
this.editForm = this.fb.group({ |
||||||
|
title: ['' , [Validators.required]], |
||||||
|
id: [null], |
||||||
|
imgUrl: [''], |
||||||
|
}); |
||||||
|
this.getRequest(); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// 查询列表
|
||||||
|
public getRequest(reset: boolean = false) { |
||||||
|
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.getListBrand(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(item?: GoodsTypeData) { |
||||||
|
if (item != null) { |
||||||
|
item.businessType = String(item.businessType); |
||||||
|
this.editForm.patchValue(item); |
||||||
|
if (!this.commonService.whetherStringIsNull(item.imgUrl)) { |
||||||
|
this.imgUrl = this.commonService.stitchImg(item.imgUrl); |
||||||
|
} |
||||||
|
} |
||||||
|
this.isVisibleEdit = true; |
||||||
|
} |
||||||
|
// 编辑表单提交
|
||||||
|
handleEdit(): void { |
||||||
|
|
||||||
|
if (this.editForm.valid) { |
||||||
|
if (this.imgUrl.length !== 0) { |
||||||
|
this.editForm.value.imgUrl = this.commonService.imgList(this.imgUrl); |
||||||
|
} |
||||||
|
this.goodsService.editGoodsBrand(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 }); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// 上传操作
|
||||||
|
handlePreview = async (file: NzUploadFile): Promise<void> => { |
||||||
|
if (!file.url && !file['preview']) { |
||||||
|
file['preview'] = await getBase64(file.originFileObj!); |
||||||
|
} |
||||||
|
this.previewImage = file.url || file['preview']; |
||||||
|
this.previewVisible = true; |
||||||
|
}; |
||||||
|
|
||||||
|
// 删除
|
||||||
|
delete(id: number): void { |
||||||
|
this.goodsService.deleteBran(id , (data: any) => { |
||||||
|
if (data['return_code'] === '000000') { |
||||||
|
this.msg.success("成功!"); |
||||||
|
this.getRequest(); |
||||||
|
} else { |
||||||
|
this.msg.error(data['return_msg']); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
protected readonly fallbackImg = fallbackImg; |
||||||
|
} |
@ -1,19 +1,111 @@ |
|||||||
|
<button nz-button (click)="showEditGoodsType()" nzType="primary">创建</button> |
||||||
|
<button nz-button [nzType]="'default'" (click)="getRequest()">查询</button> |
||||||
|
<br /> |
||||||
|
<br /> |
||||||
|
<!--列表--> |
||||||
|
<nz-table #expandTable [nzData]="listOfMapData" [nzLoading]="loading" [nzTotal]="listOfMapData.length" [nzBordered]="true" nzTableLayout="fixed"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>标题</th> |
||||||
|
<th>业务类型</th> |
||||||
|
<th>图片</th> |
||||||
|
<th>创建时间</th> |
||||||
|
<th>更新时间</th> |
||||||
|
<th>操作</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<ng-container *ngFor="let data of expandTable.data"> |
||||||
|
<ng-container *ngFor="let item of mapOfExpandedData[data.id]"> |
||||||
|
<tr *ngIf="(item.parent && item.parent.expand) || !item.parent"> |
||||||
|
<td |
||||||
|
|
||||||
<form nz-form [formGroup]="searchForm" class="search_form" [nzLayout]="'vertical'"> |
[nzIndentSize]="item.level! * 20" |
||||||
<div nz-row [nzGutter]="24"> |
[nzShowExpand]="!!item.children" |
||||||
<div nz-col [nzSpan]="6" *ngFor="let item of goodsTypeSearch"> |
[(nzExpand)]="item.expand" |
||||||
<nz-form-item> |
(nzExpandChange)="collapse(mapOfExpandedData[data.id], item, $event)" |
||||||
<nz-form-label>{{item.title}}</nz-form-label> |
> |
||||||
<nz-form-control> |
{{ item.title }} |
||||||
<input nz-input formControlName="{{item.formControlName}}" placeholder="请输入" /> |
</td> |
||||||
|
<td>{{ item.businessType | dictionary: 'GOODS_TYPE' }}</td> |
||||||
|
<td> |
||||||
|
<img nz-image width="60px" height="60px" nzSrc="{{imageUrl + item.imgUrl }}" [nzFallback]="fallbackImg" alt="" /> |
||||||
|
</td> |
||||||
|
<td>{{ item.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||||
|
<td>{{ item.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||||
|
<td> |
||||||
|
<a (click)="showEditGoodsType(item)">编辑</a> |
||||||
|
<nz-divider nzType="vertical"></nz-divider> |
||||||
|
<a nz-popconfirm nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="delete(item.id)">删除</a> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</ng-container> |
||||||
|
</ng-container> |
||||||
|
</tbody> |
||||||
|
</nz-table> |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--添加弹出框--> |
||||||
|
<nz-modal [(nzVisible)]="isVisibleEdit" [nzMaskClosable] = false nzTitle="编辑类目" (nzOnCancel)="isVisibleEdit = false" (nzOnOk)="handleEdit()"> |
||||||
|
<ng-container *nzModalContent> |
||||||
|
<form nz-form [formGroup]="editGoodSTypeForm"> |
||||||
|
<nz-form-item > |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>标题</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请输入标题!"> |
||||||
|
<input nz-input formControlName="title" placeholder="请输入" /> |
||||||
</nz-form-control> |
</nz-form-control> |
||||||
</nz-form-item> |
</nz-form-item> |
||||||
</div> |
<nz-form-item > |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>业务类型</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="请选择业务类型!"> |
||||||
|
<nz-select nzShowSearch nzAllowClear formControlName="businessType" nzPlaceHolder="请选择"> |
||||||
|
<nz-option *ngFor="let item of goodsTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||||
|
</nz-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
<nz-form-item > |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24" >上级类型</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-tree-select |
||||||
|
nzPlaceHolder="请选择" |
||||||
|
formControlName="parentId" |
||||||
|
[nzNodes]="nodes" |
||||||
|
nzShowSearch |
||||||
|
></nz-tree-select> |
||||||
|
</nz-form-control> |
||||||
|
</nz-form-item> |
||||||
|
<nz-form-item > |
||||||
|
<nz-form-label [nzSm]="6" [nzXs]="24" >上传图片</nz-form-label> |
||||||
|
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||||
|
<nz-upload |
||||||
|
nzAction="{{baseUrl}}fileUpload/fileUpload" |
||||||
|
nzListType="picture-card" |
||||||
|
[(nzFileList)]="imgUrl" |
||||||
|
[nzShowButton]="imgUrl.length < 1" |
||||||
|
[nzPreview]="handlePreview" |
||||||
|
nzAccept="image/*" |
||||||
|
> |
||||||
|
<div> |
||||||
|
<span nz-icon nzType="plus"></span> |
||||||
|
<div style="margin-top: 8px">上传图片</div> |
||||||
|
</div> |
||||||
|
</nz-upload> |
||||||
|
<nz-modal |
||||||
|
[nzVisible]="previewVisible" |
||||||
|
[nzContent]="modalContent" |
||||||
|
[nzFooter]="null" |
||||||
|
(nzOnCancel)="previewVisible = false" |
||||||
|
> |
||||||
|
<ng-template #modalContent> |
||||||
|
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" alt=""/> |
||||||
|
</ng-template> |
||||||
|
</nz-modal> |
||||||
|
|
||||||
<div nz-col [nzSpan]="6" class="search-area"> |
</nz-form-control> |
||||||
<button nz-button [nzType]="'primary'" (click)="searchFormSubmit()">查询</button> |
</nz-form-item> |
||||||
<button nz-button (click)="searchForm.reset()">重置</button> |
</form> |
||||||
<button nz-button [nzType]="'primary'" (click)="searchFormSubmit()">创建</button> |
</ng-container> |
||||||
</div> |
</nz-modal> |
||||||
</div> |
|
||||||
</form> |
|
||||||
|
@ -1,8 +1,10 @@ |
|||||||
import { Routes } from '@angular/router'; |
import { Routes } from '@angular/router'; |
||||||
import {GoodsTypeComponent} from "./goods-type/goods-type.component"; |
import {GoodsTypeComponent} from "./goods-type/goods-type.component"; |
||||||
|
import {GoodsBrandComponent} from "./goods-brand/goods-brand.component"; |
||||||
|
|
||||||
|
|
||||||
export const GOODS_ROUTES: Routes = [ |
export const GOODS_ROUTES: Routes = [ |
||||||
{ path: 'goods_type', component: GoodsTypeComponent}, |
{ path: 'goods_type', component: GoodsTypeComponent}, |
||||||
|
{ path: 'goods_brand', component: GoodsBrandComponent}, |
||||||
|
|
||||||
]; |
]; |
||||||
|
@ -0,0 +1,13 @@ |
|||||||
|
import { Pipe, PipeTransform } from '@angular/core'; |
||||||
|
|
||||||
|
@Pipe({ |
||||||
|
name: 'goodsType', |
||||||
|
standalone: true |
||||||
|
}) |
||||||
|
export class GoodsTypePipe implements PipeTransform { |
||||||
|
|
||||||
|
transform(value: unknown, ...args: unknown[]): unknown { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,9 +1,80 @@ |
|||||||
import { Injectable } from '@angular/core'; |
import { Injectable } from '@angular/core'; |
||||||
|
import {HttpClient} from "@angular/common/http"; |
||||||
|
import {environment} from "../../../environments/environment"; |
||||||
|
import {ObjectData} from "../../utils/objectData.service"; |
||||||
|
|
||||||
@Injectable({ |
@Injectable({ |
||||||
providedIn: 'root' |
providedIn: 'root' |
||||||
}) |
}) |
||||||
export class GoodsService { |
export class GoodsService { |
||||||
|
|
||||||
constructor() { } |
constructor(private http: HttpClient) { } |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑商品类型 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public editGoodsType(params: object, callBack:any) { |
||||||
|
this.http.post(environment.baseUrl + 'goodsType/editGoodsType', params).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询列表 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public getList(params: object, callBack:any) { |
||||||
|
this.http.get(environment.baseUrl + 'goodsType/getList?' + ObjectData.objectByString(params)).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除 |
||||||
|
* @param id |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public delete(id: number, callBack:any) { |
||||||
|
this.http.get(environment.baseUrl + 'goodsType/delete?id=' + id ).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑商品类型 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public editGoodsBrand(params: object, callBack:any) { |
||||||
|
this.http.post(environment.baseUrl + 'goodsBrand/editGoodsBrand', params).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询列表 |
||||||
|
* @param params |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public getListBrand(params: object, callBack:any) { |
||||||
|
this.http.get(environment.baseUrl + 'goodsBrand/getListBrand?' + ObjectData.objectByString(params)).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除 |
||||||
|
* @param id |
||||||
|
* @param callBack |
||||||
|
*/ |
||||||
|
public deleteBran(id: number, callBack:any) { |
||||||
|
this.http.get(environment.baseUrl + 'goodsBrand/delete?id=' + id ).subscribe(data => { |
||||||
|
callBack(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
Loading…
Reference in new issue