index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="common-wrap">
  3. <el-card class="content-z" style="position: relative">
  4. <a-button
  5. class="right-upload-btn"
  6. ghost
  7. type="primary"
  8. icon="upload"
  9. @click="$refs.fileDom.click()"
  10. >导入
  11. </a-button>
  12. <input id="fileDom" type="file" ref="fileDom" style="display: none" @change="handleImport($event)">
  13. <a-tabs v-model="activeKey" type="card" v-if="readyRender">
  14. <a-tab-pane
  15. v-for="item in tabs"
  16. :key="item.name"
  17. :tab="item.title"
  18. >
  19. <component
  20. :is="item.name"
  21. v-if="activeKey === item.name"
  22. />
  23. </a-tab-pane>
  24. </a-tabs>
  25. </el-card>
  26. </div>
  27. </template>
  28. <script>
  29. import Tab1 from './tab1.vue'
  30. import Tab2 from './tab2.vue'
  31. import Tab3 from './tab3.vue'
  32. import { ChartImport } from '@/api/dashboard-json'
  33. export default {
  34. name: 'Ycxx',
  35. components: {
  36. Tab1,
  37. Tab2,
  38. Tab3
  39. },
  40. data() {
  41. return {
  42. readyRender: true,
  43. activeKey: 'Tab1',
  44. tabs: [{
  45. title: '远动调试',
  46. name: 'Tab1'
  47. },
  48. {
  49. title: '高受电',
  50. name: 'Tab2'
  51. },
  52. {
  53. title: '高试验',
  54. name: 'Tab3'
  55. }
  56. ]
  57. }
  58. },
  59. handleExportXls() {
  60. },
  61. computed: {},
  62. methods: {
  63. handleImport(evt) {
  64. window.console.log('evt', evt)
  65. const file = evt.target.files[0]
  66. evt.target.value = null
  67. ChartImport('scrwb', file).then(res => {
  68. console.log('res => ', res)
  69. if (res.code === 200) {
  70. this.$message.success('导入成功')
  71. this.readyRender = false
  72. setTimeout(() => {
  73. this.readyRender = true
  74. }, 200)
  75. } else {
  76. this.$message.success('导入失败')
  77. }
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped>
  84. @import '~@/assets/less/common.less'
  85. </style>