|
|
|
@ -1,9 +1,16 @@ |
|
|
|
|
<template> |
|
|
|
|
<!-- 设置链接 --> |
|
|
|
|
<div> |
|
|
|
|
<el-dialog title="设置链接地址" :visible.sync="visible" width="500px" :close-on-click-modal="false" :before-close="close"> |
|
|
|
|
<el-form :model="data" class="model" label-width="120px"> |
|
|
|
|
<el-form-item prop="connectionType" label="连接类型"> |
|
|
|
|
<el-dialog title="设置链接地址" |
|
|
|
|
:visible.sync="visible" |
|
|
|
|
width="500px" |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
:before-close="close"> |
|
|
|
|
<el-form :model="data" |
|
|
|
|
class="model" |
|
|
|
|
label-width="120px"> |
|
|
|
|
<el-form-item prop="connectionType" |
|
|
|
|
label="连接类型"> |
|
|
|
|
<el-radio-group v-model="data.connectionType"> |
|
|
|
|
<!-- <el-radio :label="0">无</el-radio> --> |
|
|
|
|
<el-radio :label="1">站内链接</el-radio> |
|
|
|
@ -12,73 +19,72 @@ |
|
|
|
|
</el-radio-group> |
|
|
|
|
</el-form-item> |
|
|
|
|
<template v-if="data.connectionType === 1"> |
|
|
|
|
<el-form-item label="站内链接"> |
|
|
|
|
<el-cascader |
|
|
|
|
ref="column" |
|
|
|
|
v-model="data.columnId" |
|
|
|
|
:options="columns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
@change="columnChange"></el-cascader> |
|
|
|
|
<el-form-item label="栏目"> |
|
|
|
|
<el-cascader ref="column" |
|
|
|
|
v-model="data.columnId" |
|
|
|
|
:options="columns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
@change="columnChange"></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="文章"> |
|
|
|
|
<el-select v-model="data.articleId"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in articles" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.title" |
|
|
|
|
:value="item.id"> |
|
|
|
|
<el-option v-for="item in articles" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.title" |
|
|
|
|
:value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</template> |
|
|
|
|
<el-form-item v-show="data.connectionType === 2" prop="linkAddress" label="站外链接"> |
|
|
|
|
<el-input |
|
|
|
|
placeholder="请输入站外链接" |
|
|
|
|
v-model.trim="data.linkAddress" |
|
|
|
|
clearable |
|
|
|
|
></el-input> |
|
|
|
|
<el-form-item v-show="data.connectionType === 2" |
|
|
|
|
prop="linkAddress" |
|
|
|
|
label="站外链接"> |
|
|
|
|
<el-input placeholder="请输入站外链接" |
|
|
|
|
v-model.trim="data.linkAddress" |
|
|
|
|
clearable></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<template v-if="data.connectionType === 3"> |
|
|
|
|
<el-form-item prop="site" label="站点选择"> |
|
|
|
|
<el-select v-model="data.site" @change="getOtherColumn"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in sites" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.siteName" |
|
|
|
|
:value="item.id"> |
|
|
|
|
<el-form-item prop="site" |
|
|
|
|
label="站点选择"> |
|
|
|
|
<el-select v-model="data.site" |
|
|
|
|
@change="getOtherColumn"> |
|
|
|
|
<el-option v-for="item in sites" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.siteName" |
|
|
|
|
:value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="栏目"> |
|
|
|
|
<el-cascader |
|
|
|
|
ref="otherColumn" |
|
|
|
|
v-model="data.otherColumnId" |
|
|
|
|
:options="otherColumns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
@change="columnChange"></el-cascader> |
|
|
|
|
<el-cascader ref="otherColumn" |
|
|
|
|
v-model="data.otherColumnId" |
|
|
|
|
:options="otherColumns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
@change="columnChange"></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="文章"> |
|
|
|
|
<el-select v-model="data.otherArticleId"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in articles" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.title" |
|
|
|
|
:value="item.id"> |
|
|
|
|
<el-option v-for="item in articles" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.title" |
|
|
|
|
:value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</template> |
|
|
|
|
<el-form-item prop="isOpen" label="新窗口打开"> |
|
|
|
|
<el-switch |
|
|
|
|
v-model="data.isOpen" |
|
|
|
|
:active-value="1" |
|
|
|
|
:inactive-value="0"> |
|
|
|
|
<el-form-item prop="isOpen" |
|
|
|
|
label="新窗口打开"> |
|
|
|
|
<el-switch v-model="data.isOpen" |
|
|
|
|
:active-value="1" |
|
|
|
|
:inactive-value="0"> |
|
|
|
|
</el-switch> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<span slot="footer" |
|
|
|
|
class="dialog-footer"> |
|
|
|
|
<el-button @click="$emit('update:visible', false)">取消</el-button> |
|
|
|
|
<el-button type="primary" @click="linkSubmit">确定</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
@click="linkSubmit">确定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</div> |
|
|
|
@ -95,7 +101,7 @@ export default { |
|
|
|
|
required: true |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
site: this.$store.state.content.site, |
|
|
|
|
sites: [], |
|
|
|
@ -110,7 +116,7 @@ export default { |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
visible(open) { |
|
|
|
|
visible (open) { |
|
|
|
|
// 每次打开的时候处理参数 |
|
|
|
|
if (open) { |
|
|
|
|
this.data.connectionType !== 2 && this.getArticle() |
|
|
|
@ -118,40 +124,40 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
mounted () { |
|
|
|
|
this.getList() |
|
|
|
|
this.getSite() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 栏目列表 |
|
|
|
|
getList() { |
|
|
|
|
getList () { |
|
|
|
|
this.$post(this.api.listWithTree, { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
siteId: this.site.id, |
|
|
|
|
columnName: '', |
|
|
|
|
templateId: '', |
|
|
|
|
typeId : '', |
|
|
|
|
typeId: '', |
|
|
|
|
isSort: 1 |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.columns = data |
|
|
|
|
this.data.connectionType !== 2 && this.getArticle() |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}).catch(err => { }) |
|
|
|
|
}, |
|
|
|
|
// 给当前栏目加上disabled禁止选中 |
|
|
|
|
handleId(list) { |
|
|
|
|
handleId (list) { |
|
|
|
|
list.forEach(e => { |
|
|
|
|
if (e.id == this.id) e.disabled = true |
|
|
|
|
if (e.id == this.id) e.disabled = true |
|
|
|
|
e.children.length ? this.handleId(e.children) : delete e.children |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 栏目选择回调 |
|
|
|
|
columnChange() { |
|
|
|
|
columnChange () { |
|
|
|
|
this.data.articleId = '' |
|
|
|
|
this.getArticle() |
|
|
|
|
}, |
|
|
|
|
// 文章列表 |
|
|
|
|
getArticle() { |
|
|
|
|
getArticle () { |
|
|
|
|
// 站内链接/其他站点链接 |
|
|
|
|
const id = this.data.connectionType === 1 ? this.data.columnId[this.data.columnId.length - 1] : this.data.otherColumnId[this.data.otherColumnId.length - 1] |
|
|
|
|
id && this.$post(this.api.queryArticle, { |
|
|
|
@ -163,42 +169,41 @@ export default { |
|
|
|
|
isDisable: 0 |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.articles = data.records.filter(e => e.isRelease) // 只显示已发布的文章 |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}).catch(err => { }) |
|
|
|
|
}, |
|
|
|
|
// 获取站点列表 |
|
|
|
|
getSite() { |
|
|
|
|
getSite () { |
|
|
|
|
this.$post(this.api.site, { |
|
|
|
|
page: 1, |
|
|
|
|
limit: 1000, |
|
|
|
|
siteName: '' |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.sites = data.records |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
}).catch(e => { }) |
|
|
|
|
}, |
|
|
|
|
// 获取指定站点的栏目列表 |
|
|
|
|
getOtherColumn() { |
|
|
|
|
getOtherColumn () { |
|
|
|
|
this.data.site && this.$post(this.api.listWithTree, { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
siteId: this.data.site, |
|
|
|
|
columnName: '', |
|
|
|
|
templateId: '', |
|
|
|
|
typeId : '', |
|
|
|
|
typeId: '', |
|
|
|
|
isSort: 1 |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.otherColumns = data |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}).catch(err => { }) |
|
|
|
|
}, |
|
|
|
|
close() { |
|
|
|
|
close () { |
|
|
|
|
this.$emit('update:visible', false) |
|
|
|
|
}, |
|
|
|
|
// 链接设置提交 |
|
|
|
|
linkSubmit() { |
|
|
|
|
linkSubmit () { |
|
|
|
|
this.$emit('linkSubmit') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|
|
|
|
|
|
</style> |