提交 b4c4ef66 编写于 作者: sq3536's avatar sq3536

配置

上级 147e5218
......@@ -12,7 +12,6 @@
:headers="myHeaders"
:file-list="uploadFileList"
:show-file-list="false"
:limit="limit"
:http-request="customUploadFile">
<div>
<i class="el-icon-upload"></i>
......@@ -20,7 +19,6 @@
<span>{{$t('components.diskFileUpload.fileDrag')}}</span>
<span style="color:#409EFF;">{{$t('components.diskFileUpload.clickUpload')}}</span>
</div>
<div slot="tip" class="el-upload__tip">{{uploadTip}}</div>
</div>
</el-upload>
</el-col>
......@@ -34,10 +32,10 @@
:headers="myHeaders"
:file-list="uploadFileList"
:show-file-list="false"
:limit="limit"
:http-request="customUploadFile">
<el-button type="primary" size="small" icon="el-icon-upload">{{$t('components.diskFileUpload.clickUpload')}}</el-button>
<div slot="tip" class="el-upload__tip">{{uploadTip}}</div>
<el-button type="primary" size="small" icon="el-icon-upload">
{{$t('components.diskFileUpload.clickUpload')}}
</el-button>
</el-upload>
</el-col>
<!--文件操作-->
......@@ -47,8 +45,11 @@
<span>{{item.name}}</span>
</div>
<div class="fileMain">
<el-link type="success" icon="el-icon-download" @click="onDownload(item)">{{$t('components.diskFileUpload.load')}}</el-link>
<el-link type="warning" icon="el-icon-view" v-show="showPreview" @click="onPreview(item)">{{$t('components.diskFileUpload.preview')}}
<el-link type="success" icon="el-icon-download" @click="onDownload(item)">
{{$t('components.diskFileUpload.load')}}
</el-link>
<el-link type="warning" icon="el-icon-view" v-show="showPreview" @click="onPreview(item)">
{{$t('components.diskFileUpload.preview')}}
</el-link>
<el-link type="primary" icon="el-icon-edit"
v-show="showEdit && (item.name.match(/^.+\.(doc|DOC|docx|DOCX|wps|WPS|xls|XLS|xlsx|XLSX|ppt|PPT|et|ET)$/))"
......@@ -58,21 +59,46 @@
v-show="showOcrview && (item.name.match(/^.+\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP|pdf|PDF)$/))"
@click="onOcr(item)">OCR
</el-link>
<el-link type="danger" icon="el-icon-delete" @click="onRemove(item,index)">{{$t('components.diskFileUpload.delete')}}</el-link>
<el-link type="danger" icon="el-icon-delete" @click="onRemove(item,index)">
{{$t('components.diskFileUpload.delete')}}
</el-link>
</div>
</el-col>
</el-row>
<!-- 自定义弹框 -->
<div class="dialogDiv">
<el-dialog
width="70%"
top="5vh"
:visible="showDialog"
:close-on-click-modal="true"
:show-close="true"
:before-close="dialogClose"
:modal-append-to-body="false">
<div style="height: 100%;">
<iframe id="wps_npIframe" :src="iframeUrl" frameborder="0" width="100%"></iframe>
</div>
</el-dialog>
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import {Button, Row, Col, Link, Icon, Upload, Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
import {Component, Vue, Prop, Watch} from 'vue-property-decorator';
import {Button, Row, Col, Link, Icon, Upload, Message, MessageBox} from 'element-ui';
import Axios from 'axios';
import {Subject, Unsubscribable} from 'rxjs';
@Component({})
export default class DiskFileUpload extends Vue {
@Component({})
export default class DiskFileUpload extends Vue {
public showDialog = false;
public iframeUrl: any = '';
public dialogClose() {
this.showDialog = false;
this.iframeUrl = '';
}
/**
* 当前表单对象
......@@ -170,22 +196,6 @@ export default class DiskFileUpload extends Vue {
*/
@Prop({default: false}) public showOcrview?: boolean;
/**
* 单文件大小
*
* @type {number}
* @memberof DiskFileUpload
*/
@Prop({default: 1}) public size!: number;
/**
* 文件上传个数
*
* @type {number}
* @memberof DiskFileUpload
*/
@Prop({default: 5}) public limit!: number;
/**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
*
......@@ -194,15 +204,6 @@ export default class DiskFileUpload extends Vue {
*/
public srfuf: string = '0';
/**
* 上传提示语
*
* @type {string}
* @memberof DiskFileUpload
*/
get uploadTip(): string {
return this.$t('components.diskFileUpload.clues')+this.size.toString()+"M,"+this.$t('components.diskFileUpload.clues1')+this.limit;
}
/**
* 文件列表
......@@ -297,7 +298,7 @@ export default class DiskFileUpload extends Vue {
*
* @memberof DiskFileUpload
*/
public created(){
public created() {
this.formStateEvent = this.formState.subscribe(($event: any) => {
// 表单加载完成
if (Object.is($event.type, 'load')) {
......@@ -336,9 +337,9 @@ export default class DiskFileUpload extends Vue {
*
* @memberof DiskFileUpload
*/
public getFiles(){
public getFiles() {
// 拼接url
let _this:any = this;
let _this: any = this;
const getUrl = '/net-disk/files/' + this.getFolder();
// 发送get请求
Axios.get(getUrl, {
......@@ -348,7 +349,7 @@ export default class DiskFileUpload extends Vue {
},
}).then(response => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.getFileFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.getFileFailure') + '!');
return;
}
// 返回的是一个jsonArray
......@@ -359,7 +360,7 @@ export default class DiskFileUpload extends Vue {
}
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.getFileFailure')+':'+ error);
Message.error(_this.$t('components.diskFileUpload.getFileFailure') + ':' + error);
});
}
......@@ -373,12 +374,6 @@ export default class DiskFileUpload extends Vue {
// 上传的文件
let _this: any = this;
let file = param.file;
// 文件大小
const isSize = file.size / 1024 / 1024 < this.size;
if (!isSize) {
Message.error(_this.$t('components.diskFileUpload.loadFailure1')+_this.size.toString()+"M!");
return;
}
// formData传参
let formData = new FormData();
formData.append('file', file);
......@@ -387,7 +382,7 @@ export default class DiskFileUpload extends Vue {
// 发送post请求
Axios.post(uploadUrl, formData, {timeout: 2000}).then(response => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.loadFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.loadFailure') + '!');
}
// 返回的是一个jsonobject
if (response.data) {
......@@ -404,7 +399,7 @@ export default class DiskFileUpload extends Vue {
}
}
}).catch(err => {
Message.error(_this.$t('components.diskFileUpload.loadFailure')+':'+ err);
Message.error(_this.$t('components.diskFileUpload.loadFailure') + ':' + err);
})
}
......@@ -428,7 +423,7 @@ export default class DiskFileUpload extends Vue {
responseType: 'arraybuffer',
}).then(response => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.downloadFile')+'!');
Message.error(_this.$t('components.diskFileUpload.downloadFile') + '!');
return;
}
// 请求成功,后台返回的是一个文件流
......@@ -456,7 +451,7 @@ export default class DiskFileUpload extends Vue {
Message.error(_this.$t('components.diskFileUpload.downloadFile1'));
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.downloadFile')+':'+ error);
Message.error(_this.$t('components.diskFileUpload.downloadFile') + ':' + error);
});
}
......@@ -471,8 +466,9 @@ export default class DiskFileUpload extends Vue {
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const previewUrl = '/net-disk/preview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
window.open(previewUrl);
// 自定义弹框打开url
this.showDialog = true;
this.iframeUrl = previewUrl;
}
/**
......@@ -485,8 +481,10 @@ export default class DiskFileUpload extends Vue {
// 拼接url
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const editUrl = '/net-disk/edit/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
const editUrl = '/net-disk/editview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 自定义弹框打开url
// this.showDialog = true;
// this.iframeUrl = editUrl;
window.open(editUrl);
}
......@@ -501,8 +499,9 @@ export default class DiskFileUpload extends Vue {
const id = typeof item.id == "string" ? item.id : JSON.stringify(item.id);
const name = typeof item.name == "string" ? item.name : JSON.stringify(item.name);
const ocrUrl = '/net-disk/ocrview/' + this.getFolder() + '/' + id + '/' + name + '?authcode=' + item.authcode;
// 新窗口打开url
window.open(ocrUrl);
// 自定义弹框打开url
this.showDialog = true;
this.iframeUrl = ocrUrl;
}
/**
......@@ -513,7 +512,7 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public onRemove(item: any, index: number) {
let _this:any = this;
let _this: any = this;
if (item) {
MessageBox.confirm(_this.$t('components.diskFileUpload.deleteFile'), _this.$t('components.diskFileUpload.deleteFilePrompt'), {
confirmButtonText: _this.$t('components.diskFileUpload.true'),
......@@ -525,7 +524,7 @@ export default class DiskFileUpload extends Vue {
// 发送delete请求
Axios.delete(deleteUrl).then(response => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure') + '!');
}
// 从文件列表中删除
this.uploadFileList.splice(index, 1);
......@@ -536,7 +535,7 @@ export default class DiskFileUpload extends Vue {
}
}).catch(error => {
// 提示删除失败
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure')+':'+ error);
Message.error(_this.$t('components.diskFileUpload.deleteFileFailure') + ':' + error);
});
});
}
......@@ -548,7 +547,7 @@ export default class DiskFileUpload extends Vue {
* @memberof DiskFileUpload
*/
public updateFileBatch(files: any, opt: any) {
let _this:any = this;
let _this: any = this;
// 拼接url
const updateUrl = '/net-disk/files/' + this.getFolder() + '?ownertype=' + this.getOwnertype() + "&ownerid=" + this.getOwnerid();
// requestBody参数
......@@ -564,67 +563,89 @@ export default class DiskFileUpload extends Vue {
timeout: 2000
}).then(response => {
if (!response || response.status != 200) {
Message.error(_this.$t('components.diskFileUpload.updateFailure')+'!');
Message.error(_this.$t('components.diskFileUpload.updateFailure') + '!');
return;
}
}).catch(error => {
Message.error(_this.$t('components.diskFileUpload.updateFailure')+':'+ error);
Message.error(_this.$t('components.diskFileUpload.updateFailure') + ':' + error);
});
}
}
}
</script>
<style lang="less">
#file-upload {
#file-upload {
width: auto;
height: auto;
border: 0px solid black;
}
}
#el-row {
#el-row {
border: 0px solid red;
width: 400px;
}
}
.withDrag {
.withDrag {
border: 0px solid grey;
width: 400px;
}
}
.withoutDrag {
.withoutDrag {
border: 0px solid grey;
width: 400px;
text-align: left;
padding-left: 0px;
padding-top: 0px;
margin-top: 0px;
}
.el-upload__tip {
margin-top: 0px;
}
}
.fileList {
.fileList {
width: 400px;
border: 0px solid grey;
margin-top: 0px;
}
}
.fileTitle {
.fileTitle {
text-align: left;
margin-left: 0px;
}
}
.fileTitle i {
.fileTitle i {
margin-right: 5px;
}
}
.fileMain {
.fileMain {
text-align: left;
margin-left: 0px;
margin-top: -10px;
}
}
.fileMain .el-link:nth-child(n+2) {
.fileMain .el-link:nth-child(n+2) {
margin-left: 10px;
}
}
.dialogDiv{
// el-dialog头部
.el-dialog__header{
height:40px;
}
// el-dialog面板
.el-dialog__wrapper {
height: 90vh;
overflow: visible;
}
// el-dialog
.el-dialog {
height: 100%;
}
// el-dailog内容
.el-dialog__body {
height: inherit;
}
#wps_npIframe{
height: calc(100% - 40px);
}
}
</style>
\ No newline at end of file
......@@ -117,7 +117,9 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll()
.antMatchers("/lite/**").permitAll();
.antMatchers("/lite/**").permitAll()
.antMatchers("/net-disk/download/**").permitAll()
.antMatchers("/net-disk/**view/**").permitAll();
for (String excludePattern : excludesPattern) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册