Rap 原分销系统代码Web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

883ff4267a000ff2963281259fa47ec71ce47c26.svn-base 1.9KB

5 mesi fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <el-dialog append-to-body :close-on-click-modal="false" :visible.sync="dialog" title="执行脚本" width="400px">
  3. <el-form ref="form" :rules="rules" size="small">
  4. <el-upload
  5. :action="databaseUploadApi"
  6. :data="databaseInfo"
  7. :headers="headers"
  8. :on-success="handleSuccess"
  9. :on-error="handleError"
  10. class="upload-demo"
  11. drag
  12. >
  13. <i class="el-icon-upload" />
  14. <div class="el-upload__text">
  15. 将文件拖到此处,或
  16. <em>点击上传</em>
  17. </div>
  18. <div slot="tip" class="el-upload__tip">上传后,系统会自动执行SQL脚本</div>
  19. </el-upload>
  20. </el-form>
  21. <div slot="footer" class="dialog-footer">
  22. <el-button type="primary" @click="cancel">关闭</el-button>
  23. </div>
  24. </el-dialog>
  25. </template>
  26. <script>
  27. import { mapGetters } from 'vuex'
  28. import { getToken } from '@/utils/auth'
  29. export default {
  30. props: {
  31. databaseInfo: {
  32. type: Object,
  33. default() {
  34. return {}
  35. }
  36. }
  37. },
  38. data() {
  39. return {
  40. loading: false,
  41. dialog: false,
  42. headers: {
  43. Authorization: getToken()
  44. },
  45. rules: {}
  46. }
  47. },
  48. computed: {
  49. ...mapGetters(['databaseUploadApi'])
  50. },
  51. mounted() {
  52. },
  53. methods: {
  54. cancel() {
  55. this.dialog = false
  56. },
  57. handleSuccess(response, file, fileList) {
  58. if (response === 'success') {
  59. this.$notify({
  60. title: '执行成功',
  61. type: 'success',
  62. duration: 2500
  63. })
  64. } else {
  65. this.$notify({
  66. title: response,
  67. type: 'error',
  68. duration: 0
  69. })
  70. }
  71. },
  72. handleError(e, file, fileList) {
  73. const msg = JSON.parse(e.message)
  74. this.$notify({
  75. title: msg.message,
  76. type: 'error',
  77. duration: 0
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped>
  84. </style>