分组管理加导出

This commit is contained in:
dengbw
2023-05-06 17:35:11 +08:00
parent 02b60dd9aa
commit 48c6ed2d2c
2 changed files with 60 additions and 2 deletions
+14
View File
@@ -77,3 +77,17 @@ export async function removeGroups(id) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导出分组所有顾问
* @param params 查询条件
*/
export async function exportGroupsConsultant(params) {
const res = await request.get('/sylive/groups/consultant_export', {
params
});
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
+46 -2
View File
@@ -2,7 +2,7 @@
<div class="ele-body">
<el-card shadow="never" v-loading="loading">
<ele-split-layout
width="266px"
width="330px"
allow-collapse
:right-style="{ overflow: 'hidden' }"
>
@@ -39,6 +39,15 @@
>
删除
</el-button>
<el-button
size="small"
type="primary"
class="ele-btn-icon"
icon="el-icon-download"
@click="exportData"
>
导出
</el-button>
</div>
</ele-toolbar>
<div class="ele-border-lighter sys-groups-list">
@@ -82,10 +91,15 @@
<script>
import GroUserList from './components/gro-user-list.vue';
import GroEdit from './components/gro-edit.vue';
import { listGroups, removeGroups } from '@/api/sylive/groups';
import {
listGroups,
removeGroups,
exportGroupsConsultant
} from '@/api/sylive/groups';
import { listOrganizations } from '@/api/institution/organization';
import { listTeams } from '@/api/institution/team';
import { listDictionaries } from '@/api/system/dictionary';
import { utils, writeFile } from 'xlsx';
const ROUTE_PATH = '/sylive/groups';
export default {
@@ -217,6 +231,36 @@
});
})
.catch(() => {});
},
/* 导出数据 */
exportData() {
const loading = this.$loading({ lock: true });
const activityId = this.activityId;
exportGroupsConsultant({ activityId })
.then((data) => {
loading.close();
const array = [data.columns];
data.list.forEach((d) => {
let arrayItem = [];
for (let key in d) {
arrayItem.push(d[key]);
}
array.push(arrayItem);
});
writeFile(
{
SheetNames: ['Sheet1'],
Sheets: {
Sheet1: utils.aoa_to_sheet(array)
}
},
'分组顾问' + '.xlsx'
);
})
.catch((e) => {
loading.close();
this.$message.error(e.message);
});
}
},
watch: {