更新
This commit is contained in:
parent
dec5f1a46d
commit
c76f1dbf0a
File diff suppressed because one or more lines are too long
59
tansci-boot-ui/src/api/system/menu.ts
Normal file
59
tansci-boot-ui/src/api/system/menu.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 菜单树
|
||||||
|
export function list(){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysmenu/tree',
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加
|
||||||
|
export function save(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysmenu/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function update(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysmenu/update',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function del(id:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysmenu/delete/' + id,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
60
tansci-boot-ui/src/api/system/org.ts
Normal file
60
tansci-boot-ui/src/api/system/org.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 列表
|
||||||
|
export function list(param:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysorg/list',
|
||||||
|
method: 'get',
|
||||||
|
data: param
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加
|
||||||
|
export function save(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysorg/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function del(id:String){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysorg/delete/' + id,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function update(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysorg/update',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
105
tansci-boot-ui/src/api/system/role.ts
Normal file
105
tansci-boot-ui/src/api/system/role.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
export function page(param:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/page',
|
||||||
|
method: 'get',
|
||||||
|
data: param
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列表
|
||||||
|
export function list(param:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/list',
|
||||||
|
method: 'get',
|
||||||
|
data: param
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加
|
||||||
|
export function save(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function del(id:String){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/delete/' + id,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function update(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/update',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据权限
|
||||||
|
export function dataPermissions(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/dataPermissions',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 菜单权限
|
||||||
|
export function menuPermissions(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/menuPermissions',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
90
tansci-boot-ui/src/api/system/user.ts
Normal file
90
tansci-boot-ui/src/api/system/user.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
export function page(param:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/page',
|
||||||
|
method: 'get',
|
||||||
|
data: param
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列表
|
||||||
|
export function list(param:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/list',
|
||||||
|
method: 'get',
|
||||||
|
data: param
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加
|
||||||
|
export function save(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
export function del(id:String){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/delete/' + id,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export function update(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/update',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改密码
|
||||||
|
export function modifyPass(data:any){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysuser/modifyPass',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
31
tansci-boot-ui/src/components/ElIcon.vue
Normal file
31
tansci-boot-ui/src/components/ElIcon.vue
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {defineProps, reactive, toRefs} from 'vue'
|
||||||
|
import * as ElIcons from '@element-plus/icons-vue'
|
||||||
|
|
||||||
|
const prop = defineProps({
|
||||||
|
iconVisible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['onIcon'])
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
iconList: ElIcons,
|
||||||
|
})
|
||||||
|
const {iconList} = toRefs(state)
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<el-dialog v-model="prop.iconVisible" title="图标" :close-on-press-escape="false" :close-on-click-modal="false" :show-close="false" width="70%">
|
||||||
|
<el-icon v-for="icon in iconList" :key="icon" @click="$emit('onIcon', icon)" :size="30" color="#242e42"
|
||||||
|
style="border: 1px solid #e4e7ed;padding: 1rem;cursor: pointer;">
|
||||||
|
<component :is="icon"></component>
|
||||||
|
</el-icon>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.el-dialog__header{
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
195
tansci-boot-ui/src/components/Table.vue
Normal file
195
tansci-boot-ui/src/components/Table.vue
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {defineProps, reactive, toRefs} from 'vue'
|
||||||
|
import common from '@/utils/common'
|
||||||
|
|
||||||
|
const prop = defineProps({
|
||||||
|
loading: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
type: Object,
|
||||||
|
default:{
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
total: 0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
column: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
operation: { // 操作列,自定义插槽
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
tableHeight: {
|
||||||
|
type: Number,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
headerCellStyle: {
|
||||||
|
type: Object,
|
||||||
|
default:{color:'#606266', fontWeight: 700, background:'var(--bg1)'}
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
type: Array,
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
'onSizeChange','onCurrentChange','onSelectionChange','setCellColor',
|
||||||
|
'onButtonClick','onSwitchChange',
|
||||||
|
])
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
maxHeight: window.innerHeight - 280,
|
||||||
|
tableHeight: prop.tableHeight,
|
||||||
|
headerCellStyle: prop.headerCellStyle,
|
||||||
|
cellStyle: function(e){
|
||||||
|
let obj:any = {};
|
||||||
|
emit('setCellColor', e, (color = {}) =>{
|
||||||
|
obj = color;
|
||||||
|
});
|
||||||
|
obj.padding = '2px';
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const {
|
||||||
|
maxHeight,tableHeight,headerCellStyle,cellStyle,
|
||||||
|
} = toRefs(state)
|
||||||
|
|
||||||
|
const onSizeChange = (e) =>{
|
||||||
|
emit('onSizeChange', e)
|
||||||
|
}
|
||||||
|
const onCurrentChange = (e) =>{
|
||||||
|
emit('onCurrentChange', e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据属性获取对象值
|
||||||
|
function onFind(arr,val){
|
||||||
|
if(!arr) return 'info';
|
||||||
|
|
||||||
|
let temp = arr.find(v=>{ return v.value == val});
|
||||||
|
if(temp) return temp.label;
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="table-container">
|
||||||
|
<div class="search-wrap">
|
||||||
|
<slot name="search"></slot>
|
||||||
|
</div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
<el-table :data="data" border stripe size="mini" :height="tableHeight" :max-height="maxHeight" row-key="id" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
v-loading="loading" :header-cell-style="headerCellStyle" :cell-style="cellStyle"
|
||||||
|
@selection-change="onSelectionChange" style="width: 100%;">
|
||||||
|
<template v-for="item in column" :key="item">
|
||||||
|
<el-table-column v-if="!item.prop && !item.label" :fixed="item.fixed" type="selection" width="45"></el-table-column>
|
||||||
|
<!-- color值 -->
|
||||||
|
<el-table-column v-else-if="item.type == 'color'"
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<span :style="{color: scope.row[item.prop]}">{{scope.row[item.prop]}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- icon图标 -->
|
||||||
|
<el-table-column v-else-if="item.type == 'icon'"
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-icon :size="20">
|
||||||
|
<component :is="scope.row[item.prop]"></component>
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- 金额格式化 -->
|
||||||
|
<el-table-column v-else-if="item.type == 'price'"
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{common.toDecimal(scope.row[item.prop])}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-image -->
|
||||||
|
<el-table-column v-else-if="item.type == 'image'"
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-image :src="scope.row[item.prop]" :preview-src-list="[scope.row[item.prop]]" :z-index="9999" fit="cover" style="width: 50px; height: 50px"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-rate -->
|
||||||
|
<el-table-column v-else-if="item.type == 'rate'"
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-rate v-model="scope.row[item.prop]" disabled allow-half />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-tag -->
|
||||||
|
<el-table-column v-else-if="item.type == 'tag'" show-overflow-tooltip
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag :size="item.option.size"
|
||||||
|
:effect="item.option.effect"
|
||||||
|
:type="onFind(item.option.typeList, scope.row[item.prop])">
|
||||||
|
{{scope.row[item.alias==null?item.prop:item.alias]}}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-button -->
|
||||||
|
<el-table-column v-else-if="item.type == 'button'" show-overflow-tooltip
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button @click="$emit('onButtonClick',scope.row)" :type="item.option.type" link :size="item.option.size">
|
||||||
|
{{scope.row[item.alias==null?item.prop:item.alias]}}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-switch -->
|
||||||
|
<el-table-column v-else-if="item.type == 'switch'" show-overflow-tooltip
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch @change="$emit('onSwitchChange',scope.row)" :inline-prompt="item.option.inlinePrompt?false:true"
|
||||||
|
:active-value="item.option.activeValue" :active-color="item.option.activeColor" :active-text="item.option.activeText"
|
||||||
|
:inactive-value="item.option.inactiveValue" :inactive-color="item.option.inactiveColor" :inactive-text="item.option.inactiveText"
|
||||||
|
:size="item.option.size"
|
||||||
|
v-model="scope.row[item.prop]"
|
||||||
|
></el-switch>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- el-progress -->
|
||||||
|
<el-table-column v-else-if="item.type == 'progress'" show-overflow-tooltip
|
||||||
|
:label="item.label" :align="item.align != null ? item.align : 'center'" :width="item.width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-progress :percentage="scope.row[item.alias==null?item.prop:item.alias]"
|
||||||
|
:status="item.option.status"
|
||||||
|
:color="item.option.color"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- 其他数据列 -->
|
||||||
|
<el-table-column v-else show-overflow-tooltip
|
||||||
|
:prop="item.alias==null?item.prop:item.alias"
|
||||||
|
:label="item.label"
|
||||||
|
:align="item.align != null ? item.align : 'center'"
|
||||||
|
:width="item.width"
|
||||||
|
:fixed="item.fixed">
|
||||||
|
</el-table-column>
|
||||||
|
</template>
|
||||||
|
<!-- 自定义插槽 -->
|
||||||
|
<el-table-column v-if="operation" fixed="right" label="操作" align="center" width="220">
|
||||||
|
<template #default="scope">
|
||||||
|
<slot name="column" v-bind:column="scope"></slot>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<div class="pagination-wrap" v-if="page">
|
||||||
|
<el-pagination @size-change="onSizeChange" @current-change="onCurrentChange"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:current-page="page.current"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:page-size="page.size"
|
||||||
|
:total="page.total"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
</style>
|
||||||
@ -144,6 +144,9 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
.el-tabs--card > .el-tabs__header{
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
.el-tabs--card > .el-tabs__header .el-tabs__nav {
|
.el-tabs--card > .el-tabs__header .el-tabs__nav {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,10 +16,10 @@ export const filterRouter = (routers:any, level:any) => {
|
|||||||
router.path = "/" + common.uuid()
|
router.path = "/" + common.uuid()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(router.path && router.path.startsWith('http') && router.meta.openMode === 0){
|
if(router.path && router.path.startsWith('http') && router.meta.openMode === 1){
|
||||||
setIframe()
|
setIframe()
|
||||||
} else if(router.path && router.path.startsWith('/') && router.path.indexOf('.htm') != -1){
|
} else if(router.path && router.path.startsWith('/') && router.path.indexOf('.htm') != -1){
|
||||||
if(router.meta.openMode === 0){
|
if(router.meta.openMode === 1){
|
||||||
setIframe()
|
setIframe()
|
||||||
} else {
|
} else {
|
||||||
router.path = location.href.substring(0, location.href.indexOf('/', location.href.indexOf('/', location.href.indexOf('/') + 1) + 1)) + router.path
|
router.path = location.href.substring(0, location.href.indexOf('/', location.href.indexOf('/', location.href.indexOf('/') + 1) + 1)) + router.path
|
||||||
|
|||||||
@ -15,7 +15,7 @@ $--colors: (
|
|||||||
"base": #db2828,
|
"base": #db2828,
|
||||||
),
|
),
|
||||||
"info": (
|
"info": (
|
||||||
"base": #42b8dd,
|
"base": #909399,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ $--colors: (
|
|||||||
"base": #db2828,
|
"base": #db2828,
|
||||||
),
|
),
|
||||||
"info": (
|
"info": (
|
||||||
"base": #42b8dd,
|
"base": #909399,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -24,8 +24,7 @@ $--colors: (
|
|||||||
);
|
);
|
||||||
|
|
||||||
@forward "element-plus/theme-chalk/src/common/var.scss" with (
|
@forward "element-plus/theme-chalk/src/common/var.scss" with (
|
||||||
$colors: $--colors,
|
$colors: $--colors
|
||||||
$button-padding-horizontal: ("default": 50px)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@use "element-plus/theme-chalk/src/index.scss" as *;
|
@use "element-plus/theme-chalk/src/index.scss" as *;
|
||||||
|
|||||||
@ -8,6 +8,16 @@
|
|||||||
// 局部背景
|
// 局部背景
|
||||||
// --el-bg-color: radial-gradient( white 0%, #FAFDFE 10%, #ddf8e7 50%, #FAFDFE 90%, white 100%);
|
// --el-bg-color: radial-gradient( white 0%, #FAFDFE 10%, #ddf8e7 50%, #FAFDFE 90%, white 100%);
|
||||||
--el-bg-color: radial-gradient(#d9f8e5 0%, #FAFDFE 80%, #e7fcef 100%);
|
--el-bg-color: radial-gradient(#d9f8e5 0%, #FAFDFE 80%, #e7fcef 100%);
|
||||||
|
|
||||||
|
// 操作颜色
|
||||||
|
--delete: #f56c6c;
|
||||||
|
--edit: #0084ff;
|
||||||
|
--add: #63ba4d;
|
||||||
|
--query: #909399;
|
||||||
|
--down: #E6A23C;
|
||||||
|
--upper: #67C23A;
|
||||||
|
--role: #006000;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@ -19,6 +29,38 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* table组件样式
|
||||||
|
*/
|
||||||
|
.table-container{
|
||||||
|
.search-wrap{
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
background: var(--bg1);
|
||||||
|
}
|
||||||
|
.search-wrap>div{
|
||||||
|
line-height: 40px;
|
||||||
|
padding: 0.2rem 0.8rem;
|
||||||
|
}
|
||||||
|
.button-wrap{
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding-top: 0.6rem;
|
||||||
|
}
|
||||||
|
.button-wrap>div{
|
||||||
|
line-height: 40px;
|
||||||
|
padding: 0.2rem 0.8rem;
|
||||||
|
}
|
||||||
|
.table-wrap{
|
||||||
|
padding: 1rem 0;
|
||||||
|
}
|
||||||
|
.pagination-wrap{
|
||||||
|
padding-bottom: 0.2rem;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* el-table 滚动条样式
|
* el-table 滚动条样式
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -13,4 +13,27 @@ common.isComma = (value:any) => {
|
|||||||
return value.toString().indexOf(',') !== -1
|
return value.toString().indexOf(',') !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 四舍五入保留2位小数(不够位数,则用0替补)
|
||||||
|
common.toDecimal = (value:any) => {
|
||||||
|
var result = parseFloat(value);
|
||||||
|
if (isNaN(result)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
result = Math.round(value * 100) / 100;
|
||||||
|
var s_x = result.toString(); // 将数字转换为字符串
|
||||||
|
var pos_decimal = s_x.indexOf('.'); // 小数点的索引值
|
||||||
|
|
||||||
|
// 当整数时,pos_decimal=-1 自动补0
|
||||||
|
if (pos_decimal < 0) {
|
||||||
|
pos_decimal = s_x.length;
|
||||||
|
s_x += '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当数字的长度< 小数点索引+2时,补0
|
||||||
|
while (s_x.length <= pos_decimal + 2) {
|
||||||
|
s_x += '0';
|
||||||
|
}
|
||||||
|
return s_x;
|
||||||
|
}
|
||||||
|
|
||||||
export default common
|
export default common
|
||||||
@ -1,5 +1,4 @@
|
|||||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
||||||
import { showMessage } from './status'
|
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { logout, getToken } from '@/api/auth'
|
import { logout, getToken } from '@/api/auth'
|
||||||
import router from '../router'
|
import router from '../router'
|
||||||
@ -33,7 +32,7 @@ axiosInstance.interceptors.response.use(
|
|||||||
if (response.status === 200 && response.data.code === 200) {
|
if (response.status === 200 && response.data.code === 200) {
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
ElMessage.warning(showMessage(response.data.code));
|
ElMessage.warning(response.data.message);
|
||||||
if (response.data.code === 402) {
|
if (response.data.code === 402) {
|
||||||
logout()
|
logout()
|
||||||
}
|
}
|
||||||
@ -42,7 +41,7 @@ axiosInstance.interceptors.response.use(
|
|||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
router.push({path: 'login'});
|
router.push({path: 'login'});
|
||||||
}
|
}
|
||||||
return response;
|
return Promise.reject(response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 请求失败
|
// 请求失败
|
||||||
@ -50,7 +49,7 @@ axiosInstance.interceptors.response.use(
|
|||||||
const {response} = error;
|
const {response} = error;
|
||||||
if (response) {
|
if (response) {
|
||||||
// 请求已发出,但是不在2xx的范围
|
// 请求已发出,但是不在2xx的范围
|
||||||
ElMessage.warning(showMessage(response.status));
|
ElMessage.warning(response.statusText);
|
||||||
return Promise.reject(response.data);
|
return Promise.reject(response.data);
|
||||||
} else {
|
} else {
|
||||||
ElMessage.warning('网络连接异常,请稍后再试!');
|
ElMessage.warning('网络连接异常,请稍后再试!');
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
export const showMessage = (status:number|string) : string => {
|
|
||||||
let message:string = "";
|
|
||||||
switch (status) {
|
|
||||||
case 400:
|
|
||||||
message = "请求错误(400)";
|
|
||||||
break;
|
|
||||||
case 401:
|
|
||||||
// message = "未授权,请重新登录(401)";
|
|
||||||
message = "用户名或密码错误";
|
|
||||||
break;
|
|
||||||
case 403:
|
|
||||||
message = "拒绝访问(403)";
|
|
||||||
break;
|
|
||||||
case 404:
|
|
||||||
message = "请求出错(404)";
|
|
||||||
break;
|
|
||||||
case 408:
|
|
||||||
message = "请求超时(408)";
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
message = "服务器错误(500)";
|
|
||||||
break;
|
|
||||||
case 501:
|
|
||||||
message = "服务未实现(501)";
|
|
||||||
break;
|
|
||||||
case 502:
|
|
||||||
message = "网络错误(502)";
|
|
||||||
break;
|
|
||||||
case 503:
|
|
||||||
message = "服务不可用(503)";
|
|
||||||
break;
|
|
||||||
case 504:
|
|
||||||
message = "网络超时(504)";
|
|
||||||
break;
|
|
||||||
case 505:
|
|
||||||
message = "HTTP版本不受支持(505)";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message = `未授权,请重新登录!`;
|
|
||||||
}
|
|
||||||
return `${message}`;
|
|
||||||
};
|
|
||||||
@ -1,5 +1,268 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {onMounted, reactive, ref} from 'vue'
|
||||||
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||||
|
import type {FormInstance} from 'element-plus'
|
||||||
|
import {list,getById,save,update,del} from '@/api/system/menu'
|
||||||
|
import ElIcon from '@/components/ElIcon.vue'
|
||||||
|
|
||||||
|
const menuFormRef = ref<FormInstance>();
|
||||||
|
const state = reactive({
|
||||||
|
treeData: [],
|
||||||
|
operate: 0,
|
||||||
|
menuForm:{
|
||||||
|
id: '',
|
||||||
|
parentId: '',
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
icon: '',
|
||||||
|
chineseName: '',
|
||||||
|
englishName: '',
|
||||||
|
sort: 0,
|
||||||
|
component: '',
|
||||||
|
openMode: 0,
|
||||||
|
isDel: 0,
|
||||||
|
keepAlive: 0,
|
||||||
|
isShow: 0,
|
||||||
|
remarks: ''
|
||||||
|
},
|
||||||
|
menuId: null,
|
||||||
|
iconVisible: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
onMenuTree()
|
||||||
|
})
|
||||||
|
|
||||||
|
function onMenuTree(){
|
||||||
|
list().then((res:any)=>{
|
||||||
|
if(res){
|
||||||
|
state.treeData = res.result;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const onNodeClick = (data:any) =>{
|
||||||
|
state.operate = 0;
|
||||||
|
state.menuId = data.id;
|
||||||
|
state.menuForm = {
|
||||||
|
id: data.id,
|
||||||
|
parentId: data.parentId,
|
||||||
|
name: data.name,
|
||||||
|
url: data.url,
|
||||||
|
icon: data.icon,
|
||||||
|
chineseName: data.chineseName,
|
||||||
|
englishName: data.englishName,
|
||||||
|
sort: data.sort,
|
||||||
|
component: data.component,
|
||||||
|
openMode: data.openMode,
|
||||||
|
isDel: data.isDel,
|
||||||
|
keepAlive: data.keepAlive,
|
||||||
|
isShow: data.isShow,
|
||||||
|
remarks: data.remarks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onOperateChange = (val:any) =>{
|
||||||
|
if(val == 1){
|
||||||
|
let menuId = '0'
|
||||||
|
if(state.menuId){
|
||||||
|
menuId = state.menuId
|
||||||
|
}
|
||||||
|
state.operate = 1;
|
||||||
|
state.menuForm = {
|
||||||
|
id: '',
|
||||||
|
parentId: menuId,
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
icon: '',
|
||||||
|
chineseName: '',
|
||||||
|
englishName: '',
|
||||||
|
sort: 0,
|
||||||
|
component: '',
|
||||||
|
openMode: 0,
|
||||||
|
isDel: 0,
|
||||||
|
keepAlive: 0,
|
||||||
|
isShow: 0,
|
||||||
|
remarks: ''
|
||||||
|
}
|
||||||
|
} else if(val == 2) {
|
||||||
|
state.operate = 2;
|
||||||
|
} else {
|
||||||
|
if(!state.menuId){
|
||||||
|
ElMessage.warning("请选择要删除的菜单!")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.operate = 0;
|
||||||
|
ElMessageBox.confirm('此操作将永久删除该菜单, 是否继续?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
del(state.menuId).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("删除成功!");
|
||||||
|
state.menuForm = {
|
||||||
|
id: '',
|
||||||
|
parentId: '',
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
icon: '',
|
||||||
|
chineseName: '',
|
||||||
|
englishName: '',
|
||||||
|
sort: 0,
|
||||||
|
component: '',
|
||||||
|
openMode: 0,
|
||||||
|
isDel: 0,
|
||||||
|
keepAlive: 0,
|
||||||
|
isShow: 0,
|
||||||
|
remarks: ''
|
||||||
|
};
|
||||||
|
onMenuTree();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(e=>{
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onFormIcon = () =>{
|
||||||
|
state.iconVisible = true;
|
||||||
|
}
|
||||||
|
const onIcon = (val:any) =>{
|
||||||
|
state.menuForm.icon = val.name;
|
||||||
|
state.iconVisible = false;
|
||||||
|
}
|
||||||
|
const onSubmit = async (formEl: FormInstance | undefined) =>{
|
||||||
|
if (!formEl) return;
|
||||||
|
await formEl.validate((valid)=>{
|
||||||
|
if(valid){
|
||||||
|
if(state.operate == 1){
|
||||||
|
save(state.menuForm).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("添加成功!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (state.operate == 2) {
|
||||||
|
update(state.menuForm).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("更新成功!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
state.menuForm = {
|
||||||
|
id: '',
|
||||||
|
parentId: '',
|
||||||
|
name: '',
|
||||||
|
url: '',
|
||||||
|
icon: '',
|
||||||
|
chineseName: '',
|
||||||
|
englishName: '',
|
||||||
|
sort: 0,
|
||||||
|
component: '',
|
||||||
|
openMode: 0,
|
||||||
|
isDel: 0,
|
||||||
|
keepAlive: 0,
|
||||||
|
isShow: 0,
|
||||||
|
remarks: ''
|
||||||
|
};
|
||||||
|
state.operate = 0;
|
||||||
|
onMenuTree();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<el-card class="menu-container" shadow="always">
|
||||||
App
|
<el-card class="menu-tree" shadow="never">
|
||||||
</div>
|
<el-tree :data="state.treeData" :props="{children: 'children', label: 'chineseName'}" highlight-current @node-click="onNodeClick" empty-text="暂无菜单">
|
||||||
</template>
|
<template #default="{ node, data }">
|
||||||
|
<span class="custom-tree-node">
|
||||||
|
<el-icon v-if="data.icon" style="vertical-align: middle;padding-right:10px;">
|
||||||
|
<component :is="data.icon"></component>
|
||||||
|
</el-icon>
|
||||||
|
<span>{{ node.label }}</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-tree>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="menu-form" shadow="never">
|
||||||
|
<el-radio-group @change="onOperateChange" v-model="state.operate">
|
||||||
|
<el-radio-button :label="1">添加</el-radio-button>
|
||||||
|
<el-radio-button :label="2">编辑</el-radio-button>
|
||||||
|
<el-radio-button :label="3">删除</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
<el-divider content-position="left">详细信息</el-divider>
|
||||||
|
<el-form :model="state.menuForm" :rules="rules" ref="menuFormRef" :disabled="state.operate==0 || state.operate==3?true:false" label-position="right" label-width="150px">
|
||||||
|
<el-form-item label="菜单名称" prop="name" :rules="[{required: true, message: '名称不能为空', trigger: 'blur'},{pattern: /^[A-Za-z0-9]+$/, message: '必须是字母', trigger: 'blur'}]">
|
||||||
|
<el-input v-model="state.menuForm.name" placeholder="请输入名称" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="菜单路由" prop="url" :rules="[{required: true, message: '路由不能为空', trigger: 'blur'}]">
|
||||||
|
<el-input v-model="state.menuForm.url" placeholder="请输入路由" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="菜单图标" prop="icon" :rules="[{required: true, message: '菜单图标不能为空', trigger: 'blur'}]">
|
||||||
|
<el-input v-model="state.menuForm.icon" @click="onFormIcon" readonly suffix-icon="Platform" style="width:50%"></el-input>
|
||||||
|
<ElIcon :iconVisible="state.iconVisible" @onIcon="onIcon"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="中文名称" prop="chineseName" :rules="[{required: true, message: '中文名称不能为空', trigger: 'blur'},{pattern: /^[\u4e00-\u9fa5]{0,}$/, message: '必须是汉字', trigger: 'blur'}]">
|
||||||
|
<el-input v-model="state.menuForm.chineseName" placeholder="请输入中文名称" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="英文名称" prop="englishName" :rules="[{required: true, message: '英文名称不能为空', trigger: 'blur'},{pattern: /^[A-Za-z0-9]+$/, message: '必须是字母', trigger: 'blur'}]">
|
||||||
|
<el-input v-model="state.menuForm.englishName" placeholder="请输入英文名称" autocomplete="off" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="菜单顺序" prop="sort" :rules="[{required: true, message: '菜单顺序不能为空', trigger: 'blur'}]">
|
||||||
|
<el-input-number v-model="state.menuForm.sort" :min="0" :max="999" style="width:50%"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="组件名称" prop="component">
|
||||||
|
<el-input v-model="state.menuForm.component" placeholder="请输入组件名称" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="菜单类型" prop="openMode" :rules="[{required: true, message: '请选择类型', trigger: 'change'}]">
|
||||||
|
<el-select v-model="state.menuForm.openMode" placeholder="请选菜单类型" style="width:50%">
|
||||||
|
<el-option label="菜单" :value="0"></el-option>
|
||||||
|
<el-option label="Iframe" :value="1"></el-option>
|
||||||
|
<el-option label="新标签页" :value="2"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否缓存" prop="keepAlive" :rules="[{required: true, message: '请选择是否缓存', trigger: 'change'}]">
|
||||||
|
<el-radio-group v-model="state.menuForm.keepAlive">
|
||||||
|
<el-radio :label="1">缓存</el-radio>
|
||||||
|
<el-radio :label="0">不缓存</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否显示" prop="isShow" :rules="[{required: true, message: '请选择是否显示', trigger: 'change'}]">
|
||||||
|
<el-radio-group v-model="state.menuForm.isShow">
|
||||||
|
<el-radio :label="1">显示</el-radio>
|
||||||
|
<el-radio :label="0">不显示</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remarks">
|
||||||
|
<el-input v-model="state.menuForm.remarks" type="textarea" :rows="2" placeholder="请输入备注" style="width:50%"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="state.operate != 0 && state.operate != 3">
|
||||||
|
<el-button type="primary" @click="onSubmit(menuFormRef)">提交</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.menu-container{
|
||||||
|
padding-bottom: 1.5rem;
|
||||||
|
.menu-tree{
|
||||||
|
float: left;
|
||||||
|
margin-right: 1rem;
|
||||||
|
min-width: 300px;
|
||||||
|
min-height: 700px;
|
||||||
|
.el-tree-node:hover>.el-tree-node__content{
|
||||||
|
background-color: #fff !important;
|
||||||
|
color: var(--theme) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
|
||||||
|
background-color: #fff !important;
|
||||||
|
color: var(--theme) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.menu-form{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,5 +1,144 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {onMounted, reactive, ref, unref} from 'vue'
|
||||||
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||||
|
import type {FormInstance} from 'element-plus'
|
||||||
|
import {page,save,update,del} from '@/api/system/role'
|
||||||
|
import Table from '@/components/Table.vue'
|
||||||
|
|
||||||
|
const searchForm = reactive({
|
||||||
|
name: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
const table = reactive({
|
||||||
|
loading: false,
|
||||||
|
page: {
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
total: 1,
|
||||||
|
},
|
||||||
|
tableTitle: [
|
||||||
|
{prop:'',label:'',fixed:'left'},
|
||||||
|
{prop:'code',label:'角色编码'},
|
||||||
|
{prop:'name',label:'角色名称'},
|
||||||
|
{prop:'creator',label:'创建人'},
|
||||||
|
{prop:'updateTime',label:'更新时间'},
|
||||||
|
{prop:'createTime',label:'创建时间'},
|
||||||
|
{prop:'remarks',label:'描述'}
|
||||||
|
],
|
||||||
|
tableData:[],
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
const form = reactive({
|
||||||
|
roleVisible: false,
|
||||||
|
operate: 0,
|
||||||
|
roleForm:{
|
||||||
|
id:'',
|
||||||
|
name:'',
|
||||||
|
status: 0,
|
||||||
|
remarks: ''
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
onRolePage()
|
||||||
|
})
|
||||||
|
|
||||||
|
function onRolePage(){
|
||||||
|
table.loading = true;
|
||||||
|
page(Object.assign(table.page, searchForm)).then((res:any)=>{
|
||||||
|
if(res){
|
||||||
|
table.loading = false;
|
||||||
|
table.tableData = res.result.records;
|
||||||
|
table.page.current = res.result.current;
|
||||||
|
table.page.size = res.result.size;
|
||||||
|
table.page.total = res.result.total;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSizeChange(e){
|
||||||
|
table.page.size = e;
|
||||||
|
onRolePage();
|
||||||
|
}
|
||||||
|
function onCurrentChange(e){
|
||||||
|
table.page.current = e;
|
||||||
|
onRolePage();
|
||||||
|
}
|
||||||
|
function onRefresh(){
|
||||||
|
searchForm.name = null
|
||||||
|
onRolePage();
|
||||||
|
}
|
||||||
|
function onSearch(){
|
||||||
|
onRolePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
function onEdit(val){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
function onDelete(val:any){
|
||||||
|
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
del(val.column.row.id).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success('删除成功!');
|
||||||
|
onRolePage();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch(e=>{
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加信息
|
||||||
|
function onAddRole(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSubmit (){
|
||||||
|
const form = unref(formRef);
|
||||||
|
if (!form) return;
|
||||||
|
await form.validate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<el-card class="role-container" shadow="always">
|
||||||
App
|
<Table :data="table.tableData" :column="table.tableTitle" :operation="true" :page="table.page" :loading="table.loading"
|
||||||
</div>
|
@onSizeChange="onSizeChange" @onCurrentChange="onCurrentChange" @onSwitchChange="onSwitchChange">
|
||||||
</template>
|
<template #search>
|
||||||
|
<div><el-button type="info" @click="onAddRole">添加</el-button></div>
|
||||||
|
<div><el-input v-model="name" placeholder="请输入名称"></el-input></div>
|
||||||
|
<div><el-button @click="onRefresh" icon="RefreshRight" circle></el-button></div>
|
||||||
|
<div><el-button @click="onSearch" type="primary" icon="Search">查询</el-button></div>
|
||||||
|
</template>
|
||||||
|
<template #column="scope">
|
||||||
|
<el-button @click="onEdit(scope)" type='primary' text='primary' style="color:var(--edit); padding:0;">编辑</el-button>
|
||||||
|
<el-button @click="onDelete(scope)" type='primary' text='primary' style="color:var(--delete); padding:0;">删除</el-button>
|
||||||
|
<el-button @click="onMenuRole(scope)" type='primary' text='primary' style="color:var(--role); padding:0;">菜单权限</el-button>
|
||||||
|
<el-button @click="onMenuRole(scope)" type='primary' text='primary' style="color:var(--role); padding:0;">权限</el-button>
|
||||||
|
</template>
|
||||||
|
</Table>
|
||||||
|
<el-dialog title="权限信息" v-model="form.roleVisible" :show-close="false" width="40%">
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="roleVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onSubmit(formRef)">提交</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.role-container{
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,9 +58,12 @@ public class SysMenuController {
|
|||||||
|
|
||||||
@ApiOperation(value = "添加", notes = "添加")
|
@ApiOperation(value = "添加", notes = "添加")
|
||||||
@Log(modul = "菜单管理-添加", type = Constants.INSERT, desc = "添加")
|
@Log(modul = "菜单管理-添加", type = Constants.INSERT, desc = "添加")
|
||||||
@GetMapping("/save")
|
@PostMapping("/save")
|
||||||
@SaCheckPermission("menu:save")
|
@SaCheckPermission("menu:save")
|
||||||
public Wrapper<Object> save(@RequestBody SysMenu menu) {
|
public Wrapper<Object> save(@RequestBody SysMenu menu) {
|
||||||
|
menu.setIsDel(Constants.NOT_DEL_FALG);
|
||||||
|
menu.setUpdateTime(LocalDateTime.now());
|
||||||
|
menu.setCreateTime(LocalDateTime.now());
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysMenuService.save(menu));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysMenuService.save(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ public class SysMenuController {
|
|||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@SaCheckPermission("menu:update")
|
@SaCheckPermission("menu:update")
|
||||||
public Wrapper<Object> update(@RequestBody SysMenu menu) {
|
public Wrapper<Object> update(@RequestBody SysMenu menu) {
|
||||||
|
menu.setUpdateTime(LocalDateTime.now());
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysMenuService.updateById(menu));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysMenuService.updateById(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,21 @@
|
|||||||
package com.tansci.controller;
|
package com.tansci.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.tansci.common.WrapMapper;
|
||||||
|
import com.tansci.common.Wrapper;
|
||||||
|
import com.tansci.common.annotation.Log;
|
||||||
|
import com.tansci.common.constant.Constants;
|
||||||
|
import com.tansci.domain.SysOrg;
|
||||||
import com.tansci.service.SysOrgService;
|
import com.tansci.service.SysOrgService;
|
||||||
|
import com.tansci.utils.UUIDUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysOrgController.java
|
* @ClassName: SysOrgController.java
|
||||||
@ -16,11 +26,48 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
**/
|
**/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/sysrog")
|
@RequestMapping("/sysorg")
|
||||||
@Api(value = "sysrog", tags = "组织管理")
|
@Api(value = "sysorg", tags = "组织管理")
|
||||||
public class SysOrgController {
|
public class SysOrgController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysOrgService sysOrgService;
|
private SysOrgService sysOrgService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "组织管理", notes = "组织管理")
|
||||||
|
@Log(modul = "组织管理-列表", type = Constants.SELECT, desc = "列表")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@SaCheckPermission("org:list")
|
||||||
|
public Wrapper<List<SysOrg>> list(SysOrg org) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysOrgService.list(org));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "添加", notes = "添加")
|
||||||
|
@Log(modul = "组织管理-添加", type = Constants.INSERT, desc = "添加")
|
||||||
|
@PostMapping("/save")
|
||||||
|
@SaCheckPermission("org:save")
|
||||||
|
public Wrapper<Object> save(@RequestBody SysOrg org) {
|
||||||
|
org.setCode(UUIDUtils.getUUID(10));
|
||||||
|
org.setIsDel(Constants.NOT_DEL_FALG);
|
||||||
|
org.setUpdateTime(LocalDateTime.now());
|
||||||
|
org.setCreateTime(LocalDateTime.now());
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysOrgService.save(org));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除", notes = "删除")
|
||||||
|
@Log(modul = "组织管理-删除", type = Constants.DELETE, desc = "删除")
|
||||||
|
@GetMapping("/delete/{id}")
|
||||||
|
@SaCheckPermission("org:delete")
|
||||||
|
public Wrapper<Object> delete(@PathVariable String id) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysOrgService.removeById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改", notes = "修改")
|
||||||
|
@Log(modul = "组织管理-修改", type = Constants.UPDATE, desc = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
@SaCheckPermission("org:update")
|
||||||
|
public Wrapper<Object> update(@RequestBody SysOrg org) {
|
||||||
|
org.setUpdateTime(LocalDateTime.now());
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysOrgService.updateById(org));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,21 @@
|
|||||||
package com.tansci.controller;
|
package com.tansci.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.tansci.common.WrapMapper;
|
||||||
|
import com.tansci.common.Wrapper;
|
||||||
|
import com.tansci.common.annotation.Log;
|
||||||
|
import com.tansci.common.constant.Constants;
|
||||||
|
import com.tansci.domain.SysRole;
|
||||||
import com.tansci.service.SysRoleService;
|
import com.tansci.service.SysRoleService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysRoleController.java
|
* @ClassName: SysRoleController.java
|
||||||
@ -23,5 +33,59 @@ public class SysRoleController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleService sysRoleService;
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "分页", notes = "分页")
|
||||||
|
@Log(modul = "角色管理-分页", type = Constants.SELECT, desc = "列表")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Wrapper<IPage<SysRole>> page(Page page, SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.page(page, role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "列表", notes = "列表")
|
||||||
|
@Log(modul = "角色管理-列表", type = Constants.SELECT, desc = "列表")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@SaCheckPermission("role:list")
|
||||||
|
public Wrapper<List<SysRole>> list(SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.list(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "添加", notes = "添加")
|
||||||
|
@Log(modul = "角色管理-添加", type = Constants.INSERT, desc = "添加")
|
||||||
|
@PostMapping("/save")
|
||||||
|
@SaCheckPermission("role:save")
|
||||||
|
public Wrapper<Object> save(@RequestBody SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.insert(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除", notes = "删除")
|
||||||
|
@Log(modul = "角色管理-删除", type = Constants.DELETE, desc = "删除")
|
||||||
|
@GetMapping("/delete/{id}")
|
||||||
|
@SaCheckPermission("role:delete")
|
||||||
|
public Wrapper<Object> delete(@PathVariable String id) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.delete(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改", notes = "修改")
|
||||||
|
@Log(modul = "角色管理-修改", type = Constants.UPDATE, desc = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
@SaCheckPermission("role:update")
|
||||||
|
public Wrapper<Object> update(@RequestBody SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.update(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "数据权限", notes = "数据权限")
|
||||||
|
@Log(modul = "角色管理-数据权限", type = Constants.UPDATE, desc = "数据权限")
|
||||||
|
@PostMapping("/dataPermissions")
|
||||||
|
@SaCheckPermission("role:data")
|
||||||
|
public Wrapper<Object> dataPermissions(@RequestBody SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.dataPermissions(role));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "菜单权限", notes = "菜单权限")
|
||||||
|
@Log(modul = "角色管理-菜单权限", type = Constants.UPDATE, desc = "菜单权限")
|
||||||
|
@PostMapping("/menuPermissions")
|
||||||
|
@SaCheckPermission("role:menu")
|
||||||
|
public Wrapper<Object> menuPermissions(@RequestBody SysRole role) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.menuPermissions(role));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.tansci.controller;
|
package com.tansci.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.tansci.common.WrapMapper;
|
import com.tansci.common.WrapMapper;
|
||||||
@ -32,44 +33,49 @@ public class SysUserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
@ApiOperation(value = "用户分页", notes = "用户分页")
|
@ApiOperation(value = "分页", notes = "分页")
|
||||||
@Log(modul = "用户管理-用户分页", type = Constants.SELECT, desc = "用户分页")
|
@Log(modul = "用户管理-分页", type = Constants.SELECT, desc = "分页")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public Wrapper<IPage<SysUser>> page(Page page, SysUser user) {
|
public Wrapper<IPage<SysUser>> page(Page page, SysUser user) {
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.page(page, user));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.page(page, user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "用户列表", notes = "用户列表")
|
@ApiOperation(value = "列表", notes = "列表")
|
||||||
@Log(modul = "用户管理-用户列表", type = Constants.SELECT, desc = "用户列表")
|
@Log(modul = "用户管理-列表", type = Constants.SELECT, desc = "列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
|
@SaCheckPermission("user:list")
|
||||||
public Wrapper<List<SysUser>> list(SysUser user) {
|
public Wrapper<List<SysUser>> list(SysUser user) {
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.list(user));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.list(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "添加用户信息", notes = "添加用户信息")
|
@ApiOperation(value = "添加", notes = "添加")
|
||||||
@Log(modul = "用户管理-添加用户信息", type = Constants.INSERT, desc = "添加用户信息")
|
@Log(modul = "用户管理-添加", type = Constants.INSERT, desc = "添加")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
|
@SaCheckPermission("user:save")
|
||||||
public Wrapper<Object> save(@RequestBody SysUser user) {
|
public Wrapper<Object> save(@RequestBody SysUser user) {
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.insert(user));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.insert(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改用户信息", notes = "修改用户信息")
|
@ApiOperation(value = "修改", notes = "修改")
|
||||||
@Log(modul = "用户管理-修改用户信息", type = Constants.UPDATE, desc = "修改用户信息")
|
@Log(modul = "用户管理-修改", type = Constants.UPDATE, desc = "修改")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
|
@SaCheckPermission("user:update")
|
||||||
public Wrapper<Object> update(@RequestBody SysUser user) {
|
public Wrapper<Object> update(@RequestBody SysUser user) {
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.update(user));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.update(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除用户", notes = "删除用户")
|
@ApiOperation(value = "删除", notes = "删除")
|
||||||
@Log(modul = "用户管理-删除用户", type = Constants.DELETE, desc = "删除用户")
|
@Log(modul = "用户管理-删除", type = Constants.DELETE, desc = "删除")
|
||||||
@GetMapping("/del")
|
@GetMapping("/delete/{id}")
|
||||||
public Wrapper<Object> del(SysUser user) {
|
@SaCheckPermission("user:delete")
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.del(user));
|
public Wrapper<Object> delete(@PathVariable String id) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.del(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改密码", notes = "修改密码")
|
@ApiOperation(value = "修改密码", notes = "修改密码")
|
||||||
@Log(modul = "用户管理-修改密码", type = Constants.UPDATE, desc = "修改密码")
|
@Log(modul = "用户管理-修改密码", type = Constants.UPDATE, desc = "修改密码")
|
||||||
@PostMapping("/modifyPass")
|
@PostMapping("/modifyPass")
|
||||||
|
@SaCheckPermission("user:password")
|
||||||
public Wrapper<Object> modifyPass(@RequestBody SysUser user) {
|
public Wrapper<Object> modifyPass(@RequestBody SysUser user) {
|
||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.modifyPass(user));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysUserService.modifyPass(user));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,14 +32,14 @@ import java.util.List;
|
|||||||
public class SysOrg {
|
public class SysOrg {
|
||||||
|
|
||||||
@ApiModelProperty(value = "主键id")
|
@ApiModelProperty(value = "主键id")
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
private Integer id;
|
private String id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "组织名称")
|
@ApiModelProperty(value = "组织名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty(value = "父id")
|
@ApiModelProperty(value = "父id")
|
||||||
private Integer parentId;
|
private String parentId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "组织编码")
|
@ApiModelProperty(value = "组织编码")
|
||||||
private String code;
|
private String code;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.tansci.domain;
|
package com.tansci.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
@ -12,6 +13,7 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysRole.java
|
* @ClassName: SysRole.java
|
||||||
@ -61,4 +63,12 @@ public class SysRole {
|
|||||||
@ApiModelProperty(value = "描述")
|
@ApiModelProperty(value = "描述")
|
||||||
private String remarks;
|
private String remarks;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "菜单权限")
|
||||||
|
private List<String> menuIds;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "数据权限")
|
||||||
|
private List<String> orgIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3,6 +3,8 @@ package com.tansci.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.tansci.domain.SysOrg;
|
import com.tansci.domain.SysOrg;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysOrgService.java
|
* @ClassName: SysOrgService.java
|
||||||
* @ClassPath: com.tansci.service.SysOrgService.java
|
* @ClassPath: com.tansci.service.SysOrgService.java
|
||||||
@ -11,4 +13,7 @@ import com.tansci.domain.SysOrg;
|
|||||||
* @Date: 2023/3/29 9:36
|
* @Date: 2023/3/29 9:36
|
||||||
**/
|
**/
|
||||||
public interface SysOrgService extends IService<SysOrg> {
|
public interface SysOrgService extends IService<SysOrg> {
|
||||||
|
|
||||||
|
List<SysOrg> list(SysOrg org);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.tansci.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.tansci.domain.SysRoleOrg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: SysRoleOrgService.java
|
||||||
|
* @ClassPath: com.tansci.service.SysRoleOrgService.java
|
||||||
|
* @Description: 组织权限
|
||||||
|
* @Author: tanyp
|
||||||
|
* @Date: 2023/4/11 13:36
|
||||||
|
**/
|
||||||
|
public interface SysRoleOrgService extends IService<SysRoleOrg> {
|
||||||
|
}
|
||||||
@ -1,8 +1,12 @@
|
|||||||
package com.tansci.service;
|
package com.tansci.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.tansci.domain.SysRole;
|
import com.tansci.domain.SysRole;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysRoleService.java
|
* @ClassName: SysRoleService.java
|
||||||
* @ClassPath: com.tansci.service.SysRoleService.java
|
* @ClassPath: com.tansci.service.SysRoleService.java
|
||||||
@ -11,4 +15,19 @@ import com.tansci.domain.SysRole;
|
|||||||
* @Date: 2023/3/29 9:37
|
* @Date: 2023/3/29 9:37
|
||||||
**/
|
**/
|
||||||
public interface SysRoleService extends IService<SysRole> {
|
public interface SysRoleService extends IService<SysRole> {
|
||||||
|
|
||||||
|
IPage<SysRole> page(Page page, SysRole role);
|
||||||
|
|
||||||
|
List<SysRole> list(SysRole role);
|
||||||
|
|
||||||
|
Object insert(SysRole role);
|
||||||
|
|
||||||
|
Object update(SysRole role);
|
||||||
|
|
||||||
|
Object delete(String id);
|
||||||
|
|
||||||
|
Object dataPermissions(SysRole role);
|
||||||
|
|
||||||
|
Object menuPermissions(SysRole role);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public interface SysUserService extends IService<SysUser> {
|
|||||||
|
|
||||||
Object update(SysUser user);
|
Object update(SysUser user);
|
||||||
|
|
||||||
Object del(SysUser user);
|
Object del(String id);
|
||||||
|
|
||||||
SysUserVo login(HttpServletRequest request, SysUser user);
|
SysUserVo login(HttpServletRequest request, SysUser user);
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,22 @@
|
|||||||
package com.tansci.service.impl;
|
package com.tansci.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.tansci.common.constant.Constants;
|
||||||
import com.tansci.domain.SysOrg;
|
import com.tansci.domain.SysOrg;
|
||||||
|
import com.tansci.domain.SysRoleOrg;
|
||||||
import com.tansci.mapper.SysOrgMapper;
|
import com.tansci.mapper.SysOrgMapper;
|
||||||
import com.tansci.service.SysOrgService;
|
import com.tansci.service.SysOrgService;
|
||||||
|
import com.tansci.service.SysRoleOrgService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysOrgServiceImpl.java
|
* @ClassName: SysOrgServiceImpl.java
|
||||||
* @ClassPath: com.tansci.service.impl.SysOrgServiceImpl.java
|
* @ClassPath: com.tansci.service.impl.SysOrgServiceImpl.java
|
||||||
@ -18,4 +28,32 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> implements SysOrgService {
|
public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> implements SysOrgService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleOrgService sysRoleOrgService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysOrg> list(SysOrg org) {
|
||||||
|
List<String> orgIds = Lists.newArrayList();
|
||||||
|
if (Objects.nonNull(StpUtil.getRoleList()) && StpUtil.getRoleList().size() > 0) {
|
||||||
|
List<SysRoleOrg> menus = sysRoleOrgService.list(Wrappers.<SysRoleOrg>lambdaQuery().eq(SysRoleOrg::getRoleId, StpUtil.getRoleList()));
|
||||||
|
orgIds.addAll(menus.stream().map(SysRoleOrg::getOrgId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SysOrg> list = this.baseMapper.selectList(
|
||||||
|
Wrappers.<SysOrg>lambdaQuery()
|
||||||
|
.eq(SysOrg::getIsDel, Constants.NOT_DEL_FALG)
|
||||||
|
.eq(Objects.nonNull(orgIds) && orgIds.size() > 0, SysOrg::getId, orgIds)
|
||||||
|
.eq(Objects.nonNull(org.getParentId()), SysOrg::getParentId, org.getParentId())
|
||||||
|
.eq(Objects.nonNull(org.getCode()), SysOrg::getCode, org.getCode())
|
||||||
|
.like(Objects.nonNull(org.getName()), SysOrg::getName, org.getName())
|
||||||
|
.orderByDesc(SysOrg::getUpdateTime)
|
||||||
|
);
|
||||||
|
list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SysOrg::getId))), ArrayList::new));
|
||||||
|
Map<String, List<SysOrg>> map = list.stream().collect(Collectors.groupingBy(SysOrg::getParentId, Collectors.toList()));
|
||||||
|
list.stream().forEach(item -> item.setChildren(map.get(item.getId())));
|
||||||
|
|
||||||
|
List<SysOrg> orgList = map.get("0").stream().sorted(Comparator.comparing(SysOrg::getSort)).collect(Collectors.toList());
|
||||||
|
return orgList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.tansci.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.tansci.domain.SysRoleOrg;
|
||||||
|
import com.tansci.mapper.SysRoleOrgMapper;
|
||||||
|
import com.tansci.service.SysRoleOrgService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: SysRoleOrgServiceImpl.java
|
||||||
|
* @ClassPath: com.tansci.service.impl.SysRoleOrgServiceImpl.java
|
||||||
|
* @Description: 组织权限
|
||||||
|
* @Author: tanyp
|
||||||
|
* @Date: 2023/4/11 13:36
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class SysRoleOrgServiceImpl extends ServiceImpl<SysRoleOrgMapper, SysRoleOrg> implements SysRoleOrgService {
|
||||||
|
}
|
||||||
@ -1,12 +1,28 @@
|
|||||||
package com.tansci.service.impl;
|
package com.tansci.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.tansci.common.constant.Constants;
|
||||||
import com.tansci.domain.SysRole;
|
import com.tansci.domain.SysRole;
|
||||||
|
import com.tansci.domain.SysRoleMenu;
|
||||||
|
import com.tansci.domain.SysRoleOrg;
|
||||||
import com.tansci.mapper.SysRoleMapper;
|
import com.tansci.mapper.SysRoleMapper;
|
||||||
|
import com.tansci.service.SysRoleMenuService;
|
||||||
|
import com.tansci.service.SysRoleOrgService;
|
||||||
import com.tansci.service.SysRoleService;
|
import com.tansci.service.SysRoleService;
|
||||||
|
import com.tansci.utils.UUIDUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysRoleServiceImpl.java
|
* @ClassName: SysRoleServiceImpl.java
|
||||||
* @ClassPath: com.tansci.service.impl.SysRoleServiceImpl.java
|
* @ClassPath: com.tansci.service.impl.SysRoleServiceImpl.java
|
||||||
@ -17,4 +33,78 @@ import org.springframework.stereotype.Service;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRoleMenuService sysRoleMenuService;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleOrgService sysRoleOrgService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<SysRole> page(Page page, SysRole role) {
|
||||||
|
return this.baseMapper.selectPage(page,
|
||||||
|
Wrappers.<SysRole>lambdaQuery().eq(SysRole::getIsDel, Constants.NOT_DEL_FALG)
|
||||||
|
.eq(Objects.nonNull(role.getCode()), SysRole::getCode, role.getCode())
|
||||||
|
.eq(Objects.nonNull(role.getCreator()), SysRole::getCreator, role.getCreator())
|
||||||
|
.like(Objects.nonNull(role.getName()), SysRole::getName, role.getName())
|
||||||
|
.orderByDesc(SysRole::getUpdateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysRole> list(SysRole role) {
|
||||||
|
return this.baseMapper.selectList(
|
||||||
|
Wrappers.<SysRole>lambdaQuery().eq(SysRole::getIsDel, Constants.NOT_DEL_FALG)
|
||||||
|
.eq(Objects.nonNull(role.getCode()), SysRole::getCode, role.getCode())
|
||||||
|
.eq(Objects.nonNull(role.getCreator()), SysRole::getCreator, role.getCreator())
|
||||||
|
.like(Objects.nonNull(role.getName()), SysRole::getName, role.getName())
|
||||||
|
.orderByDesc(SysRole::getUpdateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object insert(SysRole role) {
|
||||||
|
role.setCreator(String.valueOf(StpUtil.getLoginId()));
|
||||||
|
role.setCode(UUIDUtils.getUUID(10));
|
||||||
|
role.setIsDel(Constants.NOT_DEL_FALG);
|
||||||
|
role.setUpdateTime(LocalDateTime.now());
|
||||||
|
role.setCreateTime(LocalDateTime.now());
|
||||||
|
return this.baseMapper.insert(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object update(SysRole role) {
|
||||||
|
role.setUpdateTime(LocalDateTime.now());
|
||||||
|
return this.baseMapper.updateById(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object delete(String id) {
|
||||||
|
int row = this.baseMapper.deleteById(id);
|
||||||
|
if (row > 0) {
|
||||||
|
sysRoleMenuService.remove(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, id));
|
||||||
|
sysRoleOrgService.remove(Wrappers.<SysRoleOrg>lambdaQuery().eq(SysRoleOrg::getRoleId, id));
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object dataPermissions(SysRole role) {
|
||||||
|
sysRoleOrgService.remove(Wrappers.<SysRoleOrg>lambdaQuery().eq(SysRoleOrg::getRoleId, role.getId()));
|
||||||
|
List<SysRoleOrg> orgs = new ArrayList<>();
|
||||||
|
role.getOrgIds().forEach(item -> {
|
||||||
|
orgs.add(SysRoleOrg.builder().roleId(role.getId()).orgId(item).build());
|
||||||
|
});
|
||||||
|
return sysRoleOrgService.saveBatch(orgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object menuPermissions(SysRole role) {
|
||||||
|
sysRoleMenuService.remove(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, role.getId()));
|
||||||
|
List<SysRoleMenu> menus = new ArrayList<>();
|
||||||
|
role.getOrgIds().forEach(item -> {
|
||||||
|
menus.add(SysRoleMenu.builder().roleId(role.getId()).menuId(item).build());
|
||||||
|
});
|
||||||
|
return sysRoleMenuService.saveBatch(menus);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,11 +93,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object del(SysUser user) {
|
public Object del(String id) {
|
||||||
user.setIsDel(Constants.IS_DEL_FALG);
|
int rows = this.baseMapper.deleteById(id);
|
||||||
int rows = this.baseMapper.updateById(user);
|
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
sysUserRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, user.getId()));
|
sysUserRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, id));
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user