分类管理
This commit is contained in:
		| @ -13,7 +13,7 @@ | |||||||
|  |  | ||||||
| </nz-card> | </nz-card> | ||||||
| <nz-card> | <nz-card> | ||||||
|   <st #st [data]="service. $api_get_account_management_page" [columns]="columns" [scroll]="{ x: '1200px' }" |   <st #st [data]="service.$api_get_account_management_page" [columns]="columns" [scroll]="{ x: '1200px' }" | ||||||
|     [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }" |     [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }" | ||||||
|     [res]="{ reName: { list: 'data.records', total: 'data.total' } }" |     [res]="{ reName: { list: 'data.records', total: 'data.total' } }" | ||||||
|     [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" |     [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" | ||||||
|  | |||||||
| @ -0,0 +1,8 @@ | |||||||
|  | <nz-spin *ngIf="!i && status !== 'add'" class="modal-spin"></nz-spin> | ||||||
|  | <sf #sf mode="edit" [schema]="schema" [ui]="ui" [formData]="i" button="none"> | ||||||
|  |   <div class="modal-footer"> | ||||||
|  |     <button nz-button type="button" (click)="close()">关闭</button> | ||||||
|  |     <button nz-button type="submit" nzType="primary" (click)="save(sf.value)" [disabled]="!sf.valid" | ||||||
|  |       [nzLoading]="service.http.loading">保存</button> | ||||||
|  |   </div> | ||||||
|  | </sf> | ||||||
| @ -0,0 +1,24 @@ | |||||||
|  | import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; | ||||||
|  | import { PartnerEditComponent } from './edit.component'; | ||||||
|  |  | ||||||
|  | describe('PartnerEditComponent', () => { | ||||||
|  |   let component: PartnerEditComponent; | ||||||
|  |   let fixture: ComponentFixture<PartnerEditComponent>; | ||||||
|  |  | ||||||
|  |   beforeEach(waitForAsync(() => { | ||||||
|  |     TestBed.configureTestingModule({ | ||||||
|  |       declarations: [ PartnerEditComponent ] | ||||||
|  |     }) | ||||||
|  |     .compileComponents(); | ||||||
|  |   })); | ||||||
|  |  | ||||||
|  |   beforeEach(() => { | ||||||
|  |     fixture = TestBed.createComponent(PartnerEditComponent); | ||||||
|  |     component = fixture.componentInstance; | ||||||
|  |     fixture.detectChanges(); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   it('should create', () => { | ||||||
|  |     expect(component).toBeTruthy(); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
| @ -0,0 +1,111 @@ | |||||||
|  | import { Component, OnInit } from '@angular/core'; | ||||||
|  | import { apiConf } from '@conf/api.conf'; | ||||||
|  | import { SFSchema, SFUISchema } from '@delon/form'; | ||||||
|  | import { NzModalRef } from 'ng-zorro-antd/modal'; | ||||||
|  | import { Observable, Observer } from 'rxjs'; | ||||||
|  | import { ClassificationService } from '../../services/classification.service'; | ||||||
|  |  | ||||||
|  | @Component({ | ||||||
|  |   selector: 'app-partner-edit', | ||||||
|  |   templateUrl: './edit.component.html', | ||||||
|  | }) | ||||||
|  | export class PartnerEditComponent implements OnInit { | ||||||
|  |   record: any = {}; | ||||||
|  |   i: any; | ||||||
|  |   schema!: SFSchema; | ||||||
|  |   ui!: SFUISchema; | ||||||
|  |   status = 'add'; | ||||||
|  |  | ||||||
|  |   constructor( | ||||||
|  |     private modal: NzModalRef, | ||||||
|  |     public service: ClassificationService | ||||||
|  |   ) { } | ||||||
|  |  | ||||||
|  |   ngOnInit(): void { | ||||||
|  |     if (this.i) { | ||||||
|  |       this.i.icon = [ | ||||||
|  |         { | ||||||
|  |           uid: -1, | ||||||
|  |           name: 'xxx.png', | ||||||
|  |           status: 'done', | ||||||
|  |           url: this.i.url, | ||||||
|  |           response: { | ||||||
|  |             resource_id: 1, | ||||||
|  |           }, | ||||||
|  |         }, | ||||||
|  |       ] | ||||||
|  |     } | ||||||
|  |     this.initSF(); | ||||||
|  |  | ||||||
|  |   } | ||||||
|  |   initSF() { | ||||||
|  |     this.schema = { | ||||||
|  |       properties: { | ||||||
|  |         abnormalCause: { | ||||||
|  |           title: '分类名称', | ||||||
|  |           type: 'string', | ||||||
|  |           maxLength: 5, | ||||||
|  |           ui: { | ||||||
|  |             placeholder: '请输入', | ||||||
|  |           }, | ||||||
|  |         }, | ||||||
|  |         icon: { | ||||||
|  |           type: 'string', | ||||||
|  |           title: '图标', | ||||||
|  |           ui: { | ||||||
|  |             action: apiConf.fileUpload, | ||||||
|  |             fileType: 'image/png,image/jpeg,image/jpg', | ||||||
|  |             limit: 1, | ||||||
|  |             resReName: 'url', | ||||||
|  |             urlReName: 'url', | ||||||
|  |             widget: 'upload', | ||||||
|  |             descriptionI18n: '支持JPG、PNG格式,文件小于2M(建议尺寸  88px * 88px)', | ||||||
|  |             name: 'multipartFile', | ||||||
|  |             multiple: false, | ||||||
|  |             listType: 'picture-card', | ||||||
|  |             beforeUpload: (file: any, _fileList: any) => { | ||||||
|  |               return new Observable((observer: Observer<boolean>) => { | ||||||
|  |                 const isLt2M = file.size / 1024 / 1024 < 2; | ||||||
|  |                 if (!isLt2M) { | ||||||
|  |                   this.service.msgSrv.warning('图片大小超过2M!'); | ||||||
|  |                   observer.complete(); | ||||||
|  |                   return; | ||||||
|  |                 } | ||||||
|  |                 observer.next(isLt2M); | ||||||
|  |                 observer.complete(); | ||||||
|  |               }); | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |         }, | ||||||
|  |         abnormalCause2: { | ||||||
|  |           title: '排序', | ||||||
|  |           type: 'number', | ||||||
|  |           maximum: 99, | ||||||
|  |           minimum: 0, | ||||||
|  |           ui: { | ||||||
|  |             placeholder: '请输入', | ||||||
|  |             widgetWidth: 350 | ||||||
|  |           } | ||||||
|  |         }, | ||||||
|  |       }, | ||||||
|  |       required: ['abnormalCause', 'icon', 'abnormalCause2'] | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |     this.ui = { '*': { spanLabelFixed: 90, grid: { span: 20, gutter: 4 } }, }; | ||||||
|  |  | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   save(value: any): void { | ||||||
|  |     this.service.request(`/user/${this.record.id}`, value).subscribe(res => { | ||||||
|  |       if (res) { | ||||||
|  |         this.service.msgSrv.success('保存成功'); | ||||||
|  |         this.modal.close(true); | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   close(): void { | ||||||
|  |     this.modal.destroy(); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -1,9 +1,28 @@ | |||||||
| <page-header [action]="phActionTpl"> | <page-header-wrapper [title]="''"> | ||||||
|   <ng-template #phActionTpl> | </page-header-wrapper> | ||||||
|     <button (click)="add()" nz-button nzType="primary">新建</button> |  | ||||||
|   </ng-template> |  | ||||||
| </page-header> |  | ||||||
| <nz-card> | <nz-card> | ||||||
|   <sf mode="search" [schema]="searchSchema" (formSubmit)="st.reset($event)" (formReset)="st.reset($event)"></sf> |   <div nz-row nzGutter="8"> | ||||||
|   <st #st [data]="url" [columns]="columns"></st> |     <div nz-col [nzSpan]="16"> | ||||||
|  |       <sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf> | ||||||
|  |     </div> | ||||||
|  |     <div nz-col [nzSpan]="8"> | ||||||
|  |       <button nz-button nzType="primary" (click)="st?.load(1)">查询</button> | ||||||
|  |       <button nz-button (click)="resetSF()">重置</button> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </nz-card> | ||||||
|  | <nz-card> | ||||||
|  |  | ||||||
|  |   <div class="mb-sm"> | ||||||
|  |     <button nz-button nzType="primary" (click)="add()">新增分类</button> | ||||||
|  |   </div> | ||||||
|  |   <st #st [data]="service.$api_get_account_management_page" [columns]="columns" [scroll]="{ x: '1200px' }" | ||||||
|  |     [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }" | ||||||
|  |     [res]="{ reName: { list: 'data.records', total: 'data.total' } }" | ||||||
|  |     [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" | ||||||
|  |     [loading]="service.http.loading"> | ||||||
|  |     <ng-template st-row="icon" let-item> | ||||||
|  |       <img nz-image width="64px" height="64px" [nzSrc]="item?.icon" alt="" /> | ||||||
|  |     </ng-template> | ||||||
|  |   </st> | ||||||
| </nz-card> | </nz-card> | ||||||
|  | |||||||
| @ -1,7 +1,11 @@ | |||||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | import { Component, OnInit, ViewChild } from '@angular/core'; | ||||||
| import { STColumn, STComponent } from '@delon/abc/st'; | import { STColumn, STComponent } from '@delon/abc/st'; | ||||||
| import { SFSchema } from '@delon/form'; | import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; | ||||||
| import { ModalHelper, _HttpClient } from '@delon/theme'; | import { ModalHelper, _HttpClient } from '@delon/theme'; | ||||||
|  | import { NzModalService } from 'ng-zorro-antd/modal'; | ||||||
|  | import { PartnerAccountManagementVirtualAccountDetailComponent } from 'src/app/routes/partner/account-management/components/virtual-account-detail/virtual-account-detail.component'; | ||||||
|  | import { AccountManagemantService } from 'src/app/routes/partner/account-management/services/account-managemant.service'; | ||||||
|  | import { PartnerEditComponent } from '../edit/edit.component'; | ||||||
|  |  | ||||||
| @Component({ | @Component({ | ||||||
|   selector: 'app-partner-list', |   selector: 'app-partner-list', | ||||||
| @ -9,37 +13,161 @@ import { ModalHelper, _HttpClient } from '@delon/theme'; | |||||||
| }) | }) | ||||||
| export class PartnerKnowledgeClassificationListComponent implements OnInit { | export class PartnerKnowledgeClassificationListComponent implements OnInit { | ||||||
|   url = `/user`; |   url = `/user`; | ||||||
|   searchSchema: SFSchema = { |   schema!: SFSchema; | ||||||
|     properties: { |   ui!: SFUISchema; | ||||||
|       no: { |  | ||||||
|         type: 'string', |  | ||||||
|         title: '编号' |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   }; |  | ||||||
|   @ViewChild('st') private readonly st!: STComponent; |   @ViewChild('st') private readonly st!: STComponent; | ||||||
|   columns: STColumn[] = [ |   @ViewChild('sf') private readonly sf!: SFComponent; | ||||||
|     { title: '编号', index: 'no' }, |   columns: STColumn[] = []; | ||||||
|     { title: '调用次数', type: 'number', index: 'callNo' }, |  | ||||||
|     { title: '头像', type: 'img', width: '50px', index: 'avatar' }, |   constructor(public service: AccountManagemantService, public modal: NzModalService) { } | ||||||
|     { title: '时间', type: 'date', index: 'updatedAt' }, |   /** | ||||||
|  |    * 查询参数 | ||||||
|  |    */ | ||||||
|  |   get reqParams() { | ||||||
|  |     const params = { ...this.sf?.value }; | ||||||
|  |     return params | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ngOnInit(): void { | ||||||
|  |     this.initSF(); | ||||||
|  |     this.initST(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   initSF() { | ||||||
|  |     this.schema = { | ||||||
|  |       properties: { | ||||||
|  |         abnormalCause: { | ||||||
|  |           title: '分类ID', | ||||||
|  |           type: 'string', | ||||||
|  |           ui: { | ||||||
|  |             placeholder: '请输入', | ||||||
|  |           }, | ||||||
|  |         }, | ||||||
|  |         abnormalCause1: { | ||||||
|  |           title: '分类名称', | ||||||
|  |           type: 'string', | ||||||
|  |           ui: { | ||||||
|  |             placeholder: '请输入', | ||||||
|  |           }, | ||||||
|  |         }, | ||||||
|  |         abnormalCause2: { | ||||||
|  |           title: '状态', | ||||||
|  |           type: 'string', | ||||||
|  |           enum: [ | ||||||
|  |             { label: '全部', value: '' }, | ||||||
|  |             { label: '正常', value: '1' }, | ||||||
|  |             { label: '禁用', value: '2' } | ||||||
|  |           ], | ||||||
|  |           default: '', | ||||||
|  |         }, | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     this.ui = { '*': { spanLabelFixed: 90, grid: { span: 8, gutter: 4 } }, }; | ||||||
|  |   } | ||||||
|  |   /** | ||||||
|  |  * 初始化数据列表 | ||||||
|  |  */ | ||||||
|  |   initST() { | ||||||
|  |     this.columns = [ | ||||||
|  |       { title: '分类ID', index: 'carNo', className: 'text-center', width: 150 }, | ||||||
|  |       { title: '分类名称', render: 'carModelLabel', className: 'text-center', width: 200 }, | ||||||
|  |       { title: '图标', render: 'icon', className: 'text-center', width: 200 }, | ||||||
|  |       { title: '文章数', render: 'approvalStatus2', className: 'text-center', width: 120 }, | ||||||
|  |       { title: '排序', render: 'approvalStatus3', className: 'text-center', width: 120 }, | ||||||
|  |       { title: '状态', index: 'approvalStatus4', className: 'text-center', width: 120 }, | ||||||
|  |       { title: '最后修改时间', index: 'approvalStatus4', className: 'text-center', width: 180 }, | ||||||
|       { |       { | ||||||
|       title: '', |         title: '操作', | ||||||
|  |         width: 150, | ||||||
|         buttons: [ |         buttons: [ | ||||||
|         // { text: '查看', click: (item: any) => `/form/${item.id}` }, |           { | ||||||
|         // { text: '编辑', type: 'static', component: FormEditComponent, click: 'reload' }, |             text: '修改', | ||||||
|  |             click: (_record) => this.edit(_record) | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             text: '启用', | ||||||
|  |             click: (_record) => this.operate(_record, 1) | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             text: '禁用', | ||||||
|  |             click: (_record) => this.operate(_record, 2) | ||||||
|  |           } | ||||||
|         ] |         ] | ||||||
|       } |       } | ||||||
|     ]; |     ]; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   constructor(private http: _HttpClient, private modal: ModalHelper) { } |   resetSF() { | ||||||
|  |     this.sf.reset(); | ||||||
|  |     setTimeout(() => { | ||||||
|  |       this.st.reset(); | ||||||
|  |     }) | ||||||
|  |   } | ||||||
|  |  | ||||||
|   ngOnInit(): void { } |   /** | ||||||
|  |    *新增 | ||||||
|  |    * @param _record 当前行信息 | ||||||
|  |    */ | ||||||
|  |   add() { | ||||||
|  |     const modalRef = this.modal.create({ | ||||||
|  |       nzTitle: '新增分类', | ||||||
|  |       nzContent: PartnerEditComponent, | ||||||
|  |       nzWidth: 600, | ||||||
|  |       nzComponentParams: { | ||||||
|  |         i: null | ||||||
|  |       }, | ||||||
|  |       nzFooter: null | ||||||
|  |     }); | ||||||
|  |     modalRef.afterClose.subscribe((res: any) => { | ||||||
|  |       if (res) { | ||||||
|  |         this.st.load(1); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *编辑 | ||||||
|  |    * @param _record 当前行信息 | ||||||
|  |    */ | ||||||
|  |   edit(record: any) { | ||||||
|  |     const modalRef = this.modal.create({ | ||||||
|  |       nzTitle: '修改分类', | ||||||
|  |       nzContent: PartnerEditComponent, | ||||||
|  |       nzWidth: 600, | ||||||
|  |       nzComponentParams: { | ||||||
|  |         i: record | ||||||
|  |       }, | ||||||
|  |       nzFooter: null | ||||||
|  |     }); | ||||||
|  |     modalRef.afterClose.subscribe((res: any) => { | ||||||
|  |       if (res) { | ||||||
|  |         this.st.load(1); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |  *禁用或者启动 | ||||||
|  |  * @param _record 当前行信息 | ||||||
|  |  */ | ||||||
|  |   operate(record: any, type = 1) { | ||||||
|  |     this.modal.confirm({ | ||||||
|  |       nzTitle: `<b>确定${type === 1 ? '启用' : '禁用'}此分类吗?</b>`, | ||||||
|  |       nzOnOk: () => | ||||||
|  |         this.service.request(this.service.$api_edit_one, { id: record.id }).subscribe((res) => { | ||||||
|  |           if (res) { | ||||||
|  |             this.st.load(1); | ||||||
|  |             this.service.msgSrv.success(`${type === 1 ? '启用' : '禁用'}成功!`); | ||||||
|  |           } | ||||||
|  |         }), | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * | ||||||
|  |    */ | ||||||
|  |   export() { | ||||||
|  |  | ||||||
|   add(): void { |  | ||||||
|     // this.modal |  | ||||||
|     //   .createStatic(FormEditComponent, { i: { id: 0 } }) |  | ||||||
|     //   .subscribe(() => this.st.reload()); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,12 @@ | |||||||
|  | import { Injectable, Injector } from '@angular/core'; | ||||||
|  | import { BaseService } from '@shared'; | ||||||
|  |  | ||||||
|  | @Injectable({ | ||||||
|  |   providedIn: 'root' | ||||||
|  | }) | ||||||
|  | export class ClassificationService extends BaseService { | ||||||
|  |  | ||||||
|  |   constructor(public injector: Injector) { | ||||||
|  |     super(injector); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -51,6 +51,7 @@ import { PartnerRecordedDetailComponent } from './recorded/components/detail/det | |||||||
| import { PartnerRecordedRecordComponent } from './recorded/components/record/record.component'; | import { PartnerRecordedRecordComponent } from './recorded/components/record/record.component'; | ||||||
| import { ParterRebateManageMentAddComponent } from './rebate-management/components/rebate-setting/add/add.component'; | import { ParterRebateManageMentAddComponent } from './rebate-management/components/rebate-setting/add/add.component'; | ||||||
| import { PartnerKnowledgeClassificationListComponent } from './knowledge/classification/components/list/list.component'; | import { PartnerKnowledgeClassificationListComponent } from './knowledge/classification/components/list/list.component'; | ||||||
|  | import { PartnerEditComponent } from './knowledge/classification/components/edit/edit.component'; | ||||||
|  |  | ||||||
| const COMPONENTS: any[] = [ | const COMPONENTS: any[] = [ | ||||||
|   PartnerBusinessStatisticsIndexComponent, |   PartnerBusinessStatisticsIndexComponent, | ||||||
| @ -92,7 +93,8 @@ const COMPONENTS: any[] = [ | |||||||
|   AddEtpPartnerComponent, |   AddEtpPartnerComponent, | ||||||
|   AddPersonalPartnerComponent, |   AddPersonalPartnerComponent, | ||||||
|   PartnerKnowledgeClassificationListComponent |   PartnerKnowledgeClassificationListComponent | ||||||
| ]; | , | ||||||
|  |   PartnerEditComponent]; | ||||||
|  |  | ||||||
| @NgModule({ | @NgModule({ | ||||||
|   declarations: [...COMPONENTS], |   declarations: [...COMPONENTS], | ||||||
|  | |||||||
| @ -46,6 +46,8 @@ import { NzAnchorModule } from 'ng-zorro-antd/anchor'; | |||||||
| import { NzAffixModule } from 'ng-zorro-antd/affix'; | import { NzAffixModule } from 'ng-zorro-antd/affix'; | ||||||
| import { NzTypographyModule } from 'ng-zorro-antd/typography'; | import { NzTypographyModule } from 'ng-zorro-antd/typography'; | ||||||
| import { NzSwitchModule } from 'ng-zorro-antd/switch'; | import { NzSwitchModule } from 'ng-zorro-antd/switch'; | ||||||
|  | import { NzImageModule } from 'ng-zorro-antd/image'; | ||||||
|  |  | ||||||
| export const SHARED_ZORRO_MODULES = [ | export const SHARED_ZORRO_MODULES = [ | ||||||
|   NzButtonModule, |   NzButtonModule, | ||||||
|   NzGridModule, |   NzGridModule, | ||||||
| @ -85,5 +87,6 @@ export const SHARED_ZORRO_MODULES = [ | |||||||
|   NzAnchorModule, |   NzAnchorModule, | ||||||
|   NzAffixModule, |   NzAffixModule, | ||||||
|   NzTypographyModule, |   NzTypographyModule, | ||||||
|   NzSwitchModule  |   NzSwitchModule, | ||||||
|  |   NzImageModule | ||||||
| ]; | ]; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user