若依文件上传组件如何使用(若依 文件上传)

若依文件上传组件如何使用(若依 文件上传)p lt 用户导入对话框 gt p lt el dialog title upload title visible sync upload open width 400px append to body gt amp

大家好,我是讯享网,很高兴认识大家。



 <p>&lt;!-- 用户导入对话框 --&gt;</p> 

讯享网

    &lt;el-dialog :title=“upload.title” :visible.sync=“upload.open” width=“400px” append-to-body&gt;

      &lt;el-upload

        ref=“upload”

        :limit=“1”

        accept=“.xlsx, .xls”

        :headers=“upload.headers”

        :action=“upload.url + ‘?updateSupport=’ + upload.updateSupport”

        :disabled=“upload.isUploading”

        :on-progress=“handleFileUploadProgress”

        :on-success=“handleFileSuccess”

        :data=“uploadparm”

        :auto-upload=“false”

        drag

      &gt;

        &lt;i class=“el-icon-upload”&gt;&lt;/i&gt;

        &lt;div class=“el-uploadtext”&gt;将文件拖到此处,或&lt;em&gt;点击上传&lt;/em&gt;&lt;/div&gt;

        &lt;div class=“el-uploadtip text-center” slot=“tip”&gt;

          &lt;div class=“el-upload__tip” slot=“tip”&gt;

            &lt;el-checkbox v-model=“upload.updateSupport” /&gt; 是否更新已经存在的用户数据

          &lt;/div&gt;

          &lt;span&gt;仅允许导入xls、xlsx格式文件。&lt;/span&gt;

          &lt;el-link type=“primary” :underline=“false” style=“font-size:12px;vertical-align: baseline;” @click=“importTemplate”&gt;下载模板&lt;/el-link&gt;

        &lt;/div&gt;

      &lt;/el-upload&gt;

      &lt;div slot=“footer” class=“dialog-footer”&gt;

        &lt;el-button type=“primary” @click=“submitFileForm”&gt;确 定&lt;/el-button&gt;

        &lt;el-button @click=“upload.open = false”&gt;取 消&lt;/el-button&gt;

      &lt;/div&gt;

    &lt;/el-dialog&gt;

import { getToken } from “@/utils/auth”;

data(){

return{

        

 uploadparm:{

        id: 0


讯享网

      },

 // 用户导入参数

      upload: {

        // 是否显示弹出层(用户导入)

        open: false,

        // 弹出层标题(用户导入)

        title: “”,

        // 是否禁用上传

        isUploading: false,

        // 是否更新已经存在的用户数据

        updateSupport: 0,

        // 设置上传的请求头部

        headers: { Authorization: “Bearer ” + getToken() },

        // 上传的地址

        url: process.env.VUE_APP_BASE_API + “/system/user/importData”

      },

}

}

  / 导入按钮操作 */

   

handleImport(row) {

    // 上传文件逻辑

    this.uploadparm.id = row.id;

      this.upload.title = “用户导入”;

      this.upload.open = true;

    },

    / 下载模板操作 */

    importTemplate() {

      this.download(‘system/user/importTemplate’, {

      }, `usertemplate\({new Date().getTime()}.xlsx&#96;)</p> <p>    },</p> <p>    // 文件上传中处理</p> <p>    handleFileUploadProgress(event, file, fileList) {</p> <p>      this.upload.isUploading &#61; true;</p> <p>    },</p> <p>    // 文件上传成功处理</p> <p>    handleFileSuccess(response, file, fileList) {</p> <p>      this.upload.open &#61; false;</p> <p>      this.upload.isUploading &#61; false;</p> <p>      this.\)refs.upload.clearFiles();

      this.\(alert(&#34;&lt;div style&#61;&#39;overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;&#39;&gt;&#34; &#43; response.msg &#43; &#34;&lt;/div&gt;&#34;, &#34;导入结果&#34;, { dangerouslyUseHTMLString: true });</p> <p>      this.getList();</p> <p>    },</p> <p>    // 提交上传文件</p> <p>    submitFileForm() {</p> <p>      this.\)refs.upload.submit();

    }

后台:

讯享网@Log(title = “文档导入”, businessType = BusinessType.IMPORT) @PreAuthorize(“@ss.hasPermi(‘system:aa:import’)”) @PostMapping(“/importData”) public AjaxResult importData(MultipartFile file, @RequestParam(“id”) Long id) throws Exception {         Systemctl.out.println(id) }

小讯
上一篇 2025-05-23 15:53
下一篇 2025-06-06 13:24

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/138670.html