duy 1 год назад
Родитель
Сommit
ec227acbcf
3 измененных файлов с 37 добавлено и 4 удалено
  1. 9 0
      src/api/modules/system/user.js
  2. 1 1
      src/views/system/role.vue
  3. 27 3
      src/views/system/user.vue

+ 9 - 0
src/api/modules/system/user.js

@@ -105,3 +105,12 @@ export const unlock = userIds => {
     },
   })
 }
+   //导出数据
+   export const getExportExcel = (form, msg = true) =>{
+    return HcApi({
+        url: '/api/blade-system/user/export-user',
+        method: 'get',
+        params: form,
+        responseType: 'blob',
+    }, msg)
+}

+ 1 - 1
src/views/system/role.vue

@@ -173,7 +173,7 @@ const roleTreedata = ref([])
 const getRoleTreedata = async () => {
     const { error, code, data } = await grantTree()
     if (!error && code === 200) {
-      roleTreedata.value = getArrValue(data)
+      roleTreedata.value = getArrValue(data['menu'])
     } else {
       roleTreedata.value = []
     }

+ 27 - 3
src/views/system/user.vue

@@ -18,7 +18,7 @@
                 <hc-icon name="refresh" />
                 <span>重置密码</span>
             </el-button>
-            <el-button v-yes-com:[exportClick] color="#6CC2FF" yes-com-text="确定导出用户数据?">
+            <el-button v-yes-com:[exportClick] color="#6CC2FF" yes-com-text="确定导出用户数据?" :loading="downloadLoading">
                 <hc-icon class="text-white" name="download" />
                 <span class="text-white">导出</span>
             </el-button>
@@ -76,10 +76,15 @@
 <script setup>
 import { onMounted, ref } from 'vue'
 import { HcDelMsg } from 'hc-vue3-ui'
-import { arrToId, formValidate, getArrValue, getObjValue } from 'js-fast-way'
-import { add, getList, getUser, remove, resetPassword, update } from '~api/system/user.js'
+import { arrToId, downloadBlob, formValidate, getArrValue, getObjValue } from 'js-fast-way'
+import { add, getExportExcel, getList, getUser, remove, resetPassword, update } from '~api/system/user.js'
 import { getRoleTree } from '~api/system/role.js'
 
+
+
+
+
+
 onMounted(()=>{
     getTableData()
 })
@@ -210,8 +215,27 @@ const resetPasswordClick = async (id)=>{
 }
 const exportClick = async (_, resolve) => {
     //这里可以写一些操作
+   await getExportExcelClick()
     resolve() //这个一定要存在,否则不会关闭弹窗
 }
+const downloadLoading = ref(false)
+const getExportExcelClick = async () => {
+    //批量下载
+    downloadLoading.value = true
+    const { error, disposition, res } = await getExportExcel({
+     
+    })
+    //处理数据
+    downloadLoading.value = false
+    if (!error) {
+        if (disposition) {
+            downloadBlob(res, disposition)
+        } else {
+            window.$message?.error('数据异常')
+        }
+    }
+}
+
 const formRef = ref(null)
 const roleIdArr = ref([])
 const addsaveLoading = ref(false)