mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
修复导入获取数据下标不对
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import request from '@/utils/request'
|
||||
import queryString from 'query-string'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import config from '@/config'
|
||||
// 管理员列表
|
||||
export function adminLists(params: any) {
|
||||
return request.get({ url: '/system/admin/list', params })
|
||||
@@ -36,9 +37,13 @@ export function adminListByDeptId(params: any) {
|
||||
return request.get({ url: '/system/admin/ListByDeptId', params })
|
||||
}
|
||||
|
||||
// 导入
|
||||
export const adminImportFile = '/system/admin/ImportFile'
|
||||
|
||||
// 导出
|
||||
export function adminExportFile(params: any) {
|
||||
// return request.get({ url: '/system/admin/ExportFile', params })
|
||||
return (window.location.href =
|
||||
`/api/admin/system/admin/ExportFile?token=${getToken()}&` + queryString.stringify(params))
|
||||
`${config.baseUrl}${config.urlPrefix}/system/admin/ExportFile?token=${getToken()}&` +
|
||||
queryString.stringify(params))
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ import { RequestCodeEnum } from '@/enums/requestEnums'
|
||||
export default defineComponent({
|
||||
components: {},
|
||||
props: {
|
||||
// 上传地址
|
||||
url: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 上传文件类型
|
||||
type: {
|
||||
type: String,
|
||||
@@ -79,7 +84,16 @@ export default defineComponent({
|
||||
setup(props, { emit }) {
|
||||
const userStore = useUserStore()
|
||||
const uploadRefs = shallowRef<InstanceType<typeof ElUpload>>()
|
||||
const action = ref(`${config.baseUrl}${config.urlPrefix}/common/upload/${props.type}`)
|
||||
let action = ''
|
||||
if (props.url) {
|
||||
if (props.url.startsWith('http')) {
|
||||
action = props.url
|
||||
} else {
|
||||
action = `${config.baseUrl}${config.urlPrefix}${props.url}`
|
||||
}
|
||||
} else {
|
||||
action = `${config.baseUrl}${config.urlPrefix}/common/upload/${props.type}`
|
||||
}
|
||||
const headers = computed(() => ({
|
||||
token: userStore.token,
|
||||
version: config.version
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
:style="{ width: setSize.imgWidth, height: setSize.imgHeight }"
|
||||
>
|
||||
<img
|
||||
v-show="backImgBase"
|
||||
:src="'data:image/png;base64,' + backImgBase"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
@@ -74,6 +75,7 @@
|
||||
}"
|
||||
>
|
||||
<img
|
||||
v-show="blockBackImgBase"
|
||||
:src="'data:image/png;base64,' + blockBackImgBase"
|
||||
alt=""
|
||||
style="
|
||||
|
||||
@@ -32,6 +32,17 @@
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
<upload
|
||||
class="mr-3"
|
||||
:url="adminImportFile"
|
||||
:data="{ cid: 0 }"
|
||||
type="file"
|
||||
:show-progress="true"
|
||||
@change="resetPage"
|
||||
>
|
||||
<el-button type="primary">导入</el-button>
|
||||
</upload>
|
||||
|
||||
<el-button type="primary" @click="exportFile">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Download" />
|
||||
@@ -98,7 +109,13 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { adminLists, adminDelete, adminStatus, adminExportFile } from '@/api/perms/admin'
|
||||
import {
|
||||
adminLists,
|
||||
adminDelete,
|
||||
adminStatus,
|
||||
adminExportFile,
|
||||
adminImportFile
|
||||
} from '@/api/perms/admin'
|
||||
import { roleAll } from '@/api/perms/role'
|
||||
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
@@ -135,6 +152,7 @@ const handleAdd = async () => {
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
const exportFile = async () => {
|
||||
await feedback.confirm('确定要导出?')
|
||||
await adminExportFile(formData)
|
||||
|
||||
Reference in New Issue
Block a user