产品课程联调

master
yujialong 5 months ago
parent 23be87ae7f
commit 26b4ae8a1a
  1. 227
      src/pages/article/add/product.vue

@ -78,7 +78,7 @@
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
<template v-if="form.articleTemplate === 78"> <template v-if="form.articleTemplate === 79">
<div class="item-line"> <div class="item-line">
<el-form-item label="匹配课程" prop="matchedCourses"> <el-form-item label="匹配课程" prop="matchedCourses">
<el-input placeholder="请输入匹配课程" v-model="form.matchedCourses" maxlength="30"></el-input> <el-input placeholder="请输入匹配课程" v-model="form.matchedCourses" maxlength="30"></el-input>
@ -119,7 +119,56 @@
<el-form-item label="简介" prop="introduction"> <el-form-item label="简介" prop="introduction">
<el-input style="width: 940px;" v-model="form.introduction" type="textarea" maxlength="200"></el-input> <el-input style="width: 940px;" v-model="form.introduction" type="textarea" maxlength="200"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="detailedDescription" label="详情">
<!-- 模板选择了链接才显示这块 -->
<template v-if="form.articleTemplate === 24">
<el-form-item prop="connectionType" label="连接类型">
<el-radio-group v-model="form.connectionType">
<el-radio :label="1">站内链接</el-radio>
<el-radio :label="2">站外链接</el-radio>
<el-radio :label="3">其他站点链接</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="form.connectionType === 1">
<el-form-item label="站内链接">
<el-cascader v-model="links" :options="columns" :props="columnProps" clearable
@change="getArticle"></el-cascader>
</el-form-item>
<el-form-item label="文章">
<el-select v-model="article" clearable>
<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="form.connectionType === 2" prop="linkAddress" label="站外链接">
<el-input placeholder="请输入站外链接" v-model.trim="form.linkAddress" clearable></el-input>
</el-form-item>
<template v-if="form.connectionType === 3">
<el-form-item prop="siteSelection" label="站点选择">
<el-select v-model="form.siteSelection" @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 v-model="otherLink" :options="otherColumns" :props="columnProps" clearable
@change="getArticle"></el-cascader>
</el-form-item>
<el-form-item label="文章">
<el-select v-model="otherArticle" clearable>
<el-option v-for="item in otherArticles" :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="form.isOpen" :active-value="1" :inactive-value="0">
</el-switch>
</el-form-item>
</template>
<el-form-item v-else prop="detailedDescription" label="详情">
<Editor api-key='rnk6zw9v267xqz7pf98twt1vmrvltmd436je7a642pckltda' v-model="form.detailedDescription" <Editor api-key='rnk6zw9v267xqz7pf98twt1vmrvltmd436je7a642pckltda' v-model="form.detailedDescription"
:init="editorConfig" /> :init="editorConfig" />
</el-form-item> </el-form-item>
@ -213,8 +262,8 @@ export default {
categories: [], categories: [],
detailStyle: [ detailStyle: [
{ {
id: 78, id: 79,
style: '产品详情' style: '产品、课程详情'
}, },
{ {
id: 72, id: 72,
@ -224,11 +273,21 @@ export default {
id: 24, id: 24,
style: '链接' style: '链接'
}, },
{
id: 79,
style: '课程详情'
},
], ],
sites: [],
columns: [],
articles: [],
otherArticles: [],
columnProps: {
checkStrictly: true,
value: 'id',
label: 'columnName'
},
links: [],
article: '',
otherColumns: [],
otherLink: [],
otherArticle: '',
subjectList: [], // subjectList: [], //
form: { form: {
siteId: this.$store.state.content.site.id, siteId: this.$store.state.content.site.id,
@ -259,6 +318,10 @@ export default {
majorId: 1, majorId: 1,
} }
], ],
connectionType: 1,
linkAddress: '',
siteSelection: '',
isOpen: 1,
}, },
rules: { rules: {
name: [ name: [
@ -276,6 +339,9 @@ export default {
detailedDescription: [ detailedDescription: [
{ required: true, message: '请输入正文', trigger: 'blur' } { required: true, message: '请输入正文', trigger: 'blur' }
], ],
connectionType: [
{ required: true, message: '请选择连接类型', trigger: 'blur' }
],
}, },
columnInfo: {}, columnInfo: {},
editorConfig, editorConfig,
@ -368,44 +434,121 @@ export default {
name: this.$route.query.id ? '编辑' : '新增' name: this.$route.query.id ? '编辑' : '新增'
} }
]) ])
this.form.id && this.getData() this.form.id ? this.getData() : this.getColumnDetail()
this.getSubject() this.getSubject()
this.getSite()
this.getColumn()
this.getClassification() this.getClassification()
this.getLabel() this.getLabel()
}, },
methods: { methods: {
// //
getData () { async getData () {
this.$post(`${this.api.productDetailsFind}?id=${this.form.id}`).then(({ data }) => { const { data } = await this.$post(`${this.api.productDetailsFind}?id=${this.form.id}`)
data.categoryId = data.categoryId ? data.categoryId.split(',').map(e => +e) : [] data.categoryId = data.categoryId ? data.categoryId.split(',').map(e => +e) : []
if (data.classificationTagId) data.classificationTagId = +data.classificationTagId if (data.classificationTagId) data.classificationTagId = +data.classificationTagId
this.originalName = data.name this.originalName = data.name
// let lableData = [] this.getColumnDetail()
// data.categoryId.forEach(item => { //
// this.categories.forEach(options => { data.subjectSpecialtyList && data.subjectSpecialtyList.map(e => {
// if (item == options.id) { e.subjectCategoryId !== 1 && this.getProfessionalClassData(e)
// lableData.push(item) e.professionalCategoryId !== 1 && this.getProfessionalData(e)
// } })
// })
// }) this.form = data
// data.categoryId = lableData
this.getColumn() //
data.subjectSpecialtyList && data.subjectSpecialtyList.map(e => { if (data.articleTemplate === 24 && data.connectionType !== 2 && data.linkAddress) {
e.subjectCategoryId !== 1 && this.getProfessionalClassData(e) const columnArticle = data.linkAddress.split('-')
e.professionalCategoryId !== 1 && this.getProfessionalData(e) const column = columnArticle[0].split(',').map(e => +e)
const article = columnArticle[1] || '' // ididlinkAddress-
const { connectionType } = data
//
const res = await this.$post(this.api.queryArticle, {
siteId: connectionType === 1 ? this.site.id : data.siteSelection,
columnIds: [column[column.length - 1]], // ididid
pageNum: 1,
pageSize: 1000,
title: '',
isDisable: 0
}) })
console.log("🚀 ~ this.$post ~ data:", data) this[connectionType === 1 ? 'articles' : 'otherArticles'] = res.data.records
this.form = data // /
}).catch(err => { }) if (connectionType === 1) {
this.links = column
this.form.linkAddress = ''
if (article) this.article = +article
} else if (connectionType === 3) {
this.otherLink = column
this.form.linkAddress = ''
if (article) this.otherArticle = +article
}
data.siteSelection && this.getOtherColumn()
}
},
//
async getSite () {
const { data } = await this.$post(this.api.site, {
page: 1,
limit: 1000,
siteName: ''
})
data.records.splice(data.records.findIndex(e => e.id == this.site.id), 1) //
this.sites = data.records
},
//
async getColumn () {
const { data } = await this.$post(this.api.listWithTree, {
siteId: this.site.id,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
})
this.columns = data
},
//
async getOtherColumn (val) {
const { data } = await this.$post(this.api.listWithTree, {
siteId: this.form.siteSelection,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
})
if (val) {
this.otherArticles = []
this.otherArticle = ''
this.otherLink = ''
}
this.otherColumns = data
},
//
async getArticle () {
// /
const inner = this.form.connectionType === 1
const id = inner ? this.links[this.links.length - 1] : this.otherLink[this.otherLink.length - 1]
this[inner ? 'article' : 'otherArticle'] = ''
const { data } = await this.$post(this.api.queryArticle, {
siteId: inner ? this.site.id : this.form.siteSelection,
columnIds: [id],
pageNum: 1,
pageSize: 1000,
title: '',
isDisable: 0
})
this[inner ? 'articles' : 'otherArticles'] = data.records.filter(e => e.isRelease) //
}, },
// //
getColumn () { getColumnDetail () {
this.$post(`${this.api.findColumn}?id=${this.$route.query.columnId}`).then(({ data }) => { this.$post(`${this.api.findColumn}?id=${this.$route.query.columnId}`).then(({ data }) => {
this.columnInfo = data this.columnInfo = data
const { form } = this const { form } = this
// /78 // /79
if (!form.templateStatus) { if (!form.templateStatus) {
form.articleTemplate = (data.typeId === 1 || data.typeId === 4) ? data.detailStyleId : 78 form.articleTemplate = (data.typeId === 1 || data.typeId === 4) ? data.detailStyleId : 79
} }
this.$nextTick(() => { this.$nextTick(() => {
@ -774,10 +917,26 @@ export default {
// //
if (publishStatus) { if (publishStatus) {
if (!form.coverImageUrl) return Util.errorMsg('请上传封面') if (!form.coverImageUrl) return Util.errorMsg('请上传封面')
if (!form.coverImageUrl) return Util.errorMsg('请上传封面')
const tId = form.articleTemplate
if (tId === 24 && form.connectionType !== 2) {
if (form.connectionType === 1) {
if (!this.links.length) return Util.errorMsg('请选择站内链接')
}
if (!this.otherLink.length && form.connectionType === 3) {
if (!this.otherLink.length) return Util.errorMsg('请选择栏目')
}
}
if (!form.source) return Util.errorMsg('请输入来源') if (!form.source) return Util.errorMsg('请输入来源')
} }
if (this.uploading) return Util.errorMsg('文件正在上传,请上传完成后再发布') if (this.uploading) return Util.errorMsg('文件正在上传,请上传完成后再发布')
if (form.connectionType === 1) {
form.linkAddress = this.links.join()
if (this.article) form.linkAddress += '-' + this.article
} else if (form.connectionType === 3) {
form.linkAddress = this.otherLink.join()
if (this.otherArticle) form.linkAddress += '-' + this.otherArticle
}
const { coverImageUrl } = form const { coverImageUrl } = form
const fileId = [] const fileId = []
// idurlid // idurlid

Loading…
Cancel
Save