index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="pa-3 white">
  3. <m-filter @search="handleSearch"></m-filter>
  4. <m-table
  5. class="mt-3"
  6. :loading="loading"
  7. :headers="headers"
  8. :items="items"
  9. :total="total"
  10. :page-info="pageInfo"
  11. :show-select="false"
  12. :is-tools="false"
  13. @pageHandleChange="pageHandleChange"
  14. @sort="handleSort"
  15. >
  16. <template #status="{ item }">
  17. <v-chip
  18. :color="item.status ? 'success' : 'error'"
  19. small
  20. >
  21. {{ item.status ? '已启用' : '已禁用'}}
  22. </v-chip>
  23. </template>
  24. <template #tag="{ item }">
  25. <m-graph-drill
  26. :id="item.tag?.id"
  27. :title="`${item.tag?.name}血缘图谱`"
  28. >{{ item.tag?.name }}</m-graph-drill>
  29. </template>
  30. <template #blood_count="{ item }">
  31. <m-graph-drill
  32. :id="item.id"
  33. :title="`${item.name}血缘图谱`"
  34. :to-api="api.getResourceGraph"
  35. >{{ item.blood_count }}</m-graph-drill>
  36. </template>
  37. <template #type="{ item }">
  38. {{ item.type === 'unstructured' ? '非结构化' : '结构化' }}
  39. </template>
  40. <template #name="{ item }">
  41. <div class="defaultLink" @click="handleDetails(item)">{{ item.name }}</div>
  42. </template>
  43. <template #alias="item">
  44. <v-chip v-for="chip in item.alias" :key="chip">{{ chip }}</v-chip>
  45. </template>
  46. </m-table>
  47. </div>
  48. </template>
  49. <script>
  50. import MFilter from '../../dataGovernance/components/Filter'
  51. import MTable from '@/components/List/table.vue'
  52. import MGraphDrill from '../components/mGraphDrill'
  53. import { api } from '@/api/dataGovernance'
  54. import {
  55. frequency,
  56. sensitivity
  57. } from '@/utils/dataGovernance'
  58. export default {
  59. name: 'data-book-resource',
  60. components: { MFilter, MTable, MGraphDrill },
  61. data () {
  62. return {
  63. api,
  64. loading: false,
  65. show: false,
  66. queryData: {
  67. name: null
  68. },
  69. headers: [
  70. { text: '中文名', value: 'name' },
  71. { text: '英文名', value: 'en_name' },
  72. { text: '分类', value: 'category' },
  73. { text: '描述', value: 'describe' },
  74. { text: '标签', value: 'tag' },
  75. { text: '状态', value: 'status' },
  76. { text: '血缘关系数量', value: 'blood_count', align: 'center' },
  77. { text: '更新频率', value: 'frequency' },
  78. { text: '数据敏感度', value: 'data_sensitivity' },
  79. { text: '创建时间', value: 'time' }
  80. ],
  81. itemData: {},
  82. items: [],
  83. // orders: [],
  84. pageInfo: {
  85. size: 10,
  86. current: 1
  87. },
  88. total: 0
  89. }
  90. },
  91. created () {
  92. this.init()
  93. },
  94. methods: {
  95. handleClose () {
  96. this.show = false
  97. this.init()
  98. },
  99. async init () {
  100. this.loading = true
  101. api.getResourceList({
  102. ...this.pageInfo,
  103. ...this.queryData,
  104. type: 'all'
  105. })
  106. .then(({ data }) => {
  107. this.items = data.records.map(e => {
  108. e.frequency = frequency.find(_e => _e.value === e.frequency)?.label
  109. e.data_sensitivity = sensitivity.find(_e => _e.value === e.data_sensitivity)?.label
  110. return e
  111. })
  112. this.total = data.total
  113. })
  114. .catch(error => {
  115. this.$snackbar.error(error)
  116. })
  117. .finally(() => {
  118. this.loading = false
  119. })
  120. },
  121. handleSearch (val) {
  122. Object.assign(this.queryData, val)
  123. this.pageInfo.current = 1
  124. this.init()
  125. },
  126. handleDetails ({ id, name }) {
  127. this.$router.push(`${this.$route.path}/details/${id}/${name}`)
  128. },
  129. pageHandleChange (page) {
  130. this.pageInfo.current = page
  131. this.init()
  132. },
  133. handleSort (val) {
  134. this.orders = val
  135. this.init()
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. </style>