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",
|
"groupId" : "1952f25c81084e24b55b11385767dc38",
|
||||||
"name" : "登录",
|
"name" : "登录",
|
||||||
"createTime" : null,
|
"createTime" : null,
|
||||||
"updateTime" : 1648567495848,
|
"updateTime" : 1648818736705,
|
||||||
"lock" : "0",
|
"lock" : "0",
|
||||||
"createBy" : null,
|
"createBy" : null,
|
||||||
"updateBy" : null,
|
"updateBy" : null,
|
||||||
@ -64,7 +64,7 @@
|
|||||||
"requestBody" : "{\r\n \"username\": \"admin\",\r\n \"password\": \"123456\"\r\n}",
|
"requestBody" : "{\r\n \"username\": \"admin\",\r\n \"password\": \"123456\"\r\n}",
|
||||||
"headers" : [ ],
|
"headers" : [ ],
|
||||||
"paths" : [ ],
|
"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,
|
"description" : null,
|
||||||
"requestBodyDefinition" : {
|
"requestBodyDefinition" : {
|
||||||
"name" : "",
|
"name" : "",
|
||||||
@ -140,7 +140,7 @@
|
|||||||
"children" : [ ]
|
"children" : [ ]
|
||||||
}, {
|
}, {
|
||||||
"name" : "data",
|
"name" : "data",
|
||||||
"value" : "319e2efb-9e42-4b86-9658-a60d3585a7fe",
|
"value" : "8dbc9feb-410a-4c7f-8805-0013e5ae1363",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"required" : false,
|
"required" : false,
|
||||||
"dataType" : "Object",
|
"dataType" : "Object",
|
||||||
@ -152,7 +152,7 @@
|
|||||||
"children" : [ ]
|
"children" : [ ]
|
||||||
}, {
|
}, {
|
||||||
"name" : "timestamp",
|
"name" : "timestamp",
|
||||||
"value" : "1648565675784",
|
"value" : "1648818573075",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"required" : false,
|
"required" : false,
|
||||||
"dataType" : "Long",
|
"dataType" : "Long",
|
||||||
@ -164,7 +164,7 @@
|
|||||||
"children" : [ ]
|
"children" : [ ]
|
||||||
}, {
|
}, {
|
||||||
"name" : "executeTime",
|
"name" : "executeTime",
|
||||||
"value" : "12",
|
"value" : "347",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"required" : false,
|
"required" : false,
|
||||||
"dataType" : "Integer",
|
"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
|
margin-bottom: 10px
|
||||||
}
|
}
|
||||||
.toolbar-container > div{
|
.toolbar-container > div{
|
||||||
margin-left: 10px;
|
margin-left: 12px;
|
||||||
}
|
}
|
||||||
.toolbar-container > div:nth-child(1){
|
.toolbar-container > div:nth-child(1){
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
<el-upload
|
<el-upload
|
||||||
:id="uploadDomId"
|
:id="uploadDomId"
|
||||||
class="upload-demo"
|
class="upload-demo"
|
||||||
:action="action"
|
ref="uploadRef"
|
||||||
|
:action="actionUrl"
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:on-preview="handlePreview"
|
:on-preview="handlePreview"
|
||||||
:on-remove="handleRemove"
|
:on-remove="handleRemove"
|
||||||
@ -11,11 +12,12 @@
|
|||||||
:limit="limit"
|
:limit="limit"
|
||||||
:on-exceed="handleExceed"
|
:on-exceed="handleExceed"
|
||||||
:file-list="fileList"
|
:file-list="fileList"
|
||||||
|
:show-file-list="showFileList"
|
||||||
:before-upload="beforeAvatarUpload"
|
:before-upload="beforeAvatarUpload"
|
||||||
:on-success="handleAvatarSuccess"
|
:on-success="handleAvatarSuccess"
|
||||||
>
|
>
|
||||||
<el-button size="small" type="primary" :disabled="!multiple && fileList.length == 1">点击上传</el-button>
|
<el-button type="primary" :loading="uploadLoading" :disabled="!multiple && fileList.length == 1">{{ label }}</el-button>
|
||||||
<div slot="tip" class="el-upload__tip">支持上传{{ getSettingSuffixs().replaceAll(',', ',') }}文件,且不超过{{ maxFileSize }}MB</div>
|
<div slot="tip" v-if="showTip" class="el-upload__tip">支持上传{{ getSettingSuffixs().replaceAll(',', ',') }}文件,且不超过{{ maxFileSize }}MB</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -59,6 +61,30 @@ export default {
|
|||||||
formats: {
|
formats: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
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() {
|
data() {
|
||||||
@ -70,13 +96,14 @@ export default {
|
|||||||
video: 'avi,flv,mp4,mpeg,mov'
|
video: 'avi,flv,mp4,mpeg,mov'
|
||||||
},
|
},
|
||||||
imageUrl: '',
|
imageUrl: '',
|
||||||
action: import.meta.env.VITE_APP_BASE_API + '/system/file/upload',
|
actionUrl: import.meta.env.VITE_APP_BASE_API + '/system/file/upload',
|
||||||
headers: {
|
headers: {
|
||||||
token: getToken()
|
token: getToken()
|
||||||
},
|
},
|
||||||
urls: [],
|
urls: [],
|
||||||
uploadDomId: Math.random(),
|
uploadDomId: Math.random(),
|
||||||
fileList: []
|
fileList: [],
|
||||||
|
uploadLoading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -90,12 +117,18 @@ export default {
|
|||||||
const { data } = res
|
const { data } = res
|
||||||
this.fileList = data
|
this.fileList = data
|
||||||
})
|
})
|
||||||
this.action = this.action + `?externalId=${this.externalId}&externalType=${this.externalType}`
|
this.actionUrl = this.actionUrl + `?externalId=${this.externalId}&externalType=${this.externalType}`
|
||||||
} else {
|
} else {
|
||||||
this.renderFile()
|
this.renderFile()
|
||||||
}
|
}
|
||||||
|
if(this.action){
|
||||||
|
this.actionUrl = import.meta.env.VITE_APP_BASE_API + this.action
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handlerRemove(file){
|
||||||
|
this.$refs.uploadRef.handleRemove(file)
|
||||||
|
},
|
||||||
renderFile() {
|
renderFile() {
|
||||||
if (this.value instanceof Array && this.value.length > 0) {
|
if (this.value instanceof Array && this.value.length > 0) {
|
||||||
this.fileList = this.value.map(it => {
|
this.fileList = this.value.map(it => {
|
||||||
@ -146,9 +179,13 @@ export default {
|
|||||||
this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
|
this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
|
||||||
},
|
},
|
||||||
beforeRemove(file, fileList) {
|
beforeRemove(file, fileList) {
|
||||||
|
if(!this.showRemoveTip){
|
||||||
|
return true
|
||||||
|
}
|
||||||
return this.$confirm(`确定移除 ${file.name}?`)
|
return this.$confirm(`确定移除 ${file.name}?`)
|
||||||
},
|
},
|
||||||
handleAvatarSuccess(res, file, fileList) {
|
handleAvatarSuccess(res, file, fileList) {
|
||||||
|
this.uploadLoading = false
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
this.urls.push(res.data.url)
|
this.urls.push(res.data.url)
|
||||||
@ -160,6 +197,9 @@ export default {
|
|||||||
this.$emit('change', res.data.url)
|
this.$emit('change', res.data.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(this.onSuccess){
|
||||||
|
this.onSuccess(res, file, fileList)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getSettingSuffixs() {
|
getSettingSuffixs() {
|
||||||
if (this.formats) {
|
if (this.formats) {
|
||||||
@ -172,6 +212,7 @@ export default {
|
|||||||
return suffixs
|
return suffixs
|
||||||
},
|
},
|
||||||
beforeAvatarUpload(file, fileList) {
|
beforeAvatarUpload(file, fileList) {
|
||||||
|
this.uploadLoading = true
|
||||||
var fileName = file.name
|
var fileName = file.name
|
||||||
var accepts = this.accept.split(',')
|
var accepts = this.accept.split(',')
|
||||||
if (accepts) {
|
if (accepts) {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="字典类型" prop="dictType">
|
<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-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
v-model="temp.componentName"
|
v-model="temp.componentName"
|
||||||
:disable-branch-nodes="true"
|
:disable-branch-nodes="true"
|
||||||
:show-count="true"
|
:show-count="true"
|
||||||
|
placeholder=""
|
||||||
:options="componentTree"
|
:options="componentTree"
|
||||||
:key="temp.componentName"
|
:key="temp.componentName"
|
||||||
style="position: fixed;z-index:999999;width: 850px;"
|
style="position: fixed;z-index:999999;width: 850px;"
|
||||||
@ -120,7 +121,7 @@ const getTemp = () => {
|
|||||||
pid: 0,
|
pid: 0,
|
||||||
icon: '',
|
icon: '',
|
||||||
keepAlive: 0,
|
keepAlive: 0,
|
||||||
componentName: ''
|
componentName: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="6">
|
<el-col :span="12">
|
||||||
<el-form-item label="排序" prop="sort">
|
<el-form-item label="排序" prop="sort">
|
||||||
<el-input-number v-model="temp.sort" controls-position="right" />
|
<el-input-number v-model="temp.sort" controls-position="right" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -34,15 +34,22 @@
|
|||||||
</template>
|
</template>
|
||||||
</mb-search>
|
</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 v-permission="'user:save'" class="filter-item" type="primary" icon="ElEdit" @click="handleCreate">
|
||||||
添加
|
添加
|
||||||
</el-button>
|
</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-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>
|
</el-row>
|
||||||
|
|
||||||
<mb-table ref="table" v-bind="tableOptions" @selection-change="selectionChange" />
|
<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">
|
<mb-dialog ref="userFormDialog" :title="dialogTitle" @confirm-click="userForm.save($event)" width="670px">
|
||||||
<template #content>
|
<template #content>
|
||||||
<user-form ref="userForm" :key="'userForm'" @reload-table="reloadTable" />
|
<user-form ref="userForm" :key="'userForm'" @reload-table="reloadTable" />
|
||||||
@ -58,10 +65,50 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import UserForm from './user-form.vue'
|
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 { 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({
|
const tableOptions = reactive({
|
||||||
url: '/system/user/list',
|
url: '/system/user/list',
|
||||||
page: true,
|
page: true,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<druid.version>1.1.10</druid.version>
|
<druid.version>1.1.10</druid.version>
|
||||||
<hutool-all.version>5.7.22</hutool-all.version>
|
<hutool-all.version>5.7.22</hutool-all.version>
|
||||||
<sa-token.version>1.26.0</sa-token.version>
|
<sa-token.version>1.26.0</sa-token.version>
|
||||||
|
<poi.version>4.1.2</poi.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -62,6 +63,11 @@
|
|||||||
<artifactId>magic-api-plugin-component</artifactId>
|
<artifactId>magic-api-plugin-component</artifactId>
|
||||||
<version>${magic-api.version}</version>
|
<version>${magic-api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user