| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <div>
- <div @click="detail" class="pointer">
- <slot name="title">
- <el-button type="primary" text>查看</el-button>
- </slot>
- </div>
- <el-image-viewer
- v-if="showImage"
- :url-list="preList"
- @close="showImage = false"
- />
- <el-drawer v-model="show" :size="1200" append-to-body>
- <template #title>
- <h4
- class="ml-20 black flex flex-center flex-justify-start full-width font-16 bold"
- >
- {{ data ? data.title : '' }}
- </h4>
- </template>
- <div>
- <div v-if="data">
- <div v-if="data.imgs.length === 0" class="flex flex-center">
- <div v-html="data.content" class="preview"></div>
- </div>
- <div v-else v-for="item in data.imgs" :key="item.id">
- <img :src="item.filePath" style="width: 1100px" />
- </div>
- </div>
- <div
- class="bottom flex flex-center flex-justify-center"
- v-if="isAccess === 2 || showAction"
- >
- <el-button type="primary" icon="Download" @click="downloadClick"
- >下 载
- </el-button>
- <share
- class="ml-20"
- :project-id="projectId"
- :ids="id"
- v-if="isAccess === 2"
- />
- <el-button
- class="ml-20"
- type="primary"
- @click="moreDetail"
- v-if="liButton"
- >文件历史
- </el-button>
- <el-drawer v-model="liShow" :size="600">
- <div
- class="flex ml-10"
- v-for="item in fileHistoryList"
- @click="newDetail(item)"
- >
- <div class="mt-10">{{ item.coverUser }}</div>
- <div class="ml-20 mt-10">在{{ item.createTime }}上传,</div>
- <div class="ml-20 mt-10">编码{{ item.fileVO.md5 }}</div>
- </div>
- </el-drawer>
- </div>
- </div>
- </el-drawer>
- </div>
- </template>
- <script>
- import api from '@/api/index.js'
- import share from '@/views/resource/component/share.vue'
- export default {
- components: {
- share
- },
- props: {
- title: {
- type: String,
- default: () => {
- return ''
- }
- },
- isAccess: {
- type: Number,
- default: 3
- },
- showAction: {
- type: Boolean,
- default: false
- },
- projectId: {
- type: String,
- default: ''
- },
- id: {
- type: String,
- default: null
- }
- },
- watch: {
- id: {
- handler(val) {
- if (val != null) {
- this.fileId = val
- }
- },
- immediate: true
- }
- },
- data() {
- return {
- fileId: '',
- liButton: false,
- liShow: false,
- show: false,
- data: null,
- preList: [],
- fileHistoryList: [1, 2, 3],
- showImage: false,
- watermarkOptions: {
- content: 'watermark',
- gap: [20, 20],
- offset: [10, 10],
- zIndex: 5,
- rotate: -20
- }
- }
- },
- methods: {
- newDetail(item) {
- this.fileId = item.fileVO.id
- this.detail()
- },
- detail() {
- //先判断是否存在历史列表
- this.$api.project
- .fileHistory({ fileId: this.fileId, current: 1, size: 100 })
- .then(res => {
- if (res.code === 200) {
- console.log(res)
- if (res.data.total > 0) {
- this.liButton = true
- this.fileHistoryList = res.data.records
- }
- }
- })
- if (Number(this.fileId, 10).toString() === 'NaN') {
- console.log('yyyy')
- // 如果id 不是数字开头,即mongo 62开头的id,查看文章详情
- this.$api.resource.fileDetail(this.fileId).then(res => {
- if (res.code === 200) {
- this.data = res.data
- this.show = true
- }
- })
- } else {
- this.$api.resource.fileInfo({ id: this.fileId }).then(res => {
- if (res.code === 200) {
- const tmp = res.data
- if (api.offices.includes(tmp.suffix)) {
- this.openByFile()
- } else {
- this.preList.length = 0
- this.preList.push(tmp.filePath)
- this.showImage = true
- }
- }
- })
- }
- },
- moreDetail() {
- //显示侧边
- this.liShow = true
- },
- openByFile() {
- this.$api.resource.fileDetailByFile(this.fileId).then(res => {
- if (res.code === 200) {
- this.data = res.data
- this.show = true
- }
- })
- },
- moreClick() {},
- async downloadClick() {
- const link = document.createElement('a')
- link.href = this.data.url
- link.download = this.data.title
- link.click()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .preview {
- width: 960px;
- padding: 20px;
- }
- .bottom {
- position: fixed;
- bottom: 0;
- box-shadow: -2px 0px 2px rgba(0, 0, 0, 0.1);
- background-color: white;
- height: 30px;
- padding: 10px;
- width: 1200px;
- border: #e6e8ed solid 1px;
- }
- :deep(.el-drawer__body) {
- padding: 0;
- }
- </style>
|