PatentPDF.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="patent-pdf height_100">
  3. <div>
  4. <el-button-group class="float_left margin-bottom_10" v-if="patent.pdf && patent.pdf.length > 1">
  5. <el-button size="small" :type="pdfType === 1 ? 'primary' : ''" @click="handleSelect(1)">授权文档</el-button>
  6. <el-button size="small" :type="pdfType === 0 ? 'primary' : ''" @click="handleSelect(0)">公开文档</el-button>
  7. </el-button-group>
  8. <!-- <el-upload class="float_right" action="#" :auto-upload="false" :show-file-list="false" :on-change="handleChange"
  9. :multiple="false">
  10. <el-button type="success" size="small" :loading="btnLoading" v-if="projectId"
  11. :disabled="!($permission('/workspace/details/updataInstruction') && $r(projectId, [1, 2]))">上传文档</el-button>
  12. <div slot="tip" class="el-upload__tip"></div>
  13. </el-upload> -->
  14. </div>
  15. <div style="height:calc(100% - 120px)" v-loading="loading">
  16. <myIframe v-if="show" :src="src" frameborder="0" :height="height" width="100%"></myIframe>
  17. <div v-else class="no-pdf-file">
  18. <span>暂无文档</span>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { patentDetails } from './mixins';
  25. export default {
  26. mixins: [patentDetails],
  27. props: ['patent', 'projectId', 'patentNo'],
  28. components: {},
  29. data() {
  30. return {
  31. src: '',
  32. fullHeight: document.documentElement.clientHeight,
  33. height: 0,
  34. show: true,
  35. btnLoading: false,
  36. pdfType: 1,
  37. pdf: null
  38. }
  39. },
  40. watch: {
  41. patentNo() {
  42. this.pdfType = 1
  43. if (this.outside) {
  44. this.getData()
  45. }else{
  46. this.refreshData()
  47. }
  48. }
  49. },
  50. created() {
  51. window.addEventListener('resize', this.handleResize)
  52. },
  53. mounted() {
  54. // outside为true是外部
  55. if (this.outside) {//外部
  56. this.getData()
  57. } else {
  58. this.refreshData()
  59. }
  60. },
  61. methods: {
  62. // 获取外部的pdf地址
  63. getData() {
  64. this.height = (this.fullHeight - 230) + 'px'
  65. if (this.patent.pdf && this.patent.pdf.length > 0) {
  66. this.getSrc()
  67. return false
  68. }
  69. var params = {
  70. appNo: this.patent.appNo,
  71. rowApplicationNo: this.patent.rowApplicationNo,
  72. }
  73. this.loading = true
  74. this.$api.getCnPdf(params).then(response => {
  75. if (response.code == 200) {
  76. this.$set(this.patent, 'pdf', response.data)
  77. this.getSrc()
  78. this.loading = false
  79. }
  80. }).catch(error=>{
  81. this.loading = false
  82. })
  83. },
  84. // 内部专利根据guid获取路径
  85. getSrc() {
  86. if(this.patent.pdf.length==0){
  87. this.show = false
  88. return
  89. }
  90. let obj = this.patent.pdf.find(item => {
  91. return item.type == this.pdfType
  92. })
  93. var guid = ''
  94. if (obj) {//外部内部都是返回guid
  95. guid = obj.pdfGuid
  96. }else{
  97. this.pdfType = this.patent.pdf[0].type
  98. guid = this.patent.pdf[0].pdfGuid
  99. }
  100. this.src = this.$commonJS.checkGuid(guid)
  101. this.$nextTick(() => {
  102. this.show = true
  103. })
  104. },
  105. // 点击切换按钮(授权、公开)
  106. handleSelect(type) {
  107. this.pdfType = type
  108. this.show = false
  109. this.getSrc()
  110. },
  111. // 上传文档
  112. // handleChange(file, fileList) {
  113. // if (file.name.split('.')[1].toLowerCase() !== 'pdf') {
  114. // this.$message.error('请选择PDF格式文件')
  115. // return false
  116. // }
  117. // let formData = new FormData()
  118. // formData.append('file', file.raw)
  119. // formData.append('type', this.pdfType)
  120. // formData.append('patentNo', this.patent.patentNo)
  121. // if (this.pdf) {
  122. // formData.append('url', this.pdf.url)
  123. // }
  124. // this.btnLoading = true
  125. // this.$api.editPatentInstruction(formData).then(response => {
  126. // this.$message.success('操作成功')
  127. // this.btnLoading = false
  128. // this.$emit('refreshData')
  129. // this.refreshData()
  130. // }).catch(error => {
  131. // this.btnLoading = false
  132. // })
  133. // },
  134. // 请求内部pdf的guid
  135. refreshData() {
  136. this.show = false
  137. this.height = (this.fullHeight - 230) + 'px'
  138. if(this.patent.pdf && this.patent.pdf.length>0){
  139. this.getSrc()
  140. return
  141. }
  142. let params = {
  143. appNo: this.patent.appNo,
  144. // type: this.pdfType,//0公开1授权
  145. }
  146. this.loading = true
  147. this.$api.getTextPdf(params).then(response => {
  148. if (response.code == 200) {
  149. this.$set(this.patent, 'pdf', response.data)
  150. this.getSrc()
  151. this.loading =false
  152. }
  153. }).catch(error=>{
  154. this.loading = false
  155. })
  156. },
  157. handleResize(event) {
  158. this.fullHeight = document.documentElement.clientHeight
  159. },
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. .patent-pdf {
  165. height: 100%;
  166. .no-pdf-file {
  167. float: left;
  168. text-align: center;
  169. width: 100%;
  170. background: #e3e2e2;
  171. height: calc(100% - 120px);
  172. padding-top: 50px;
  173. span {
  174. font-size: 50px;
  175. }
  176. }
  177. }
  178. </style>