Merge pull request 'feat : 文件下载组件删除功能' (#195) from dj into master
Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/195
This commit is contained in:
@@ -11,13 +11,15 @@
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-error="uploadError"
|
||||
:before-remove="beforeRemove"
|
||||
:on-remove="handleRemove"
|
||||
>
|
||||
<el-button color="#DED0B2" :loading="loading">上传文件</el-button>
|
||||
</el-upload>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ElMessage} from "element-plus";
|
||||
import {ElMessage,ElMessageBox} from "element-plus";
|
||||
import {getToken} from '@/utils/auth'
|
||||
const baseURL = import.meta.env.VITE_BASE_URL
|
||||
const uploadFileUrl = ref(baseURL + "/workflow/process/file/upload")
|
||||
@@ -45,7 +47,7 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(["input", "getFile"])
|
||||
const emit = defineEmits(["input", "getFile","delete"])
|
||||
const fileList = ref([])
|
||||
const _value = computed({
|
||||
get() {
|
||||
@@ -55,7 +57,17 @@ const _value = computed({
|
||||
emit("input", val);
|
||||
}
|
||||
})
|
||||
const beforeRemove = (file, fileList) => {
|
||||
return ElMessageBox.confirm(`确认删除名称为${file.name}的文件吗?`, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => true)
|
||||
}
|
||||
|
||||
const handleRemove = (file, fileList) => {
|
||||
emit("delete",file.response.data.id)
|
||||
}
|
||||
const beforeUpload = (file) => {
|
||||
// const FileExt = file.name.replace(/.+\./, "");
|
||||
// if (['zip', 'rar', 'pdf', 'doc', 'docx', 'xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
|
||||
@@ -94,4 +106,7 @@ a {
|
||||
font-size: 14px;
|
||||
color: #2a99ff;
|
||||
}
|
||||
:deep(.el-upload-list) {
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<Tinymce image-url="/notice/file" file-url="/notice/file" v-model:value="formData.collectExplain" height="300"
|
||||
v-if="showTinymce"/>
|
||||
<baseTitle title="申请文件"></baseTitle>
|
||||
<file-upload ref="uploadFile" @getFile="getFile"/>
|
||||
<file-upload @getFile="getFile"/>
|
||||
<fvTable style="width: 100%;max-height: 200px" v-if="showTable" :tableConfig="tableConfig" :data="formData.fileList"
|
||||
:isSettingCol="false" :pagination="false">
|
||||
<template #empty>
|
||||
@@ -199,15 +199,15 @@ const init = async () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
const submitParam=()=>{
|
||||
const submitParam=(item)=>{
|
||||
return {
|
||||
collectExplain: formData.value.collectExplain,
|
||||
collectType: formData.value.collectType,
|
||||
companyIds: formData.value.companyIds,
|
||||
deadline: formData.value.deadline,
|
||||
requirementId: formData.value.requirementId?formData.value.requirementId:0,
|
||||
requirementName: formData.value.requirementName,
|
||||
files: formData.value.fileList,
|
||||
collectExplain: item.collectExplain,
|
||||
collectType: item.collectType,
|
||||
companyIds: item.companyIds,
|
||||
deadline: item.deadline,
|
||||
requirementId: item.requirementId?item.requirementId:0,
|
||||
requirementName: item.requirementName,
|
||||
files: item.fileList,
|
||||
deploymentId: processInstanceData.value.deploymentId
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ const handleSubmit = async (instance) => {
|
||||
if (!instance) return
|
||||
instance.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
let res = await addRequirement(submitParam())
|
||||
let res = await addRequirement(submitParam(formData.value))
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success(res.msg)
|
||||
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="项目验收附件" prop="attachment">
|
||||
<file-upload @getFile="getAttachment" :showFileList="true"/>
|
||||
<file-upload @getFile="getAttachment" :showFileList="true" @delete="handleDelete"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="其他文件">
|
||||
<el-card style="width: 100%">
|
||||
<file-upload @getFile="getOtherFile" :showFileList="true"/>
|
||||
<file-upload @getFile="getOtherFile" :showFileList="false" />
|
||||
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
|
||||
:data="otherFileList" :isSettingCol="false" :pagination="false">
|
||||
<template #empty>
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
<script setup lang="jsx">
|
||||
import FileUpload from "@/components/FileUpload.vue";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {deleteFile} from "@/api/project-demand";
|
||||
|
||||
const formData = ref({})
|
||||
const rules = reactive({
|
||||
@@ -99,30 +101,22 @@ const compositeParam = (item) => {
|
||||
}
|
||||
const getAttachment = (val) => {
|
||||
console.log('上传文件', val)
|
||||
showTable.value = false
|
||||
nextTick(() => {
|
||||
showTable.value = true
|
||||
})
|
||||
let fileObj = {}
|
||||
let newFileArray = []
|
||||
if (route.query.isAdd === undefined) {
|
||||
val.forEach(item => {
|
||||
fileObj = compositeParam(item)
|
||||
newFileArray.push(fileObj)
|
||||
formData.value.fileList.push(fileObj)
|
||||
})
|
||||
fileList.value = formData.value.fileList
|
||||
} else {
|
||||
val.forEach(item => {
|
||||
fileObj = compositeParam(item)
|
||||
newFileArray.push(fileObj)
|
||||
})
|
||||
formData.value.fileList = newFileArray
|
||||
fileList.value = newFileArray
|
||||
}
|
||||
// showTable.value = false
|
||||
// let fileObj = compositeParam(val)
|
||||
// formData.value.fileList.push(fileObj)
|
||||
// nextTick(() => {
|
||||
// showTable.value = true
|
||||
// })
|
||||
}
|
||||
const getOtherFile = () => {
|
||||
|
||||
}
|
||||
const handleDelete=(val)=>{
|
||||
deleteFile(val).then(res => {
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success("删除成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
const handleSubmit = (instance) => {
|
||||
if (!instance) return
|
||||
|
||||
Reference in New Issue
Block a user