diff --git a/src/app/routes/partner/article-management/components/edit/edit.component.html b/src/app/routes/partner/article-management/components/edit/edit.component.html new file mode 100644 index 00000000..e8e4a5fc --- /dev/null +++ b/src/app/routes/partner/article-management/components/edit/edit.component.html @@ -0,0 +1,17 @@ + + + + + + + 取消 + 确认 + + + + + 取消 + 确认 + + + diff --git a/src/app/routes/partner/article-management/components/edit/edit.component.ts b/src/app/routes/partner/article-management/components/edit/edit.component.ts new file mode 100644 index 00000000..f65dea8f --- /dev/null +++ b/src/app/routes/partner/article-management/components/edit/edit.component.ts @@ -0,0 +1,189 @@ +import { AfterViewInit, ChangeDetectorRef, Component, OnChanges, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { apiConf } from '@conf/api.conf'; +import { SFComponent, SFRadioWidgetSchema, SFSchema, SFSchemaEnumType, SFSelectWidgetSchema, SFTextareaWidgetSchema, SFUISchema, SFUploadWidgetSchema } from '@delon/form'; +import { _HttpClient } from '@delon/theme'; +import { Observable, Observer } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { AmapPoiPickerComponent } from 'src/app/shared/components/amap'; +import { ChannelSalesService } from '../../services/channel-sales.service'; + +@Component({ + selector: 'app-parter-article-management-edit', + templateUrl: './edit.component.html' +}) +export class ParterArticleManagementEditComponent implements OnInit { + @ViewChild('sf', { static: false }) sf!: SFComponent; + schema!: SFSchema; + ui!: SFUISchema; + i: any; + type: any; + + constructor( + public http: _HttpClient, + private cdr: ChangeDetectorRef, + private route: ActivatedRoute, + public service: ChannelSalesService, + ) {} + + ngOnInit(): void { + this.initSF(); + } + initSF() { + this.schema = { + properties: { + id: { + type: 'string', + title: '', + ui: { hidden: true } + }, + name1: { + type: 'string', + title: '文章标题', + maxLength: 50, + ui: { + widget: 'textarea', + autosize: { minRows: 3, maxRows: 6 }, + placeholder:'请输入50字符' + } as SFTextareaWidgetSchema, + }, + name2: { + type: 'string', + title: '文章简介', + maxLength: 50, + ui: { + widget: 'textarea', + autosize: { minRows: 3, maxRows: 6 }, + placeholder:'请输入50字符' + } as SFTextareaWidgetSchema, + }, + name3: { + type: 'string', + title: '封面图', + ui: { + action: apiConf.fileUpload, + accept: 'image/png,image/jpeg,image/jpg', + limit: 1, + limitFileCount: 1, + resReName: 'data.fullFilePath', + urlReName: 'data.fullFilePath', + widget: 'upload', + descriptionI18n: '支持JPG、PNG格式,文件小于2M(建议尺寸 280px * 180 px)', + 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(); + }); + } + } as SFUploadWidgetSchema + }, + name: { + title: '分类', + type: 'string', + enum: [ + { label: '管理员', value: '1'}, + ], + ui: { + widget: 'select', + } as SFSelectWidgetSchema, + }, + name4: { + type: 'number', + title: '排序', + minimum: 0, + maximum: 99, + ui: { + widgetWidth: 300 , + placeholder:'请输入0~99,数字越大,排序越靠前' + } + }, + name5: { + type: 'string', + title: '跳转路径', + enum: [ + { label: '图文', value: '1'}, + { label: '视频', value: '2'}, + ], + ui: { + widget: 'radio', + } as SFRadioWidgetSchema, + default: '1', + }, + content: { + type: 'string', + title: '正文', + ui: { + widget: 'tinymce', + loadingTip: 'loading...', + config: { + height: 450 + }, + visibleIf: { name5: (value: string) => value === '1' } + }, + }, + name6: { + type: 'string', + title: '视频', + ui: { + action: apiConf.fileUpload, + accept: 'video/mp4,video/avi,video/mkv,video/vob', + limit: 1, + limitFileCount: 1, + resReName: 'data.fullFilePath', + urlReName: 'data.fullFilePath', + widget: 'upload', + descriptionI18n: '支持MP4、AVI、DAT、MKV、FLV、VOB格式,文件小于20M。', + name: 'multipartFile', + multiple: false, + listType: 'picture-card', + beforeUpload: (file: any, _fileList: any) => { + return new Observable((observer: Observer) => { + const isLt2M = file.size / 1024 / 1024 < 20; + if (!isLt2M) { + this.service.msgSrv.warning('视频大小超过20M!'); + observer.complete(); + return; + } + observer.next(isLt2M); + observer.complete(); + }); + }, + visibleIf: { name5: (value: string) => value === '2' } + } as SFUploadWidgetSchema + }, + }, + required: ['name1', 'name2'] + }; + this.ui = { + '*': { + spanLabelFixed: 150, + grid: { span: 20 } + }, + + }; + } + + close() { + + } + save() { + this.sf.validator({ emitError: true }); + if(!this.sf.valid) return; + // this.service.request('', { ...this.sf.value }).subscribe(res => { + // if (res) { + // this.modalRef.destroy(true); + // } else { + // this.service.msgSrv.error(res.msg); + // } + // }); + } +} diff --git a/src/app/routes/partner/article-management/components/list/list.component.html b/src/app/routes/partner/article-management/components/list/list.component.html new file mode 100644 index 00000000..721c85c0 --- /dev/null +++ b/src/app/routes/partner/article-management/components/list/list.component.html @@ -0,0 +1,49 @@ + + + + + + + + + + + 4"> + + + + + 查询 + 重置 + + {{ !_$expand ? '展开' : '收起' }} + + + + + + + + + 新增文章 + + + + diff --git a/src/app/routes/partner/article-management/components/list/list.component.ts b/src/app/routes/partner/article-management/components/list/list.component.ts new file mode 100644 index 00000000..61db7824 --- /dev/null +++ b/src/app/routes/partner/article-management/components/list/list.component.ts @@ -0,0 +1,200 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st'; +import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; +import { processSingleSort } from '@shared'; +import { NzModalService } from 'ng-zorro-antd/modal'; +import { ChannelSalesService } from '../../services/channel-sales.service'; +import { ParterArticleManagementEditComponent } from '../edit/edit.component'; + +@Component({ + selector: 'app-parter-article-management-list', + templateUrl: './list.component.html' +}) +export class ParterArticleManagementListComponent implements OnInit { + schema: SFSchema = {}; + columns!: STColumn[]; + ui!: SFUISchema; + @ViewChild('st', { static: false }) + st!: STComponent; + @ViewChild('sf', { static: false }) + sf!: SFComponent; + spuStatus = '1'; + _$expand = false; + + data=[{name1:1111}] + constructor( + public router: Router, + public ar: ActivatedRoute, + public service: ChannelSalesService, + private modalService: NzModalService + ) {} + + /** + * 查询参数 + */ + get reqParams() { + return { ...this.sf?.value }; + } + + /** + * 重置表单 + */ + resetSF() { + this.sf.reset(); + this.st.load(1); + } + + search() { + // this.st1?.load(1); + } + + /** + * 查询字段个数 + */ + get queryFieldCount(): number { + return Object.keys(this.schema?.properties || {}).length; + } + /** + * 伸缩查询条件 + */ + expandToggle(): void { + this._$expand = !this._$expand; + this.sf?.setValue('/_$expand', this._$expand); + } + ngOnInit() { + this.initSF(); + this.initST(); + } + + initSF() { + this.schema = { + properties: { + _$expand: { type: 'boolean', ui: { hidden: true } }, + name: { + type: 'string', + title: '文章标题' + }, + phone: { + type: 'string', + title: '分类' + }, + phone1: { + type: 'string', + title: '状态' + }, + phone2: { + type: 'string', + title: '推荐到首页', + ui: { + visibleIf: { + _$expand: (value: boolean) => value + } + } + }, + + } + }; + this.ui = { + '*': { + grid: { span: 8, gutter: 4 } + } + }; + } + + initST() { + this.columns = [ + { + title: '销售渠道姓名', + index: 'name1' + }, + { + title: '手机号', + index: 'name1' + }, + { + title: '所属组织', + index: 'name1' + }, + { + title: '职级', + index: 'name1' + }, + { + title: '等级', + index: 'name1' + }, + { + title: '省市', + index: 'name1' + }, + { + title: '邀请码', + index: 'name1' + }, + { + title: '操作', + className: 'text-center', + buttons: [ + { + text: '修改', + click: (_record, _modal, _instance) => this.edit(_record), + }, + { + text: '禁用', + click: (_record, _modal, _instance) => this.stop(_record), + }, + { + text: '启用', + click: (_record, _modal, _instance) => this.start(_record.id), + }, + { + text: '推荐到首页', + click: (_record, _modal, _instance) => this.recommend(_record.id), + } + ] + } + ]; + } + // 新增 + add() { + this.router.navigate(['/partner/article-management/add'], { queryParams: {} }); + } + + // 编辑 + edit(record: STData) { + this.router.navigate(['/partner/article-management/edit'], { queryParams: {} }); + } + + + stop(record: STData) { + this.modalService.confirm({ + nzTitle: '禁用确认', + nzContent: `确定禁用此文章吗?`, + // nzOnOk: () => + // this.service.request('', '').subscribe(res => { + // if (res) { + // this.service.msgSrv.success('冻结成功!'); + // this.st.reload(); + // } + // }) + }); + } + start(record: STData) { + this.modalService.confirm({ + nzTitle: '启用确认', + nzContent: `确定启用此文章吗?`, + // nzOnOk: () => + // this.service.request('', '').subscribe(res => { + // if (res) { + // this.service.msgSrv.success('冻结成功!'); + // this.st.reload(); + // } + // }) + }); + } + recommend(record: STData) { + + } + +} diff --git a/src/app/routes/partner/article-management/services/channel-sales.service.ts b/src/app/routes/partner/article-management/services/channel-sales.service.ts new file mode 100644 index 00000000..6e7cb18c --- /dev/null +++ b/src/app/routes/partner/article-management/services/channel-sales.service.ts @@ -0,0 +1,12 @@ +import { Injectable, Injector } from '@angular/core'; +import { BaseService } from '@shared'; + +@Injectable({ + providedIn: 'root', +}) +export class ChannelSalesService extends BaseService { + + constructor(public injector: Injector) { + super(injector); + } +} diff --git a/src/app/routes/partner/partner-routing.module.ts b/src/app/routes/partner/partner-routing.module.ts index 2ceac3d8..69c8c4da 100644 --- a/src/app/routes/partner/partner-routing.module.ts +++ b/src/app/routes/partner/partner-routing.module.ts @@ -38,6 +38,8 @@ import { AddPersonalPartnerComponent } from './partner-list/components/add-perso import { PartnerDetailComponent } from './partner-list/components/partner-detail/partner-detail.component'; import { PartnerListComponent } from './partner-list/components/index/partner-list.component'; import { ParterRebateManageMentAddComponent } from './rebate-management/components/rebate-setting/add/add.component'; +import { ParterArticleManagementListComponent } from './article-management/components/list/list.component'; +import { ParterArticleManagementEditComponent } from './article-management/components/edit/edit.component'; const routes: Routes = [ { @@ -125,6 +127,15 @@ const routes: Routes = [ { path: 'record/detail/:id', component: PartnerRecordedDetailComponent } ] }, + { + path: 'article-management', + children: [ + { path: '', component: ParterArticleManagementListComponent }, + { path: 'list', component: ParterArticleManagementListComponent}, + { path: 'add', component: ParterArticleManagementEditComponent}, + { path: 'edit', component: ParterArticleManagementEditComponent}, + ] + }, ]; @NgModule({ diff --git a/src/app/routes/partner/partner.module.ts b/src/app/routes/partner/partner.module.ts index 6eadaab1..cb9f380b 100644 --- a/src/app/routes/partner/partner.module.ts +++ b/src/app/routes/partner/partner.module.ts @@ -50,6 +50,8 @@ import { ParterRebateManageMenAbnormalFeedbackComponent } from './rebate-managem import { PartnerRecordedDetailComponent } from './recorded/components/detail/detail.component'; import { PartnerRecordedRecordComponent } from './recorded/components/record/record.component'; import { ParterRebateManageMentAddComponent } from './rebate-management/components/rebate-setting/add/add.component'; +import { ParterArticleManagementEditComponent } from './article-management/components/edit/edit.component'; +import { ParterArticleManagementListComponent } from './article-management/components/list/list.component'; const COMPONENTS: any[] = [ PartnerBusinessStatisticsIndexComponent, @@ -90,7 +92,8 @@ const COMPONENTS: any[] = [ ParterRebateManageMentAddComponent, AddEtpPartnerComponent, AddPersonalPartnerComponent, - + ParterArticleManagementEditComponent, + ParterArticleManagementListComponent ]; @NgModule({ diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index 20178a6b..64e38c54 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -604,7 +604,22 @@ "children": [{ "text": "banner管理", "link": "/knowledge/banner" - }] + }, + { + "text": "文章管理", + "link": "/partner/article-management/list" + }, + { + "text": "新增文章", + "link": "/partner/article-management/add", + "hide": true + }, + { + "text": "编辑文章", + "link": "/partner/article-management/edit", + "hide": true + } + ] } ] }