父组件是列表,子组件是弹窗。通过列表插槽的查看详情打开弹窗,点击a链接查看附件,跳到新页面查看pdf等网页文件
<a :href="attachUrl" :target="targetUrl" @click="checkAttach()">查看附件</a>
attachUrl: '#',
targetUrl: null,
在点击查看详情,子组件获取列表当前行数据的方法中
add(certifyData) {
this.visible = true
this.DataHistoryId = this.$parent.DataHistoryId//获取参数
this.execution_id = certifyData.execution_id//获取参数
this.attachUrl = '#'
this.targetUrl = null
let form = {
DataId: this.DataHistoryId,
ItemId: this.execution_id
}
getHistoryAttach(form).then(res => {
if (res.length !== 0) {
this.attachUrl = res[0].fVcPreviewUrl
this.targetUrl = '_blank'
}
})
},
checkAttach() {
if (this.attachUrl == '#') {
this.$message.warning('暂无附件')
}
}