前后台-- -- 上传附件

This commit is contained in:
gaoyuanwei 2022-09-01 13:50:42 +08:00
parent 7ff222761c
commit 2ff89ea6e4
9 changed files with 136 additions and 8 deletions

View File

@ -293,7 +293,7 @@ export default {
})
this.allData = JSON.parse(JSON.stringify(this.transferData))
}).catch(err => {
this.$message.error(err)
this.$message.error('未搜索到相关数据资源')
})
}
},
@ -316,6 +316,7 @@ export default {
title: this.type,
list: this.selectedArray
})
console.log(this.selectedArray, this.displayList, 'this.displayList')
},
getDisplay (displayList) {
this.displayList = []

View File

@ -36,8 +36,10 @@
tip="支持文件类型大小不超过100M"></upload>
<upload @changeInfoList='changeInfoList' :title='item.name' accept='.mp4' :list="item" v-else-if="item.type == 'video'" type="视频" btnName="上传视频" :maxCount="1" :dataList="item"
tip="支持视频类型大小不超过100M"></upload>
<upload @changeInfoList='changeInfoList' :title='item.name' accept='.zip' :list="item" v-else-if="item.type == 'package'" type="安装包" btnName="上传安装包" :maxCount="1" :dataList="item"
<upload @changeInfoList='changeInfoList' :title='item.name' accept='.zip' :list="item" v-else-if="item.type == 'package' &&item.name != '上传附件'" type="安装包" btnName="上传安装包" :maxCount="1" :dataList="item"
tip="支持.zip类型大小不超过100M"></upload>
<upload @changeInfoList='changeInfoList' :title='item.name' accept='.pdf,.ppt,.xlsx,.doc,.docx,.zip' :list="item" v-else-if="item.name == '上传附件'" type="附件" btnName="上传附件" :maxCount="1" :dataList="item"
tip="大小不超过100M"></upload>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'AbilityType'" type="disabled" :data="item" :name="item.name" :value="typeInput"></input-select-checkbox>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'ComponentType'" type="disabled" :data="item" :name="item.name" :value="type"></input-select-checkbox>
<input-select-checkbox :changeField='changeField' :list="[]" v-else-if="item.type == 'input'" type="input" :data="item" :name="item.name"></input-select-checkbox>
@ -267,7 +269,7 @@ export default {
}
.item {
position: relative;
.box{
.box {
display: flex;
align-items: center;
margin: 25px 0;
@ -276,17 +278,17 @@ export default {
display: flex;
align-items: center;
}
.required{
.required {
color: #f56c6c;
margin-right: 3px;
}
}
.requiredTips{
.requiredTips {
font-size: 14px;
color: #f56c6c;
position: absolute;
bottom:-20px;
left:110px;
bottom: -20px;
left: 110px;
}
}
</style>

View File

@ -69,6 +69,7 @@
:dataFrom="dataFrom"
:fileList="fileList"
:packageList="packageList"
:accessoryList="accessoryList"
:imgList="imgList"
:externalField="['接口服务', '接口请求方式']"
:configure="bs"
@ -370,6 +371,7 @@
const navList2 = ref([])
const fileList = ref({})
const packageList = ref({})
const accessoryList = ref({})
const imgList = ref({})
const videoList = ref({})
const data = ref({})
@ -787,6 +789,9 @@
mybus.on('chagePackageList', (obj) => {
packageList.value = obj
})
mybus.on('chageAccessory', (obj) => {
accessoryList.value = obj
})
mybus.on('chageImgList', (obj) => {
imgList.value = obj
})
@ -836,6 +841,7 @@
mybus.off('chageDataFromDwon')
mybus.off('chageVideoList')
mybus.off('chagePackageList')
mybus.off('chageAccessory')
})
</script>
<style lang="less" scoped>

View File

@ -69,6 +69,7 @@
:dataFrom="dataFrom"
:fileList="fileList"
:fileList2="fileList2"
:accessoryList="accessoryList"
:imgList="imgList"
:configure="bs"
@submit="submit()"
@ -339,6 +340,7 @@
const navList2 = ref([])
const fileList = ref({})
const fileList2 = ref({})
const accessoryList = ref({})
const imgList = ref({})
const videoList = ref({})
const data = ref({})
@ -751,6 +753,9 @@
mybus.on('chageVideoList', (obj) => {
videoList.value = obj
})
mybus.on('chageAccessory', (obj) => {
accessoryList.value = obj
})
//datafrom
mybus.on('chageDataFromDwon', (obj) => {
switch (obj.attrType) {
@ -793,6 +798,7 @@
mybus.off('chageFileList2')
mybus.off('chageImgList')
mybus.off('chageDataFromDwon')
mybus.off('chageAccessory')
})
</script>
<style lang="less" scoped>

View File

@ -69,6 +69,7 @@
:dataFrom="dataFrom"
:fileList="fileList"
:fileList2="fileList2"
:accessoryList="accessoryList"
:configure="bs"
@submit="submit()"
@back="back()"
@ -338,6 +339,7 @@
const navList2 = ref([])
const fileList = ref({})
const fileList2 = ref({})
const accessoryList = ref({})
const imgList = ref({})
const videoList = ref({})
const data = ref({})
@ -748,6 +750,9 @@
mybus.on('chageVideoList', (obj) => {
videoList.value = obj
})
mybus.on('chageAccessory', (obj) => {
accessoryList.value = obj
})
//datafrom
mybus.on('chageDataFromDwon', (obj) => {
switch (obj.attrType) {
@ -790,6 +795,7 @@
mybus.off('chageFileList2')
mybus.off('chageImgList')
mybus.off('chageDataFromDwon')
mybus.off('chageAccessory')
})
</script>
<style lang="less" scoped>

View File

@ -66,6 +66,7 @@
:dataFrom="dataFrom"
:fileList="fileList"
:fileList2="fileList2"
:accessoryList="accessoryList"
:configure="bs"
@submit="submit()"
@back="back()"
@ -237,6 +238,7 @@
const navList2 = ref([])
const fileList = ref({})
const fileList2 = ref({})
const accessoryList = ref({})
const imgList = ref({})
const videoList = ref({})
const data = ref({})
@ -618,6 +620,9 @@
mybus.on('chageVideoList', (obj) => {
videoList.value = obj
})
mybus.on('chageAccessory', (obj) => {
accessoryList.value = obj
})
//datafrom
mybus.on('chageDataFromDwon', (obj) => {
switch (obj.attrType) {
@ -660,6 +665,7 @@
mybus.off('chageFileList2')
mybus.off('chageImgList')
mybus.off('chageDataFromDwon')
mybus.off('chageAccessory')
})
</script>
<style lang="less" scoped>

View File

@ -301,6 +301,16 @@
:list="props.fileList2"
tip="支持文件类型大小不超过100M"
></upload>
<upload
v-else-if="item.type == 'package' && item.name == '上传附件'"
type="附件"
btnName="上传附件"
:maxCount="1"
:data="item"
:busType="2"
:list="props.fileList2"
tip="支持文件类型大小不超过100M"
></upload>
<upload
v-else-if="item.type == 'package'"
type="压缩包"

View File

@ -78,6 +78,13 @@
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
} else if (props.type === '压缩包') {
flag = file.type === 'application/x-zip-compressed'
} else if (props.type === '附件') {
flag =
file.type === 'application/pdf' ||
file.type === 'application/msword' ||
file.type ===
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
file.type === 'application/x-zip-compressed'
}
console.log(flag)
if (!flag) {
@ -131,6 +138,8 @@
}
} else if (props.type === '压缩包') {
mybus.emit('chagePackageList', fileList.value)
} else if (props.type === '附件') {
mybus.emit('chageAccessory', fileList.value)
} else if (props.type === '视频') {
console.log(fileList.value)
mybus.emit('chageVideoList', fileList.value)

View File

@ -84,7 +84,12 @@
</div>
<div class="box" v-if="item.list.length > 0">
<div class="ability" v-for="val in item.list" :key="val.id">
<div
class="ability"
v-for="val in item.list"
:key="val.id"
:class="item.approveStatus === '通过' ? 'clickCursor' : ''"
>
<div
class="left"
:class="
@ -148,6 +153,25 @@
申请结果{{
item.ended ? item.approveStatus || '审核完成' : '审核中'
}}
<a-button
v-if="
item.approveStatus === '通过' &&
val.infoList.filter(
(item) => item.attrType == '上传附件'
)[0]
"
@click.stop="downloadFile(item, '附件下载')"
class="DownloadAttachment"
>
附件下载
</a-button>
<a-button
v-if="item.approveStatus === '通过'"
@click.stop="switchFunction(item)"
class="DownloadAttachment2"
>
查看详情
</a-button>
</div>
</div>
</div>
@ -313,6 +337,48 @@
}
}
}
const switchFunction = (data) => {
if (data.approveStatus === '通过') {
let id = data.list[0].id
const applypage = router.resolve({
path: '/details', //
query: {
id: id,
},
})
window.open(applypage.href, '_blank')
}
}
const downloadFile = (data, name) => {
let path = data.list[0].infoList.filter(
(item) => item.attrType === '上传附件'
)[0].attrValue
console.log(path, 'obj')
const xhr = new XMLHttpRequest()
xhr.open('get', path)
xhr.responseType = 'blob'
xhr.send()
xhr.onload = function () {
if (this.status === 200 || this.status === 304) {
// IE10downloadmsSaveOrOpenBlobIE10msSaveOrOpenBlob
if ('msSaveOrOpenBlob' in navigator) {
navigator.msSaveOrOpenBlob(this.response, name)
return
}
// const blob = new Blob([this.response], { type: xhr.getResponseHeader('Content-Type') });
// const url = URL.createObjectURL(blob);
const url = URL.createObjectURL(this.response)
const a = document.createElement('a')
a.style.display = 'none'
a.href = url
a.download = name
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
}
}
}
</script>
<style lang="less" scoped>
.title {
@ -487,8 +553,24 @@
// color: #0058e1;
// cursor: pointer;
// }
.result {
position: relative;
}
}
}
.DownloadAttachment {
position: absolute;
right: 10px;
top: -150px;
}
.DownloadAttachment2 {
position: absolute;
right: 10px;
top: -110px;
}
}
.clickCursor {
cursor: pointer;
}
}
}