modelTrainTable.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <m-dialog title="表名清单" :visible.sync="show" :footer="false">
  3. <div class="mb-3">
  4. <v-btn class="mr-3" color="primary" rounded @click="handleAdd">修改表名</v-btn>
  5. <UploadBtn color="primary" @change="handleChangeFile">导入表名</UploadBtn>
  6. </div>
  7. <div
  8. style="min-height: 300px;"
  9. v-loading="loading"
  10. >
  11. <v-list
  12. subheader
  13. >
  14. <v-list-item
  15. v-for="item in items"
  16. :key="item"
  17. >
  18. <v-list-item-content>
  19. <v-list-item-title>{{ item }}</v-list-item-title>
  20. </v-list-item-content>
  21. </v-list-item>
  22. </v-list>
  23. </div>
  24. <ModelTrainTableSubmit ref="modelTrainTableSubmitRefs" @success="getData"></ModelTrainTableSubmit>
  25. </m-dialog>
  26. </template>
  27. <script>
  28. import UploadBtn from '@/components/UploadBtn'
  29. import MDialog from '@/components/Dialog'
  30. import ModelTrainTableSubmit from './modelTrainTableSubmit'
  31. import {
  32. getDataBaseList,
  33. uploadDataTasksList
  34. } from '@/api/dataChart'
  35. export default {
  36. name: 'modelTrainTable',
  37. components: {
  38. MDialog,
  39. UploadBtn,
  40. ModelTrainTableSubmit
  41. },
  42. data () {
  43. return {
  44. show: false,
  45. loading: false,
  46. items: [],
  47. id: null
  48. }
  49. },
  50. methods: {
  51. open (id) {
  52. this.id = id
  53. this.show = true
  54. this.getData()
  55. },
  56. async getData () {
  57. try {
  58. this.loading = true
  59. const { data } = await getDataBaseList({
  60. task_id: this.id
  61. })
  62. this.items = data.tables
  63. } catch (error) {
  64. this.$snackbar.error(error)
  65. } finally {
  66. this.loading = false
  67. }
  68. },
  69. handleAdd () {
  70. this.$refs.modelTrainTableSubmitRefs.open(this.id)
  71. },
  72. async handleChangeFile (file) {
  73. const query = new FormData()
  74. query.append('file', file)
  75. this.loading = true
  76. try {
  77. await uploadDataTasksList(this.id, query)
  78. this.$snackbar.success('更新成功')
  79. this.getData()
  80. } catch (error) {
  81. this.$snackbar.error(error)
  82. } finally {
  83. this.loading = false
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. </style>