yujialong 2 years ago
parent 9fef54b793
commit 088dc619a4
  1. 19
      src/libs/util.js
  2. 5
      src/mixins/page/index.js
  3. 150
      src/pages/article/add/index.vue
  4. 4
      src/pages/article/list/index.vue
  5. 5
      src/pages/column/add/index.vue
  6. 6
      src/pages/column/list/index.vue
  7. 1
      src/plugins/requests/index.js

@ -175,25 +175,6 @@ const util = {
Message.closeAll(); Message.closeAll();
return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration });
}, },
// 登录互踢
getToken() {
if (process.env.NODE_ENV != "production") {
if (store.state.user.dataTime && !logout) {
axios.get(`${api.queryToken}?token=${_local.get(Setting.tokenKey)}`).then(res => {
if (store.state.user.dataTime && (res.data.message != store.state.user.dataTime)) {
logout || Message.error("您已在另一台设备登录,本次登录已下线!");
logout = true;
setTimeout(() => {
_local.remove(Setting.storeKey);
_local.remove(Setting.tokenKey);
location.reload();
}, 1500);
}
}).catch(err => {
});
}
}
},
debounce(fn, delay) { // 防抖 debounce(fn, delay) { // 防抖
let timeout = null; let timeout = null;
return function() { return function() {

@ -9,7 +9,6 @@ export default {
userId: +this.$store.state.user.userId, userId: +this.$store.state.user.userId,
site: this.$store.state.content.site, site: this.$store.state.content.site,
columnId: +this.$route.query.id, columnId: +this.$route.query.id,
listStyleId: +this.$route.query.listStyleId,
id: '', id: '',
diaVisible: false, diaVisible: false,
curModule: 0, curModule: 0,
@ -45,7 +44,6 @@ export default {
if (form && form.link && !form.link.site) form.link.site = siteId if (form && form.link && !form.link.site) form.link.site = siteId
if (form && type === 'column' && !form.site) form.site = siteId if (form && type === 'column' && !form.site) form.site = siteId
}) })
console.log(555, this.modules)
// 查询页面详情 // 查询页面详情
this.$post(`${this.api.findPage}?columnId=${this.columnId}`).then(({ data }) => { this.$post(`${this.api.findPage}?columnId=${this.columnId}`).then(({ data }) => {
if (data.length) { if (data.length) {
@ -102,8 +100,7 @@ export default {
json: this.handleJson() json: this.handleJson()
}).then(res => { }).then(res => {
load.close() load.close()
const item = ColumnConst.pageStyle.find(e => e.id == this.listStyleId) window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136/front') + `/#/${this.$route.query.path}?id=${this.columnId}&preview=1&siteId=${this.$route.query.siteId}`)
window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136') + `/#/${item ? item.path : 'home'}?id=${this.columnId}&preview=1&siteId=${this.$route.query.siteId}`)
}).catch(err => { }).catch(err => {
load.close() load.close()
}) })

@ -44,8 +44,7 @@
ref="column" ref="column"
v-model="form.columnId" v-model="form.columnId"
:options="columns" :options="columns"
:props="columnProps" :props="columnProps"></el-cascader>
clearable></el-cascader>
</el-form-item> </el-form-item>
<el-form-item v-if="form.articleTemplate === 25" prop="classificationId" label="所属分类"> <el-form-item v-if="form.articleTemplate === 25" prop="classificationId" label="所属分类">
<el-select style="width: 234px;" v-model="form.classificationId"> <el-select style="width: 234px;" v-model="form.classificationId">
@ -120,7 +119,7 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
</div> </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-form-item prop="edit" label="编辑">
<el-input <el-input
placeholder="请输入编辑" placeholder="请输入编辑"
@ -170,7 +169,7 @@
</el-form-item> </el-form-item>
</template> </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-form-item prop="source" label="所属分类">
<el-select style="width: 234px;" v-model="form.classificationId"> <el-select style="width: 234px;" v-model="form.classificationId">
<template v-for="item in classifications"> <template v-for="item in classifications">
@ -198,7 +197,7 @@
<el-button class="set-btn" type="primary" @click="setLabel">设置</el-button> <el-button class="set-btn" type="primary" @click="setLabel">设置</el-button>
</el-form-item> </el-form-item>
</div> </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 <el-input
style="width: 940px" style="width: 940px"
type="textarea" type="textarea"
@ -223,7 +222,7 @@
</div> </div>
</el-upload> </el-upload>
</el-form-item> </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 <el-upload
class="avatar-uploader avatar-uploader-lg" class="avatar-uploader avatar-uploader-lg"
accept=".jpg,.png,.jpeg,.gif" accept=".jpg,.png,.jpeg,.gif"
@ -239,15 +238,16 @@
</div> </div>
</el-upload> </el-upload>
</el-form-item> </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" /> <Editor api-key='rnk6zw9v267xqz7pf98twt1vmrvltmd436je7a642pckltda' v-model="form.mainBody" :init="editorConfig" />
</el-form-item> </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 <el-upload
:before-upload="fileBeforeUpload"
:on-remove="handleRemove" :on-remove="handleRemove"
:on-success="uploadSuccessFile" :on-success="uploadSuccessFile"
:action="this.api.upload" :action="this.api.upload"
:file-list="fileList" :file-list="form.fileList"
:data="{ :data="{
quote: form.title, quote: form.title,
site: site.siteName, site: site.siteName,
@ -281,19 +281,19 @@
</el-form-item> </el-form-item>
<template v-if="form.connectionType === 3"> <template v-if="form.connectionType === 3">
<el-form-item prop="siteSelection" label="站点选择"> <el-form-item prop="siteSelection" label="站点选择">
<el-select v-model="form.siteSelection"> <el-select v-model="form.siteSelection" @change="getOtherColumn">
<el-option <el-option
v-for="item in sites" v-for="item in sites"
:key="item.id" :key="item.id"
:label="item.name" :label="item.siteName"
:value="item.id"> :value="item.id">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="栏目"> <el-form-item label="栏目">
<el-cascader <el-cascader
v-model="links" v-model="otherLink"
:options="columns" :options="otherColumns"
:props="columnProps" :props="columnProps"
clearable></el-cascader> clearable></el-cascader>
</el-form-item> </el-form-item>
@ -385,7 +385,6 @@
<script> <script>
import Setting from '@/setting' import Setting from '@/setting'
import util from '@/libs/util' import util from '@/libs/util'
import ColumnConst from '@/const/column'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import Editor from '@tinymce/tinymce-vue' import Editor from '@tinymce/tinymce-vue'
import editorConfig from './editor' import editorConfig from './editor'
@ -397,7 +396,9 @@ export default {
site: this.$store.state.content.site, site: this.$store.state.content.site,
userId: this.$store.state.user.userId, userId: this.$store.state.user.userId,
nameRepeat: false, nameRepeat: false,
sites: ColumnConst.sites, sites: [],
otherColumns: [],
otherLink: [],
detailStyle: [], detailStyle: [],
columns: [], columns: [],
columnProps: { columnProps: {
@ -436,7 +437,6 @@ export default {
isRelease: 0, isRelease: 0,
mainBody: '', mainBody: '',
releaseTime: new Date(), releaseTime: new Date(),
// releaseTime: '',
source: '', source: '',
summary : '', summary : '',
title: '', title: '',
@ -444,6 +444,7 @@ export default {
connectionType : 1, connectionType : 1,
linkAddress: '', linkAddress: '',
siteSelection: 1, siteSelection: 1,
fileList: []
}, },
rules: { rules: {
title: [ title: [
@ -478,10 +479,10 @@ export default {
], ],
}, },
columnInfo: {}, columnInfo: {},
fileList: [],
editorConfig, editorConfig,
submiting: false, // submiting: false, //
pass: false, pass: false,
uploading: 0,
updateTime: 0, updateTime: 0,
cropperModel: false, cropperModel: false,
isUpload: false, isUpload: false,
@ -559,6 +560,7 @@ export default {
]) ])
this.getList() this.getList()
this.form.id ? this.getData() : this.getColumn() this.form.id ? this.getData() : this.getColumn()
this.getSite()
this.getLabel() this.getLabel()
this.getTemplate() this.getTemplate()
}, },
@ -606,15 +608,25 @@ export default {
// //
getData() { getData() {
this.$post(`${this.api.findArticle}?id=${this.form.id}`).then(({ data }) => { 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.activityStartTime && data.activityEndTime) data.time = [data.activityStartTime, data.activityEndTime]
//
if (data.fileList) {
data.fileList.map(e => {
e.name = e.fileName
})
}
this.form = data 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.originalName = data.title
this.getColumn() this.getColumn()
// const { file } = data
// if (file) this.fileList = [{name: file, url: file}] //
this.getFile()
}).catch(err => {}) }).catch(err => {})
}, },
// //
@ -634,6 +646,28 @@ export default {
this.getClassification() this.getClassification()
}).catch(err => {}) }).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() { getTemplate() {
this.$post(this.api.individualTemplateDetailsStyle).then(({ data }) => { this.$post(this.api.individualTemplateDetailsStyle).then(({ data }) => {
@ -642,7 +676,6 @@ export default {
result.find(n => n.style === e.style) || result.push(e) result.find(n => n.style === e.style) || result.push(e)
}) })
this.detailStyle = result this.detailStyle = result
console.log("🚀 ~ file: index.vue ~ line 642 ~ this.$post ~ data", result)
}).catch(err => {}) }).catch(err => {})
}, },
// //
@ -772,15 +805,6 @@ export default {
this.nameRepeat = false 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) { customUpload(data) {
const blob = this.dataURItoBlob(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 => {}) url && this.$del(this.api.delFile, [url.split('/').pop()]).then(res => {}).catch(e => {})
this.form.bannerImg = res.url this.form.bannerImg = res.url
}, },
//
fileBeforeUpload(file) {
this.uploading++
},
// //
uploadSuccessFile(res) { uploadSuccessFile(res) {
console.log("🚀 ~ file: index.vue ~ line 739 ~ handleRemove ~ e", res, this.fileList) this.uploading--
this.form.id ? this.form.id ?
this.$post(this.api.saveContentFile, { this.$post(this.api.saveContentFile, {
contentId: this.form.id, contentId: this.form.id,
@ -892,20 +920,20 @@ export default {
fileName: res.original, fileName: res.original,
filePath: res.url filePath: res.url
}).then(({ data }) => { }).then(({ data }) => {
this.fileList.push({ this.form.fileList.push({
name: res.original, name: res.original,
url: res.url, url: res.url,
id: data id: data
}) })
}).catch(res => {}) : }).catch(res => {}) :
this.fileList.push({ this.form.fileList.push({
name: res.original, name: res.original,
url: res.url url: res.url
}) })
}, },
// //
preview() { 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() { back() {
@ -930,28 +958,46 @@ export default {
const form = JSON.parse(JSON.stringify(this.form)) const form = JSON.parse(JSON.stringify(this.form))
if (!form.title) return util.errorMsg('请填写标题') if (!form.title) return util.errorMsg('请填写标题')
if (this.nameRepeat) 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 (typeof form.fatherId === 'object') form.fatherId = form.fatherId[form.fatherId.length - 1]
// if (form.articleTemplate === 24 && form.connectionType !== 2) { const tId = form.articleTemplate
// const { links } = this //
// if (!links.length && form.connectionType === 1 && isRelease) return util.errorMsg('') if (isRelease) {
// if (!links.length && form.connectionType === 3 && isRelease) return util.errorMsg('') if (tId !== 25) {
// form.linkAddress = links.join() if (!form.releaseTime) return util.errorMsg('请选择发布日期')
// } }
// if (((form.templateStatus && form.articleTemplate === 2) || !form.templateStatus) && !form.mainBody && isRelease) return util.errorMsg('') if (tId === 22 || tId === 23) {
if (form.articleTemplate === 25) { if (!form.titleImg ) return util.errorMsg('请上传封面')
if (!form.time.length && isRelease) return util.errorMsg('请选择起止时间') }
form.activityStartTime = form.time[0] if (tId === 25) {
form.activityEndTime = form.time[1] 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 = [] const fileId = []
if (typeof columnId === 'object') form.columnId = columnId[columnId.length - 1] // id if (typeof columnId === 'object') form.columnId = columnId[columnId.length - 1] // id
// idurlid // idurlid
if (bannerImg) fileId.push(bannerImg.substr(bannerImg.lastIndexOf('/') + 1)) 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)) 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(',') form.lableId = form.lableId.join(',')
// //
fileId.map(e => { fileId.map(e => {
@ -976,7 +1022,7 @@ export default {
} else { } else {
this.$post(this.api.saveArticle, form).then(({ data }) => { this.$post(this.api.saveArticle, form).then(({ data }) => {
// //
this.fileList.map(e => { form.fileList.map(e => {
this.$post(this.api.saveContentFile, { this.$post(this.api.saveContentFile, {
contentId: data, contentId: data,
editorId: this.userId, editorId: this.userId,

@ -38,7 +38,7 @@
<el-table :data="list" class="table" ref="table" header-align="center" @selection-change="handleSelectionChange" row-key="id"> <el-table :data="list" class="table" ref="table" header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column v-if="settings[0].show" type="selection" width="55" align="center" :reserve-selection="true"></el-table-column> <el-table-column v-if="settings[0].show" type="selection" width="55" align="center" :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column v-if="settings[1].show" prop="title" label="标题" align="center" min-width="150"></el-table-column> <el-table-column v-if="settings[1].show" show-overflow-tooltip prop="title" label="标题" align="center" min-width="150"></el-table-column>
<el-table-column v-if="settings[2].show" prop="columnName" label="栏目" align="center" min-width="120"></el-table-column> <el-table-column v-if="settings[2].show" prop="columnName" label="栏目" align="center" min-width="120"></el-table-column>
<el-table-column v-if="settings[3].show" prop="typeId" label="栏目类型" align="center" min-width="100"> <el-table-column v-if="settings[3].show" prop="typeId" label="栏目类型" align="center" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
@ -289,7 +289,7 @@ export default {
}, },
// //
preview(row) { preview(row) {
window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136') + `/#/article?id=${row.id}&siteId=${this.$refs.column.getCurrentNode().siteId}`) window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136/front') + `/#/article?id=${row.id}&siteId=${this.$refs.column.getCurrentNode().siteId}`)
}, },
// //
edit(row) { edit(row) {

@ -671,11 +671,12 @@ export default {
const { listStyleId } = this.form const { listStyleId } = this.form
this.$post(this.api[this.id ? 'updatePage' : 'savePage'], { this.$post(this.api[this.id ? 'updatePage' : 'savePage'], {
columnId, columnId,
state: 0, state: 1,
sort: 1, sort: 1,
founderId: this.userId, founderId: this.userId,
editorId: this.userId, editorId: this.userId,
jsonBeforeEditing: Modules[this.pageStyle.find(e => e.id === listStyleId).path] jsonBeforeEditing: Modules[this.pageStyle.find(e => e.id === listStyleId).path],
theEditedJson: Modules[this.pageStyle.find(e => e.id === listStyleId).path],
}).then(res => {}).catch(err => {}) }).then(res => {}).catch(err => {})
} }
} }

@ -25,7 +25,7 @@
<el-table v-loading="listLoading" ref="table" :data="list" default-expand-all class="table" header-align="center" @selection-change="handleSelectionChange" @select-all="selectAll" row-key="id"> <el-table v-loading="listLoading" ref="table" :data="list" default-expand-all class="table" header-align="center" @selection-change="handleSelectionChange" @select-all="selectAll" row-key="id">
<el-table-column v-if="settings[0].show" type="selection" width="50" align="center" :reserve-selection="true"></el-table-column> <el-table-column v-if="settings[0].show" type="selection" width="50" align="center" :reserve-selection="true"></el-table-column>
<el-table-column prop="columnName" label="名称" min-width="140"></el-table-column> <el-table-column prop="columnName" show-overflow-tooltip label="名称" min-width="140"></el-table-column>
<el-table-column v-if="settings[1].show" prop="typeId" label="栏目类型" min-width="100"> <el-table-column v-if="settings[1].show" prop="typeId" label="栏目类型" min-width="100">
<template slot-scope="scope"> <template slot-scope="scope">
{{ types.find(e => e.id == scope.row.typeId) && types.find(e => e.id == scope.row.typeId).name }} {{ types.find(e => e.id == scope.row.typeId) && types.find(e => e.id == scope.row.typeId).name }}
@ -294,11 +294,11 @@ export default {
const item = this.pageStyle.find(e => e.id == row.listStyleId) const item = this.pageStyle.find(e => e.id == row.listStyleId)
if (item) path = item.path if (item) path = item.path
} }
window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136') + `/#/${row.typeId === 3 ? row.path : 'column'}?id=${row.id}&siteId=${row.siteId}`) window.open((Setting.isDev ? `http://${location.hostname}:8095` : 'http://192.168.31.136/front') + `/#/${row.typeId === 3 ? row.path : 'column'}?id=${row.id}&siteId=${row.siteId}`)
}, },
// //
page(row) { page(row) {
this.$router.push(`${row.path}?id=${row.id}&listStyleId=${row.listStyleId}&siteId=${row.siteId}`) this.$router.push(`${row.path}?id=${row.id}&path=${row.path}&siteId=${row.siteId}`)
}, },
// //
batchDel() { batchDel() {

@ -14,7 +14,6 @@ service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"
// 请求拦截器 // 请求拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
util.getToken();
let token = util.local.get(Setting.tokenKey); let token = util.local.get(Setting.tokenKey);
config.headers.captcha = '' config.headers.captcha = ''
return config; return config;

Loading…
Cancel
Save