src/views/system/user.vue
@@ -1,5 +1,6 @@
<template>
  <div class="user viewWrap">
    <a ref="download" style="display: none" />
    <h2>用户管理</h2>
    <!-- 搜索功能区 -->
    <div class="wrap">
@@ -28,9 +29,13 @@
    </div>
    <!-- 数据功能按钮区 -->
    <div>
    <el-button type="primary" style="margin-top: 20px; width: 100px;" icon="el-icon-plus"
      @click="handleFormDataAdd">添加</el-button>
    <el-button type="primary" style="margin-top: 20px; width: 100px;" icon="el-icon-download"
      @click="handleExport">导出</el-button>
    </div>
    <!-- 数据表格区 -->
    <el-table stripe :data="tableData" height="0" style="margin-top: 20px;">
      <el-table-column type="index" label="序号"> </el-table-column>
@@ -320,6 +325,28 @@
      this.onGetRoleData();
      this.onGetDefaultPassword();
    },
    // 导出
    handleExport: function () {
      var that = this;
      that
        .$axiosAdmin({
          method: "post",
          responseType: "blob",
          url: "base/user/export",
          data: JSON.stringify({
            "type":""
          })
        })
        .then((res) => {
          const blob = res;
          that.$refs.download.href = window.URL.createObjectURL(new Blob([blob], {type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}));
          that.$refs.download.download = `用户信息.xlsx`;
          that.$refs.download.click();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 关闭
    handleFormDataClose: function () {
      this.formData.id = null;