Table.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="patent-table-list-view">
  3. <el-table
  4. v-if="refreshData"
  5. ref="table"
  6. class="view-table"
  7. :data="records"
  8. style=""
  9. border
  10. :height="tableHeight"
  11. header-row-class-name="custom-table-header"
  12. @cell-click="handleClick"
  13. :cell-class-name="cellClassName"
  14. >
  15. <el-table-column width="80" align="center">
  16. <template slot="header">
  17. <patent-table-view-sort prop="id" @on-sort="onSort" />
  18. </template>
  19. <template slot-scope="scope">
  20. <div v-if="refresh">
  21. <el-checkbox :label="scope.row.id" @change="changeSelect(scope.row)" :checked="selected.indexOf(scope.row.id) !== -1 || patentNoList.indexOf(scope.row.patentNo)!== -1 || patentNoList.indexOf(scope.row.applicationNo)!== -1 ">
  22. <span>{{ (scope.$index + 1) + ((params.current - 1) * params.size) }}</span>
  23. </el-checkbox>
  24. </div>
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="专利号" show-overflow-tooltip align="center" width="180">
  28. <template slot="header">
  29. <patent-table-view-sort title="专利号" prop="patentNo" @on-sort="onSort" />
  30. </template>
  31. <template slot-scope="scope">
  32. <el-popover placement="right-start" width="500" trigger="hover" >
  33. <table class="patent-popover-table" >
  34. <tr>
  35. <td>
  36. <div class="patent-abstract-image text-align_center" >
  37. <!-- <img :src="getPatentAbstractImage(scope.row.abstractPath)"> -->
  38. <!-- <img :src="getImagePath1(scope.row)"> -->
  39. <el-image v-if="(!reportId && scope.row.abstractPath2)||reportId" :src="scope.row.abstractPath2?scope.row.abstractPath2:getImagePath1(scope.row)" :preview-src-list="[scope.row.abstractPath2]" style="vertical-align:middle;" :style="{width:scope.row.imgWidth?scope.row.imgWidth:'100%',height:scope.row.imgHeight?scope.row.imgHeight:'100%'}">
  40. <div slot="error" class="image-slot">
  41. <el-image :src="getErrorImage(scope.row)" :preview-src-list="[getErrorImage(scope.row)]">
  42. <div slot="error" class="image-slot">
  43. <img src="https://www.patentstar.com.cn/img/Common/nopic.jpg" alt="" style="">
  44. </div>
  45. </el-image>
  46. </div>
  47. </el-image>
  48. </div>
  49. </td>
  50. <td>
  51. <p v-html="getViewDom2(scope.row, 'abstractStr')"></p>
  52. <el-link v-if="reportId" type="primary" @click.native="handleChange(scope.row, 'abstractStr')">
  53. <span v-if="!scope.row.change2">切换译文</span>
  54. <span v-else>切换原文</span>
  55. </el-link>
  56. </td>
  57. </tr>
  58. </table>
  59. <el-link slot="reference" :disabled="!$permission('/workspace/details')" :class="$permission('/workspace/details')?'':'jinzhi'" :type="scope.row.read === 1 ? 'success' : 'danger'" @click.native="handleLink(scope.row,scope.$index)">
  60. <span v-html="getViewDom(scope.row.patentNo)"></span>
  61. </el-link>
  62. </el-popover>
  63. </template>
  64. </el-table-column>
  65. <el-table-column v-for="column in columnList" :label="column.name" show-overflow-tooltip align="center">
  66. <template slot="header">
  67. <patent-table-view-sort :title="column.name" :prop="column.key" :reportId="reportId" @on-sort="onSort" />
  68. </template>
  69. <template slot-scope="scope">
  70. <div style="" v-for="data in getColumnValue(scope.row, column)">
  71. <template v-if="column.key === 'name'">
  72. <span v-html="getViewDom2(scope.row, 'name')"></span>
  73. <br>
  74. <el-link v-if="reportId" type="primary" @click.native="handleChange(scope.row, 'name')">
  75. <span v-if="!scope.row.change">切换译文</span>
  76. <span v-else>切换原文</span>
  77. </el-link>
  78. </template>
  79. <template v-else-if="column.key === 'abstractStr'">
  80. <span v-html="getViewDom2(scope.row, 'abstractStr')"></span>
  81. <br>
  82. <el-link v-if="reportId" type="primary" @click.native="handleChange(scope.row, 'abstractStr')">
  83. <span v-if="!scope.row.change2">切换译文</span>
  84. <span v-else>切换原文</span>
  85. </el-link>
  86. </template>
  87. <template v-else>
  88. <span v-html="getViewDom(data)"></span>
  89. </template>
  90. </div>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </template>
  96. <script>
  97. import { commonMixins } from "@/views/workspace/folder/articles/components/mixins.js"
  98. import { patentViewList, patentKeywordsHighlight } from '@/views/workspace/folder/components/mixins.js'
  99. import PatentTableViewSort from "./TableSort";
  100. export default {
  101. props: ['viewField'],
  102. mixins: [patentViewList, patentKeywordsHighlight,commonMixins],
  103. components: {
  104. PatentTableViewSort
  105. },
  106. data() {
  107. return {
  108. tableData: [],
  109. tableHeight: null,
  110. refreshData: false
  111. }
  112. },
  113. watch: {
  114. viewField: {
  115. handler(n, o) {
  116. this.refreshTable()
  117. },
  118. deep: true
  119. },
  120. records(val,oldval) {
  121. if(val != oldval){
  122. this.$nextTick(() => {
  123. this.addRecords()
  124. this.refreshCheckBox()
  125. this.setHeight()
  126. })
  127. }
  128. },
  129. refreshData(val){
  130. if(val){
  131. this.$nextTick(()=>{
  132. this.setHeight()
  133. })
  134. }
  135. }
  136. },
  137. activated() {
  138. // this.refreshTable()
  139. },
  140. computed: {
  141. columnList() {
  142. return this.viewField.filter(item => !item.hidden)
  143. }
  144. },
  145. created(){
  146. },
  147. mounted() {
  148. if(this.viewField.length>0){
  149. this.refreshTable()
  150. }
  151. this.$nextTick(()=>{
  152. this.addRecords()
  153. })
  154. // console.log(this.columnList);
  155. },
  156. methods: {
  157. getPatentAbstractImage(path) {
  158. if (!path) {
  159. return ''
  160. }
  161. return this.$p + path
  162. },
  163. onSort(data) {
  164. this.$emit('on-sort', data)
  165. },
  166. setHeight() {
  167. const offsetTop = window.innerHeight -250
  168. const body = document.querySelector('.el-table__body')
  169. if (!body) {
  170. return false
  171. }
  172. const offsetBodyHeight = body.offsetHeight
  173. if (this.records.length && offsetBodyHeight < offsetTop) {
  174. this.tableHeight = offsetBodyHeight + 75
  175. } else if (!this.records.length) {
  176. this.tableHeight = null
  177. } else {
  178. this.tableHeight = offsetTop
  179. }
  180. },
  181. refreshTable() {
  182. this.refreshData = false
  183. this.$nextTick(() => {
  184. this.refreshData = true
  185. })
  186. },
  187. getColumnValue(row, column) {
  188. if (column.type !== 'list') {
  189. const field = row.field.find(item => item.id === parseInt(column.key))
  190. if (field) {
  191. return field.selected
  192. }
  193. } else if (column.key === 'label') {
  194. if(row.label)
  195. return row.label.map(item => item.name)
  196. } else {
  197. const value = row[column.key]
  198. if (column.key === 'inventor' || column.key === 'agent') {
  199. if(value)
  200. return value.map(item => item.name)
  201. }
  202. if (column.key === 'applicant1') {
  203. if(row.applicant)
  204. return row.applicant.filter(a => a.dataType === 1).map(item => item.shortName)
  205. }
  206. if (column.key === 'applicant2') {
  207. if(row.applicant)
  208. return row.applicant.filter(a => a.dataType === 1).map(item => item.name)
  209. }
  210. if (column.key === 'applicant3') {
  211. if(row.applicant)
  212. return row.applicant.filter(a => a.dataType === 2).map(item => item.shortName)
  213. }
  214. if (column.key === 'applicant4') {
  215. if(row.applicant)
  216. return row.applicant.filter(a => a.dataType === 2).map(item => item.name)
  217. }
  218. if (column.key === 'simpleFamily') {
  219. return [row.family.simple.length]
  220. }
  221. if (column.key === 'inpadocFamily') {
  222. return [row.family.inpadoc.length]
  223. }
  224. if (column.key === 'patSnapFamily') {
  225. return [row.family.patSnap.length]
  226. }
  227. if (column.key === 'agency' && value) {
  228. return [value.name]
  229. }
  230. if (value instanceof Array) {
  231. return value
  232. } else if (typeof value === 'string' || typeof value === 'number') {
  233. return [value]
  234. }
  235. return ''
  236. }
  237. },
  238. cellClassName({ row, column, rowIndex, columnIndex }) {
  239. if (this.validationCustomField(column.label)) {
  240. return 'custom-field-cell'
  241. }
  242. },
  243. validationCustomField(label) {
  244. const customField = this.viewField.filter(item => item.type !== 'list' || item.key === 'label')
  245. const field = customField.find(item => item.name === label)
  246. if (field) {
  247. return field
  248. }
  249. return false
  250. },
  251. handleClick(row, column, cell,event) {
  252. const field = this.validationCustomField(column.label)
  253. if (field) {
  254. this.$emit('index-setting', row, field)
  255. }
  256. },
  257. }
  258. }
  259. </script>
  260. <style lang="scss">
  261. .patent-popover-table {
  262. tbody, tr, td {
  263. height: 100%;
  264. vertical-align: top;
  265. }
  266. p {
  267. padding: 0 !important;
  268. margin: 0 !important;
  269. }
  270. .patent-abstract-image {
  271. padding: 10px;
  272. border: 1px solid #bcc2cc;
  273. border-radius: 4px;
  274. width: 120px;
  275. height: 150px;
  276. line-height: 150px;
  277. img {
  278. width: 100%;
  279. height: 100%;
  280. }
  281. }
  282. }
  283. .patent-table-list-view {
  284. .view-table {
  285. width: 100%;
  286. }
  287. .el-table .cell {
  288. white-space: pre-line !important;
  289. }
  290. .custom-field-cell {
  291. cursor: pointer;
  292. }
  293. }
  294. </style>