feat: Add Export in some menu
fix: Left menu height fix: Export csv when double quotation marks in data
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { onMounted, reactive, watch } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { list, remove, changePwd } from '@/api/user'
|
||||
import { list as groups } from '@/api/group'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { T } from '@/utils/i18n'
|
||||
import { downBlob, jsonToCsv } from '@/utils/file'
|
||||
|
||||
export function useRepositories () {
|
||||
|
||||
@@ -42,18 +43,24 @@ export function useRepositories () {
|
||||
listRes.groups = res.data.list
|
||||
}
|
||||
}
|
||||
onMounted(getGroups)
|
||||
|
||||
onMounted(getList)
|
||||
|
||||
watch(() => listQuery.page, getList)
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
const toExport = async () => {
|
||||
const q = { ...listQuery }
|
||||
q.page_size = 1000000
|
||||
q.page = 1
|
||||
const res = await list(q).catch(_ => false)
|
||||
if (res) {
|
||||
const csv = jsonToCsv(res.data.list)
|
||||
downBlob(csv, 'users.csv')
|
||||
}
|
||||
}
|
||||
return {
|
||||
listRes,
|
||||
listQuery,
|
||||
handlerQuery,
|
||||
getList,
|
||||
getGroups,
|
||||
toExport,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
||||
<el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
||||
<el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@@ -63,14 +64,24 @@
|
||||
import { DISABLE_STATUS, ENABLE_STATUS } from '@/utils/common_options'
|
||||
import { update } from '@/api/user'
|
||||
import { ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { onMounted, watch } from 'vue'
|
||||
//列表
|
||||
const {
|
||||
listRes,
|
||||
listQuery,
|
||||
handlerQuery,
|
||||
getList,
|
||||
getGroups,
|
||||
toExport,
|
||||
} = useRepositories()
|
||||
|
||||
onMounted(getGroups)
|
||||
|
||||
onMounted(getList)
|
||||
|
||||
watch(() => listQuery.page, getList)
|
||||
watch(() => listQuery.page_size, handlerQuery)
|
||||
|
||||
const { toEdit, toAdd, toAddressBook, toTag } = useToEditOrAdd()
|
||||
|
||||
const { changePass } = useChangePwd()
|
||||
|
||||
Reference in New Issue
Block a user