|
|
@@ -6,7 +6,7 @@ |
|
|
|
:size="drawerWidth" |
|
|
|
:before-close="handleClose" |
|
|
|
> |
|
|
|
<div class="info-form"> |
|
|
|
<div v-loading="uploadLoading" class="info-form"> |
|
|
|
<el-form ref="ruleForm" :model="data" size="small" label-width="80px"> |
|
|
|
<el-form-item label="类型" prop="type" :rules="{ |
|
|
|
required: true, message: '类型不能为空', trigger: 'blur' |
|
|
@@ -24,6 +24,24 @@ |
|
|
|
<el-form-item label="正文" prop="content"> |
|
|
|
<vue-editor useCustomImageHandler @image-added="handleImageAdded" v-model="data.content"></vue-editor> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="附件" prop="attachment"> |
|
|
|
<el-button |
|
|
|
@click="uploadFile" |
|
|
|
size="small" |
|
|
|
type="primary" |
|
|
|
icon="el-icon-upload2" |
|
|
|
>上传 |
|
|
|
</el-button> |
|
|
|
<el-button |
|
|
|
v-if="data.attachment" |
|
|
|
@click="dowxText(data.attachment)" |
|
|
|
size="small" |
|
|
|
type="primary" |
|
|
|
icon="el-icon-upload" |
|
|
|
>下载 |
|
|
|
</el-button> |
|
|
|
</el-form-item> |
|
|
|
<input id="upload" type="file" name="file" @change="uploadClick" style="display: none;"/> |
|
|
|
</el-form> |
|
|
|
<div style="text-align: center"> |
|
|
|
<el-button |
|
|
@@ -50,11 +68,13 @@ |
|
|
|
import api from '@/api/work/notice' |
|
|
|
import { VueEditor } from "vue2-editor"; |
|
|
|
import userApi from '@/api/user/user' |
|
|
|
import $ from 'jquery' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "add-form", |
|
|
|
data() { |
|
|
|
return { |
|
|
|
uploadLoading:false, |
|
|
|
addBtnLoading:false, |
|
|
|
drawerWidth: document.body.clientWidth - 190 + "px", |
|
|
|
data: {}, |
|
|
@@ -81,6 +101,42 @@ |
|
|
|
mounted() { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
uploadClick(event) { |
|
|
|
let file = event.target.files[0]; |
|
|
|
let maxSize=5*1024*1024 |
|
|
|
if(file.size>maxSize){ |
|
|
|
this.$message({ |
|
|
|
type: "success", |
|
|
|
message: "文件大小不能超过5M" |
|
|
|
}); |
|
|
|
}else{ |
|
|
|
let formdata = new window.FormData(); |
|
|
|
formdata.append("file", file); |
|
|
|
this.uploadLoading = true; |
|
|
|
userApi.upload(formdata).then( |
|
|
|
rs => { |
|
|
|
this.$message({ |
|
|
|
type: "success", |
|
|
|
message: "上传成功" |
|
|
|
}); |
|
|
|
let data = JSON.parse(JSON.stringify(this.data)) |
|
|
|
data.attachment= rs.data.url; |
|
|
|
this.data = Object.assign({}, data) |
|
|
|
this.uploadLoading = false; |
|
|
|
}, |
|
|
|
error => { |
|
|
|
this.uploadLoading = false; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
event.target.value = ""; |
|
|
|
}, |
|
|
|
uploadFile(name) { |
|
|
|
$("#upload").click(); |
|
|
|
}, |
|
|
|
dowxText(path){ |
|
|
|
window.open(path) |
|
|
|
}, |
|
|
|
handleImageAdded(file, Editor, cursorLocation, resetUploader){ |
|
|
|
var formData = new FormData(); |
|
|
|
formData.append("file", file); |