From 644bca4edd30cee8bbe8f0848aa1701f8ee16b6a Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Tue, 14 May 2024 15:23:54 +0800 Subject: [PATCH] 1 --- angular.json | 14 +- package-lock.json | 4 +- package.json | 6 +- src/app/app.routes.ts | 6 +- src/app/data/login/login.namespace.ts | 6 +- .../goods-list/goods-list.component.html | 5 +- .../goods/goods-type/goods-type.component.ts | 4 +- .../discount-list.component.html | 98 +++++++++ .../discount-list.component.less | 12 ++ .../discount-list/discount-list.component.ts | 203 ++++++++++++++++++ src/app/pages/marketing/marketing.module.ts | 12 ++ src/app/pages/marketing/marketing.routes.ts | 9 + src/assets/login/{图片整理.png => 1.png} | Bin src/assets/login/{多端协同.png => 2.png} | Bin src/assets/login/{达成合作.png => 3.png} | Bin src/environments/environment.dev.ts | 8 +- 16 files changed, 363 insertions(+), 24 deletions(-) create mode 100644 src/app/pages/marketing/discount-list/discount-list.component.html create mode 100644 src/app/pages/marketing/discount-list/discount-list.component.less create mode 100644 src/app/pages/marketing/discount-list/discount-list.component.ts create mode 100644 src/app/pages/marketing/marketing.module.ts create mode 100644 src/app/pages/marketing/marketing.routes.ts rename src/assets/login/{图片整理.png => 1.png} (100%) rename src/assets/login/{多端协同.png => 2.png} (100%) rename src/assets/login/{达成合作.png => 3.png} (100%) diff --git a/angular.json b/angular.json index e4cc368..63142cd 100644 --- a/angular.json +++ b/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "high-web": { + "phg-web": { "projectType": "application", "schematics": { "@schematics/angular:component": { @@ -17,7 +17,7 @@ "build": { "builder": "@angular-devkit/build-angular:application", "options": { - "outputPath": "dist/high-web", + "outputPath": "dist/phg-web", "index": "src/index.html", "browser": "src/main.ts", "polyfills": [ @@ -50,7 +50,7 @@ { "type": "initial", "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumError": "2mb" }, { "type": "anyComponentStyle", @@ -71,7 +71,7 @@ { "type": "initial", "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumError": "2mb" }, { "type": "anyComponentStyle", @@ -99,10 +99,10 @@ "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "buildTarget": "high-web:build:production" + "buildTarget": "phg-web:build:production" }, "development": { - "buildTarget": "high-web:build:development" + "buildTarget": "phg-web:build:development" } }, "defaultConfiguration": "development" @@ -110,7 +110,7 @@ "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "buildTarget": "high-web:build" + "buildTarget": "phg-web:build" } }, "test": { diff --git a/package-lock.json b/package-lock.json index 6e23b34..0fdf534 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "high-web", + "name": "phg-web", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "high-web", + "name": "phg-web", "version": "0.0.0", "dependencies": { "@angular/animations": "^17.0.0", diff --git a/package.json b/package.json index e137e06..3ee62e8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "high-web", + "name": "phg-web", "version": "0.0.0", "scripts": { "ng": "ng", @@ -7,7 +7,7 @@ "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", - "serve:ssr:high-web": "node dist/high-web/server/server.mjs" + "serve:ssr:phg-web": "node dist/phg-web/server/server.mjs" }, "private": true, "dependencies": { @@ -42,4 +42,4 @@ "karma-jasmine-html-reporter": "~2.1.0", "typescript": "~5.2.2" } -} \ No newline at end of file +} diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 54eb13b..39967ef 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,7 +1,6 @@ import { Routes } from '@angular/router'; import {IndexComponent} from "./pages/body/index/index.component"; import {InitGuardService} from "./utils/initGuard.service"; -import {TRADE_ROUTES} from "./pages/trade/trade.routes"; export const routes: Routes = [ {path: '', pathMatch: 'full', redirectTo: 'admin/index'}, { @@ -45,6 +44,11 @@ export const routes: Routes = [ loadChildren: () => import('./pages/system/system.routes').then(m => m.SYSTEM_ROUTES), canActivate: [InitGuardService] }, + { + path: 'marketing', + loadChildren: () => import('./pages/marketing/marketing.routes').then(m => m.MARKETING_ROUTES), + canActivate: [InitGuardService] + }, ] } ]; diff --git a/src/app/data/login/login.namespace.ts b/src/app/data/login/login.namespace.ts index 47a13c3..da61583 100644 --- a/src/app/data/login/login.namespace.ts +++ b/src/app/data/login/login.namespace.ts @@ -1,5 +1,5 @@ export const backgroundImage = [ - "./assets/login/图片整理.png", - "./assets/login/多端协同.png", - "./assets/login/达成合作.png"]; + "./assets/login/1.png", + "./assets/login/2.png", + "./assets/login/3.png"]; 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 ec905b8..8f4cae9 100644 --- a/src/app/pages/goods/goods-list/goods-list.component.html +++ b/src/app/pages/goods/goods-list/goods-list.component.html @@ -204,7 +204,7 @@ nzAction="{{baseUrl}}fileUpload/fileUpload" nzListType="picture-card" [(nzFileList)]="bannerImg" - [nzShowButton]="bannerImg.length < 1" + [nzShowButton]="bannerImg.length < 20" [nzPreview]="handlePreview" nzAccept="image/*" > @@ -223,7 +223,6 @@ - @@ -233,7 +232,7 @@ nzAction="{{baseUrl}}fileUpload/fileUpload" nzListType="picture-card" [(nzFileList)]="detailImg" - [nzShowButton]="detailImg.length < 1" + [nzShowButton]="detailImg.length < 20" [nzPreview]="handlePreview" nzAccept="image/*" > diff --git a/src/app/pages/goods/goods-type/goods-type.component.ts b/src/app/pages/goods/goods-type/goods-type.component.ts index 884de7c..cfc94c3 100644 --- a/src/app/pages/goods/goods-type/goods-type.component.ts +++ b/src/app/pages/goods/goods-type/goods-type.component.ts @@ -189,13 +189,15 @@ export class GoodsTypeComponent { } // 唤醒编辑表单 - showEditGoodsType(item?: GoodsTypeData) { + showEditGoodsType(item?: GoodsTypeData): void { if (item != null) { item.businessType = String(item.businessType); this.editGoodSTypeForm.patchValue(item); if (!this.commonService.whetherStringIsNull(item.imgUrl)) { this.imgUrl = this.commonService.stitchImg(item.imgUrl); } + } else { + this.editGoodSTypeForm.reset(); } this.isVisibleEdit = true; } diff --git a/src/app/pages/marketing/discount-list/discount-list.component.html b/src/app/pages/marketing/discount-list/discount-list.component.html new file mode 100644 index 0000000..5356fdb --- /dev/null +++ b/src/app/pages/marketing/discount-list/discount-list.component.html @@ -0,0 +1,98 @@ +
+
+
+ + 品牌名称 + + + + +
+ +
+ + + +
+
+
+ + + + + 品牌名称 + 品牌图片 + 创建时间 + 更新时间 + 操作 + + + + + {{data.title}} + + + + {{ data.createTime | date: 'yyyy-MM-dd HH:mm'}} + {{ data.updateTime | date: 'yyyy-MM-dd HH:mm'}} + + 修改 + + 删除 + + + + 总计 {{ total }} 条 + + + + + +
+ + 标题 + + + + + + + 上传图片 + + +
+ +
上传图片
+
+
+ + + + + + +
+
+
+
+
diff --git a/src/app/pages/marketing/discount-list/discount-list.component.less b/src/app/pages/marketing/discount-list/discount-list.component.less new file mode 100644 index 0000000..6d5c351 --- /dev/null +++ b/src/app/pages/marketing/discount-list/discount-list.component.less @@ -0,0 +1,12 @@ +[nz-form-label] { + overflow: visible; +} +button { + margin-left: 8px; +} +.submit-btn { + width: 150px; +} +.search-area { + margin-top: 30px; +} diff --git a/src/app/pages/marketing/discount-list/discount-list.component.ts b/src/app/pages/marketing/discount-list/discount-list.component.ts new file mode 100644 index 0000000..bfe82161 --- /dev/null +++ b/src/app/pages/marketing/discount-list/discount-list.component.ts @@ -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 {NzModalComponent, NzModalContentDirective, NzModalModule} from "ng-zorro-antd/modal"; +import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; +import {NzIconDirective} from "ng-zorro-antd/icon"; +import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; +import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload"; +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 {NzImageModule} from "ng-zorro-antd/image"; +import {environment} from "../../../../environments/environment"; +import {NzMessageService} from "ng-zorro-antd/message"; +import {CommonService} from "../../../services/common/common.service"; +import {GoodsService} from "../../../services/goods/goods.service"; +import {GoodsTypeData} from "../../../model/goods.interface"; +import { fallbackImg } from '../../../data/goods/goods.namespace'; + +const getBase64 = (file: File): Promise => + new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); + +@Component({ + selector: 'app-discount-list', + 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: './discount-list.component.html', + styleUrl: './discount-list.component.less' +}) +export class DiscountListComponent { + // 表单页数 + 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; + + protected readonly fallbackImg = fallbackImg; + + 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 => { + 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']); + } + }); + } +} diff --git a/src/app/pages/marketing/marketing.module.ts b/src/app/pages/marketing/marketing.module.ts new file mode 100644 index 0000000..f5e5afa --- /dev/null +++ b/src/app/pages/marketing/marketing.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + + + +@NgModule({ + declarations: [], + imports: [ + CommonModule + ] +}) +export class MarketingModule { } diff --git a/src/app/pages/marketing/marketing.routes.ts b/src/app/pages/marketing/marketing.routes.ts new file mode 100644 index 0000000..df3defb --- /dev/null +++ b/src/app/pages/marketing/marketing.routes.ts @@ -0,0 +1,9 @@ +import { Routes } from '@angular/router'; +import {DiscountListComponent} from "./discount-list/discount-list.component"; + + + +export const MARKETING_ROUTES: Routes = [ + { path: 'discount-list', component: DiscountListComponent}, + +]; diff --git a/src/assets/login/图片整理.png b/src/assets/login/1.png similarity index 100% rename from src/assets/login/图片整理.png rename to src/assets/login/1.png diff --git a/src/assets/login/多端协同.png b/src/assets/login/2.png similarity index 100% rename from src/assets/login/多端协同.png rename to src/assets/login/2.png diff --git a/src/assets/login/达成合作.png b/src/assets/login/3.png similarity index 100% rename from src/assets/login/达成合作.png rename to src/assets/login/3.png diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts index 213322b..088432e 100644 --- a/src/environments/environment.dev.ts +++ b/src/environments/environment.dev.ts @@ -1,7 +1,7 @@ export const environment = { production: true, - baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) - imageUrl: 'https://hsgcs.dctpay.com/filesystem/', - orderUrl: 'https://hsgcs.dctpay.com/order/', - userUrl: 'https://hsgcs.dctpay.com/User/', + baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) + orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) + userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) + imageUrl: 'https://phgcs.dctpay.com/filesystem/', };