Merge pull request 'fix : 修复附件上传组件bug' (#198) from dj into master
Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/198
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item :label="label" prop="attachment">
|
<el-form-item :label="label" prop="attachment">
|
||||||
<file-upload @getFile="getAttachment" :showFileList="showFileList" @delete="deleteFile"/>
|
<file-upload @getFile="getAttachment" :showFileList="showFileList" @delete="deleteAttachment"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
@@ -25,7 +25,10 @@
|
|||||||
|
|
||||||
<script setup lang="jsx">
|
<script setup lang="jsx">
|
||||||
import FileUpload from '@/components/FileUpload.vue'
|
import FileUpload from '@/components/FileUpload.vue'
|
||||||
const emit = defineEmits(["getAttachment", "getOtherFile", "deleteFile","deleteOtherFile","download"])
|
import {deleteFile, downloadFile} from "../api/project-demand";
|
||||||
|
import {ElMessage, ElMessageBox} from "element-plus";
|
||||||
|
|
||||||
|
const emit = defineEmits(["getAttachment", "getOtherFile"])
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
const tableConfig = reactive({
|
const tableConfig = reactive({
|
||||||
columns: [
|
columns: [
|
||||||
@@ -52,20 +55,20 @@ const tableConfig = reactive({
|
|||||||
align: 'center',
|
align: 'center',
|
||||||
currentRender: ({row, index}) => (parseInt(row.size / 1024) + 'KB')
|
currentRender: ({row, index}) => (parseInt(row.size / 1024) + 'KB')
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
prop: 'oper',
|
// prop: 'oper',
|
||||||
label: '操作',
|
// label: '操作',
|
||||||
align: 'center',
|
// align: 'center',
|
||||||
showOverflowTooltip: false,
|
// showOverflowTooltip: false,
|
||||||
currentRender: ({row, index}) => {
|
// currentRender: ({row, index}) => {
|
||||||
return (
|
// return (
|
||||||
<div>
|
// <div>
|
||||||
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
|
// <el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
|
||||||
<el-button type="primary" size="large" link onClick={() => deleteOtherFile(row)}>删除</el-button>
|
// <el-button type="primary" size="large" link onClick={() => deleteOtherFile(row)}>删除</el-button>
|
||||||
</div>
|
// </div>
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
@@ -74,39 +77,61 @@ const rules = reactive({
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
showFileList: {
|
showFileList: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default:false
|
default: false
|
||||||
},label: {
|
}, label: {
|
||||||
type: String,
|
type: String,
|
||||||
default:'项目附件'
|
default: '项目附件'
|
||||||
|
}, showTable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
},otherFileList: {
|
},otherFileList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default:[]
|
default: []
|
||||||
},showTable: {
|
|
||||||
type: Boolean,
|
|
||||||
default:true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
watch(() => props.showTable, (newVal) => {
|
watch(() => props.showTable, (newVal) => {
|
||||||
props.showTable=newVal
|
props.showTable = newVal
|
||||||
}, {deep: true})
|
}, {deep: true})
|
||||||
watch(() => props.otherFileList, (newVal) => {
|
watch(() => props.otherFileList, (newVal) => {
|
||||||
props.otherFileList=newVal
|
props.otherFileList = newVal
|
||||||
}, {deep: true})
|
}, {deep: true})
|
||||||
|
|
||||||
const getAttachment = (val) => {
|
const getAttachment = (val) => {
|
||||||
emit('getAttachment',val)
|
emit('getAttachment', val)
|
||||||
}
|
}
|
||||||
const getOtherFile = (val) => {
|
const getOtherFile = (val) => {
|
||||||
emit('getOtherFile',val)
|
emit('getOtherFile', val)
|
||||||
}
|
}
|
||||||
const deleteFile = (val) => {
|
const deleteAttachment = (val) => {
|
||||||
emit('deleteFile',val)
|
deleteFile(val).then(res => {
|
||||||
|
if (res.code === 1000) {
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const deleteOtherFile = (row) => {
|
const deleteOtherFile = (row) => {
|
||||||
emit('deleteOtherFile',row)
|
ElMessageBox.confirm(`确认删除名称为${row.originalFileName}的表格吗?`, '系统提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
deleteFile(row.fileId).then(res => {
|
||||||
|
if (res.code === 1000) {
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
otherFileList.value.splice(otherFileList.value.findIndex((item) => item.id === row.fileId), 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
ElMessage.warning("用户取消删除! ");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const handleDownload = (row) => {
|
const handleDownload = (row) => {
|
||||||
emit('download',row)
|
downloadFile(row.fileId).then(res => {
|
||||||
|
const blob = new Blob([res])
|
||||||
|
let a = document.createElement('a')
|
||||||
|
a.href = URL.createObjectURL(blob)
|
||||||
|
a.download = row.originalFileName
|
||||||
|
a.click()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<AttachmentUpload label="项目验收附件" :showTable="showTable" :otherFileList="otherFileList"
|
<AttachmentUpload label="项目验收附件" :showTable="showTable" :otherFileList="otherFileList"
|
||||||
@deleteOtherFile="deleteOtherFile" @download="downloadOtherFile" @getAttachment="getAttachment"
|
@getAttachment="getAttachment"
|
||||||
@getOtherFile="getOtherFile" :showFileList="true" @deleteFile="deleteAttachment"/>
|
@getOtherFile="getOtherFile" :showFileList="true"/>
|
||||||
<div class="oper-page-btn">
|
<div class="oper-page-btn">
|
||||||
<el-button color="#DED0B2" @click="handleSubmit(applyForm)">提交</el-button>
|
<el-button color="#DED0B2" @click="handleSubmit(applyForm)">提交</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,15 +20,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="jsx">
|
<script setup lang="jsx">
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
import {deleteFile,downloadFile} from "@/api/project-demand";
|
|
||||||
|
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
const fileList = ref(null)
|
const fileList = ref(null)
|
||||||
const applyForm = ref()
|
const applyForm = ref()
|
||||||
const showTable = ref(true)
|
const showTable = ref(true)
|
||||||
const otherFileList = ref([])
|
const otherFileList = ref([])
|
||||||
const compositeParam = (item) => {
|
const compositeParam = (item) => {
|
||||||
|
let tag=''
|
||||||
|
if(!formData.value.collectType&&router.currentRoute.value.name==='Implementation/check'){
|
||||||
|
tag='项目实施'
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
fileId: item.id,
|
fileId: item.id,
|
||||||
size: item.size,
|
size: item.size,
|
||||||
@@ -36,17 +37,13 @@ const compositeParam = (item) => {
|
|||||||
fileType: item.fileType,
|
fileType: item.fileType,
|
||||||
url: item.url,
|
url: item.url,
|
||||||
processNodeTag: null,
|
processNodeTag: null,
|
||||||
tag: formData.value.collectType
|
tag: tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const getAttachment = (val) => {
|
const getAttachment = (val) => {
|
||||||
console.log('上传文件getAttachment', val)
|
console.log('上传文件getAttachment', val)
|
||||||
showTable.value = false
|
|
||||||
let fileObj = compositeParam(val)
|
let fileObj = compositeParam(val)
|
||||||
fileList.value.push(fileObj)
|
// fileList.value.push(fileObj)
|
||||||
nextTick(() => {
|
|
||||||
showTable.value = true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
const getOtherFile = (val) => {
|
const getOtherFile = (val) => {
|
||||||
console.log('上传文件getOtherFile', val)
|
console.log('上传文件getOtherFile', val)
|
||||||
@@ -57,39 +54,8 @@ const getOtherFile = (val) => {
|
|||||||
showTable.value = true
|
showTable.value = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const deleteAttachment = (val) => {
|
|
||||||
deleteFile(val).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success("删除成功");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const deleteOtherFile = (row) => {
|
|
||||||
ElMessageBox.confirm(`确认删除名称为${row.originalFileName}的表格吗?`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
deleteFile(row.fileId).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success("删除成功");
|
|
||||||
otherFileList.value.splice(otherFileList.value.findIndex((item) => item.id === row.fileId), 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
ElMessage.warning("用户取消删除! ");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const downloadOtherFile = (row) => {
|
|
||||||
downloadFile(row.fileId).then(res => {
|
|
||||||
const blob = new Blob([res])
|
|
||||||
let a = document.createElement('a')
|
|
||||||
a.href = URL.createObjectURL(blob)
|
|
||||||
a.download = row.originalFileName
|
|
||||||
a.click()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const handleSubmit = (instance) => {
|
const handleSubmit = (instance) => {
|
||||||
if (!instance) return
|
if (!instance) return
|
||||||
instance.validate(async (valid) => {
|
instance.validate(async (valid) => {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ const tableConfig = reactive({
|
|||||||
} else if (row.state === '4') {
|
} else if (row.state === '4') {
|
||||||
btn.push({label: '台账', func: () => handleStandingBook(row), type: 'primary'})
|
btn.push({label: '台账', func: () => handleStandingBook(row), type: 'primary'})
|
||||||
btn.push({label: '附件', func: () => handleAttachment(row), type: 'primary'})
|
btn.push({label: '附件', func: () => handleAttachment(row), type: 'primary'})
|
||||||
btn.push({label: '分摊', func: () => handleShare(row), type: 'primary'})
|
btn.push({label: '查看分摊', func: () => handleShare(row), type: 'primary'})
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div style={{width: '100%'}}>
|
<div style={{width: '100%'}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user