<template>
|
<a-modal
|
title="编辑blog文章"
|
:width="900"
|
:visible="visible"
|
:confirmLoading="confirmLoading"
|
@ok="handleSubmit"
|
@cancel="handleCancel"
|
>
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
<a-form-item v-show="false"><a-input v-decorator="['id']" /></a-form-item>
|
<a-form-item
|
label="文章标题"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入文章标题" v-decorator="['title', {rules: [{required: true, message: '请输入文章标题!'}]}]" />
|
</a-form-item>
|
<a-form-item
|
label="文章文件id"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入文章文件id" v-decorator="['articleFileId', {rules: [{required: true, message: '请输入文章文件id!'}]}]" />
|
</a-form-item>
|
<a-form-item
|
label="文件类型"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-radio-group placeholder="请选择文件类型" v-decorator="['articleFileType']" >
|
<a-radio v-for="(item,index) in articleFileTypeData" :key="index" :value="item.code">{{ item.name }}</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
<a-form-item
|
label="文章分类"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入文章分类" v-decorator="['articleTypeId', {rules: [{required: true, message: '请输入文章分类!'}]}]" />
|
</a-form-item>
|
<a-form-item
|
label="文章引言"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-textarea placeholder="请输入文章引言" v-decorator="['introduce']" :auto-size="{ minRows: 3, maxRows: 6 }"/>
|
</a-form-item>
|
<a-form-item
|
label="封面文件"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入封面文件" v-decorator="['coverFileId']" />
|
</a-form-item>
|
<a-form-item
|
label="是否置顶"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-select style="width: 100%" placeholder="请选择是否置顶" v-decorator="['isTop', {rules: [{ required: true, message: '请选择是否置顶!' }]}]">
|
<a-select-option v-for="(item,index) in isTopData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
|
</a-select>
|
</a-form-item>
|
<a-form-item
|
label="置顶值"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入置顶值" v-decorator="['topValue']" />
|
</a-form-item>
|
<a-form-item
|
label="公开状态"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-radio-group placeholder="请选择公开状态" v-decorator="['authStatus']" >
|
<a-radio v-for="(item,index) in authStatusData" :key="index" :value="item.code">{{ item.name }}</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
<a-form-item
|
label="授权密码"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入授权密码" v-decorator="['authPassword']" />
|
</a-form-item>
|
<a-form-item
|
label="编辑状态"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
>
|
<a-radio-group placeholder="请选择编辑状态" v-decorator="['editorStatus']" >
|
<a-radio v-for="(item,index) in editorStatusData" :key="index" :value="item.code">{{ item.name }}</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
<a-form-item
|
label="是否启用"
|
:labelCol="labelCol"
|
:wrapperCol="wrapperCol"
|
has-feedback
|
>
|
<a-input placeholder="请输入是否启用" v-decorator="['isEnable']" />
|
</a-form-item>
|
</a-form>
|
</a-spin>
|
</a-modal>
|
</template>
|
|
<script>
|
import { blogArticleEdit } from '@/api/modular/main/blogarticle/blogArticleManage'
|
export default {
|
data () {
|
return {
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 15 }
|
},
|
articleFileTypeData: [],
|
isTopData: [],
|
authStatusData: [],
|
editorStatusData: [],
|
visible: false,
|
confirmLoading: false,
|
form: this.$form.createForm(this)
|
}
|
},
|
methods: {
|
// 初始化方法
|
edit (record) {
|
this.visible = true
|
const articleFileTypeOption = this.$options
|
this.articleFileTypeData = articleFileTypeOption.filters['dictData']('blog_file_type')
|
const isTopOption = this.$options
|
this.isTopData = isTopOption.filters['dictData']('blog_yes_or_no')
|
const authStatusOption = this.$options
|
this.authStatusData = authStatusOption.filters['dictData']('blog_auth_status')
|
const editorStatusOption = this.$options
|
this.editorStatusData = editorStatusOption.filters['dictData']('blog_editor_status')
|
setTimeout(() => {
|
this.form.setFieldsValue(
|
{
|
id: record.id,
|
title: record.title,
|
articleFileId: record.articleFileId,
|
articleFileType: record.articleFileType,
|
articleTypeId: record.articleTypeId,
|
introduce: record.introduce,
|
coverFileId: record.coverFileId,
|
isTop: record.isTop,
|
topValue: record.topValue,
|
authStatus: record.authStatus,
|
authPassword: record.authPassword,
|
editorStatus: record.editorStatus,
|
isEnable: record.isEnable
|
}
|
)
|
}, 100)
|
},
|
handleSubmit () {
|
const { form: { validateFields } } = this
|
this.confirmLoading = true
|
validateFields((errors, values) => {
|
if (!errors) {
|
for (const key in values) {
|
if (typeof (values[key]) === 'object' && values[key] != null) {
|
values[key] = JSON.stringify(values[key])
|
}
|
}
|
blogArticleEdit(values).then((res) => {
|
if (res.success) {
|
this.$message.success('编辑成功')
|
this.confirmLoading = false
|
this.$emit('ok', values)
|
this.handleCancel()
|
} else {
|
this.$message.error('编辑失败')// + res.message
|
}
|
}).finally((res) => {
|
this.confirmLoading = false
|
})
|
} else {
|
this.confirmLoading = false
|
}
|
})
|
},
|
handleCancel () {
|
this.form.resetFields()
|
this.visible = false
|
}
|
}
|
}
|
</script>
|