diff --git a/src/app/routes/partner/account-management/components/list/list.component.html b/src/app/routes/partner/account-management/components/list/list.component.html index 465b42a3..d071efc2 100644 --- a/src/app/routes/partner/account-management/components/list/list.component.html +++ b/src/app/routes/partner/account-management/components/list/list.component.html @@ -13,7 +13,7 @@ - + + + diff --git a/src/app/routes/partner/knowledge/classification/components/edit/edit.component.spec.ts b/src/app/routes/partner/knowledge/classification/components/edit/edit.component.spec.ts new file mode 100644 index 00000000..e31fd9c9 --- /dev/null +++ b/src/app/routes/partner/knowledge/classification/components/edit/edit.component.spec.ts @@ -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; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ PartnerEditComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PartnerEditComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/routes/partner/knowledge/classification/components/edit/edit.component.ts b/src/app/routes/partner/knowledge/classification/components/edit/edit.component.ts new file mode 100644 index 00000000..817ac254 --- /dev/null +++ b/src/app/routes/partner/knowledge/classification/components/edit/edit.component.ts @@ -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) => { + 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(); + } +} diff --git a/src/app/routes/partner/knowledge/classification/components/list/list.component.html b/src/app/routes/partner/knowledge/classification/components/list/list.component.html index 482ccb06..2947e9a8 100644 --- a/src/app/routes/partner/knowledge/classification/components/list/list.component.html +++ b/src/app/routes/partner/knowledge/classification/components/list/list.component.html @@ -1,9 +1,28 @@ - - - - - + + - - +
+
+ +
+
+ + +
+
+
+ + +
+ +
+ + + + +
diff --git a/src/app/routes/partner/knowledge/classification/components/list/list.component.ts b/src/app/routes/partner/knowledge/classification/components/list/list.component.ts index f90502b6..db88bed4 100644 --- a/src/app/routes/partner/knowledge/classification/components/list/list.component.ts +++ b/src/app/routes/partner/knowledge/classification/components/list/list.component.ts @@ -1,7 +1,11 @@ import { Component, OnInit, ViewChild } from '@angular/core'; 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 { 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({ selector: 'app-partner-list', @@ -9,37 +13,161 @@ import { ModalHelper, _HttpClient } from '@delon/theme'; }) export class PartnerKnowledgeClassificationListComponent implements OnInit { url = `/user`; - searchSchema: SFSchema = { - properties: { - no: { - type: 'string', - title: '编号' + schema!: SFSchema; + ui!: SFUISchema; + @ViewChild('st') private readonly st!: STComponent; + @ViewChild('sf') private readonly sf!: SFComponent; + columns: STColumn[] = []; + + constructor(public service: AccountManagemantService, public modal: NzModalService) { } + /** + * 查询参数 + */ + 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: '', + }, } } - }; - @ViewChild('st') private readonly st!: STComponent; - columns: STColumn[] = [ - { title: '编号', index: 'no' }, - { title: '调用次数', type: 'number', index: 'callNo' }, - { title: '头像', type: 'img', width: '50px', index: 'avatar' }, - { title: '时间', type: 'date', index: 'updatedAt' }, - { - title: '', - buttons: [ - // { text: '查看', click: (item: any) => `/form/${item.id}` }, - // { text: '编辑', type: 'static', component: FormEditComponent, click: 'reload' }, - ] - } - ]; + 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: '操作', + width: 150, + buttons: [ + { + 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: `确定${type === 1 ? '启用' : '禁用'}此分类吗?`, + 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()); } } diff --git a/src/app/routes/partner/knowledge/classification/services/classification.service.ts b/src/app/routes/partner/knowledge/classification/services/classification.service.ts new file mode 100644 index 00000000..034cdb74 --- /dev/null +++ b/src/app/routes/partner/knowledge/classification/services/classification.service.ts @@ -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); + } +} diff --git a/src/app/routes/partner/partner.module.ts b/src/app/routes/partner/partner.module.ts index c38615d4..1c3c0486 100644 --- a/src/app/routes/partner/partner.module.ts +++ b/src/app/routes/partner/partner.module.ts @@ -51,6 +51,7 @@ import { PartnerRecordedDetailComponent } from './recorded/components/detail/det import { PartnerRecordedRecordComponent } from './recorded/components/record/record.component'; import { ParterRebateManageMentAddComponent } from './rebate-management/components/rebate-setting/add/add.component'; import { PartnerKnowledgeClassificationListComponent } from './knowledge/classification/components/list/list.component'; +import { PartnerEditComponent } from './knowledge/classification/components/edit/edit.component'; const COMPONENTS: any[] = [ PartnerBusinessStatisticsIndexComponent, @@ -92,7 +93,8 @@ const COMPONENTS: any[] = [ AddEtpPartnerComponent, AddPersonalPartnerComponent, PartnerKnowledgeClassificationListComponent -]; +, + PartnerEditComponent]; @NgModule({ declarations: [...COMPONENTS], diff --git a/src/app/shared/shared-zorro.module.ts b/src/app/shared/shared-zorro.module.ts index ab105080..bb75f8c0 100644 --- a/src/app/shared/shared-zorro.module.ts +++ b/src/app/shared/shared-zorro.module.ts @@ -44,8 +44,10 @@ import { NzUploadModule } from 'ng-zorro-antd/upload'; import { NzCascaderModule } from 'ng-zorro-antd/cascader'; import { NzAnchorModule } from 'ng-zorro-antd/anchor'; 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 { NzImageModule } from 'ng-zorro-antd/image'; + export const SHARED_ZORRO_MODULES = [ NzButtonModule, NzGridModule, @@ -85,5 +87,6 @@ export const SHARED_ZORRO_MODULES = [ NzAnchorModule, NzAffixModule, NzTypographyModule, - NzSwitchModule + NzSwitchModule, + NzImageModule ];