接口调整,对接后端部分的v2版本
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {Tag} from '../../../../class/Tag';
|
||||
import {Category, Tag} from '../../../../class/Tag';
|
||||
|
||||
@Component({
|
||||
selector: 'c-publish-form',
|
||||
@@ -15,9 +15,9 @@ export class PublishFormComponent implements OnInit {
|
||||
@ViewChild('inputElement', {static: false}) tagInputElement: ElementRef;
|
||||
|
||||
@Input() tagNacList: { name: string, size: number }[];
|
||||
@Input() categoryList: Tag[];
|
||||
@Input() primaryData: { id: number, type: boolean, tags: string, category: string, url?: string };
|
||||
@Output() submitEvent = new EventEmitter<{ id: number, type: boolean, tags: string, category: string, url?: string }>();
|
||||
@Input() categoryList: Category[];
|
||||
@Input() primaryData: { id: number, type: boolean, tags: string[], category: string, url?: string };
|
||||
@Output() submitEvent = new EventEmitter<{ id: number, type: boolean, tags: string[], category: string, url?: string }>();
|
||||
|
||||
formGroup: FormGroup;
|
||||
tagTmpList: string[] = [];
|
||||
@@ -36,8 +36,8 @@ export class PublishFormComponent implements OnInit {
|
||||
if (this.primaryData) {
|
||||
this.formGroup.get('type').setValue(this.primaryData.type);
|
||||
const tags = this.primaryData.tags;
|
||||
this.formGroup.get('tagList').setValue(tags ? this.primaryData.tags.split(',') : tags);
|
||||
this.tagTmpList = tags ? this.primaryData.tags.split(',') : [...tags];
|
||||
this.formGroup.get('tagList').setValue(tags);
|
||||
this.tagTmpList = tags;
|
||||
this.formGroup.get('category').setValue(this.primaryData.category);
|
||||
this.formGroup.get('url').setValue(this.primaryData.url);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export class PublishFormComponent implements OnInit {
|
||||
const formData = {
|
||||
id: this.formGroup.value.isUpdate ? this.primaryData.id : null,
|
||||
type: this.formGroup.value.type,
|
||||
tags: this.formGroup.value.tagList.toString(),
|
||||
tags: this.formGroup.value.tagList,
|
||||
category: this.formGroup.value.category,
|
||||
url: this.formGroup.value.type ? null : this.formGroup.value.url
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ export class WriteComponent implements OnInit {
|
||||
});
|
||||
this.apiService.categories().subscribe({
|
||||
next: data => {
|
||||
this.categoryList = data.result;
|
||||
this.categoryList = data.result.list;
|
||||
},
|
||||
error: err => {
|
||||
this.message.error('获取分类信息失败');
|
||||
@@ -109,17 +109,19 @@ export class WriteComponent implements OnInit {
|
||||
/**
|
||||
* 文章数据提交
|
||||
*/
|
||||
publishArticle(e: { id: number, type: boolean, tags: string, category: string, url?: string }) {
|
||||
publishArticle(e: { id: number, type: boolean, tags: string[], category: string, url?: string }) {
|
||||
this.article.type = e.type;
|
||||
this.article.tags = e.tags;
|
||||
this.article.category = e.category;
|
||||
this.article.url = e.url;
|
||||
this.article.id = e.id;
|
||||
|
||||
if (!this.article.id && this.title === this.article.title) {
|
||||
this.message.error('文章标题未经更改,请修改后再发布');
|
||||
return;
|
||||
}
|
||||
this.modalVisible = false;
|
||||
|
||||
// if (!this.article.id && this.title === this.article.title) {
|
||||
// this.message.error('文章标题未经更改,请修改后再发布');
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 文章 暂存
|
||||
localStorage.setItem('tmpArticle', JSON.stringify(this.article));
|
||||
@@ -182,7 +184,9 @@ export class WriteComponent implements OnInit {
|
||||
next: data => {
|
||||
this.article.category = data.result.category;
|
||||
this.article.mdContent = data.result.mdContent;
|
||||
this.article.tags = String(data.result.tags);
|
||||
const tags = []
|
||||
data.result.tags.forEach(t => tags.push(t.name))
|
||||
this.article.tags = tags;
|
||||
this.article.type = data.result.original;
|
||||
this.article.url = data.result.url;
|
||||
this.article.title = data.result.title;
|
||||
|
||||
Reference in New Issue
Block a user