clay commit : 第一阶段完成
This commit is contained in:
@@ -89,6 +89,7 @@ export default {
|
||||
init () {
|
||||
const _this = this
|
||||
this.editor = new Editor(this.$refs.editor)
|
||||
this.editor.config.uploadImgAccept = ['doc', 'docx', 'png', 'gif', 'bmp', 'webp']
|
||||
this.editor.config.uploadImgShowBase64 = true // 使用 base64 保存图片
|
||||
this.editor.config.height = this.height
|
||||
this.editor.config.pasteFilterStyle = false
|
||||
|
||||
@@ -43,7 +43,6 @@ import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
||||
// 值
|
||||
value: [String, Object, Array],
|
||||
// 大小限制(MB)
|
||||
@@ -141,7 +140,7 @@ export default {
|
||||
handleUploadSuccess(res, file) {
|
||||
this.$message.success("提交成功!");
|
||||
this.$emit("input", res.url);
|
||||
this.$emit("change",res.fileName);
|
||||
this.$emit("change",res);
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
|
||||
@@ -59,6 +59,7 @@ const user = {
|
||||
const avatar = user.avatar == "" ? require("@/assets/image/profile.jpg") : user.avatar;
|
||||
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
commit('SET_ROLES', res.roles)
|
||||
sessionStorage.setItem("roles",JSON.stringify(user.roles))
|
||||
commit('SET_PERMISSIONS', res.permissions)
|
||||
} else {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||
|
||||
129
ebts-ui/src/views/sist/article/components/ArticleFile.vue
Normal file
129
ebts-ui/src/views/sist/article/components/ArticleFile.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { addFile, delFile } from '../../../../api/sist/file'
|
||||
|
||||
export default {
|
||||
name: 'ArticleFile',
|
||||
props: {
|
||||
|
||||
value: {
|
||||
type: Object,
|
||||
default: function () {
|
||||
return {
|
||||
fileList: [],
|
||||
fileMapper: []
|
||||
}
|
||||
}
|
||||
},
|
||||
fileList:{
|
||||
type:Array,
|
||||
default: function () {
|
||||
return []
|
||||
}
|
||||
},
|
||||
fileMapper:{
|
||||
type:Array,
|
||||
default: function () {
|
||||
return []
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + getToken()
|
||||
},
|
||||
// fileList: value.fileList,
|
||||
// fileList: [{
|
||||
// name: 'food.jpeg',
|
||||
// url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
|
||||
// }, {
|
||||
// name: 'food2.jpeg',
|
||||
// url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
|
||||
// }],
|
||||
// fileMapper: value.fileMapper
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
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('提交成功!')
|
||||
})
|
||||
this.$emit('input', {
|
||||
fileList: this.fileList,
|
||||
fileMapper: this.fileMapper
|
||||
})
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
console.log(file)
|
||||
console.log(res)
|
||||
let data = {
|
||||
isPublic: '1',
|
||||
fileType: '',
|
||||
fileAddr: res.fileName
|
||||
}
|
||||
addFile(data).then(res => {
|
||||
console.log(res)
|
||||
let data = res.data
|
||||
let mapperItem = {
|
||||
id: data.fileId,
|
||||
uid: file.uid
|
||||
}
|
||||
this.fileMapper.push(mapperItem)
|
||||
})
|
||||
this.$message.success('提交成功!')
|
||||
|
||||
this.$emit('input', {
|
||||
fileList: this.fileList,
|
||||
fileMapper: this.fileMapper
|
||||
})
|
||||
this.$emit('change', {
|
||||
fileList: this.fileList,
|
||||
fileMapper: this.fileMapper
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -105,6 +105,26 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<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">
|
||||
<Editor v-model="formData.content" :height="800"/>
|
||||
@@ -122,20 +142,31 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// import ArticleFile from './ArticleFile'
|
||||
import Editor from '@/components/Editor';
|
||||
import {updateArticle, getArticle, drafts, getArticleType, getArticleApprove} from "@/api/sist/article";
|
||||
import {Message} from "element-ui";
|
||||
import UploadFile from '@/views/utils/uploadFile.vue';
|
||||
import { getArticleNav } from '../../../../api/sist/article'
|
||||
import { getToken } from '../../../../utils/auth'
|
||||
import { addFile, delFile } from '../../../../api/sist/file'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Editor,
|
||||
UploadFile
|
||||
UploadFile,
|
||||
// ArticleFile
|
||||
},
|
||||
props: [],
|
||||
data() {
|
||||
return {
|
||||
isAdmin:false,
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + getToken()
|
||||
},
|
||||
fileList:[],
|
||||
fileMapper:[],
|
||||
submit: 1,
|
||||
imgurlShow:false,
|
||||
formData: {
|
||||
@@ -219,21 +250,22 @@ export default {
|
||||
this.formData = response.data
|
||||
if (this.formData.siteType === '2') {
|
||||
this.approveShow.sist = false
|
||||
this.params.labArticleType = parseInt(this.formData.type)
|
||||
if (null != this.formData.navId){
|
||||
this.params.labArticleType = parseInt(this.formData.navId)
|
||||
this.getLabApprove(this.params.labArticleType)
|
||||
}
|
||||
} else if (this.formData.siteType === '1') {
|
||||
this.approveShow.lab = false
|
||||
this.params.sistArticleType = parseInt(this.formData.type)
|
||||
if (null != this.formData.navId){
|
||||
this.params.sistArticleType = parseInt(this.formData.navId)
|
||||
this.getSistApprove(this.params.sistArticleType)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.getDicts("article_site_type").then(response => {
|
||||
this.sitetypeOptions = response.data;
|
||||
});
|
||||
// this.getDicts("article_type").then(response => {
|
||||
// this.articleTypeOptions = response.data;
|
||||
// });
|
||||
this.getDicts("is_top").then(response => {
|
||||
this.isTopOptions = response.data;
|
||||
});
|
||||
@@ -256,28 +288,54 @@ export default {
|
||||
this.labArticleTypeOption.push(item)
|
||||
}
|
||||
}
|
||||
console.log(res)
|
||||
})
|
||||
// getArticleType().then(res => {
|
||||
// let dictCodes = res.data
|
||||
// let articleList = this.articleTypeOptions
|
||||
// console.log("dictCodes",dictCodes,"articleList",articleList)
|
||||
// for (let i = 0; i < articleList.length; i++) {
|
||||
// for (let j = 0; j < dictCodes.length; j++) {
|
||||
// if (articleList[i].dictCode == dictCodes[j]) {
|
||||
// if (articleList[i].attribute2 == 1) {
|
||||
// this.sistArticleTypeOption.push(articleList[i])
|
||||
// } else if (articleList[i].attribute2 == 2) {
|
||||
// this.labArticleTypeOption.push(articleList[i])
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
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 fileStr = '<p><a target="_blank" href="'+mapperItem.url+'">'+mapperItem.fileName+'</a><br/></p>'
|
||||
this.formData.content = this.formData.content + fileStr
|
||||
this.fileMapper.push(mapperItem)
|
||||
})
|
||||
this.$message.success('提交成功!')
|
||||
},
|
||||
|
||||
getSistApprove(navId) {
|
||||
this.judgeThumbnail(navId)
|
||||
getArticleApprove(navId).then(res => {
|
||||
@@ -323,13 +381,6 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
// if (that_.imgurlShow&&(that_.formData.imgurl == ''||that_.formData.imgurl == null)){
|
||||
// Message({
|
||||
// message: "请选择缩略图",
|
||||
// type: "error",
|
||||
// })
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
that_.formData.params = that_.params
|
||||
if (that_.submit == 0) {
|
||||
@@ -360,16 +411,16 @@ export default {
|
||||
this.$router.push({path: "/SIST/article/", query: {t: Date.now()}})
|
||||
},
|
||||
saveDrafts() {
|
||||
let that_ = this
|
||||
let that = this
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
drafts(this.formData).then(res => {
|
||||
if (this.formData.id == null || this.formData.id == "") {
|
||||
this.formData.id = res.data
|
||||
drafts(that.formData).then(res => {
|
||||
if (that.formData.id == null || this.formData.id == "") {
|
||||
that.formData.id = res.data
|
||||
}
|
||||
if (res.code == 200) {
|
||||
that_.msgSuccess('保存成功');
|
||||
that.msgSuccess('保存成功');
|
||||
} else {
|
||||
that_.Message({
|
||||
that.Message({
|
||||
message: res.code,
|
||||
type: "error"
|
||||
})
|
||||
|
||||
@@ -146,11 +146,11 @@
|
||||
<!-- disable-transitions>完成-->
|
||||
<!-- </el-tag>-->
|
||||
<!-- </template>-->
|
||||
<!-- <el-table-column label="修改时间 " align="center" prop="createTime" width="180">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布时间 " align="center" prop="publishTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
@@ -183,7 +183,7 @@
|
||||
@click="handleApprova(scope.row)"
|
||||
>审批
|
||||
</el-button>
|
||||
<span v-show="scope.row.approvalUserId===userId && scope.row.status === '3'">
|
||||
<span v-show="(scope.row.approvalUserId===userId || isAdmin) && scope.row.status === '3'">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
@@ -363,6 +363,19 @@ export default {
|
||||
this.getList()
|
||||
},
|
||||
created() {
|
||||
|
||||
|
||||
let roles = JSON.parse(sessionStorage.getItem("roles"))
|
||||
console.log(roles,"roles")
|
||||
for (const role of roles) {
|
||||
console.log(role)
|
||||
if (role.roleName == 'admin'){
|
||||
this.isAdmin = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getArticleNav().then(res=>{
|
||||
let data = res.data
|
||||
this.articleTypeOptions = data
|
||||
@@ -385,6 +398,11 @@ export default {
|
||||
this.getDicts('article_status').then(response => {
|
||||
this.statusOptions = response.data
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
// activated() {
|
||||
// this.getList()
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
@click="handleFileUpdate"
|
||||
v-hasPermi="['sist:file:edit']"
|
||||
>文件上传
|
||||
</el-button>
|
||||
</el-col>
|
||||
@@ -118,7 +117,6 @@
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['sist:file:remove']"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
@@ -224,10 +222,10 @@
|
||||
<FileUpload v-model="addFile.url" @change="changeAddress"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitAddFile">确 定</el-button>
|
||||
<el-button @click="addCancel">取 消</el-button>
|
||||
</div>
|
||||
<!-- <div slot="footer" class="dialog-footer">-->
|
||||
<!-- <el-button type="primary" @click="submitAddFile">确 定</el-button>-->
|
||||
<!-- <el-button @click="addCancel">取 消</el-button>-->
|
||||
<!-- </div>-->
|
||||
</el-dialog>
|
||||
|
||||
|
||||
@@ -464,8 +462,10 @@ export default {
|
||||
* 改变地址
|
||||
*/
|
||||
changeAddress(addr) {
|
||||
console.log(addr)
|
||||
this.form.fileAddr = addr
|
||||
console.log(addr,"res")
|
||||
this.form.fileAddr = addr.fileAddr
|
||||
this.form.fileName = addr.fileName
|
||||
this.submitAddFile()
|
||||
},
|
||||
/** 文件上传 */
|
||||
handleFileUpdate() {
|
||||
|
||||
Reference in New Issue
Block a user