PatentPDF.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. if (this.outside) {
  43. this.getData()
  44. }else{
  45. this.refreshData()
  46. }
  47. }
  48. },
  49. created() {
  50. window.addEventListener('resize', this.handleResize)
  51. },
  52. mounted() {
  53. // outside为true是外部
  54. if (this.outside) {//外部
  55. this.getData()
  56. } else {
  57. this.refreshData()
  58. }
  59. },
  60. methods: {
  61. // 获取外部的pdf地址
  62. getData() {
  63. this.height = (this.fullHeight - 230) + 'px'
  64. if (this.patent.pdf && this.patent.pdf.length > 0) {
  65. this.getSrc()
  66. return false
  67. }
  68. var params = {
  69. appNo: this.patent.appNo,
  70. rowApplicationNo: this.patent.rowApplicationNo,
  71. }
  72. this.loading = true
  73. this.$api.getCnPdf(params).then(response => {
  74. if (response.code == 200) {
  75. this.$set(this.patent, 'pdf', response.data)
  76. this.getSrc()
  77. this.loading = false
  78. }
  79. }).catch(error=>{
  80. this.loading = false
  81. })
  82. },
  83. // 内部专利根据guid获取路径
  84. getSrc() {
  85. if(this.patent.pdf.length==0){
  86. this.show = false
  87. return
  88. }
  89. let obj = this.patent.pdf.find(item => {
  90. return item.type == this.pdfType
  91. })
  92. var guid = ''
  93. if (obj) {//外部内部都是返回guid
  94. guid = obj.pdfGuid
  95. }else{
  96. this.pdfType = this.patent.pdf[0].type
  97. guid = this.patent.pdf[0].pdfGuid
  98. }
  99. this.src = this.$commonJS.checkGuid(guid)
  100. this.$nextTick(() => {
  101. this.show = true
  102. })
  103. },
  104. // 点击切换按钮(授权、公开)
  105. handleSelect(type) {
  106. this.pdfType = type
  107. this.show = false
  108. this.getSrc()
  109. },
  110. // 上传文档
  111. // handleChange(file, fileList) {
  112. // if (file.name.split('.')[1].toLowerCase() !== 'pdf') {
  113. // this.$message.error('请选择PDF格式文件')
  114. // return false
  115. // }
  116. // let formData = new FormData()
  117. // formData.append('file', file.raw)
  118. // formData.append('type', this.pdfType)
  119. // formData.append('patentNo', this.patent.patentNo)
  120. // if (this.pdf) {
  121. // formData.append('url', this.pdf.url)
  122. // }
  123. // this.btnLoading = true
  124. // this.$api.editPatentInstruction(formData).then(response => {
  125. // this.$message.success('操作成功')
  126. // this.btnLoading = false
  127. // this.$emit('refreshData')
  128. // this.refreshData()
  129. // }).catch(error => {
  130. // this.btnLoading = false
  131. // })
  132. // },
  133. // 请求内部pdf的guid
  134. refreshData() {
  135. this.show = false
  136. this.height = (this.fullHeight - 230) + 'px'
  137. if(this.patent.pdf && this.patent.pdf.length>0){
  138. this.getSrc()
  139. return
  140. }
  141. let params = {
  142. appNo: this.patent.appNo,
  143. // type: this.pdfType,//0公开1授权
  144. }
  145. this.loading = true
  146. this.$api.getTextPdf(params).then(response => {
  147. if (response.code == 200) {
  148. this.$set(this.patent, 'pdf', response.data)
  149. this.getSrc()
  150. this.loading =false
  151. }
  152. }).catch(error=>{
  153. this.loading = false
  154. })
  155. },
  156. handleResize(event) {
  157. this.fullHeight = document.documentElement.clientHeight
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .patent-pdf {
  164. height: 100%;
  165. .no-pdf-file {
  166. float: left;
  167. text-align: center;
  168. width: 100%;
  169. background: #e3e2e2;
  170. height: calc(100% - 120px);
  171. padding-top: 50px;
  172. span {
  173. font-size: 50px;
  174. }
  175. }
  176. }
  177. </style>