Commit 80bc8171 authored by ztf's avatar ztf

添加自定义组件

parent fc9f14ca
<!-- 提资信息-附件 -->
<template>
<span>
<el-button v-show="showAdd" type="text" @click.stop="btnClick">操作</el-button>
<el-dropdown>
<span class="el-dropdown-link">
<el-button v-show="files.length" type="text">{{ `查看(${files.length})` }}</el-button>
</span>
<el-dropdown-menu slot="dropdown" class="ExtReviewDocComLink-updateflie">
<el-dropdown-item v-for="(file,index) in files" :key="index">
<div class="file-row">
<span class="file-name" :title="file.originalFileName" @click="downloadFile(file)">
{{ file.originalFileName }}
</span>
</div></el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</span>
</template>
<script>
import _get from 'lodash.get'
import { downFileByFileCode, downFileByFileId } from '@/api/file'
export default {
name: 'InterfaceInfoObjFileLinks',
componentName: '提资信息-附件',
props: {
scope: {
type: Object,
default: null
},
filterKey: {
type: String,
default: () => ''
},
showAdd: {
type: Boolean,
default: false
}
},
data() {
return {}
},
computed: {
files() {
if (!this.scope || !this.scope.row || !this.scope.column) {
return []
}
let objFileLinks = _get(this.scope.row, this.scope.column.property)
if (!objFileLinks) {
return []
}
if (this.filterKey) {
objFileLinks = objFileLinks.filter(link => this.filterKey.includes(link.contentType))
}
return objFileLinks.map(link => link.target)
}
},
watch: {},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {},
methods: {
btnClick(row) {
this.$emit('clickRowFun', this.scope, { btnvalue: 'objFileLinks' })
},
downloadFile(file) {
if (!file.fileCode && !file.resourceId) {
this.$utils.showMessageWarning('没有权限下载该文件!')
return
}
if (file.fileCode) {
downFileByFileCode(file.fileCode).then(res => {
this.downLoadFileUrl(res)
})
return
}
if (file.resourceId) {
downFileByFileId(file.resourceId).then(res => {
this.downLoadFileUrl(res)
})
}
},
downLoadFileUrl(res) {
if (res.headers['content-disposition']) {
const fileName = decodeURI(res.headers['content-disposition'].substring(res.headers['content-disposition'].indexOf('=') + 1, res.headers['content-disposition'].length))
const url = window.URL.createObjectURL(new Blob([res.data], { type: res.headers['content-type'] }))
this.$utils.downLoadFileUrl(url, decodeURI(fileName))
} else {
if (res.data instanceof Blob) {
var reader = new FileReader()
reader.addEventListener('loadend', () => {
const message = reader.result && JSON.parse(reader.result)
this.$utils.showMessageWarning(message ? message.message : '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
})
reader.readAsText(res.data, 'utf-8')
} else {
const message = res.data && res.data.message
this.$utils.showMessageWarning(message || '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
}
}
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
</style>
<!--
* @Author: zhangtianfeng 3232807530@qq.com
* @Date: 2024-08-07 10:59:21
* @LastEditors: zhangtianfeng 3232807530@qq.com
* @LastEditTime: 2024-08-07 11:00:57
-->
<template>
<div class="RelatedInterfaceLinkAddList">
<dee-as-com
class="FeatureTypicalcom"
:lay-config="{
typeName: 'InternalInterface',
layKey: 'RelatedInterfaceLink-Result'
}"
@selectionChange="selectionChange"
/>
<div class="btns">
<el-button type="primary" class="submitBTN" :disabled="!isDisable" @click="tosubmit">确定</el-button>
<el-button type="primary" @click="$emit('cancel')">取消</el-button>
</div>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
name: 'RelatedInterfaceLinkAddList',
componentName: '相关接口单-添加',
props: {
basicData: {
type: Object,
default: () => {}
}
},
data() {
return {
selections: []
}
},
computed: {
isDisable() {
return Boolean(this.selections.length)
}
},
mounted() {
},
methods: {
selectionChange(data) {
this.selections = data
},
tosubmit() {
const source = this.$parent.$parent.$parent.$parent.basicData
const params = this.selections.map(r => {
return {
source: source,
operator: 'ADD',
target: r
}
})
post('ExtRelatedInterfaceLink/recursions', params).then(res => {
this.$emit('completeEven')
})
}
}
}
</script>
<style lang='scss' scoped>
.RelatedInterfaceLinkAddList{
height: 80%;
.FeatureTypicalcom{
height: calc(100% - 50px);
}
.btns{
margin-top: 20px;
display: flex;
justify-content: center;
.submitBTN{
margin-right: 25px;
}
}
}
</style>
<template>
<span v-show="!!value">
<el-button type="text" size="mini" @click="drawer = true">
显示
</el-button>
<el-drawer
title="提资信息"
:visible.sync="drawer"
:append-to-body="true"
direction="rtl"
:before-close="handleClose"
>
<div class="drawer-pop-content">
{{ value }}
</div>
</el-drawer>
</span>
</template>
<script>
export default {
name: 'InfoContent',
componentName: '提资内容显示',
props: {
value: {
type: String,
default: () => ''
},
width: {
type: String,
default: () => '400'
},
// eslint-disable-next-line vue/require-default-prop
scope: {
type: Object,
defalut: () => null
}
},
data() {
return {
drawer: false
}
},
computed: {
title() {
if (!this.scope || !this.scope.column) {
return '标题'
}
return this.scope.column.title || '标题'
}
},
watch: {},
// 生命周期 - 创建完成(访问当前this实例)
created() {},
// 生命周期 - 挂载完成(访问DOM元素)
mounted() {},
methods: {
handleClose() {
this.drawer = false
}
}
}
</script>
<style lang="scss">
/* @import url(); 引入css类 */
.drawer-pop-content{
height: calc(100% - 20px);
padding: 10px;
word-wrap: break-all;
word-wrap:break-word;
word-break: break-word;
overflow-y: auto;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment