验证,组件优化,样式优化等

This commit is contained in:
吕金泽 2022-03-19 23:20:06 +08:00
parent 284823a671
commit d007875a43
24 changed files with 383 additions and 606 deletions

View File

@ -5,7 +5,7 @@
"groupId" : "4f0230049d7e4f39b1e0897cc0f46f9a",
"name" : "删除",
"createTime" : null,
"updateTime" : 1646553121622,
"updateTime" : 1647618260057,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@ -48,6 +48,10 @@
================================
import org.ssssssss.magicapi.modules.db.cache.SqlCache
if(Arrays.asList(id.split(',')).contains('1')){
exit 500, '不允许删除超级管理员'
}
for(userId in id.split(',')){
SqlCache.delete(`permissions:${userId}`)
db.table("sys_user").logic().where().eq("id",userId).delete();

View File

@ -4,8 +4,8 @@
"script" : null,
"groupId" : "8295fc13678d4144bf7363c465247a50",
"name" : "保存",
"createTime" : 1646490239492,
"updateTime" : 1644121675551,
"createTime" : null,
"updateTime" : 1647615397163,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@ -42,7 +42,19 @@
"paths" : [ ],
"responseBody" : null,
"description" : null,
"requestBodyDefinition" : null,
"requestBodyDefinition" : {
"name" : "",
"value" : "",
"description" : "",
"required" : false,
"dataType" : "Object",
"type" : null,
"defaultValue" : null,
"validateType" : "",
"error" : "",
"expression" : "",
"children" : [ ]
},
"responseBodyDefinition" : null
}
================================

View File

@ -5,7 +5,7 @@
"groupId" : "8295fc13678d4144bf7363c465247a50",
"name" : "删除",
"createTime" : null,
"updateTime" : 1646553126039,
"updateTime" : 1647615807925,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@ -118,5 +118,17 @@
}
}
================================
var pCount = db.selectInt("select count(1) from sys_office where is_del = 0 and pid = #{id}")
if(pCount > 0){
exit 500,'存在下级机构,不允许删除'
}
var userCount = db.selectInt("select count(1) from sys_user where is_del = 0 and office_id = #{id}")
if(userCount > 0){
exit 500, '机构存在用户,不允许删除'
}
var root = db.selectValue("select pid from sys_office where is_del = 0 and id = #{id}")
if(root == '0'){
exit 500, '不能删除根节点'
}
// db.table('sys_user_office').where().eq("office_id",id).delete();
return db.table("sys_office").logic().where().eq("id",id).delete();

View File

@ -5,7 +5,7 @@
"groupId" : "89130d496f6f467c88b22ae4a7f688eb",
"name" : "删除",
"createTime" : null,
"updateTime" : 1646553106085,
"updateTime" : 1647615829916,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@ -47,6 +47,12 @@
}
================================
import '@get:/role/cache/delete' as cacheDelete
var userCount = db.selectInt("select count(1) from sys_user_role where role_id = #{id}")
if(userCount > 0){
exit 500, '角色已分配,不允许删除'
}
var roleId = id
cacheDelete()

View File

@ -28,6 +28,7 @@ body{
--mb-main-icon-color: #909399;
--mb-header-height: 60px;
--mb-avatar-text-size: 18px;
/*--mb-menu-item-height: 50px;*/
}
.el-header{
--el-header-height: var(--mb-header-height);
@ -40,6 +41,9 @@ body{
.el-dialog__body{
padding: 5px 20px;
}
/*.el-sub-menu__title, .el-menu-item{*/
/* height: var(--mb-menu-item-height) !important;*/
/*}*/
.app-container hr {
border: none;
height: 1px;

View File

@ -69,8 +69,7 @@
var data = {}
props.form.rows.forEach(row => {
row.cols.forEach(col => {
// data[col.name] = col.defaultValue === null ? col.defaultValue : col.defaultValue || ''
data[col.name] = undefined
data[col.name] = col.defaultValue || undefined
})
})
return data

View File

@ -92,9 +92,17 @@ function reset() {
for(var key in props.where){
if(props.notReset.indexOf(key) == -1){
if(props.where[key] instanceof Object){
props.where[key].value = null
if(props.where[key].value instanceof Array){
props.where[key].value = []
}else{
props.where[key].value = null
}
}else{
props.where[key] = null
if(props.where[key] instanceof Array){
props.where[key] = []
}else{
props.where[key] = null
}
}
}
}

View File

@ -15,13 +15,15 @@
{{ $common.getDictLabel(col.dictType, scope.row[col.field] + '') }}
</span>
<slot v-else-if="col.type == 'dynamic'" :name="col.field" :row="scope.row" :index="scope.$index" />
<el-switch
v-else-if="col.type == 'switch'"
v-model="scope.row[col.field]"
:active-value="col.activeValue || 1"
:inactive-value="col.inactiveValue || 0"
@change="col.change(scope.row)"
/>
<div v-else-if="col.type == 'switch'">
<el-switch
v-if="col.if === undefined ? true : col.if(scope.row)"
v-model="scope.row[col.field]"
:active-value="col.activeValue || 1"
:inactive-value="col.inactiveValue || 0"
@change="col.change(scope.row)"
/>
</div>
<div v-else-if="col.type == 'btns'">
<template v-for="btn in col.btns">
<el-button v-if="btn.if === undefined ? true : btn.if(scope.row)" :icon="btn.icon" :key="btn.label" v-permission="btn.permission" :type="btn.type" :size="btn.size || 'small'" :class="btn.class" @click="btn.click(scope.row, scope.$index)">

View File

@ -118,18 +118,22 @@ function getList() {
} else {
newWhere.size = 99999999
}
request({
url: props.url,
method: props.method,
params: newWhere,
data: newWhere
}).then(res => {
var then = (res) => {
const { data } = res
total.value = data.total
list.value = data.list
listLoading.value = false
props.done()
})
}
if(props.method.toLowerCase() == 'post'){
proxy.$post(props.url, newWhere).then(res => {
then(res)
})
}else{
proxy.$get(props.url, newWhere).then(res => {
then(res)
})
}
}
function sortChange(column) {

View File

@ -1,6 +1,6 @@
<template>
<el-checkbox-group
v-model="modelValue"
v-model="selectValue"
:size="size"
:disabled="disabled"
:min="min"
@ -9,25 +9,24 @@
:fill="fill"
@change="change"
>
<el-checkbox-button v-if="button" v-for="it in options" v-bind="it" :label="it[valueField]">
<el-checkbox-button v-if="button" v-for="it in checkboxOptions" v-bind="it" :label="it[valueField]">
{{ it[labelField] }}
</el-checkbox-button>
<el-checkbox v-if="!button" v-for="it in options" v-bind="it" :label="it[valueField]">
<el-checkbox v-if="!button" v-for="it in checkboxOptions" v-bind="it" :label="it[valueField]">
{{ it[labelField] }}
</el-checkbox>
</el-checkbox-group>
</template>
<script setup>
import {watch, ref, getCurrentInstance} from "vue";
import {watch, ref, getCurrentInstance, onMounted} from "vue";
import request from '@/scripts/request'
const emit = defineEmits(['update:modelValue', 'change'])
const { proxy } = getCurrentInstance()
const props = defineProps({
modelValue: {
type: Array,
default: () => []
required: true
},
type: String,
button: {
@ -36,7 +35,7 @@ import {watch, ref, getCurrentInstance} from "vue";
},
options: Array,
url: String,
params: Object,
data: Object,
method: {
type: String,
default: 'get'
@ -63,31 +62,72 @@ import {watch, ref, getCurrentInstance} from "vue";
fill: {
type: String,
default: '#409EFF'
},
join: {
type: Boolean,
default: true
}
})
const options = ref([])
const selectValue = ref([])
const checkboxOptions = ref([])
if(props.type){
options.value = proxy.$common.getDictType(props.type)
}else if(props.url){
request({
url: props.url,
method: props.method,
params: props.params,
data: props.params
}).then(res => {
options.value = res.data.list || res.data
})
}else if(props.options){
options.value = props.options
watch(() => [props.type, props.url, props.options], () => {
loadData()
}, { deep: true })
watch(() => props.modelValue, (value) => {
setValue(value)
})
watch(selectValue, (value) => {
if(props.join){
emit('update:modelValue', value.join(','))
emit('change', value.join(','))
}else{
emit('update:modelValue', value)
emit('change', value)
}
})
onMounted(() => {
loadData()
})
function setValue(value){
if(value){
if(props.join){
selectValue.value = value.split(',')
}else{
selectValue.value = value
}
}
}
function loadData(){
if(props.type){
checkboxOptions.value = proxy.$common.getDictType(props.type)
setValue(props.modelValue)
}else if(props.url){
if(props.method.toLowerCase() == 'post'){
proxy.$post(props.url, props.data).then(res => {
checkboxOptions.value = res.data.list || res.data
setValue(props.modelValue)
})
}else{
proxy.$get(props.url, props.data).then(res => {
checkboxOptions.value = res.data.list || res.data
setValue(props.modelValue)
})
}
}else if(props.options){
checkboxOptions.value = props.options
setValue(props.modelValue)
}
}
function change(value){
emit('change', value)
}
watch(() => props.modelValue, (value) => {
emit('update:modelValue', value)
})
</script>

View File

@ -31,7 +31,7 @@
},
options: Array,
url: String,
params: Object,
data: Object,
method: {
type: String,
default: 'get'
@ -64,14 +64,18 @@
if(props.type){
options.value = proxy.$common.getDictType(props.type)
}else if(props.url){
request({
url: props.url,
method: props.method,
params: props.params,
data: props.params
}).then(res => {
var then = (res) => {
options.value = res.data.list || res.data
})
}
if(props.method.toLowerCase() == 'post'){
proxy.$post(props.url, props.data).then(res => {
then(res)
})
}else{
proxy.$get(props.url, props.data).then(res => {
then(res)
})
}
}else if(props.options){
options.value = props.options
}

View File

@ -1,5 +1,5 @@
<template>
<el-select v-if="mbType === 'select'" v-model="selectValue" v-bind="el" :style="{ width }" :placeholder="placeholder || '请选择'" filterable clearable>
<el-select v-model="selectValue" v-bind="props.props" :multiple="multiple" :style="{ width }" :placeholder="placeholder || (itemLabel && '请输入' + itemLabel)" filterable clearable>
<el-option
v-for="item in selectList"
:key="item.value"
@ -7,11 +7,6 @@
:value="item.value"
/>
</el-select>
<el-radio-group v-if="mbType === 'radio'" v-model="selectValue">
<el-radio v-for="item in selectList" :key="item.value" :label="item.value">
{{ item.label }}
</el-radio>
</el-radio-group>
</template>
<script setup>
@ -23,25 +18,16 @@ const { proxy } = getCurrentInstance()
const emit = defineEmits(['update:modelValue', 'change'])
const props = defineProps({
data: {
type: Array,
default: () => []
modelValue: {
required: true
},
type: {
type: String,
default: ''
},
// eslint-disable-next-line vue/require-prop-types
modelValue: {
required: true
},
width: {
type: String,
default: '100%'
},
allOption: {
type: Boolean,
default: false
options: {
type: Array,
default: () => []
},
url: {
type: String,
@ -59,72 +45,77 @@ const props = defineProps({
type: String,
default: 'value'
},
mbType: {
type: String,
default: 'select'
},
el: {
props: {
type: Object,
default: () => {}
},
width: {
type: String,
default: '100%'
},
allOption: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ''
},
itemLabel: String,
multiple: {
type: Boolean,
default: false
},
join: {
type: Boolean,
default: true
}
})
const selectList = ref([])
const selectValue = ref('')
const selectValue = ref(props.multiple ? [] : '')
watch(() => props.type, () => {
if (props.modelValue instanceof Array || props.modelValue.toString().indexOf(',') !== -1) {
selectValue.value = []
} else {
selectValue.value = ''
}
watch(() => [props.type, props.url, props.options], () => {
loadData()
})
}, { deep: true })
watch(() => props.modelValue, () => {
loadData()
watch(() => props.modelValue, (value) => {
setValue(value)
})
watch(selectValue, (value) => {
if (props.el && props.el.multiple && value.length > 0) {
value = value.join(',')
if(props.multiple && props.join){
emit('update:modelValue', value.join(','))
emit('change', value.join(','))
}else{
emit('update:modelValue', value)
emit('change', value)
}
emit('update:modelValue', value)
emit('change', value)
})
onMounted(() => {
loadData()
})
async function loadData() {
if (props.modelValue || props.modelValue == '') {
if ((!(props.modelValue instanceof Array) && props.modelValue.toString().indexOf(',') !== -1)) {
selectValue.value = props.modelValue.split(',')
} else {
if (props.el && props.el.multiple && !(props.modelValue instanceof Array)) {
selectValue.value = [props.modelValue]
} else {
selectValue.value = props.modelValue
}
}
} else {
if (props.el && props.el.multiple) {
selectValue.value = []
function setValue(value){
if(value){
if(props.multiple && props.join){
selectValue.value = value.split(',')
}else{
selectValue.value = value
}
}
if (props.data && props.data.length > 0) {
listConcat(handlerData(props.data))
} else if (props.url) {
}
function loadData() {
if(props.type){
listConcat(proxy.$common.getDictType(props.type))
}else if(props.url){
proxy.$get(props.url, props.params).then(res => {
listConcat(handlerData(res.data.list || res.data))
})
} else {
listConcat(proxy.$common.getDictType(props.type))
}else if(props.options && props.options.length > 0){
listConcat(handlerData(props.options))
}
}
@ -138,6 +129,7 @@ function listConcat(dictData) {
} else {
selectList.value = dictData
}
setValue(props.modelValue)
}
function handlerData(data) {

View File

@ -171,4 +171,8 @@ common.setDefaultValue = (obj, attr, value) => {
obj[attr] = obj[attr] === undefined ? value : obj[attr]
}
common.isComma = (value) => {
return value.toString().indexOf(',') !== -1
}
export default common

View File

@ -1,138 +0,0 @@
<template>
<el-form
ref="dataForm"
:rules="rules"
:model="temp"
v-bind="form.el"
:label-position="form.el.labelPosition === undefined ? 'right' : form.el.labelPosition"
:label-width="form.el.labelWidth === undefined ? '120px' : form.el.labelWidth"
:style="form.el.style === undefined ? '' : form.el.style"
>
<el-row v-for="(row,i) in form.rows" :key="i" :gutter="row.gutter">
<el-col v-for="(col,j) in row.cols" :key="j" :span="col.span" v-bind="col.colEl">
<el-form-item :label="col.label" :label-width="col.labelWidth" :prop="col.name" v-bind="col.formItemEl">
<el-switch
v-if="col.type === 'switch'"
v-model="temp[col.name]"
:active-value="col.activeValue"
:inactive-value="col.inactiveValue"
/>
<el-checkbox-group v-else-if="col.type === 'checkboxGroup'" v-model="temp[col.name]" size="small">
<el-checkbox v-for="checkboxIt in temp['_'+col.name]" :key="checkboxIt[col.defaultValue.value]" :label="checkboxIt[col.defaultValue.value]">{{ checkboxIt[col.defaultValue.text] }}</el-checkbox>
</el-checkbox-group>
<mb-select v-else-if="col.type === 'select'" v-model="temp[col.name]" v-bind="col.el" />
<el-input v-else v-model="temp[col.name]" :type="col.type" :value="col.defaultValue" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'CommonForm',
props: {
visible: {
type: Boolean,
default: false
},
form: {
type: Object,
default: () => {}
},
detail: {
type: Object,
default: () => {}
},
params: {
type: Object,
default: () => {}
}
},
data() {
return {
rules: {
},
temp: this.getTemp()
}
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
watch: {
visible(newVal) {
this.temp = this.getTemp()
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
}
},
created() {
this.form.el = this.form.el || {}
this.form.rows.forEach(row => {
row.cols.forEach(col => {
if (col.rule) {
this.$set(this.rules, col.name, col.rule)
}
})
})
},
methods: {
getTemp() {
var _temp = {}
this.form.rows.forEach(row => {
row.cols.forEach(col => {
if (col.type === 'checkboxGroup') {
_temp[col.name] = []
this.$request({
url: col.defaultValue.request.url,
method: col.defaultValue.request.method
}).then(res => {
const { data } = res
this.$set(this.temp, '_' + col.name, data)
})
} else {
_temp[col.name] = col.defaultValue || ''
}
})
})
return _temp
},
save() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$post(this.form.request.url, this.temp).then(res => {
this.dialogVisible = false
this.$notify({
title: '成功',
message: (!this.temp.id ? '创建' : '修改') + '成功',
type: 'success',
duration: 2000
})
this.$emit('reload-table')
})
}
})
},
getDetail(row) {
this.temp.id = row.id
this.$get(this.detail.request.url, { id: row.id }).then(res => {
const { data } = res
for (var t in this.temp) {
if (data[t] && (!this.detail.excludeAssign || this.detail.excludeAssign.indexOf(t) === -1)) {
this.$set(this.temp, t, data[t])
}
}
})
}
}
}
</script>

View File

@ -1,197 +0,0 @@
<template>
<div class="app-container">
<div class="filter-container">
<el-form :inline="true">
<el-form-item v-for="col in queryOptions.cols" :key="col.field" :label="col.title">
<el-input v-if="col.type === 'input'" v-model="tableOptions.where[col.field]" v-bind="col.el" :placeholder="'请输入'+col.title" :style="col.style" />
<mb-select v-else-if="col.type === 'select'" v-model="tableOptions.where[col.field]" v-bind="col.el" width="100%" />
</el-form-item>
<el-form-item v-for="(btn, i) in queryOptions.btns" :key="i">
<el-button v-if="btn.type == 'query'" class="filter-item" type="primary" icon="el-icon-search" @click="reloadTable">
搜索
</el-button>
<el-button v-if="btn.type == 'export'" :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
导出
</el-button>
</el-form-item>
</el-form>
</div>
<template v-if="toolOptions && toolOptions.btns">
<hr>
<el-row class="tool-row">
<div v-for="(btn, i) in toolOptions.btns" :key="'toolBtn' + i">
<el-button v-if="btn.btnType == 'add'" class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">
添加
</el-button>
<mb-button
v-else
:el="btn.el || {}"
:request-url="btn.request.url"
:request-data="toolBtnData[i]"
:btn-type="btn.btnType"
:before-confirm="btn.beforeConfirm"
:is-open="btn.isOpen"
:success-tips="btn.successTips"
:fail-tips="btn.failTips"
:after-handler="btn.afterHandler"
/>
</div>
</el-row>
<hr>
</template>
<mb-table ref="table" v-bind="tableOptions" @selection-change="selectionChange" />
<mb-dialog :params="formParams" v-bind="formConfig && formConfig.dialog" :visible.sync="dialogFormVisible" @confirm-click="$refs.inputForm.save()">
<template #content>
<common-form ref="inputForm" v-bind="formConfig" :visible.sync="dialogFormVisible" :dialog-status="dialogStatus" @reload-table="reloadTable" />
</template>
</mb-dialog>
</div>
</template>
<script>
import CommonForm from './form'
var _this
export default {
name: 'CommonList',
components: { CommonForm },
props: {
formConfig: {
type: Object,
default: () => {}
},
queryOptions: {
type: Object,
default: () => {}
},
toolOptions: {
type: Object,
default: () => {}
},
tableOptions: {
type: Object,
default: () => {}
}
},
data() {
return {
formParams: {},
formComponent: '',
dialogFormVisible: false,
dialogStatus: 'create',
downloadLoading: false,
selectionData: [],
toolBtnData: []
}
},
created() {
_this = this
if (this.toolOptions && this.toolOptions.btns) {
this.toolOptions.btns.forEach((it, i) => {
if (it.btnType) {
if (it.btnType === 'delete') {
it.afterHandler = () => {
_this.reloadTable()
}
}
}
})
}
this.tableOptions.where = this.tableOptions.where || _this.$set(this.tableOptions, 'where', {})
this.queryOptions.cols.forEach(it => this.$set(_this.tableOptions.where, it.field, ''))
this.tableOptions.cols.forEach(it => {
if (it.type === 'switch') {
it.change = (row) => {
this.$request(this.handlerRequest(it, row, {
id: row.id,
[it.field]: row[it.field]
}))
}
}
if (it.type === 'btns') {
it.btns.forEach(btn => {
btn.click = (row) => {
if (btn.btnType === 'delete') {
this.$common.handleDelete({
url: btn.request.url,
id: row.id,
done: () => this.reloadTable()
})
} else if (btn.btnType === 'update') {
this.handleUpdate(row)
}
}
})
}
})
},
methods: {
selectionChange(columns) {
if (this.toolOptions && this.toolOptions.btns) {
this.toolOptions.btns.forEach((it, i) => { it && it.request && it.request.data && this.$set(this.toolBtnData, i, ({ ...it.request.data })) })
this.toolBtnData.forEach((it, i) => Object.keys(it).filter(key => it[key] === 'rowField').forEach(key => { this.$set(this.toolBtnData[i], key, columns.map(it => it[key]).join(',')) }))
}
},
handlerRequest(it, row, defaultData) {
var requestOptions = {}
requestOptions.url = it.request.url
requestOptions.method = it.request.method || 'get'
var requestData = {}
if (!it.request.data && defaultData) {
requestData = defaultData
} else {
requestData = it.request.data
for (var d in it.request.data) {
var value = requestData[d]
if (value === 'rowField') {
requestData[d] = row[d]
}
}
}
if (requestOptions.method === 'get') {
requestOptions.params = requestData
} else {
requestOptions.data = requestData
}
return requestOptions
},
reloadTable() {
this.$refs.table.reloadList()
},
handleCreate() {
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
handleUpdate(row) {
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['inputForm'].getDetail(row)
})
},
handleDownload() {
this.$common.exportExcel({
url: this.tableOptions.url,
headers: this.queryOptions.btns.filter(it => it.type === 'export')[0].headers,
columns: this.queryOptions.btns.filter(it => it.type === 'export')[0].columns,
where: this.tableOptions.where
})
}
}
}
</script>
<style scoped>
.tool-row {
margin-bottom: 6px
}
.tool-row > div {
display: inline-block;
margin-left: 10px;
}
</style>

View File

@ -2,7 +2,7 @@
<div style="padding: 50px;">
<h2>多选</h2>
<el-button type="primary" @click="getData" style="margin-bottom: 10px">获取数据</el-button>
<mb-select v-model="dictType" type="dict_type" :el="{ multiple: true }" />
<mb-select v-model="dictType" type="dict_type" multiple />
</div>
</template>

View File

@ -18,7 +18,8 @@ const formOptions = reactive({
cols: [{
span: 12,
name: 'input',
label: 'input'
label: 'input',
rules: [{ required: true, message: '请输入input', trigger: 'change' }]
},{
span: 12,
name: 'switch',
@ -114,7 +115,7 @@ const formOptions = reactive({
props: {
url: 'role/all',
placeholder: '请选择角色',
el: { multiple: true }
multiple: true
}
},{
span: 12,
@ -127,6 +128,6 @@ const formOptions = reactive({
}
})
function getFormData(){
console.log(magicForm.value.getFormData())
console.log(magicForm.value.getFormData().select)
}
</script>

View File

@ -47,148 +47,147 @@ let menuTree = ref([])
const menuData = ref([])
let searchValue = ref('')
const tableOptions = reactive({
el: {
'default-expand-all': true,
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
'row-key': 'id'
},
showNo: false,
page: false,
cols: [
{
field: 'name',
label: '菜单名称',
align: 'left',
type: 'html'
},
{
field: 'url',
label: '路径',
align: 'left',
type: 'html'
},
{
field: 'permission',
label: '权限标识',
width: 150,
align: 'left',
type: 'html'
},
{
field: 'icon',
label: '图标',
width: 55,
align: 'center',
templet: (row) => {
return generateIconCode(row.icon)
}
},
{
field: 'sort',
label: '序号',
width: 60
},
{
label: '排序',
type: 'btns',
width: 150,
btns: [
{
label: '上移',
type: 'text',
icon: 'ElSortUp',
click: (row) => {
proxy.$get('menu/sort/up',{
id: row.id,
pid: row.pid,
sort: row.sort
}).then(() => {
reloadTable()
})
}
},
{
label: '下移',
type: 'text',
icon: 'ElSortDown',
click: (row) => {
proxy.$get('menu/sort/down',{
id: row.id,
pid: row.pid,
sort: row.sort
}).then(() => {
reloadTable()
})
}
}
]
},
{
field: 'isShow',
label: '是否显示',
type: 'switch',
width: 100,
change: (row) => {
proxy.$get('menu/change', {
id: row.id,
isShow: row.isShow
})
}
},
{
field: 'keepAlive',
label: '是否缓存',
type: 'switch',
width: 100,
change: (row) => {
proxy.$get('menu/change', {
id: row.id,
keepAlive: row.keepAlive
})
}
},
{
label: '操作',
type: 'btns',
width: 260,
fixed: 'right',
align: 'left',
btns: [
{
label: '添加下级菜单',
type: 'text',
permission: 'menu:save',
icon: 'ElPlus',
click: (row) => {
addSubMenu(row.id)
}
},
{
label: '修改',
type: 'text',
permission: 'menu:save',
icon: 'ElEdit',
click: (row) => {
handleUpdate(row)
}
},
{
label: '删除',
type: 'text',
permission: 'menu:delete',
icon: 'ElDelete',
click: (row) => {
proxy.$common.handleDelete({
url: 'menu/delete',
id: row.id,
done: () => reloadTable()
})
}
}
]
el: {
'tree-props': { children: 'children', hasChildren: 'hasChildren' },
'row-key': 'id'
},
showNo: false,
page: false,
cols: [
{
field: 'name',
label: '菜单名称',
align: 'left',
type: 'html'
},
{
field: 'url',
label: '路径',
align: 'left',
type: 'html'
},
{
field: 'permission',
label: '权限标识',
width: 150,
align: 'left',
type: 'html'
},
{
field: 'icon',
label: '图标',
width: 55,
align: 'center',
templet: (row) => {
return generateIconCode(row.icon)
}
},
{
field: 'sort',
label: '序号',
width: 60
},
{
label: '排序',
type: 'btns',
width: 150,
btns: [
{
label: '上移',
type: 'text',
icon: 'ElSortUp',
click: (row) => {
proxy.$get('menu/sort/up',{
id: row.id,
pid: row.pid,
sort: row.sort
}).then(() => {
reloadTable()
})
}
]
})
},
{
label: '下移',
type: 'text',
icon: 'ElSortDown',
click: (row) => {
proxy.$get('menu/sort/down',{
id: row.id,
pid: row.pid,
sort: row.sort
}).then(() => {
reloadTable()
})
}
}
]
},
{
field: 'isShow',
label: '是否显示',
type: 'switch',
width: 100,
change: (row) => {
proxy.$get('menu/change', {
id: row.id,
isShow: row.isShow
})
}
},
{
field: 'keepAlive',
label: '是否缓存',
type: 'switch',
width: 100,
change: (row) => {
proxy.$get('menu/change', {
id: row.id,
keepAlive: row.keepAlive
})
}
},
{
label: '操作',
type: 'btns',
width: 260,
fixed: 'right',
align: 'left',
btns: [
{
label: '添加下级菜单',
type: 'text',
permission: 'menu:save',
icon: 'ElPlus',
click: (row) => {
addSubMenu(row.id)
}
},
{
label: '修改',
type: 'text',
permission: 'menu:save',
icon: 'ElEdit',
click: (row) => {
handleUpdate(row)
}
},
{
label: '删除',
type: 'text',
permission: 'menu:delete',
icon: 'ElDelete',
click: (row) => {
proxy.$common.handleDelete({
url: 'menu/delete',
id: row.id,
done: () => reloadTable()
})
}
}
]
}
]
})
let dialogTitle = ref('')
let searchTimeout = reactive()
const menuFormDialog = ref()

View File

@ -29,13 +29,19 @@
{
field: 'type',
label: '登录状态',
width: '100px',
templet: (row) => {
return row.type == '成功' ? '<b style="color: #409EFF">成功</b>' : '<b style="color: red">失败</b>'
}
},
{
field: 'address',
label: '登录地址'
},
{
field: 'ip',
label: 'ip'
label: 'ip',
width: '150px'
},
{
field: 'browser',
@ -50,7 +56,8 @@
},
{
field: 'createDate',
label: '操作时间'
label: '操作时间',
width: '180px'
}
]
})

View File

@ -28,15 +28,18 @@
},
{
field: 'apiMethod',
label: '方法'
label: '方法',
width: '100px'
},
{
field: 'userIp',
label: 'ip'
label: 'ip',
width: '150px'
},
{
field: 'costTime',
label: '耗时'
label: '耗时',
width: '100px'
},
{
field: 'userAgent',
@ -47,11 +50,13 @@
},
{
field: 'username',
label: '操作人'
label: '操作人',
width: '150px'
},
{
field: 'createDate',
label: '操作时间'
label: '操作时间',
width: '180px'
}
]
})

View File

@ -182,6 +182,9 @@ const tableOptions = reactive({
type: 'text',
permission: 'office:delete',
icon: 'ElDelete',
if: (row) => {
return row.pid != '0';
},
click: (row) => {
proxy.$common.handleDelete({
url: 'office/delete',

View File

@ -46,7 +46,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="数据权限" prop="permission">
<mb-select v-model="temp.permission" :data="permissionData" />
<mb-select v-model="temp.permission" :options="permissionData" />
<mb-tree v-if="temp.permission == 1" max-height="270px" :el="{ 'check-strictly': true, 'show-checkbox': true }" ref="office" url="office/tree" v-model:select-values="temp.offices" />
</el-form-item>
</el-col>
@ -55,7 +55,7 @@
</template>
</mb-dialog>
<mb-dialog ref="assignPermissionsDialog" title="分配权限" width="750px" @confirm-click="assignPermissions.save($event)">
<mb-dialog ref="assignPermissionsDialog" title="分配权限" width="550px" @confirm-click="assignPermissions.save($event)">
<template #content>
<role-assign-permissions ref="assignPermissions" :key="Math.random()" :id="temp.id" @close="() => { assignPermissionsDialog.value.hide(); temp.id = '' }" />
</template>

View File

@ -32,11 +32,11 @@
</el-col>
<el-col :span="12">
<el-form-item label="选择角色" prop="roles">
<mb-select v-model="temp.roles" url="role/all" placeholder="请选择角色" :el="{ multiple: true }" />
<mb-select v-model="temp.roles" url="role/all" placeholder="请选择角色" multiple />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="登录状态" prop="isLogin">
<el-form-item label="登录状态" prop="isLogin" v-if="temp.id != '1'">
<el-radio-group v-model="temp.isLogin">
<el-radio-button label="0">有效</el-radio-button>
<el-radio-button label="1">锁定</el-radio-button>

View File

@ -84,7 +84,7 @@ const tableOptions = reactive({
value: '',
properties: {
url: 'role/all',
el: { multiple: true }
multiple: true
}
},
officeId: ''
@ -118,6 +118,9 @@ const tableOptions = reactive({
label: '禁止登录',
type: 'switch',
width: 100,
if: (row) => {
return row.id != '1'
},
change: (row) => {
proxy.$get('/user/change/login/status', {
id: row.id,
@ -150,6 +153,9 @@ const tableOptions = reactive({
label: '删除',
type: 'text',
icon: 'ElDelete',
if: (row) => {
return row.id != '1'
},
click: (row) => {
proxy.$common.handleDelete({
url: 'user/delete',