<template>
|
<a-modal title="新增友情链接" :width="900" :visible="visible" :confirmLoading="confirmLoading" @ok="handleSubmit"
|
@cancel="handleCancel">
|
<a-spin :spinning="confirmLoading">
|
<a-form :form="form">
|
<a-form-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
<a-input placeholder="请输入名称" v-decorator="['name', {rules: [{required: true, message: '请输入名称!'}]}]" />
|
</a-form-item>
|
<a-form-item label="url地址" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
<a-input placeholder="请输入url地址" v-decorator="['url', {rules: [{required: true, message: '请输入url地址!'}]}]" />
|
</a-form-item>
|
<a-form-item label="头像地址" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
<a-input placeholder="请输入头像地址"
|
v-decorator="['avatar', {rules: [{required: false, message: '请输入头像地址!'}]}]" />
|
</a-form-item>
|
<a-form-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
<a-input placeholder="请输入描述" v-decorator="['remark', {rules: [{required: false, message: '请输入描述!'}]}]" />
|
</a-form-item>
|
<a-form-item label="链接类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-radio-group placeholder="请选择链接类型"
|
v-decorator="['linkType',{rules: [{ required: true, message: '请选择链接类型!' }]}]">
|
<a-radio v-for="(item,index) in linkTypeData" :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="['topValue', {rules: [{required: true, message: '请输入权重!'}]}]" />
|
</a-form-item>
|
<a-form-item label="是否新窗口打开" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-radio-group placeholder="请选择是否新窗口打开"
|
v-decorator="['isNewWindowOpen',{rules: [{ required: true, message: '请选择是否新窗口打开!' }]}]">
|
<a-radio v-for="(item,index) in isNewWindowOpenData" :key="index" :value="item.code">{{ item.name }}
|
</a-radio>
|
</a-radio-group>
|
</a-form-item>
|
</a-form>
|
</a-spin>
|
</a-modal>
|
</template>
|
|
<script>
|
import {
|
blogFriendshipLinkAdd
|
} from '@/api/modular/main/blogfriendshiplink/blogFriendshipLinkManage'
|
export default {
|
data() {
|
return {
|
labelCol: {
|
xs: {
|
span: 24
|
},
|
sm: {
|
span: 5
|
}
|
},
|
wrapperCol: {
|
xs: {
|
span: 24
|
},
|
sm: {
|
span: 15
|
}
|
},
|
linkTypeData: [],
|
isNewWindowOpenData: [],
|
visible: false,
|
confirmLoading: false,
|
form: this.$form.createForm(this)
|
}
|
},
|
methods: {
|
// 初始化方法
|
add(record) {
|
this.visible = true
|
const linkTypeOption = this.$options
|
this.linkTypeData = linkTypeOption.filters['dictData']('blog_link_type')
|
const isNewWindowOpenOption = this.$options
|
this.isNewWindowOpenData = isNewWindowOpenOption.filters['dictData']('blog_yes_or_no')
|
},
|
/**
|
* 提交表单
|
*/
|
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])
|
}
|
}
|
blogFriendshipLinkAdd(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>
|