mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-04-11 23:33:08 +08:00
组件优化
This commit is contained in:
parent
337e170f85
commit
ea9ef20c96
@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"element-plus": "^2.1.8",
|
"element-plus": "^2.1.11",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"vue": "^3.2.25",
|
"vue": "^3.2.25",
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-button
|
<el-button
|
||||||
v-bind="el_"
|
v-bind="props_"
|
||||||
|
:plain="plain"
|
||||||
@click="buttonClick"
|
@click="buttonClick"
|
||||||
>
|
>
|
||||||
{{ el_.text }}
|
{{ props_.text }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -14,10 +15,14 @@ import {ElNotification} from "element-plus";
|
|||||||
export default {
|
export default {
|
||||||
name: 'MbButton',
|
name: 'MbButton',
|
||||||
props: {
|
props: {
|
||||||
el: {
|
props: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
|
plain: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
btnType: {
|
btnType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
@ -61,7 +66,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
el_: this.el || {},
|
props_: this.props || {},
|
||||||
requestMethod_: this.requestMethod,
|
requestMethod_: this.requestMethod,
|
||||||
beforeConfirm_: this.beforeConfirm,
|
beforeConfirm_: this.beforeConfirm,
|
||||||
successTips_: this.successTips,
|
successTips_: this.successTips,
|
||||||
@ -72,9 +77,9 @@ export default {
|
|||||||
if (this.btnType) {
|
if (this.btnType) {
|
||||||
if (this.btnType === 'delete') {
|
if (this.btnType === 'delete') {
|
||||||
this.requestMethod_ = 'delete'
|
this.requestMethod_ = 'delete'
|
||||||
this.el_.type = 'danger'
|
this.props_.type = 'danger'
|
||||||
this.el_.text = '删除'
|
this.props_.text = '删除'
|
||||||
this.el_.icon = 'ElIconDelete'
|
this.props_.icon = 'ElIconDelete'
|
||||||
this.beforeConfirm_ = '此操作将永久删除该数据, 是否继续?'
|
this.beforeConfirm_ = '此操作将永久删除该数据, 是否继续?'
|
||||||
this.successTips_ = '删除成功!'
|
this.successTips_ = '删除成功!'
|
||||||
this.failTips_ = '删除失败!'
|
this.failTips_ = '删除失败!'
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</mb-table>
|
</mb-table>
|
||||||
|
<mb-table ref="magicTable" v-bind="tableOptions">
|
||||||
|
<template v-for="col in cols" #[col.field]="{ row, index }">
|
||||||
|
{{ row.name }}
|
||||||
|
</template>
|
||||||
|
</mb-table>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<span v-for="(it, i) in where">
|
<span v-for="(it, i) in where">
|
||||||
<el-form-item v-if="it && it.label" :label="it.label" :key="i">
|
<el-form-item v-if="it && it.label" :label="it.label" :key="i">
|
||||||
<el-input v-if="!it.type || it.type == 'input'" @input="input(it.input)" v-model="it.value" :placeholder="it.placeholder || ('请输入' + it.label)" style="width: 200px;" class="filter-item" />
|
<el-input v-if="!it.type || it.type == 'input'" @input="input(it.input)" v-model="it.value" :placeholder="it.placeholder || ('请输入' + it.label)" style="width: 200px;" class="filter-item" />
|
||||||
<mb-select v-else-if="it.type == 'select'" v-model="it.value" :placeholder="'请选择' + it.label" v-bind="it.properties" />
|
<mb-select v-else-if="it.type == 'select'" v-model="it.value" :placeholder="'请选择' + it.label" v-bind="it.props" />
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-else-if="it.type == 'date' || it.type == 'datetime' || it.type == 'daterange' || it.type == 'datetimerange'"
|
v-else-if="it.type == 'date' || it.type == 'datetime' || it.type == 'daterange' || it.type == 'datetimerange'"
|
||||||
v-model="it.value"
|
v-model="it.value"
|
||||||
@ -18,7 +18,7 @@
|
|||||||
>
|
>
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
<mb-inputrange v-model="it.value" v-else-if="it.type == 'inputrange'" />
|
<mb-inputrange v-model="it.value" v-else-if="it.type == 'inputrange'" />
|
||||||
<component v-else :is="it.type" v-model="it.value" v-bind="it.properties" />
|
<component v-else :is="it.type" v-model="it.value" v-bind="it.props" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</span>
|
</span>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import { nextTick, watch, onMounted } from 'vue'
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
where: {
|
where: {
|
||||||
@ -55,7 +55,7 @@ for(var key in props.where){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['search', 'mounted'])
|
const emit = defineEmits(['search'])
|
||||||
|
|
||||||
function input(input){
|
function input(input){
|
||||||
if(input){
|
if(input){
|
||||||
@ -104,10 +104,6 @@ function reset() {
|
|||||||
nextTick(() => emit('search'))
|
nextTick(() => emit('search'))
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
emit('mounted')
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
border
|
border
|
||||||
fit
|
fit
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
v-bind="el"
|
v-bind="props.props"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
@sort-change="sortChange"
|
@sort-change="sortChange"
|
||||||
@selection-change="selectionChange"
|
@selection-change="selectionChange"
|
||||||
@ -43,7 +43,7 @@ import common from "../../../scripts/common";
|
|||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
el: {
|
props: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
@ -87,9 +87,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
cols: {
|
cols: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => {
|
default: () => []
|
||||||
return []
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
emptyText: {
|
emptyText: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
:on-exceed="handleExceed"
|
:on-exceed="handleExceed"
|
||||||
:file-list="fileList"
|
v-bind="uploadDynamicProps"
|
||||||
:show-file-list="showFileList"
|
:show-file-list="showFileList"
|
||||||
:before-upload="beforeAvatarUpload"
|
:before-upload="beforeAvatarUpload"
|
||||||
:on-success="handleAvatarSuccess"
|
:on-success="handleAvatarSuccess"
|
||||||
@ -103,7 +103,8 @@ export default {
|
|||||||
urls: [],
|
urls: [],
|
||||||
uploadDomId: Math.random(),
|
uploadDomId: Math.random(),
|
||||||
fileList: [],
|
fileList: [],
|
||||||
uploadLoading: false
|
uploadLoading: false,
|
||||||
|
uploadDynamicProps: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -121,6 +122,14 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.renderFile()
|
this.renderFile()
|
||||||
}
|
}
|
||||||
|
// 解决多文件上传时,第一次上传的多个的时候 只能有一个成功的bug
|
||||||
|
if (this.modelValue instanceof Array && this.modelValue.length > 0) {
|
||||||
|
this.uploadDynamicProps.fileList = this.fileList
|
||||||
|
} else {
|
||||||
|
if (this.modelValue) {
|
||||||
|
this.uploadDynamicProps.fileList = this.fileList
|
||||||
|
}
|
||||||
|
}
|
||||||
if(this.action){
|
if(this.action){
|
||||||
this.actionUrl = import.meta.env.VITE_APP_BASE_API + this.action
|
this.actionUrl = import.meta.env.VITE_APP_BASE_API + this.action
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,12 @@
|
|||||||
tag="div"
|
tag="div"
|
||||||
draggable=".draggable-item"
|
draggable=".draggable-item"
|
||||||
@end="onDragEnd"
|
@end="onDragEnd"
|
||||||
|
item-key="id"
|
||||||
>
|
>
|
||||||
<template #item="{ element }">
|
<template #item="{ element }">
|
||||||
<div
|
<div
|
||||||
class="draggable-item"
|
class="draggable-item"
|
||||||
:style="{ width: width.replace('px', '') + 'px', height: height.replace('px', '') + 'px' }"
|
:style="{ width: width + 'px', height: height + 'px' }"
|
||||||
>
|
>
|
||||||
<el-image
|
<el-image
|
||||||
:src="$global.baseApi + element"
|
:src="$global.baseApi + element"
|
||||||
@ -35,9 +36,9 @@
|
|||||||
v-if="(!multiple && urls.length == 0) || (multiple && urls.length < limit)"
|
v-if="(!multiple && urls.length == 0) || (multiple && urls.length < limit)"
|
||||||
ref="uploadRef"
|
ref="uploadRef"
|
||||||
class="uploadBox"
|
class="uploadBox"
|
||||||
:style="{ width: width.replace('px', '') + 'px', height: height.replace('px', '') + 'px' }"
|
:style="{ width: width + 'px', height: height + 'px' }"
|
||||||
:action="action"
|
:action="action"
|
||||||
:file-list="fileList"
|
v-bind="uploadDynamicProps"
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
accept=".jpg,.jpeg,.png,.gif"
|
accept=".jpg,.jpeg,.png,.gif"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@ -118,12 +119,12 @@ export default {
|
|||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '100'
|
default: 100
|
||||||
},
|
},
|
||||||
height: {
|
height: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '100'
|
default: 100
|
||||||
},
|
},
|
||||||
tip: {
|
tip: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -146,7 +147,8 @@ export default {
|
|||||||
isUploading: false,
|
isUploading: false,
|
||||||
cropperOption: {},
|
cropperOption: {},
|
||||||
urls: [],
|
urls: [],
|
||||||
fileList: []
|
fileList: [],
|
||||||
|
uploadDynamicProps: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -179,6 +181,14 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 解决多图片上传时,第一次上传的多个的时候 只能有一个成功的bug
|
||||||
|
if (this.modelValue instanceof Array && this.modelValue.length > 0) {
|
||||||
|
this.uploadDynamicProps.fileList = this.fileList
|
||||||
|
} else {
|
||||||
|
if (this.modelValue) {
|
||||||
|
this.uploadDynamicProps.fileList = this.fileList
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleRemove(url) {
|
handleRemove(url) {
|
||||||
@ -205,10 +215,11 @@ export default {
|
|||||||
console.log(file)
|
console.log(file)
|
||||||
},
|
},
|
||||||
handleAvatarSuccess(res, file, fileList) {
|
handleAvatarSuccess(res, file, fileList) {
|
||||||
|
console.log(res)
|
||||||
this.fileList = fileList
|
this.fileList = fileList
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
this.urls.push(res.data.url)
|
this.urls.push(res.data.url)
|
||||||
console.log(this.urls)
|
// console.log(this.urls)
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
this.$emit('update:modelValue', this.urls)
|
this.$emit('update:modelValue', this.urls)
|
||||||
this.$emit('change', this.urls)
|
this.$emit('change', this.urls)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<el-button v-if="it.type == 'add'" v-permission="it.permission" class="filter-item" type="primary" icon="ElIconPlus" @click="it.click">
|
<el-button v-if="it.type == 'add'" v-permission="it.permission" class="filter-item" type="primary" icon="ElIconPlus" @click="it.click">
|
||||||
{{ it.label || '添加' }}
|
{{ it.label || '添加' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<mb-button v-if="it.type == 'delete'" v-permission="it.permission" :el="{ plain: true }" :request-url="it.url" :btn-type="'delete'" :request-data="{ id: ids }" :after-handler="reload" />
|
<mb-button v-if="it.type == 'delete'" v-permission="it.permission" :plain="true" :request-url="it.url" :btn-type="'delete'" :request-data="{ id: ids }" :after-handler="reload" />
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ const listOptions = reactive({
|
|||||||
label: '角色',
|
label: '角色',
|
||||||
props: {
|
props: {
|
||||||
url: '/system/role/all',
|
url: '/system/role/all',
|
||||||
el: { multiple: true }
|
multiple: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -177,7 +177,7 @@ const formOptions = reactive({
|
|||||||
props: {
|
props: {
|
||||||
url: '/system/role/all',
|
url: '/system/role/all',
|
||||||
placeholder: '请选择角色',
|
placeholder: '请选择角色',
|
||||||
el: { multiple: true }
|
multiple: true
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div style="padding: 50px;">
|
<div style="padding: 50px;">
|
||||||
<h2>上传文件</h2>
|
<h2>上传文件(单文件)</h2>
|
||||||
<mb-upload-file v-model="fileUrl" @change="fileChange" />
|
<mb-upload-file v-model="fileUrl" @change="fileChange" />
|
||||||
|
<h2>上传文件(多文件)</h2>
|
||||||
|
<mb-upload-file v-model="fileUrls" @change="fileChange" multiple />
|
||||||
<h2>上传图片(id)</h2>
|
<h2>上传图片(id)</h2>
|
||||||
<mb-upload-image :external-id="externalId" multiple :external-type="externalType" />
|
<mb-upload-image :external-id="externalId" multiple :external-type="externalType" />
|
||||||
<h2>上传图片(url、单图)</h2>
|
<h2>上传图片(url、单图)</h2>
|
||||||
<mb-upload-image v-model="imgUrl" @change="imgChange" tip="建议上传尺寸:710*345" />
|
<mb-upload-image v-model="imgUrl" @change="imgChange" tip="建议上传尺寸:710*345" />
|
||||||
<h2>上传图片(url、多图)</h2>
|
<h2>上传图片(url、多图)</h2>
|
||||||
<mb-upload-image v-model="multipleImgUrl" width="120" height="120" multiple :limit="3" @change="multipleImgChange" />
|
<mb-upload-image v-model="multipleImgUrl" :width="120" :height="120" multiple :limit="3" @change="multipleImgChange" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -20,8 +22,9 @@ export default {
|
|||||||
externalId: this.$common.uuid(),
|
externalId: this.$common.uuid(),
|
||||||
externalType: '营业执照',
|
externalType: '营业执照',
|
||||||
imgUrl: '',
|
imgUrl: '',
|
||||||
multipleImgUrl: '',
|
multipleImgUrl: ['userfiles/2022-05-13/6be62f3203904410a92530f8e300e233/QQ图片20220505165410.jpg'],
|
||||||
fileUrl: ''
|
fileUrl: '',
|
||||||
|
fileUrls: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -32,7 +35,7 @@ export default {
|
|||||||
console.log(this.imgUrl)
|
console.log(this.imgUrl)
|
||||||
},
|
},
|
||||||
multipleImgChange() {
|
multipleImgChange() {
|
||||||
console.log(this.multipleImgUrl)
|
// console.log(this.multipleImgUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ const tableOptions = reactive({
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '字典类型',
|
label: '字典类型',
|
||||||
value: '',
|
value: '',
|
||||||
properties: {
|
props: {
|
||||||
'all-option': true,
|
'all-option': true,
|
||||||
type: 'dict_type'
|
type: 'dict_type'
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ let menuTree = ref([])
|
|||||||
const menuData = ref([])
|
const menuData = ref([])
|
||||||
let searchValue = ref('')
|
let searchValue = ref('')
|
||||||
const tableOptions = reactive({
|
const tableOptions = reactive({
|
||||||
el: {
|
props: {
|
||||||
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
|
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
|
||||||
'row-key': 'id'
|
'row-key': 'id'
|
||||||
},
|
},
|
||||||
|
@ -82,7 +82,7 @@ const officeData = ref([])
|
|||||||
const officeTree = ref([])
|
const officeTree = ref([])
|
||||||
const searchValue = ref('')
|
const searchValue = ref('')
|
||||||
const tableOptions = reactive({
|
const tableOptions = reactive({
|
||||||
el: {
|
props: {
|
||||||
'default-expand-all': true,
|
'default-expand-all': true,
|
||||||
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
|
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
|
||||||
'row-key': 'id'
|
'row-key': 'id'
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<el-button v-permission="'user:save'" class="filter-item" type="primary" icon="ElIconEdit" @click="handleCreate">
|
<el-button v-permission="'user:save'" class="filter-item" type="primary" icon="ElIconEdit" @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'" plain :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" />
|
<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>
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ const tableOptions = reactive({
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '角色',
|
label: '角色',
|
||||||
value: '',
|
value: '',
|
||||||
properties: {
|
props: {
|
||||||
url: '/system/role/all',
|
url: '/system/role/all',
|
||||||
multiple: true
|
multiple: true
|
||||||
}
|
}
|
||||||
|
4
magic-boot/src/main/resources/application-demo.yml
Normal file
4
magic-boot/src/main/resources/application-demo.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
magic-api:
|
||||||
|
web: /magic/web
|
||||||
|
resource:
|
||||||
|
readonly: true
|
Loading…
x
Reference in New Issue
Block a user