feat: 咨询管理代码审查
This commit is contained in:
1 parent
de50ca5f66
commit
aed501d308
2 files changed
+15
-21
No files matched your search
+3
-3
@@ -6,7 +6,7 @@ export const searchArticlesRequest = (articleFilterParam:ArticleSearchFilter ) =
|
||||
return httpClient.get<PageResult<Article>>('/articles',articleFilterParam)
|
||||
}
|
||||
|
||||
export const createArticlesRequest = (article: CreateArticleRequest) => {
|
||||
export const createArticle = (article: CreateArticleRequest) => {
|
||||
return httpClient.post<Article>('/articles',article)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export const searchArticlesByIdRequest = (id: string) => {
|
||||
return httpClient.get<Article>(`/articles/${id}`)
|
||||
}
|
||||
|
||||
export const updateArticlesByIdRequest = (id: string,article:CreateArticleRequest) => {
|
||||
export const updateArticle = (id: string, article:CreateArticleRequest) => {
|
||||
return httpClient.put<Article>(`/articles/${id}`,article)
|
||||
}
|
||||
|
||||
@@ -28,4 +28,4 @@ export const publishArticlesByIdRequest = (id: string,) => {
|
||||
|
||||
export const closeArticlesByIdRequest = (id: string,) => {
|
||||
return httpClient.put<Article>(`/articles/${id}/close`,)
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,12 @@ import type {
|
||||
TdSelectProps
|
||||
} from 'tdesign-vue-next'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { updateArticlesByIdRequest, createArticlesRequest } from '@/api/article'
|
||||
import { updateArticle, createArticle } from '@/api/article'
|
||||
import { searchCategories } from '@/api/category'
|
||||
const props = defineProps<{
|
||||
isEdit?: Boolean | null
|
||||
headerTitle?: String | null
|
||||
article?: Article | null
|
||||
categoryList: Category[] | []
|
||||
article: Article | null
|
||||
categoryList: Category[]
|
||||
}>()
|
||||
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||
const headerText = computed(() => `${props.article ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
@@ -92,27 +91,24 @@ const emit = defineEmits<{
|
||||
success: [void]
|
||||
onInputChange: [void]
|
||||
}>()
|
||||
const saveArticleData = async () => {
|
||||
if (formRef.value) {
|
||||
const handleSave = async () => {
|
||||
if (!formRef.value) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (valid && typeof valid === 'boolean') {
|
||||
if (valid === true) {
|
||||
if (props.article) {
|
||||
await updateArticlesByIdRequest(props.article.id, articleData)
|
||||
await updateArticle(props.article.id, articleData)
|
||||
} else {
|
||||
await createArticlesRequest(articleData)
|
||||
await createArticle(articleData)
|
||||
}
|
||||
MessagePlugin.success(`${props.isEdit ? '编辑' : '创建'}咨询成功`)
|
||||
MessagePlugin.success(`${props.article ? '编辑' : '创建'}咨询成功`)
|
||||
emit('success')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
const handleCloseDialog = () => {
|
||||
// 数据&&规则校验结果重置
|
||||
if (formRef.value) {
|
||||
if (!formRef.value) return
|
||||
formRef.value.reset()
|
||||
formRef.value.clearValidate()
|
||||
}
|
||||
}
|
||||
|
||||
const categoryOptions = ref<TdSelectProps['options']>([])
|
||||
@@ -138,7 +134,7 @@ fetchCategories('')
|
||||
:confirmBtn="confirmBtnText"
|
||||
:closeOnOverlayClick="false"
|
||||
@close="handleCloseDialog"
|
||||
@confirm="saveArticleData"
|
||||
@confirm="handleSave"
|
||||
>
|
||||
<t-space direction="vertical" style="width: 100%">
|
||||
<TForm ref="formRef" :data="articleData" :rules="rules" resetType="initial">
|
||||
@@ -154,9 +150,7 @@ fetchCategories('')
|
||||
@search="fetchCategories"
|
||||
/>
|
||||
</TFormItem>
|
||||
<TFormItem label="内容:" name="content">
|
||||
<TTextarea v-model="articleData.content"></TTextarea>
|
||||
</TFormItem>
|
||||
<TFormItem label="内容:" name="content"><TTextarea v-model="articleData.content"></TTextarea> </TFormItem>
|
||||
</TForm>
|
||||
</t-space>
|
||||
</t-dialog>
|
||||
|
||||
Reference in new issue
Block a user