mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-05-14 20:54:04 +08:00
导入用户
This commit is contained in:
parent
df0bb5c38f
commit
10418297d7
@ -5,7 +5,7 @@
|
||||
"groupId" : "1952f25c81084e24b55b11385767dc38",
|
||||
"name" : "登录",
|
||||
"createTime" : null,
|
||||
"updateTime" : 1648567495848,
|
||||
"updateTime" : 1648818736705,
|
||||
"lock" : "0",
|
||||
"createBy" : null,
|
||||
"updateBy" : null,
|
||||
@ -64,7 +64,7 @@
|
||||
"requestBody" : "{\r\n \"username\": \"admin\",\r\n \"password\": \"123456\"\r\n}",
|
||||
"headers" : [ ],
|
||||
"paths" : [ ],
|
||||
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": \"319e2efb-9e42-4b86-9658-a60d3585a7fe\",\n \"timestamp\": 1648565675784,\n \"executeTime\": 12\n}",
|
||||
"responseBody" : "{\n \"code\": 200,\n \"message\": \"success\",\n \"data\": \"8dbc9feb-410a-4c7f-8805-0013e5ae1363\",\n \"timestamp\": 1648818573075,\n \"executeTime\": 347\n}",
|
||||
"description" : null,
|
||||
"requestBodyDefinition" : {
|
||||
"name" : "",
|
||||
@ -140,7 +140,7 @@
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "data",
|
||||
"value" : "319e2efb-9e42-4b86-9658-a60d3585a7fe",
|
||||
"value" : "8dbc9feb-410a-4c7f-8805-0013e5ae1363",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Object",
|
||||
@ -152,7 +152,7 @@
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "timestamp",
|
||||
"value" : "1648565675784",
|
||||
"value" : "1648818573075",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Long",
|
||||
@ -164,7 +164,7 @@
|
||||
"children" : [ ]
|
||||
}, {
|
||||
"name" : "executeTime",
|
||||
"value" : "12",
|
||||
"value" : "347",
|
||||
"description" : "",
|
||||
"required" : false,
|
||||
"dataType" : "Integer",
|
||||
|
247
data/magic-api/api/系统管理/用户管理/导入.ms
Normal file
247
data/magic-api/api/系统管理/用户管理/导入.ms
Normal file
File diff suppressed because one or more lines are too long
245
data/magic-api/api/系统管理/用户管理/导入数据预览.ms
Normal file
245
data/magic-api/api/系统管理/用户管理/导入数据预览.ms
Normal file
File diff suppressed because one or more lines are too long
@ -53,7 +53,7 @@ body{
|
||||
margin-bottom: 10px
|
||||
}
|
||||
.toolbar-container > div{
|
||||
margin-left: 10px;
|
||||
margin-left: 12px;
|
||||
}
|
||||
.toolbar-container > div:nth-child(1){
|
||||
margin-left: 0px;
|
||||
|
@ -2,7 +2,8 @@
|
||||
<el-upload
|
||||
:id="uploadDomId"
|
||||
class="upload-demo"
|
||||
:action="action"
|
||||
ref="uploadRef"
|
||||
:action="actionUrl"
|
||||
:headers="headers"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
@ -11,11 +12,12 @@
|
||||
:limit="limit"
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList"
|
||||
:show-file-list="showFileList"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
:on-success="handleAvatarSuccess"
|
||||
>
|
||||
<el-button size="small" type="primary" :disabled="!multiple && fileList.length == 1">点击上传</el-button>
|
||||
<div slot="tip" class="el-upload__tip">支持上传{{ getSettingSuffixs().replaceAll(',', ',') }}文件,且不超过{{ maxFileSize }}MB</div>
|
||||
<el-button type="primary" :loading="uploadLoading" :disabled="!multiple && fileList.length == 1">{{ label }}</el-button>
|
||||
<div slot="tip" v-if="showTip" class="el-upload__tip">支持上传{{ getSettingSuffixs().replaceAll(',', ',') }}文件,且不超过{{ maxFileSize }}MB</div>
|
||||
</el-upload>
|
||||
</template>
|
||||
|
||||
@ -59,6 +61,30 @@ export default {
|
||||
formats: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
default: '点击上传'
|
||||
},
|
||||
showTip: {
|
||||
type: Boolean,
|
||||
default: () => true
|
||||
},
|
||||
action: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
showFileList: {
|
||||
type: Boolean,
|
||||
default: () => true
|
||||
},
|
||||
onSuccess: {
|
||||
type: Function,
|
||||
default: () => {}
|
||||
},
|
||||
showRemoveTip: {
|
||||
type: Boolean,
|
||||
default: () => true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -70,13 +96,14 @@ export default {
|
||||
video: 'avi,flv,mp4,mpeg,mov'
|
||||
},
|
||||
imageUrl: '',
|
||||
action: import.meta.env.VITE_APP_BASE_API + '/system/file/upload',
|
||||
actionUrl: import.meta.env.VITE_APP_BASE_API + '/system/file/upload',
|
||||
headers: {
|
||||
token: getToken()
|
||||
},
|
||||
urls: [],
|
||||
uploadDomId: Math.random(),
|
||||
fileList: []
|
||||
fileList: [],
|
||||
uploadLoading: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -90,12 +117,18 @@ export default {
|
||||
const { data } = res
|
||||
this.fileList = data
|
||||
})
|
||||
this.action = this.action + `?externalId=${this.externalId}&externalType=${this.externalType}`
|
||||
this.actionUrl = this.actionUrl + `?externalId=${this.externalId}&externalType=${this.externalType}`
|
||||
} else {
|
||||
this.renderFile()
|
||||
}
|
||||
if(this.action){
|
||||
this.actionUrl = import.meta.env.VITE_APP_BASE_API + this.action
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handlerRemove(file){
|
||||
this.$refs.uploadRef.handleRemove(file)
|
||||
},
|
||||
renderFile() {
|
||||
if (this.value instanceof Array && this.value.length > 0) {
|
||||
this.fileList = this.value.map(it => {
|
||||
@ -146,9 +179,13 @@ export default {
|
||||
this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
|
||||
},
|
||||
beforeRemove(file, fileList) {
|
||||
if(!this.showRemoveTip){
|
||||
return true
|
||||
}
|
||||
return this.$confirm(`确定移除 ${file.name}?`)
|
||||
},
|
||||
handleAvatarSuccess(res, file, fileList) {
|
||||
this.uploadLoading = false
|
||||
if (res.data) {
|
||||
if (this.multiple) {
|
||||
this.urls.push(res.data.url)
|
||||
@ -160,6 +197,9 @@ export default {
|
||||
this.$emit('change', res.data.url)
|
||||
}
|
||||
}
|
||||
if(this.onSuccess){
|
||||
this.onSuccess(res, file, fileList)
|
||||
}
|
||||
},
|
||||
getSettingSuffixs() {
|
||||
if (this.formats) {
|
||||
@ -172,6 +212,7 @@ export default {
|
||||
return suffixs
|
||||
},
|
||||
beforeAvatarUpload(file, fileList) {
|
||||
this.uploadLoading = true
|
||||
var fileName = file.name
|
||||
var accepts = this.accept.split(',')
|
||||
if (accepts) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="字典类型" prop="dictType">
|
||||
<mb-select v-model="temp.dictType" type="dict_type" width="185px" />
|
||||
<mb-select v-model="temp.dictType" type="dict_type" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
|
@ -32,6 +32,7 @@
|
||||
v-model="temp.componentName"
|
||||
:disable-branch-nodes="true"
|
||||
:show-count="true"
|
||||
placeholder=""
|
||||
:options="componentTree"
|
||||
:key="temp.componentName"
|
||||
style="position: fixed;z-index:999999;width: 850px;"
|
||||
@ -120,7 +121,7 @@ const getTemp = () => {
|
||||
pid: 0,
|
||||
icon: '',
|
||||
keepAlive: 0,
|
||||
componentName: ''
|
||||
componentName: null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="6">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="temp.sort" controls-position="right" />
|
||||
</el-form-item>
|
||||
|
@ -34,15 +34,22 @@
|
||||
</template>
|
||||
</mb-search>
|
||||
|
||||
<el-row style="margin-bottom: 15px">
|
||||
<el-row class="toolbar-container">
|
||||
<el-button v-permission="'user:save'" class="filter-item" type="primary" icon="ElEdit" @click="handleCreate">
|
||||
添加
|
||||
</el-button>
|
||||
<mb-button v-permission="'user:delete'" :el="{ plain: true }" :request-url="'/system/user/delete'" :btn-type="'delete'" :request-data="{ id: ids }" :after-handler="reloadTable" />
|
||||
<mb-upload-file ref="importUserRef" action="/system/user/import/preview" label="导入用户" :show-tip="false" :show-file-list="false" :show-remove-tip="false" :on-success="importUserSuccess" />
|
||||
</el-row>
|
||||
|
||||
<mb-table ref="table" v-bind="tableOptions" @selection-change="selectionChange" />
|
||||
|
||||
<mb-dialog ref="previewUsersDialog" title="预览数据" @confirm-click="importUsers">
|
||||
<template #content>
|
||||
<mb-table v-bind="importUserTableOptions" />
|
||||
</template>
|
||||
</mb-dialog>
|
||||
|
||||
<mb-dialog ref="userFormDialog" :title="dialogTitle" @confirm-click="userForm.save($event)" width="670px">
|
||||
<template #content>
|
||||
<user-form ref="userForm" :key="'userForm'" @reload-table="reloadTable" />
|
||||
@ -58,10 +65,50 @@
|
||||
<script setup>
|
||||
import UserForm from './user-form.vue'
|
||||
|
||||
import { ref, reactive, getCurrentInstance, onMounted, nextTick } from 'vue'
|
||||
import { ref, reactive, getCurrentInstance, nextTick, watch } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const importUserRef = ref()
|
||||
const previewUsersDialog = ref()
|
||||
const importUserTableOptions = reactive({
|
||||
|
||||
})
|
||||
const sourceDatas = ref()
|
||||
function importUserSuccess(res, file, fileList){
|
||||
const { datas } = res.data
|
||||
sourceDatas.value = res.data.sourceDatas
|
||||
console.log(JSON.stringify(res.data.sourceDatas))
|
||||
importUserRef.value.handlerRemove(file)
|
||||
if(datas && datas.length){
|
||||
var cols = []
|
||||
for(var key in datas[0]){
|
||||
cols.push({
|
||||
field: key,
|
||||
label: key
|
||||
})
|
||||
}
|
||||
previewUsersDialog.value.show(() => {
|
||||
importUserTableOptions.data = datas
|
||||
importUserTableOptions.cols = cols
|
||||
})
|
||||
}
|
||||
}
|
||||
function importUsers(){
|
||||
proxy.$postJson('/system/user/import', {
|
||||
datas: sourceDatas.value
|
||||
}).then(res => {
|
||||
if(res.data){
|
||||
proxy.$notify({
|
||||
title: '成功',
|
||||
message: '导入成功',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
previewUsersDialog.value.hide()
|
||||
table.value.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
const tableOptions = reactive({
|
||||
url: '/system/user/list',
|
||||
page: true,
|
||||
|
@ -18,6 +18,7 @@
|
||||
<druid.version>1.1.10</druid.version>
|
||||
<hutool-all.version>5.7.22</hutool-all.version>
|
||||
<sa-token.version>1.26.0</sa-token.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -62,6 +63,11 @@
|
||||
<artifactId>magic-api-plugin-component</artifactId>
|
||||
<version>${magic-api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
Loading…
x
Reference in New Issue
Block a user