This commit is contained in:
clay
2022-12-08 15:40:33 +08:00
parent 0a2a804ca8
commit 2cfbfef8bd
5 changed files with 348 additions and 243 deletions

View File

@@ -2,11 +2,11 @@
ENV = 'development' ENV = 'development'
# EBTS/开发环境 # EBTS/开发环境
#VUE_APP_BASE_API = '/dev-api' VUE_APP_BASE_API = '/dev-api'
#VUE_APP_BASE_API = 'http://192.168.190.67/dev-api' #VUE_APP_BASE_API = 'http://192.168.190.67/dev-api'
#VUE_APP_BASE_API = 'http://127.0.0.1:8085/dev-api' #VUE_APP_BASE_API = 'http://127.0.0.1:8085/dev-api'
#VUE_APP_BASE_API = 'http://sistapi.hchyun.cn/dev-api' #VUE_APP_BASE_API = 'http://sistapi.hchyun.cn/dev-api'
VUE_APP_BASE_API = 'http://sist.swjtu.edu.cn/dev-api' #VUE_APP_BASE_API = 'http://sist.swjtu.edu.cn/dev-api'
# 路由懒加载 # 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true VUE_CLI_BABEL_TRANSPILE_MODULES = true

View File

@@ -133,10 +133,10 @@ export default {
}, },
mounted() { mounted() {
this.initInform() this.initInform()
let notice_text = document.getElementById('notice_text') // let notice_text = document.getElementById('notice_text')
notice_text.addEventListener('webkitAnimationEnd', function() { // notice_text.addEventListener('webkitAnimationEnd', function() {
this.style.marginLeft = 0 // this.style.marginLeft = 0
}, false) // }, false)
// this.initFiche() // this.initFiche()
}, },
methods: { methods: {

View File

@@ -16,7 +16,8 @@
type="textarea" type="textarea"
:rows="4" :rows="4"
placeholder="请输入内容" placeholder="请输入内容"
clearable :style="{width: '100%'}"> clearable :style="{width: '100%'}"
>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -26,25 +27,27 @@
<el-form-item label="是否新闻" prop="isTop"> <el-form-item label="是否新闻" prop="isTop">
<el-radio-group v-model="formData.isTop"> <el-radio-group v-model="formData.isTop">
<el-radio-button v-for="(item, index) in isTopOptions" :key="index" <el-radio-button v-for="(item, index) in isTopOptions" :key="index"
:label="item.dictValue">{{ item.dictLabel }} :label="item.dictValue"
>{{ item.dictLabel }}
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-col :span="8">--> <!-- <el-col :span="8">-->
<!-- <el-form-item label="是否显示" prop="isView">--> <!-- <el-form-item label="是否显示" prop="isView">-->
<!-- <el-radio-group v-model="formData.isView">--> <!-- <el-radio-group v-model="formData.isView">-->
<!-- <el-radio-button v-for="(item, index) in isViewOptions" :key="index"--> <!-- <el-radio-button v-for="(item, index) in isViewOptions" :key="index"-->
<!-- :label="item.dictValue">{{ item.dictLabel }}--> <!-- :label="item.dictValue">{{ item.dictLabel }}-->
<!-- </el-radio-button>--> <!-- </el-radio-button>-->
<!-- </el-radio-group>--> <!-- </el-radio-group>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- </el-col>--> <!-- </el-col>-->
<el-col :span="8"> <el-col :span="8">
<el-form-item label="是否英语" prop="isEnglish"> <el-form-item label="是否英语" prop="isEnglish">
<el-radio-group v-model="formData.isEnglish"> <el-radio-group v-model="formData.isEnglish">
<el-radio-button v-for="(item, index) in isEnglishOptions" :key="index" <el-radio-button v-for="(item, index) in isEnglishOptions" :key="index"
:label="item.dictValue">{{ item.dictLabel }} :label="item.dictValue"
>{{ item.dictLabel }}
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
@@ -56,7 +59,8 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item label="信息网站"> <el-form-item label="信息网站">
<el-select v-model="params.sistArticleType" @change="getSistApprove(params.sistArticleType)" <el-select v-model="params.sistArticleType" @change="getSistApprove(params.sistArticleType)"
placeholder="请选择文章类型" clearable :style="{width: '100%'}"> placeholder="请选择文章类型" clearable :style="{width: '100%'}"
>
<el-option <el-option
v-for="dict in sistArticleTypeOption" v-for="dict in sistArticleTypeOption"
:key="dict.id" :key="dict.id"
@@ -83,7 +87,8 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item label="实验室网站"> <el-form-item label="实验室网站">
<el-select v-model="params.labArticleType" placeholder="请选择文章类型" <el-select v-model="params.labArticleType" placeholder="请选择文章类型"
@change="getLabApprove(params.labArticleType)" clearable :style="{width: '100%'}"> @change="getLabApprove(params.labArticleType)" clearable :style="{width: '100%'}"
>
<el-option <el-option
v-for="dict in labArticleTypeOption" v-for="dict in labArticleTypeOption"
:key="dict.id" :key="dict.id"
@@ -108,7 +113,7 @@
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="12" v-show="imgurlShow"> <el-col :span="12" v-show="imgurlShow">
<el-form-item > <el-form-item>
<UploadFile v-model="formData.imgurl" <UploadFile v-model="formData.imgurl"
file-type="image" file-type="image"
:v-public="true" :v-public="true"
@@ -132,7 +137,7 @@
:auto-upload="true" :auto-upload="true"
> >
<el-button slot="trigger" size="small" type="primary">选取文件</el-button> <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>--> <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>-->
</el-upload> </el-upload>
</el-col> </el-col>
@@ -146,7 +151,8 @@
<el-col :span="24" class="submitForm"> <el-col :span="24" class="submitForm">
<el-form-item size="large"> <el-form-item size="large">
<el-button type="success" @click="saveDrafts">保存草稿</el-button> <el-button type="success" @click="saveDrafts">保存草稿</el-button>
<el-button type="primary" @click="submitForm">{{(isAuditShow.sist || isAuditShow.lab) ? "提交审核":"发布"}}</el-button> <el-button type="primary" @click="submitForm">{{ (isAuditShow.sist || isAuditShow.lab) ? '提交审核' : '发布' }}
</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -155,53 +161,52 @@
</template> </template>
<script> <script>
import TinymceEditor from '@/views/utils/tinymce/Tinymce' import TinymceEditor from '@/views/utils/tinymce/Tinymce'
import {updateArticle, getArticle, drafts, getArticleType, getArticleApprove} from "@/api/sist/article"; import { updateArticle, getArticle, drafts, getArticleApprove } from '@/api/sist/article'
import {Message} from "element-ui"; import { Message } from 'element-ui'
import UploadFile from '@/views/utils/uploadFile.vue'; import UploadFile from '@/views/utils/uploadFile.vue'
import { getArticleNav } from '../../../../api/sist/article' import { getArticleNav } from '../../../../api/sist/article'
import { getToken } from '../../../../utils/auth' import { getToken } from '../../../../utils/auth'
import { addFile, delFile } from '../../../../api/sist/file' import { addFile, delFile } from '../../../../api/sist/file'
export default { export default {
components: { components: {
TinymceEditor, TinymceEditor,
UploadFile, UploadFile
// ArticleFile // ArticleFile
}, },
props: [], props: [],
data() { data() {
return { return {
isAdmin:false, isAdmin: false,
uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址 uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
headers: { headers: {
Authorization: 'Bearer ' + getToken() Authorization: 'Bearer ' + getToken()
}, },
fileList:[], fileList: [],
fileMapper:[], fileMapper: [],
submit: 1, submit: 1,
imgurlShow:false, imgurlShow: false,
formData: { formData: {
id: null, id: null,
title: null, title: null,
isTop: '2', isTop: '2',
isEnglish: '0', isEnglish: '0',
content: "", content: '',
imgurl:null, imgurl: null
}, },
approveShow: { approveShow: {
sist: true, sist: true,
lab: true, lab: true
}, },
isAuditShow:{ isAuditShow: {
sist:false, sist: false,
lab:false lab: false
}, },
params: { params: {
sistArticleType: null, sistArticleType: null,
sistApprove: null, sistApprove: null,
labArticleType: null, labArticleType: null,
labApprove: null, labApprove: null
}, },
sistArticleTypeOption: [], sistArticleTypeOption: [],
labArticleTypeOption: [], labArticleTypeOption: [],
@@ -247,8 +252,8 @@ export default {
required: true, required: true,
message: '请选择发布日期', message: '请选择发布日期',
trigger: 'change' trigger: 'change'
}], }]
}, }
} }
}, },
computed: {}, computed: {},
@@ -258,49 +263,49 @@ export default {
sist: true, sist: true,
lab: true lab: true
} }
this.formData.id = this.$route.params && this.$route.params.articleId; this.formData.id = this.$route.params && this.$route.params.articleId
if (this.formData.id === undefined) { if (this.formData.id === undefined) {
this.formData.id = null; this.formData.id = null
} else { } else {
getArticle(this.formData.id).then(response => { getArticle(this.formData.id).then(response => {
this.formData = response.data this.formData = response.data
if (this.formData.siteType === '2') { if (this.formData.siteType === '2') {
this.approveShow.sist = false this.approveShow.sist = false
if (null != this.formData.navId){ if (null != this.formData.navId) {
this.params.labArticleType = parseInt(this.formData.navId) this.params.labArticleType = parseInt(this.formData.navId)
this.getLabApprove(this.params.labArticleType) this.getLabApprove(this.params.labArticleType)
} }
} else if (this.formData.siteType === '1') { } else if (this.formData.siteType === '1') {
this.approveShow.lab = false this.approveShow.lab = false
if (null != this.formData.navId){ if (null != this.formData.navId) {
this.params.sistArticleType = parseInt(this.formData.navId) this.params.sistArticleType = parseInt(this.formData.navId)
this.getSistApprove(this.params.sistArticleType) this.getSistApprove(this.params.sistArticleType)
} }
} }
}) })
} }
this.getDicts("article_site_type").then(response => { this.getDicts('article_site_type').then(response => {
this.sitetypeOptions = response.data; this.sitetypeOptions = response.data
}); })
this.getDicts("is_top").then(response => { this.getDicts('is_top').then(response => {
this.isTopOptions = response.data; this.isTopOptions = response.data
}); })
this.getDicts("is_view").then(response => { this.getDicts('is_view').then(response => {
this.isViewOptions = response.data; this.isViewOptions = response.data
}); })
this.getDicts("is_english").then(response => { this.getDicts('is_english').then(response => {
this.isEnglishOptions = response.data; this.isEnglishOptions = response.data
}); })
this.getDicts("article_status").then(response => { this.getDicts('article_status').then(response => {
this.statusOptions = response.data; this.statusOptions = response.data
}); })
getArticleNav().then(res=>{ getArticleNav().then(res => {
let data = res.data let data = res.data
this.articleTypeOptions = data this.articleTypeOptions = data
for (let item of data) { for (let item of data) {
if (item.sitetype == 1){ if (item.sitetype == 1) {
this.sistArticleTypeOption.push(item) this.sistArticleTypeOption.push(item)
}else { } else {
this.labArticleTypeOption.push(item) this.labArticleTypeOption.push(item)
} }
} }
@@ -333,7 +338,7 @@ export default {
let data = { let data = {
isPublic: '1', isPublic: '1',
fileType: '', fileType: '',
fileName:res.fileName, fileName: res.fileName,
fileAddr: res.fileAddr fileAddr: res.fileAddr
} }
addFile(data).then(res => { addFile(data).then(res => {
@@ -342,12 +347,12 @@ export default {
let mapperItem = { let mapperItem = {
id: dataFile.fileId, id: dataFile.fileId,
uid: file.uid, uid: file.uid,
url:dataFile.url, url: dataFile.url,
fileName:data.fileName, fileName: data.fileName
} }
let url = dataFile.uri let url = dataFile.uri
url = url.replace("/pubfiles","/attached") url = url.replace('/pubfiles', '/attached')
let fileStr = '<p><a target="_blank" href="'+url+'">'+mapperItem.fileName+'</a><br/></p>' let fileStr = '<p><a target="_blank" href="' + url + '">' + mapperItem.fileName + '</a><br/></p>'
this.formData.content = this.formData.content + fileStr this.formData.content = this.formData.content + fileStr
this.fileMapper.push(mapperItem) this.fileMapper.push(mapperItem)
}) })
@@ -355,44 +360,44 @@ export default {
}, },
getSistApprove(navId) { getSistApprove(navId) {
if (!navId){ if (!navId) {
return return
} }
this.isAuditShow.sist = false this.isAuditShow.sist = false
this.auditShow(navId,1) this.auditShow(navId, 1)
this.judgeThumbnail(navId) this.judgeThumbnail(navId)
getArticleApprove(navId).then(res => { getArticleApprove(navId).then(res => {
this.sistApproveOption = res.data this.sistApproveOption = res.data
}) })
}, },
getLabApprove(navId) { getLabApprove(navId) {
if (!navId){ if (!navId) {
return return
} }
this.isAuditShow.lab = false this.isAuditShow.lab = false
this.auditShow(navId,2) this.auditShow(navId, 2)
this.judgeThumbnail(navId) this.judgeThumbnail(navId)
getArticleApprove(navId).then(res => { getArticleApprove(navId).then(res => {
this.labApproveOption = res.data this.labApproveOption = res.data
}) })
}, },
judgeThumbnail(navId){ judgeThumbnail(navId) {
let articleList = this.articleTypeOptions let articleList = this.articleTypeOptions
for (let article of articleList) { for (let article of articleList) {
console.log(article.title) console.log(article.title)
if (navId === article.id && article.isThumbnail == 1){ if (navId === article.id && article.isThumbnail == 1) {
this.imgurlShow = true this.imgurlShow = true
return return
} }
} }
}, },
auditShow(navId,type){ auditShow(navId, type) {
let typeList = this.articleTypeOptions let typeList = this.articleTypeOptions
for (let item of typeList) { for (let item of typeList) {
if (navId === item.id && item.isAudit == 1){ if (navId === item.id && item.isAudit == 1) {
if (type == 1){ if (type == 1) {
this.isAuditShow.sist = true this.isAuditShow.sist = true
}else { } else {
this.isAuditShow.lab = true this.isAuditShow.lab = true
} }
return return
@@ -403,22 +408,22 @@ export default {
let that_ = this let that_ = this
this.$refs['elForm'].validate(valid => { this.$refs['elForm'].validate(valid => {
if (valid) { if (valid) {
if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType === null || that_.params.labArticleType === "")) { if ((that_.params.sistArticleType === null || that_.params.sistArticleType === '') && (that_.params.labArticleType === null || that_.params.labArticleType === '')) {
Message({ Message({
message: "请至少选择一个网站发布文章", message: '请至少选择一个网站发布文章',
type: "error", type: 'error'
}) })
return return
} else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType !== null || that_.params.labArticleType !== "") && (that_.formData.sistApprove === null || that_.params.sistApprove === "")) { } else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === '') && (that_.params.labArticleType !== null || that_.params.labArticleType !== '') && (that_.formData.sistApprove === null || that_.params.sistApprove === '')) {
Message({ Message({
message: "请选择信息网站的审批人", message: '请选择信息网站的审批人',
type: "error", type: 'error'
}) })
return return
} else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === "") && (that_.params.labArticleType != null || that_.params.labArticleType !== "") && (that_.params.labApprove === null || that_.params.labApprove === "")) { } else if ((that_.params.sistArticleType === null || that_.params.sistArticleType === '') && (that_.params.labArticleType != null || that_.params.labArticleType !== '') && (that_.params.labApprove === null || that_.params.labApprove === '')) {
Message({ Message({
message: "请选择实验室网站的审批人", message: '请选择实验室网站的审批人',
type: "error", type: 'error'
}) })
return return
} }
@@ -426,49 +431,49 @@ export default {
that_.formData.params = that_.params that_.formData.params = that_.params
if (that_.submit == 0) { if (that_.submit == 0) {
Message({ Message({
message: "您操作过快", message: '您操作过快',
type: "error", type: 'error'
}) })
} else { } else {
that_.submit = 0 that_.submit = 0
that_.loading = true; that_.loading = true
// this.formData.imgurl = this.form.imgurl.url // this.formData.imgurl = this.form.imgurl.url
updateArticle(that_.formData).then(response => { updateArticle(that_.formData).then(response => {
that_.loading = false; that_.loading = false
if (response.code == 200) { if (response.code == 200) {
that_.msgSuccess("提交审批成功"); that_.msgSuccess('提交审批成功')
that_.submit = 1 that_.submit = 1
that_.close(); that_.close()
} }
}).catch(e => { }).catch(e => {
that_.submit = 1 that_.submit = 1
}); })
} }
// TODO 提交表单 // TODO 提交表单
}) })
}, },
close() { close() {
this.$store.dispatch("tagsView/delView", this.$route); this.$store.dispatch('tagsView/delView', this.$route)
this.$router.push({path: "/SIST/article/", query: {t: Date.now()}}) this.$router.push({ path: '/SIST/article/', query: { t: Date.now() } })
}, },
saveDrafts() { saveDrafts() {
let that = this let that = this
this.$refs['elForm'].validate(valid => { this.$refs['elForm'].validate(valid => {
drafts(that.formData).then(res => { drafts(that.formData).then(res => {
if (that.formData.id == null || this.formData.id == "") { if (that.formData.id == null || this.formData.id == '') {
that.formData.id = res.data that.formData.id = res.data
} }
if (res.code == 200) { if (res.code == 200) {
that.msgSuccess('保存成功'); that.msgSuccess('保存成功')
} else { } else {
that.Message({ that.Message({
message: res.code, message: res.code,
type: "error" type: 'error'
}) })
} }
}) })
}) })
}, }
} }
} }

View File

@@ -10,25 +10,25 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<!-- <el-form-item label="操作人员" prop="createBy">--> <!-- <el-form-item label="操作人员" prop="createBy">-->
<!-- <el-input--> <!-- <el-input-->
<!-- v-model="queryParams.createBy"--> <!-- v-model="queryParams.createBy"-->
<!-- placeholder="请输入操作人员"--> <!-- placeholder="请输入操作人员"-->
<!-- clearable--> <!-- clearable-->
<!-- size="small"--> <!-- size="small"-->
<!-- @keyup.enter.native="handleQuery"--> <!-- @keyup.enter.native="handleQuery"-->
<!-- />--> <!-- />-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- <el-form-item label="类型" prop="noticeType">--> <!-- <el-form-item label="类型" prop="noticeType">-->
<!-- <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small">--> <!-- <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small">-->
<!-- <el-option--> <!-- <el-option-->
<!-- v-for="dict in typeOptions"--> <!-- v-for="dict in typeOptions"-->
<!-- :key="dict.dictValue"--> <!-- :key="dict.dictValue"-->
<!-- :label="dict.dictLabel"--> <!-- :label="dict.dictLabel"-->
<!-- :value="dict.dictValue"--> <!-- :value="dict.dictValue"-->
<!-- />--> <!-- />-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item> <el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -44,7 +44,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['system:notice:add']" v-hasPermi="['system:notice:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@@ -55,7 +56,8 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['system:notice:edit']" v-hasPermi="['system:notice:edit']"
>修改</el-button> >修改
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@@ -66,35 +68,36 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['system:notice:remove']" v-hasPermi="['system:notice:remove']"
>删除</el-button> >删除
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="noticeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" align="center" prop="noticeId" width="100" /> <el-table-column label="序号" align="center" prop="noticeId" width="100"/>
<el-table-column <el-table-column
label="公告标题" label="公告标题"
align="center" align="center"
prop="noticeTitle" prop="noticeTitle"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
/> />
<!-- <el-table-column--> <!-- <el-table-column-->
<!-- label="公告类型"--> <!-- label="公告类型"-->
<!-- align="center"--> <!-- align="center"-->
<!-- prop="noticeType"--> <!-- prop="noticeType"-->
<!-- :formatter="typeFormat"--> <!-- :formatter="typeFormat"-->
<!-- width="100"--> <!-- width="100"-->
<!-- />--> <!-- />-->
<!-- <el-table-column--> <!-- <el-table-column-->
<!-- label="状态"--> <!-- label="状态"-->
<!-- align="center"--> <!-- align="center"-->
<!-- prop="status"--> <!-- prop="status"-->
<!-- :formatter="statusFormat"--> <!-- :formatter="statusFormat"-->
<!-- width="100"--> <!-- width="100"-->
<!-- />--> <!-- />-->
<!-- <el-table-column label="创建者" align="center" prop="createBy" width="100" />--> <!-- <el-table-column label="创建者" align="center" prop="createBy" width="100" />-->
<el-table-column label="创建时间" align="center" prop="createTime" width="100"> <el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
@@ -108,14 +111,16 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['system:notice:edit']" v-hasPermi="['system:notice:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:notice:remove']" v-hasPermi="['system:notice:remove']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -134,38 +139,63 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="公告标题" prop="noticeTitle"> <el-form-item label="公告标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入公告标题" /> <el-input v-model="form.noticeTitle" placeholder="请输入公告标题"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-col :span="12">--> <!-- <el-col :span="12">-->
<!-- <el-form-item label="公告类型" prop="noticeType">--> <!-- <el-form-item label="公告类型" prop="noticeType">-->
<!-- <el-select v-model="form.noticeType" placeholder="请选择">--> <!-- <el-select v-model="form.noticeType" placeholder="请选择">-->
<!-- <el-option--> <!-- <el-option-->
<!-- v-for="dict in typeOptions"--> <!-- v-for="dict in typeOptions"-->
<!-- :key="dict.dictValue"--> <!-- :key="dict.dictValue"-->
<!-- :label="dict.dictLabel"--> <!-- :label="dict.dictLabel"-->
<!-- :value="dict.dictValue"--> <!-- :value="dict.dictValue"-->
<!-- ></el-option>--> <!-- ></el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- </el-col>--> <!-- </el-col>-->
<!-- <el-col :span="24">--> <!-- <el-col :span="24">-->
<!-- <el-form-item label="状态">--> <!-- <el-form-item label="状态">-->
<!-- <el-radio-group v-model="form.status">--> <!-- <el-radio-group v-model="form.status">-->
<!-- <el-radio--> <!-- <el-radio-->
<!-- v-for="dict in statusOptions"--> <!-- v-for="dict in statusOptions"-->
<!-- :key="dict.dictValue"--> <!-- :key="dict.dictValue"-->
<!-- :label="dict.dictValue"--> <!-- :label="dict.dictValue"-->
<!-- >{{dict.dictLabel}}</el-radio>--> <!-- >{{dict.dictLabel}}</el-radio>-->
<!-- </el-radio-group>--> <!-- </el-radio-group>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- </el-col>--> <!-- </el-col>-->
<el-col :span="24"> <el-col :span="24">
<el-form-item label="内容"> <el-form-item label="公告标题" prop="noticeContent">
<editor v-model="form.noticeContent" :min-height="192"/> <el-row>
</el-form-item> <el-col :offset="1" :span="22">
<el-upload
class="upload-demo"
ref="upload"
:action="uploadFileUrl"
:headers="headers"
:on-remove="handleRemove"
:on-success="handleUploadSuccess"
:file-list="fileList"
:auto-upload="true"
>
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件且不超过500kb</div>-->
</el-upload>
</el-col>
</el-row>
<el-row>
<el-col :offset="1" :span="22">
<!-- <TinymceEditor ref="tinymce" v-model="form.noticeContent"></TinymceEditor>-->
<editor v-model="form.noticeContent" :min-height="192"/>
</el-col>
</el-row>
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<!-- <TinymceEditor v-model="form.noticeContent"></TinymceEditor>-->
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@@ -176,16 +206,24 @@
</template> </template>
<script> <script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice, exportNotice } from "@/api/system/notice"; import { listNotice, getNotice, delNotice, addNotice, updateNotice } from '@/api/system/notice'
import Editor from '@/components/Editor'; import Editor from '@/components/Editor'
import { addFile, delFile } from '../../../api/sist/file'
import { getToken } from '../../../utils/auth'
export default { export default {
name: "Notice", name: 'Notice',
components: { components: {
Editor Editor
}, },
data() { data() {
return { return {
uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
headers: {
Authorization: 'Bearer ' + getToken()
},
fileList: [],
fileMapper: [],
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
@@ -201,7 +239,7 @@ export default {
// 公告表格数据 // 公告表格数据
noticeList: [], noticeList: [],
// 弹出层标题 // 弹出层标题
title: "", title: '',
// 是否显示弹出层 // 是否显示弹出层
open: false, open: false,
// 类型数据字典 // 类型数据字典
@@ -217,134 +255,185 @@ export default {
status: undefined status: undefined
}, },
// 表单参数 // 表单参数
form: {}, form: {
noticeId: undefined,
noticeTitle: undefined,
noticeType: '2',
noticeContent: undefined,
status: '0'
},
// 表单校验 // 表单校验
rules: { rules: {
noticeTitle: [ noticeTitle: [
{ required: true, message: "公告标题不能为空", trigger: "blur" } { required: true, message: '公告标题不能为空', trigger: 'blur' }
], ],
noticeType: [ noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "blur" } { required: true, message: '公告类型不能为空', trigger: 'blur' }
] ]
} }
}; }
}, },
created() { created() {
this.getList(); this.getList()
this.getDicts("sys_notice_status").then(response => { this.getDicts('sys_notice_status').then(response => {
this.statusOptions = response.data; this.statusOptions = response.data
}); })
this.getDicts("sys_notice_type").then(response => { this.getDicts('sys_notice_type').then(response => {
this.typeOptions = response.data; this.typeOptions = response.data
}); })
}, },
methods: { methods: {
handleRemove(file, fileList) {
let fileId = null
let index = 0
for (let item of this.fileMapper) {
console.log(file.uid, item)
if (file.uid == item.uid) {
fileId = item.id
break
}
index++
}
console.log(index)
let that = this
delFile(fileId).then(res => {
that.fileMapper.splice(index, 1)
console.log(that.fileMapper)
that.$message.success('提交成功!')
})
},
// 上传成功回调
handleUploadSuccess(res, file) {
let data = {
isPublic: '1',
fileType: '',
fileName: res.fileName,
fileAddr: res.fileAddr
}
addFile(data).then(res => {
console.log(res)
let dataFile = res.data
let mapperItem = {
id: dataFile.fileId,
uid: file.uid,
url: dataFile.url,
fileName: data.fileName
}
let url = dataFile.uri
url = url.replace('/pubfiles', '/attached')
let fileStr = '<p><a style="color: blue;text-decoration: underline;" target="_blank" href="' + url + '">' + mapperItem.fileName + '</a><br/></p>'
this.form.noticeContent = this.form.noticeContent + fileStr
this.fileMapper.push(mapperItem)
})
this.$message.success('提交成功!')
},
/** 查询公告列表 */ /** 查询公告列表 */
getList() { getList() {
this.loading = true; this.loading = true
listNotice(this.queryParams).then(response => { listNotice(this.queryParams).then(response => {
this.noticeList = response.rows; this.noticeList = response.rows
this.total = response.total; this.total = response.total
this.loading = false; this.loading = false
}); })
}, },
// 公告状态字典翻译 // 公告状态字典翻译
statusFormat(row, column) { statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status); return this.selectDictLabel(this.statusOptions, row.status)
}, },
// 公告状态字典翻译 // 公告状态字典翻译
typeFormat(row, column) { typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.noticeType); return this.selectDictLabel(this.typeOptions, row.noticeType)
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false; this.open = false
this.reset(); this.reset()
}, },
// 表单重置 // 表单重置
reset() { reset() {
this.form = { this.form = {
noticeId: undefined, noticeId: undefined,
noticeTitle: undefined, noticeTitle: undefined,
noticeType: "2", noticeType: '2',
noticeContent: undefined, noticeContent: undefined,
status: "0", status: '0'
}; }
this.resetForm("form"); this.resetForm('form')
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm('queryForm')
this.handleQuery(); this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.noticeId) this.ids = selection.map(item => item.noticeId)
this.single = selection.length!=1 this.single = selection.length != 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset()
this.open = true; this.open = true
this.title = "添加公告"; this.title = '添加公告'
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset()
const noticeId = row.noticeId || this.ids const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => { getNotice(noticeId).then(response => {
this.form = response.data; this.form = response.data
this.open = true; this.open = true
this.title = "修改公告"; this.title = '修改公告'
}); })
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs['form'].validate(valid => {
this.form.noticeType = "1" this.form.noticeType = '1'
this.form.status = "0" this.form.status = '0'
if (valid) { if (valid) {
if (this.form.noticeId != undefined) { if (this.form.noticeId != undefined) {
updateNotice(this.form).then(response => { updateNotice(this.form).then(response => {
this.msgSuccess("修改成功"); this.msgSuccess('修改成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} else { } else {
addNotice(this.form).then(response => { addNotice(this.form).then(response => {
this.msgSuccess("新增成功"); this.msgSuccess('新增成功')
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} }
} }
}); })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const noticeIds = row.noticeId || this.ids const noticeIds = row.noticeId || this.ids
this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', "警告", { this.$confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?', '警告', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning" type: 'warning'
}).then(function() { }).then(function() {
return delNotice(noticeIds); return delNotice(noticeIds)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.msgSuccess("删除成功"); this.msgSuccess('删除成功')
}) })
} }
} }
}; }
</script> </script>
<style scoped> <style scoped>
/deep/.w-e-text{ /deep/ .w-e-text {
min-height: 242px; min-height: 242px;
} }
</style> </style>

View File

@@ -174,19 +174,29 @@ export default {
} }
}, },
mounted() { mounted() {
tinymce.init({ this.initTinymce()
// tinymce.init({
images_upload_handler: (blobInfo, success, failure) => { // images_upload_handler: (blobInfo, success, failure) => {
this.upload_handler(blobInfo, success, failure) // this.upload_handler(blobInfo, success, failure)
} // }
// })
})
}, },
// created() { // created() {
// tinymce.init({}) // this.initTinymce()
// tinymce.init({
// images_upload_handler: (blobInfo, success, failure) => {
// this.upload_handler(blobInfo, success, failure)
// }
// })
// }, // },
methods: { methods: {
initTinymce(){
tinymce.init({
images_upload_handler: (blobInfo, success, failure) => {
this.upload_handler(blobInfo, success, failure)
}
})
},
upload_handler(blobInfo, success, failure) { upload_handler(blobInfo, success, failure) {
console.log('我被触发了') console.log('我被触发了')
console.log(blobInfo, 'blobInfo') console.log(blobInfo, 'blobInfo')
@@ -216,6 +226,7 @@ export default {
}, },
watch: { watch: {
value(newValue) { value(newValue) {
// this.initTinymce()
this.myValue = newValue this.myValue = newValue
}, },
myValue(newValue) { myValue(newValue) {