ImportFileModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div ref="container">
  3. <a-modal
  4. :title="title"
  5. :width="500"
  6. :visible="visible"
  7. :confirm-loading="confirmLoading"
  8. :getContainer="() => $refs.container"
  9. :maskStyle="{ top: '93px', left: '154px' }"
  10. :wrapClassName="wrapClassNameInfo()"
  11. :mask="isDesktop()"
  12. :maskClosable="false"
  13. @cancel="handleCancel"
  14. style="top: 20%; height: 55%"
  15. >
  16. <template slot="footer">
  17. <a-button key="back" @click="handleCancel">取消</a-button>
  18. </template>
  19. <a-spin :spinning="confirmLoading">
  20. <a-row class="form-row" :gutter="24">
  21. <a-col :md="24" :sm="24">
  22. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="第一步:">
  23. <a ref="myLink" @click="importTemplate" :href="templateUrl"
  24. ><b>{{ templateName }}</b></a
  25. >
  26. <p>提示:模板中的第一行请勿删除</p>
  27. </a-form-item>
  28. </a-col>
  29. </a-row>
  30. <a-row class="form-row" :gutter="24">
  31. <a-col :md="24" :sm="24">
  32. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="第二步:">
  33. <a-upload
  34. name="file"
  35. :showUploadList="false"
  36. :multiple="false"
  37. :headers="tokenHeader"
  38. :action="importExcelUrl"
  39. @change="handleImportExcel"
  40. >
  41. <a-button type="primary" icon="import">导入</a-button>
  42. </a-upload>
  43. </a-form-item>
  44. </a-col>
  45. </a-row>
  46. </a-spin>
  47. </a-modal>
  48. </div>
  49. </template>
  50. <script>
  51. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  52. import { mixinDevice } from '@/utils/mixin'
  53. export default {
  54. name: 'ImportFileModal',
  55. mixins: [JeecgListMixin, mixinDevice],
  56. data() {
  57. return {
  58. title: '',
  59. visible: false,
  60. model: {},
  61. labelCol: {
  62. xs: { span: 24 },
  63. sm: { span: 5 },
  64. },
  65. wrapperCol: {
  66. xs: { span: 24 },
  67. sm: { span: 18 },
  68. },
  69. confirmLoading: false,
  70. disableMixinCreated: true,
  71. templateUrl: '',
  72. templateName: '',
  73. templateDownloadName: '',
  74. url: {
  75. importExcelUrl: '',
  76. },
  77. }
  78. },
  79. created() {},
  80. computed: {
  81. importExcelUrl: function () {
  82. return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`
  83. },
  84. },
  85. methods: {
  86. initModal(apiUrl, templateUrl, templateName, templateDownloadName = '供应商模板') {
  87. this.url.importExcelUrl = apiUrl
  88. this.templateUrl = templateUrl
  89. this.templateName = templateName
  90. this.templateDownloadName = templateDownloadName
  91. this.visible = true
  92. },
  93. importTemplate() {
  94. let link = this.$refs.myLink
  95. link.setAttribute('download', this.templateDownloadName + '.xls')
  96. },
  97. close() {
  98. this.$emit('close')
  99. this.visible = false
  100. },
  101. handleCancel() {
  102. this.close()
  103. },
  104. },
  105. }
  106. </script>
  107. <style scoped></style>