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

137 lines
4.4 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"
2023-11-02 14:30:57 +08:00
:data="filedata" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess"
:file-list="fileList" :auto-upload="false">
2023-10-27 15:18:15 +08:00
<el-button slot="trigger" size="small" type="primary" :disabled="flagBtn">选取文件</el-button>
2023-11-02 14:30:57 +08:00
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload"
:disabled="flagBtn">上传压缩包</el-button>
<div slot="tip" class="el-upload__tip">
<div>结构示例</div>
<el-tree :data="dataTip"></el-tree>
<div>说明:1、压缩包目录结构为三级目录,
2、第2级目录名称应为“申请书”或“证据材料”。</div>
</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: {
2023-11-02 14:30:57 +08:00
id: this.uploadCaseData.id
2023-10-27 15:18:15 +08:00
},
2023-11-02 14:30:57 +08:00
flagBtn: false,
dataTip: [{
label: '压缩包名称',
children: [{
label: '申请书',
children: [{
label: '申请书名称.pdf'
}]
}, {
label: '证据材料',
children: [{
label: '证据1.pdf'
}, {
label: '证据2.pdf'
}]
}]
},],
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-11-02 14:30:57 +08:00
let headPath = window.location.origin + "/API";
if(data.annexPath){
window.open(headPath + data.annexPath, "_blank")
}
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;
2023-11-02 14:30:57 +08:00
if (this.data.length > 0) {
2023-10-27 15:18:15 +08:00
this.flagBtn = true;
2023-11-02 14:30:57 +08:00
} else {
2023-10-27 15:18:15 +08:00
this.flagBtn = false;
}
})
},
2023-11-02 14:30:57 +08:00
handleSuccess() {
2023-10-27 15:18:15 +08:00
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>