123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <template>
- <div class="patent-pdf height_100">
- <div>
- <el-button-group class="float_left margin-bottom_10" v-if="patent.pdf && patent.pdf.length > 1">
- <el-button size="small" :type="pdfType === 1 ? 'primary' : ''" @click="handleSelect(1)">授权文档</el-button>
- <el-button size="small" :type="pdfType === 0 ? 'primary' : ''" @click="handleSelect(0)">公开文档</el-button>
- </el-button-group>
- <!-- <el-upload class="float_right" action="#" :auto-upload="false" :show-file-list="false" :on-change="handleChange"
- :multiple="false">
- <el-button type="success" size="small" :loading="btnLoading" v-if="projectId"
- :disabled="!($permission('/workspace/details/updataInstruction') && $r(projectId, [1, 2]))">上传文档</el-button>
- <div slot="tip" class="el-upload__tip"></div>
- </el-upload> -->
- </div>
- <div style="height:calc(100% - 120px)" v-loading="loading">
- <myIframe v-if="show" :src="src" frameborder="0" :height="height" width="100%"></myIframe>
- <div v-else class="no-pdf-file">
- <span>暂无文档</span>
- </div>
- </div>
-
- </div>
- </template>
- <script>
- import { patentDetails } from './mixins';
- export default {
- mixins: [patentDetails],
- props: ['patent', 'projectId', 'patentNo'],
- components: {},
- data() {
- return {
- src: '',
- fullHeight: document.documentElement.clientHeight,
- height: 0,
- show: true,
- btnLoading: false,
- pdfType: 1,
- pdf: null
- }
- },
- watch: {
- patentNo() {
- if (this.outside) {
- this.getData()
- }else{
- this.refreshData()
- }
- }
- },
- created() {
- window.addEventListener('resize', this.handleResize)
- },
- mounted() {
- // outside为true是外部
- if (this.outside) {//外部
- this.getData()
- } else {
- this.refreshData()
- }
- },
- methods: {
- // 获取外部的pdf地址
- getData() {
-
- this.height = (this.fullHeight - 230) + 'px'
- if (this.patent.pdf && this.patent.pdf.length > 0) {
- this.getSrc()
- return false
- }
- var params = {
- appNo: this.patent.appNo,
- rowApplicationNo: this.patent.rowApplicationNo,
- }
- this.loading = true
- this.$api.getCnPdf(params).then(response => {
- if (response.code == 200) {
- this.$set(this.patent, 'pdf', response.data)
- this.getSrc()
- this.loading = false
- }
- }).catch(error=>{
- this.loading = false
- })
- },
- // 内部专利根据guid获取路径
- getSrc() {
- if(this.patent.pdf.length==0){
- this.show = false
- return
- }
- let obj = this.patent.pdf.find(item => {
- return item.type == this.pdfType
- })
- var guid = ''
- if (obj) {//外部内部都是返回guid
- guid = obj.pdfGuid
- }else{
- this.pdfType = this.patent.pdf[0].type
- guid = this.patent.pdf[0].pdfGuid
- }
-
- this.src = this.$commonJS.checkGuid(guid)
- this.$nextTick(() => {
- this.show = true
- })
- },
- // 点击切换按钮(授权、公开)
- handleSelect(type) {
- this.pdfType = type
- this.show = false
- this.getSrc()
- },
- // 上传文档
- // handleChange(file, fileList) {
- // if (file.name.split('.')[1].toLowerCase() !== 'pdf') {
- // this.$message.error('请选择PDF格式文件')
- // return false
- // }
- // let formData = new FormData()
- // formData.append('file', file.raw)
- // formData.append('type', this.pdfType)
- // formData.append('patentNo', this.patent.patentNo)
- // if (this.pdf) {
- // formData.append('url', this.pdf.url)
- // }
- // this.btnLoading = true
- // this.$api.editPatentInstruction(formData).then(response => {
- // this.$message.success('操作成功')
- // this.btnLoading = false
- // this.$emit('refreshData')
- // this.refreshData()
- // }).catch(error => {
- // this.btnLoading = false
- // })
- // },
- // 请求内部pdf的guid
- refreshData() {
- this.show = false
- this.height = (this.fullHeight - 230) + 'px'
- if(this.patent.pdf && this.patent.pdf.length>0){
- this.getSrc()
- return
- }
- let params = {
- appNo: this.patent.appNo,
- // type: this.pdfType,//0公开1授权
- }
- this.loading = true
- this.$api.getTextPdf(params).then(response => {
- if (response.code == 200) {
- this.$set(this.patent, 'pdf', response.data)
- this.getSrc()
- this.loading =false
- }
- }).catch(error=>{
- this.loading = false
- })
- },
- handleResize(event) {
- this.fullHeight = document.documentElement.clientHeight
- },
- }
- }
- </script>
- <style lang="scss">
- .patent-pdf {
- height: 100%;
- .no-pdf-file {
- float: left;
- text-align: center;
- width: 100%;
- background: #e3e2e2;
- height: calc(100% - 120px);
- padding-top: 50px;
- span {
- font-size: 50px;
- }
- }
- }
- </style>
|