|
|
|
@ -44,8 +44,7 @@ |
|
|
|
|
ref="column" |
|
|
|
|
v-model="form.columnId" |
|
|
|
|
:options="columns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
clearable></el-cascader> |
|
|
|
|
:props="columnProps"></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 25" prop="classificationId" label="所属分类"> |
|
|
|
|
<el-select style="width: 234px;" v-model="form.classificationId"> |
|
|
|
@ -120,7 +119,7 @@ |
|
|
|
|
></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
</div> |
|
|
|
|
<div v-if="form.articleTemplate === 22" class="item-line"> |
|
|
|
|
<div v-if="form.articleTemplate === 22 || form.articleTemplate === 23" class="item-line"> |
|
|
|
|
<el-form-item prop="edit" label="编辑"> |
|
|
|
|
<el-input |
|
|
|
|
placeholder="请输入编辑" |
|
|
|
@ -170,7 +169,7 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<div v-if="form.articleTemplate === 22" class="item-line"> |
|
|
|
|
<div v-if="form.articleTemplate === 22 || form.articleTemplate === 23" class="item-line"> |
|
|
|
|
<el-form-item prop="source" label="所属分类"> |
|
|
|
|
<el-select style="width: 234px;" v-model="form.classificationId"> |
|
|
|
|
<template v-for="item in classifications"> |
|
|
|
@ -198,7 +197,7 @@ |
|
|
|
|
<el-button class="set-btn" type="primary" @click="setLabel">设置</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
</div> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22" prop="summary" label="摘要"> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22 || form.articleTemplate === 23" prop="summary" label="摘要"> |
|
|
|
|
<el-input |
|
|
|
|
style="width: 940px" |
|
|
|
|
type="textarea" |
|
|
|
@ -223,7 +222,7 @@ |
|
|
|
|
</div> |
|
|
|
|
</el-upload> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="bannerImg" label="Banner图(选填)" style="flex: 1;"> |
|
|
|
|
<el-form-item v-if="form.articleTemplate !== 23" prop="bannerImg" label="Banner图(选填)" style="flex: 1;"> |
|
|
|
|
<el-upload |
|
|
|
|
class="avatar-uploader avatar-uploader-lg" |
|
|
|
|
accept=".jpg,.png,.jpeg,.gif" |
|
|
|
@ -239,15 +238,16 @@ |
|
|
|
|
</div> |
|
|
|
|
</el-upload> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22 || form.articleTemplate === 25" prop="mainBody" label="正文"> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22 || form.articleTemplate === 23 || form.articleTemplate === 25" prop="mainBody" label="正文"> |
|
|
|
|
<Editor api-key='rnk6zw9v267xqz7pf98twt1vmrvltmd436je7a642pckltda' v-model="form.mainBody" :init="editorConfig" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22 || form.articleTemplate === 25" prop="file" label="文件上传"> |
|
|
|
|
<el-form-item v-if="form.articleTemplate === 22 || form.articleTemplate === 23 || form.articleTemplate === 25" prop="file" label="文件上传"> |
|
|
|
|
<el-upload |
|
|
|
|
:before-upload="fileBeforeUpload" |
|
|
|
|
:on-remove="handleRemove" |
|
|
|
|
:on-success="uploadSuccessFile" |
|
|
|
|
:action="this.api.upload" |
|
|
|
|
:file-list="fileList" |
|
|
|
|
:file-list="form.fileList" |
|
|
|
|
:data="{ |
|
|
|
|
quote: form.title, |
|
|
|
|
site: site.siteName, |
|
|
|
@ -281,19 +281,19 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
<template v-if="form.connectionType === 3"> |
|
|
|
|
<el-form-item prop="siteSelection" label="站点选择"> |
|
|
|
|
<el-select v-model="form.siteSelection"> |
|
|
|
|
<el-select v-model="form.siteSelection" @change="getOtherColumn"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in sites" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:label="item.siteName" |
|
|
|
|
:value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="栏目"> |
|
|
|
|
<el-cascader |
|
|
|
|
v-model="links" |
|
|
|
|
:options="columns" |
|
|
|
|
v-model="otherLink" |
|
|
|
|
:options="otherColumns" |
|
|
|
|
:props="columnProps" |
|
|
|
|
clearable></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
@ -385,7 +385,6 @@ |
|
|
|
|
<script> |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import util from '@/libs/util' |
|
|
|
|
import ColumnConst from '@/const/column' |
|
|
|
|
import { mapState } from 'vuex' |
|
|
|
|
import Editor from '@tinymce/tinymce-vue' |
|
|
|
|
import editorConfig from './editor' |
|
|
|
@ -397,7 +396,9 @@ export default { |
|
|
|
|
site: this.$store.state.content.site, |
|
|
|
|
userId: this.$store.state.user.userId, |
|
|
|
|
nameRepeat: false, |
|
|
|
|
sites: ColumnConst.sites, |
|
|
|
|
sites: [], |
|
|
|
|
otherColumns: [], |
|
|
|
|
otherLink: [], |
|
|
|
|
detailStyle: [], |
|
|
|
|
columns: [], |
|
|
|
|
columnProps: { |
|
|
|
@ -436,7 +437,6 @@ export default { |
|
|
|
|
isRelease: 0, |
|
|
|
|
mainBody: '', |
|
|
|
|
releaseTime: new Date(), |
|
|
|
|
// releaseTime: '', |
|
|
|
|
source: '', |
|
|
|
|
summary : '', |
|
|
|
|
title: '', |
|
|
|
@ -444,6 +444,7 @@ export default { |
|
|
|
|
connectionType : 1, |
|
|
|
|
linkAddress: '', |
|
|
|
|
siteSelection: 1, |
|
|
|
|
fileList: [] |
|
|
|
|
}, |
|
|
|
|
rules: { |
|
|
|
|
title: [ |
|
|
|
@ -478,10 +479,10 @@ export default { |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
columnInfo: {}, |
|
|
|
|
fileList: [], |
|
|
|
|
editorConfig, |
|
|
|
|
submiting: false, // 新增编辑防抖标识 |
|
|
|
|
pass: false, |
|
|
|
|
uploading: 0, |
|
|
|
|
updateTime: 0, |
|
|
|
|
cropperModel: false, |
|
|
|
|
isUpload: false, |
|
|
|
@ -559,6 +560,7 @@ export default { |
|
|
|
|
]) |
|
|
|
|
this.getList() |
|
|
|
|
this.form.id ? this.getData() : this.getColumn() |
|
|
|
|
this.getSite() |
|
|
|
|
this.getLabel() |
|
|
|
|
this.getTemplate() |
|
|
|
|
}, |
|
|
|
@ -606,15 +608,25 @@ export default { |
|
|
|
|
// 获取文章详情 |
|
|
|
|
getData() { |
|
|
|
|
this.$post(`${this.api.findArticle}?id=${this.form.id}`).then(({ data }) => { |
|
|
|
|
data.lableId = data.lableId.split(',').map(e => +e) |
|
|
|
|
data.lableId = data.lableId ? data.lableId.split(',').map(e => +e) : [] |
|
|
|
|
if (data.activityStartTime && data.activityEndTime) data.time = [data.activityStartTime, data.activityEndTime] |
|
|
|
|
// 文件上传回显 |
|
|
|
|
if (data.fileList) { |
|
|
|
|
data.fileList.map(e => { |
|
|
|
|
e.name = e.fileName |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.form = data |
|
|
|
|
// if (data.articleTemplate === 3 && data.connectionType !== 2 && data.linkAddress) this.links = data.linkAddress.split(',').map(e => +e) |
|
|
|
|
// 链接回显 |
|
|
|
|
if (data.articleTemplate === 24 && data.connectionType !== 2 && data.linkAddress) { |
|
|
|
|
const links = data.linkAddress.split(',').map(e => +e) |
|
|
|
|
if (data.connectionType === 1) this.links = links |
|
|
|
|
if (data.connectionType === 3) this.otherLink = links |
|
|
|
|
data.linkAddress = '' |
|
|
|
|
} |
|
|
|
|
data.siteSelection && this.getOtherColumn() |
|
|
|
|
this.originalName = data.title |
|
|
|
|
this.getColumn() |
|
|
|
|
// const { file } = data |
|
|
|
|
// if (file) this.fileList = [{name: file, url: file}] // 文件上传回显 |
|
|
|
|
this.getFile() |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取栏目详情 |
|
|
|
@ -634,6 +646,28 @@ export default { |
|
|
|
|
this.getClassification() |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取站点列表 |
|
|
|
|
getSite() { |
|
|
|
|
this.$post(this.api.site, { |
|
|
|
|
page: 1, |
|
|
|
|
limit: 1000, |
|
|
|
|
siteName: '' |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.sites = data.records |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取指定站点的栏目列表 |
|
|
|
|
getOtherColumn() { |
|
|
|
|
this.$post(this.api.listWithTree, { |
|
|
|
|
siteId: this.form.siteSelection, |
|
|
|
|
columnName: '', |
|
|
|
|
templateId: '', |
|
|
|
|
typeId : '', |
|
|
|
|
isSort: 1 |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.otherColumns = data |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取所有模板 |
|
|
|
|
getTemplate() { |
|
|
|
|
this.$post(this.api.individualTemplateDetailsStyle).then(({ data }) => { |
|
|
|
@ -642,7 +676,6 @@ export default { |
|
|
|
|
result.find(n => n.style === e.style) || result.push(e) |
|
|
|
|
}) |
|
|
|
|
this.detailStyle = result |
|
|
|
|
console.log("🚀 ~ file: index.vue ~ line 642 ~ this.$post ~ data", result) |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取所属分类 |
|
|
|
@ -772,15 +805,6 @@ export default { |
|
|
|
|
this.nameRepeat = false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 获取附件 |
|
|
|
|
getFile() { |
|
|
|
|
this.$post(`${this.api.theAttachmentUnderTheQueryColumn}?contentId=${this.form.id}`).then(({ data }) => { |
|
|
|
|
data.map(e => { |
|
|
|
|
e.name = e.fileName |
|
|
|
|
}) |
|
|
|
|
this.fileList = data |
|
|
|
|
}).catch(err => {}) |
|
|
|
|
}, |
|
|
|
|
// 图片裁剪上传事件 |
|
|
|
|
customUpload(data) { |
|
|
|
|
const blob = this.dataURItoBlob(data) |
|
|
|
@ -880,9 +904,13 @@ export default { |
|
|
|
|
url && this.$del(this.api.delFile, [url.split('/').pop()]).then(res => {}).catch(e => {}) |
|
|
|
|
this.form.bannerImg = res.url |
|
|
|
|
}, |
|
|
|
|
// 附件上传之前的钩子 |
|
|
|
|
fileBeforeUpload(file) { |
|
|
|
|
this.uploading++ |
|
|
|
|
}, |
|
|
|
|
// 附件上传成功 |
|
|
|
|
uploadSuccessFile(res) { |
|
|
|
|
console.log("🚀 ~ file: index.vue ~ line 739 ~ handleRemove ~ e", res, this.fileList) |
|
|
|
|
this.uploading-- |
|
|
|
|
this.form.id ? |
|
|
|
|
this.$post(this.api.saveContentFile, { |
|
|
|
|
contentId: this.form.id, |
|
|
|
@ -892,20 +920,20 @@ export default { |
|
|
|
|
fileName: res.original, |
|
|
|
|
filePath: res.url |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
this.fileList.push({ |
|
|
|
|
this.form.fileList.push({ |
|
|
|
|
name: res.original, |
|
|
|
|
url: res.url, |
|
|
|
|
id: data |
|
|
|
|
}) |
|
|
|
|
}).catch(res => {}) : |
|
|
|
|
this.fileList.push({ |
|
|
|
|
this.form.fileList.push({ |
|
|
|
|
name: res.original, |
|
|
|
|
url: res.url |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 预览 |
|
|
|
|
preview() { |
|
|
|
|
window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136') + `/#/article?id=${this.form.id}&siteId=${this.form.siteId}`) |
|
|
|
|
window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136/front') + `/#/article?id=${this.form.id}&siteId=${this.form.siteId}`) |
|
|
|
|
}, |
|
|
|
|
// 返回 |
|
|
|
|
back() { |
|
|
|
@ -930,28 +958,46 @@ export default { |
|
|
|
|
const form = JSON.parse(JSON.stringify(this.form)) |
|
|
|
|
if (!form.title) return util.errorMsg('请填写标题') |
|
|
|
|
if (this.nameRepeat) return util.errorMsg('该标题已重复!') |
|
|
|
|
// if (!form.releaseTime && isRelease) return util.errorMsg('请选择发布日期') |
|
|
|
|
// if (!form.titleImg && isRelease) return util.errorMsg('请上传封面') |
|
|
|
|
if (typeof form.fatherId === 'object') form.fatherId = form.fatherId[form.fatherId.length - 1] |
|
|
|
|
// if (form.articleTemplate === 24 && form.connectionType !== 2) { |
|
|
|
|
// const { links } = this |
|
|
|
|
// if (!links.length && form.connectionType === 1 && isRelease) return util.errorMsg('请选择站内链接') |
|
|
|
|
// if (!links.length && form.connectionType === 3 && isRelease) return util.errorMsg('请选择栏目') |
|
|
|
|
// form.linkAddress = links.join() |
|
|
|
|
// } |
|
|
|
|
// if (((form.templateStatus && form.articleTemplate === 2) || !form.templateStatus) && !form.mainBody && isRelease) return util.errorMsg('请输入正文') |
|
|
|
|
if (form.articleTemplate === 25) { |
|
|
|
|
if (!form.time.length && isRelease) return util.errorMsg('请选择起止时间') |
|
|
|
|
form.activityStartTime = form.time[0] |
|
|
|
|
form.activityEndTime = form.time[1] |
|
|
|
|
const tId = form.articleTemplate |
|
|
|
|
// 如果是发布 |
|
|
|
|
if (isRelease) { |
|
|
|
|
if (tId !== 25) { |
|
|
|
|
if (!form.releaseTime) return util.errorMsg('请选择发布日期') |
|
|
|
|
} |
|
|
|
|
if (tId === 22 || tId === 23) { |
|
|
|
|
if (!form.titleImg ) return util.errorMsg('请上传封面') |
|
|
|
|
} |
|
|
|
|
if (tId === 25) { |
|
|
|
|
if (!form.time.length && isRelease) return util.errorMsg('请选择起止时间') |
|
|
|
|
form.activityStartTime = form.time[0] |
|
|
|
|
form.activityEndTime = form.time[1] |
|
|
|
|
} |
|
|
|
|
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 ((tId === 22 || tId === 23 || tId === 25) && !form.mainBody) return util.errorMsg('请输入正文') |
|
|
|
|
} |
|
|
|
|
if (this.uploading) return util.errorMsg('文件正在上传,请上传完成后再发布') |
|
|
|
|
if (form.connectionType === 1) { |
|
|
|
|
form.linkAddress = this.links.join() |
|
|
|
|
} else if (form.connectionType === 3) { |
|
|
|
|
form.linkAddress = this.otherLink.join() |
|
|
|
|
} |
|
|
|
|
const { columnId, bannerImg, file, titleImg } = form |
|
|
|
|
const { columnId, bannerImg, fileList, titleImg } = form |
|
|
|
|
const fileId = [] |
|
|
|
|
if (typeof columnId === 'object') form.columnId = columnId[columnId.length - 1] // 如果更换了栏目id,值会变成数组,需要手动获取最后一个 |
|
|
|
|
// 获取几个附件的id,url后面的数字串即是附件id |
|
|
|
|
if (bannerImg) fileId.push(bannerImg.substr(bannerImg.lastIndexOf('/') + 1)) |
|
|
|
|
if (file) fileId.push(file.substr(file.lastIndexOf('/') + 1)) |
|
|
|
|
if (titleImg) fileId.push(titleImg.substr(titleImg.lastIndexOf('/') + 1)) |
|
|
|
|
fileList && fileList.map(e => { |
|
|
|
|
e.url && fileId.push(e.url.substr(e.url.lastIndexOf('/') + 1)) |
|
|
|
|
}) |
|
|
|
|
form.lableId = form.lableId.join(',') |
|
|
|
|
// 更新附件的状态为发布 |
|
|
|
|
fileId.map(e => { |
|
|
|
@ -976,7 +1022,7 @@ export default { |
|
|
|
|
} else { |
|
|
|
|
this.$post(this.api.saveArticle, form).then(({ data }) => { |
|
|
|
|
// 新增文章完后需要把上传的附件添加到文章附件表 |
|
|
|
|
this.fileList.map(e => { |
|
|
|
|
form.fileList.map(e => { |
|
|
|
|
this.$post(this.api.saveContentFile, { |
|
|
|
|
contentId: data, |
|
|
|
|
editorId: this.userId, |
|
|
|
|