Files
Arbitrate-Frontend/src/views/caseManagement/components/uploadCaseDialog.vue
T

111 lines
3.5 KiB
Vue
Raw Normal View History

2023-10-24 16:27:30 +08:00
<template>
<div>
<el-dialog title="上传证据目录" :visible="uploadCaseVisable" @close="cancel" center :distroy-on-close="true">
2023-10-27 15:18:15 +08:00
<el-upload class="upload-demo" :before-upload="beforeUpload" ref="upload" accept=".zip"
action="https://jsonplaceholder.typicode.com/posts/" :action="UploadUrl()" :headers="headers"
:data="filedata" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary" :disabled="flagBtn">选取文件</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload" :disabled="flagBtn">上传压缩包</el-button>
<div slot="tip" class="el-upload__tip">只能上传zip文件,并且格式为一级目录上传申请书证据材料,二级目录为申请书和证据材料</div>
2023-10-24 16:27:30 +08:00
</el-upload>
<div class="title">证据目录结构</div>
<el-tree :data="data" @node-click="handleNodeClick"></el-tree>
</el-dialog>
</div>
</template>
<!-- hearDate -->
<script>
2023-10-27 15:18:15 +08:00
import { evidenceTree } from '@/api/caseAccess/caseEntry.js'
import { getToken } from "@/utils/auth";
2023-10-24 16:27:30 +08:00
export default {
props: ["uploadCaseVisable", "uploadCaseData"],
data() {
return {
fileList: [],
2023-10-27 15:18:15 +08:00
data: [],
headers: {
Authorization: "Bearer " + getToken(),
2023-10-24 16:27:30 +08:00
},
2023-10-27 15:18:15 +08:00
filedata: {
id:this.uploadCaseData.id
},
flagBtn:false
2023-10-24 16:27:30 +08:00
};
},
watch: {
2023-10-27 15:18:15 +08:00
uploadCaseVisable(val) {
if (val) {
this.evidenceTreeFn({ caseId: this.uploadCaseData.id })
}
}
2023-10-24 16:27:30 +08:00
},
created() {
},
methods: {
2023-10-27 15:18:15 +08:00
UploadUrl() {
return window.location.origin + "/API/caseApplication/uploadZipFile";
},
2023-10-24 16:27:30 +08:00
cancel() {
this.$emit("uploadCaseCancel");
},
submitUpload() {
2023-10-27 15:18:15 +08:00
this.filedata.id = this.uploadCaseData.id
2023-10-24 16:27:30 +08:00
this.$refs.upload.submit();
},
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
handleNodeClick(data) {
console.log(data);
2023-10-27 15:18:15 +08:00
},
// 递归替换key
setData(data) {
data.forEach((val, i) => {
val.label = val.evidenceName
this.setData(val.children)
})
},
// 获取证据目录
evidenceTreeFn(data) {
evidenceTree(data).then(res => {
this.setData(res.data);
this.data = res.data;
if(this.data.length > 0){
this.flagBtn = true;
}else{
this.flagBtn = false;
}
})
},
handleSuccess(){
this.evidenceTreeFn({ caseId: this.uploadCaseData.id })
},
beforeUpload(file) {
console.log(file.type);
const isZip = file.type === 'application/x-zip-compressed'
if (!isZip) {
this.$message.error('只能上传zip格式的文件')
}
return isZip
2023-10-24 16:27:30 +08:00
}
},
};
</script>
<style lang="scss" scoped>
.title {
margin-top: 30px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 600;
}
2023-10-27 15:18:15 +08:00
.el-upload__tip {
color: red;
}
2023-10-24 16:27:30 +08:00
</style>