mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 23:40:24 +08:00
refactor: code review
This commit is contained in:
@@ -10,11 +10,13 @@
|
||||
<el-card>
|
||||
<div class="query" ref="queryRef">
|
||||
<div>
|
||||
<div v-if="props.query.length > 0" class="query-head">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<el-form :model="props.queryForm" label-width="auto" style="display: flex;">
|
||||
<el-form-item :label="item.label" style="margin-right: 20px; margin-bottom: 0px;"
|
||||
v-for="item in props.query?.slice(0, defaultQueryCount)" :key="item.prop">
|
||||
<div v-if="props.query.length > 0">
|
||||
<el-form :model="props.queryForm" label-width="auto">
|
||||
<el-row v-for="i in Math.ceil((props.query.length + 1) / (defaultQueryCount + 1))" :key="i"
|
||||
v-show="i == 1 || isOpenMoreQuery" :class="i > 1 && isOpenMoreQuery ? 'is-open' : ''">
|
||||
|
||||
<el-form-item :label="item.label" style="margin-right: 12px; margin-bottom: 0px;"
|
||||
v-for="item in getRowQueryItem(i)" :key="item.prop">
|
||||
<!-- 这里只获取指定个数的筛选条件 -->
|
||||
<el-input v-model="queryForm[item.prop]" :placeholder="'输入' + item.label + '关键字'"
|
||||
clearable v-if="item.type == 'text'"></el-input>
|
||||
@@ -26,40 +28,22 @@
|
||||
format="YYYY-MM-DD hh:mm:ss" value-format="x" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间" v-else-if="item.type == 'date'" />
|
||||
|
||||
<template v-else-if="item.slot == 'queryBtns'">
|
||||
<template v-if="props.query?.length > defaultQueryCount">
|
||||
<el-button @click="isOpenMoreQuery = !isOpenMoreQuery" v-if="!isOpenMoreQuery"
|
||||
icon="ArrowDownBold" circle></el-button>
|
||||
<el-button @click="isOpenMoreQuery = !isOpenMoreQuery" v-else icon="ArrowUpBold"
|
||||
circle></el-button>
|
||||
</template>
|
||||
|
||||
<el-button @click="queryData()" type="primary" icon="search" plain>查询</el-button>
|
||||
<el-button @click="reset()" icon="RefreshRight">重置</el-button>
|
||||
</template>
|
||||
|
||||
<slot :name="item.slot"></slot>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template v-if="props.query?.length > defaultQueryCount">
|
||||
<el-button @click="isOpenMoreQuery = !isOpenMoreQuery" v-if="!isOpenMoreQuery"
|
||||
icon="ArrowDownBold" circle></el-button>
|
||||
<el-button @click="isOpenMoreQuery = !isOpenMoreQuery" v-else icon="ArrowUpBold"
|
||||
circle></el-button>
|
||||
</template>
|
||||
|
||||
<el-button @click="queryData()" type="primary" plain>查询</el-button>
|
||||
<el-button @click="reset()">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 这里做的是一个类似于折叠面板的功能 -->
|
||||
<div class="query-content" :class="isOpenMoreQuery ? 'is-open' : ''">
|
||||
<el-form :model="props.queryForm" label-width="auto" style="display: flex; flex-wrap: wrap;">
|
||||
<el-form-item :label="item.label" style="margin-right: 20px; margin-bottom: 0px;"
|
||||
v-for="item in props.query?.slice(defaultQueryCount)" :key="item.prop">
|
||||
|
||||
<!-- 这里获取除前两个以外所有的筛选条件 -->
|
||||
<el-input v-model="queryForm[item.prop]" :placeholder="'输入' + item.label + '关键字'" clearable
|
||||
v-if="item.type == 'text'"></el-input>
|
||||
|
||||
<el-select-v2 v-model="queryForm[item.prop]" :options="item.options" clearable
|
||||
:placeholder="'选择' + item.label + '关键字'" v-else-if="item.type == 'select'" />
|
||||
|
||||
<el-date-picker v-model="queryForm[item.prop]" clearable type="datetimerange"
|
||||
format="YYYY-MM-DD hh:mm:ss" value-format="x" range-separator="至"
|
||||
start-placeholder="开始时间" end-placeholder="结束时间" v-else-if="item.type == 'date'" />
|
||||
|
||||
<slot :name="item.slot"></slot>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,7 +55,7 @@
|
||||
<!--
|
||||
动态表头显示,根据表格每条配置项中的show字段来决定改列是否显示或者隐藏
|
||||
columns 就是我们表格配置的数组对象
|
||||
-->
|
||||
-->
|
||||
<el-popover placement="bottom" title="表格配置"
|
||||
popper-style="max-height: 550px; overflow: auto; max-width: 450px" width="auto" trigger="click">
|
||||
<div v-for="(item, index) in props.columns" :key="index">
|
||||
@@ -92,8 +76,8 @@
|
||||
|
||||
<template v-for="(item, index) in columns">
|
||||
<el-table-column :key="index" v-if="item.show" :prop="item.prop" :label="item.label" :fixed="item.fixed"
|
||||
:align="item.align" :show-overflow-tooltip="item.showOverflowTooltip"
|
||||
:min-width="item.minWidth" :sortable="item.sortable || false" :type="item.type" :width="item.width">
|
||||
:align="item.align" :show-overflow-tooltip="item.showOverflowTooltip" :min-width="item.minWidth"
|
||||
:sortable="item.sortable || false" :type="item.type" :width="item.width">
|
||||
|
||||
<!-- 插槽:预留功能 -->
|
||||
<template #default="scope" v-if="item.slot">
|
||||
@@ -179,7 +163,7 @@ const state = reactive({
|
||||
chooseData: null as any,
|
||||
chooseId: 0 as any,
|
||||
isOpenMoreQuery: false,
|
||||
defaultQueryCount: 2, // 默认显示的查询参数个数
|
||||
defaultQueryCount: 2, // 默认显示的查询参数个数,展开后每行显示个数为该值加1。第一行用最后一列来占用按钮
|
||||
queryForm: {} as any,
|
||||
loadingData: false,
|
||||
})
|
||||
@@ -220,6 +204,18 @@ onMounted(() => {
|
||||
state.queryForm = props.queryForm;
|
||||
})
|
||||
|
||||
const getRowQueryItem = (row: number) => {
|
||||
// 第一行需要加个查询等按钮列
|
||||
if (row === 1) {
|
||||
const res = props.query.slice(row - 1, defaultQueryCount.value)
|
||||
// 查询等按钮列
|
||||
res.push(TableQuery.slot("", "", "queryBtns"))
|
||||
return res
|
||||
}
|
||||
const columnCount = defaultQueryCount.value + 1;
|
||||
return props.query.slice((row - 1) * columnCount - 1, row * columnCount - 1)
|
||||
}
|
||||
|
||||
const handleSelectionChange = (val: any) => {
|
||||
emit('update:selectionData', val);
|
||||
}
|
||||
@@ -265,44 +261,19 @@ defineExpose({ loading })
|
||||
margin-bottom: 10px;
|
||||
overflow: hidden;
|
||||
|
||||
.query-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.query-content {
|
||||
width: 100%;
|
||||
max-height: 0px;
|
||||
transition: all 0.8s;
|
||||
}
|
||||
|
||||
.is-open {
|
||||
padding: 10px 0;
|
||||
// padding: 10px 0;
|
||||
max-height: 200px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.query-content {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
||||
.query-form {
|
||||
.el-form-item {
|
||||
margin: 0px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.slot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,9 +130,9 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch, toRefs, reactive, ref } from 'vue';
|
||||
import { TYPE_LIST, CHARACTER_SET_NAME_LIST, COLLATION_SUFFIX_LIST } from './service.ts';
|
||||
import { TYPE_LIST, CHARACTER_SET_NAME_LIST, COLLATION_SUFFIX_LIST } from './service';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import SqlExecBox from './component/SqlExecBox.ts';
|
||||
import SqlExecBox from './component/SqlExecBox';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
@@ -336,7 +336,7 @@ const submit = async () => {
|
||||
SqlExecBox({
|
||||
sql: sql,
|
||||
dbId: props.dbId as any,
|
||||
db: props.db,
|
||||
db: props.db as any,
|
||||
runSuccessCallback: () => {
|
||||
emit('submit-sql', {tableName: state.tableData.tableName });
|
||||
// cancel();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-dialog :title="title" v-model="dialogVisible" :before-close="cancel" :close-on-click-modal="false"
|
||||
:destroy-on-close="true" width="38%">
|
||||
<el-form :model="form" ref="dbForm" :rules="rules" label-width="95px">
|
||||
<el-form :model="form" ref="dbForm" :rules="rules" label-width="auto">
|
||||
<el-tabs v-model="tabActiveName">
|
||||
<el-tab-pane label="基础信息" name="basic">
|
||||
<el-form-item prop="tagId" label="标签:" required>
|
||||
|
||||
@@ -291,7 +291,7 @@ const queryConfig = [
|
||||
TableQuery.slot("tagPath", "标签", "tagPathSelect"),
|
||||
]
|
||||
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("tagPath", "标签路径").isSlot().setAddWidth(20),
|
||||
TableColumn.new("name", "名称"),
|
||||
TableColumn.new("host", "host:port").setFormatFunc((data: any, _prop: string) => `${data.host}:${data.port}`),
|
||||
@@ -300,11 +300,11 @@ const columns = [
|
||||
TableColumn.new("username", "用户名"),
|
||||
TableColumn.new("remark", "备注"),
|
||||
TableColumn.new("more", "更多").isSlot().setMinWidth(165).fixedRight(),
|
||||
]
|
||||
])
|
||||
|
||||
// 该用户拥有的的操作列按钮权限
|
||||
const actionBtns = hasPerms([perms.saveDb,])
|
||||
const actionColumn = TableColumn.new("action", "操作").isSlot().setMinWidth(65).fixedRight();
|
||||
const actionColumn = TableColumn.new("action", "操作").isSlot().setMinWidth(65).fixedRight()
|
||||
|
||||
const pageTableRef: any = ref(null)
|
||||
|
||||
@@ -429,7 +429,7 @@ const {
|
||||
|
||||
onMounted(async () => {
|
||||
if (Object.keys(actionBtns).length > 0) {
|
||||
columns.push(actionColumn);
|
||||
columns.value.push(actionColumn);
|
||||
}
|
||||
search();
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="addDataDialog.visible" :title="addDataDialog.title" :destroy-on-close="true" width="600px">
|
||||
<el-form ref="dataForm" :model="addDataDialog.data" label-width="160px" size="small">
|
||||
<el-form ref="dataForm" :model="addDataDialog.data" label-width="auto" size="small">
|
||||
<el-form-item v-for="column in columns" class="w100" :prop="column.columnName" :label="column.columnName"
|
||||
:required="column.nullable != 'YES' && column.columnKey != 'PRI'">
|
||||
<el-input-number v-if="DbInst.isNumber(column.columnType)"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-dialog :title="title" v-model="dialogVisible" :close-on-click-modal="false" :destroy-on-close="true"
|
||||
:before-close="cancel" width="650px">
|
||||
<el-form :model="form" ref="machineForm" :rules="rules" label-width="85px">
|
||||
<el-form :model="form" ref="machineForm" :rules="rules" label-width="auto">
|
||||
<el-tabs v-model="tabActiveName">
|
||||
<el-tab-pane label="基础信息" name="basic">
|
||||
<el-form-item prop="tagId" label="标签:">
|
||||
|
||||
@@ -179,7 +179,7 @@ const queryConfig = [
|
||||
TableQuery.text("name", "名称"),
|
||||
]
|
||||
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("tagPath", "标签路径").isSlot().setAddWidth(20),
|
||||
TableColumn.new("name", "名称"),
|
||||
TableColumn.new("ipPort", "ip:port").isSlot().setAddWidth(35),
|
||||
@@ -187,7 +187,7 @@ const columns = [
|
||||
TableColumn.new("status", "状态").isSlot().setMinWidth(85),
|
||||
TableColumn.new("remark", "备注"),
|
||||
TableColumn.new("action", "操作").isSlot().setMinWidth(238).fixedRight(),
|
||||
]
|
||||
])
|
||||
// 该用户拥有的的操作列按钮权限,使用v-if进行判断,v-auth对el-dropdown-item无效
|
||||
const actionBtns = hasPerms([perms.updateMachine, perms.closeCli])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="mock-data-dialog">
|
||||
<el-dialog :title="title" v-model="dialogVisible" :close-on-click-modal="false" :before-close="cancel"
|
||||
:show-close="true" :destroy-on-close="true" width="900px">
|
||||
<el-form :model="form" ref="scriptForm" label-width="50px" size="small">
|
||||
<el-form :model="form" ref="scriptForm" label-width="auto" size="small">
|
||||
<el-form-item prop="method" label="名称">
|
||||
<el-input v-model="form.name" placeholder="请输入名称"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="脚本参数" v-model="scriptParamsDialog.visible" width="400px">
|
||||
<el-form ref="paramsForm" :model="scriptParamsDialog.params" label-width="70px" size="small">
|
||||
<el-form ref="paramsForm" :model="scriptParamsDialog.params" label-width="auto" size="small">
|
||||
<el-form-item v-for="item in scriptParamsDialog.paramsFormItem as any" :key="item.name" :prop="item.model"
|
||||
:label="item.name" required>
|
||||
<el-input v-if="!item.options" v-model="scriptParamsDialog.params[item.model]"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-dialog :title="title" v-model="dvisible" :show-close="false" :before-close="cancel" width="500px"
|
||||
:destroy-on-close="true">
|
||||
<el-form ref="acForm" :rules="rules" :model="form" label-width="90px">
|
||||
<el-form ref="acForm" :rules="rules" :model="form" label-width="auto">
|
||||
<el-form-item prop="name" label="名称:" required>
|
||||
<el-input v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</el-row>
|
||||
|
||||
<el-dialog width="600px" title="find参数" v-model="findDialog.visible">
|
||||
<el-form label-width="70px">
|
||||
<el-form label-width="auto">
|
||||
<el-form-item label="filter">
|
||||
<monaco-editor style="width: 100%;" height="150px" ref="monacoEditorRef"
|
||||
v-model="findDialog.findParam.filter" language="json" />
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog width="400px" title="新建集合" v-model="createCollectionDialog.visible" :destroy-on-close="true">
|
||||
<el-form :model="createCollectionDialog.form" label-width="70px">
|
||||
<el-form :model="createCollectionDialog.form" label-width="auto">
|
||||
<el-form-item prop="name" label="集合名" required>
|
||||
<el-input v-model="createCollectionDialog.form.name" clearable></el-input>
|
||||
</el-form-item>
|
||||
@@ -183,14 +183,14 @@ const pageTableRef: any = ref(null)
|
||||
const queryConfig = [
|
||||
TableQuery.slot("tagPath", "标签", "tagPathSelect"),
|
||||
]
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("tagPath", "标签路径").isSlot().setAddWidth(20),
|
||||
TableColumn.new("name", "名称"),
|
||||
TableColumn.new("uri", "连接uri"),
|
||||
TableColumn.new("createTime", "创建时间").isTime(),
|
||||
TableColumn.new("creator", "创建人"),
|
||||
TableColumn.new("action", "操作").isSlot().setMinWidth(100).fixedRight(),
|
||||
]
|
||||
])
|
||||
|
||||
const state = reactive({
|
||||
tags: [],
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<SvgIcon name="iconfont icon-op-redis" :size="18" />
|
||||
</template>
|
||||
<template #default>
|
||||
<el-form class="instances-pop-form" label-width="50px" :size="'small'">
|
||||
<el-form class="instances-pop-form" label-width="auto" :size="'small'">
|
||||
<el-form-item label="名称:">{{ data.params.name }}</el-form-item>
|
||||
<el-form-item label="模式:">{{ data.params.mode }}</el-form-item>
|
||||
<el-form-item label="链接:">{{ data.params.host }}</el-form-item>
|
||||
@@ -34,7 +34,7 @@
|
||||
<el-col :span="20" style="border-left: 1px solid var(--el-card-border-color);">
|
||||
<div class="mt10 ml5">
|
||||
<el-col>
|
||||
<el-form class="search-form" label-position="right" :inline="true" label-width="60px">
|
||||
<el-form class="search-form" label-position="right" :inline="true" label-width="auto">
|
||||
<el-form-item label="key" label-width="40px">
|
||||
<el-input placeholder="match 支持*模糊key" style="width: 250px" v-model="scanParam.match"
|
||||
@clear="clear()" clearable></el-input>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form class='key-content-string' label-width="85px">
|
||||
<el-form class='key-content-string' label-width="auto">
|
||||
<div>
|
||||
<format-viewer ref="formatViewerRef" :content="string.value"></format-viewer>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-dialog :title="title" v-model="dialogVisible" :before-close="cancel" :close-on-click-modal="false"
|
||||
:destroy-on-close="true" width="38%">
|
||||
<el-form :model="form" ref="redisForm" :rules="rules" label-width="85px">
|
||||
<el-form :model="form" ref="redisForm" :rules="rules" label-width="auto">
|
||||
<el-tabs v-model="tabActiveName">
|
||||
<el-tab-pane label="基础信息" name="basic">
|
||||
<el-form-item prop="tagId" label="标签:" required>
|
||||
|
||||
@@ -157,7 +157,7 @@ const pageTableRef: any = ref(null)
|
||||
const queryConfig = [
|
||||
TableQuery.slot("tagPath", "标签", "tagPathSelect"),
|
||||
]
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("tagPath", "标签路径").isSlot().setAddWidth(20),
|
||||
TableColumn.new("name", "名称"),
|
||||
TableColumn.new("host", "host:port"),
|
||||
@@ -165,7 +165,7 @@ const columns = [
|
||||
TableColumn.new("remark", "备注"),
|
||||
TableColumn.new("more", "更多").isSlot().setMinWidth(155).fixedRight(),
|
||||
TableColumn.new("action", "操作").isSlot().setMinWidth(65).fixedRight(),
|
||||
]
|
||||
])
|
||||
|
||||
const state = reactive({
|
||||
tags: [],
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
<el-dialog width="500px" :title="saveTabDialog.title" :before-close="cancelSaveTag"
|
||||
v-model="saveTabDialog.visible">
|
||||
<el-form ref="tagForm" :rules="rules" :model="saveTabDialog.form" label-width="70px">
|
||||
<el-form ref="tagForm" :rules="rules" :model="saveTabDialog.form" label-width="auto">
|
||||
<el-form-item prop="code" label="标识:" required>
|
||||
<el-input :disabled="saveTabDialog.form.id ? true : false" v-model="saveTabDialog.form.code"
|
||||
auto-complete="off"></el-input>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</page-table>
|
||||
|
||||
<el-dialog width="400px" title="团队编辑" :before-close="cancelSaveTeam" v-model="addTeamDialog.visible">
|
||||
<el-form ref="teamForm" :model="addTeamDialog.form" label-width="70px">
|
||||
<el-form ref="teamForm" :model="addTeamDialog.form" label-width="auto">
|
||||
<el-form-item prop="name" label="团队名:" required>
|
||||
<el-input v-model="addTeamDialog.form.name" auto-complete="off"></el-input>
|
||||
</el-form-item>
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
<el-dialog width="500px" :title="showTagDialog.title" :before-close="closeTagDialog"
|
||||
v-model="showTagDialog.visible">
|
||||
<el-form label-width="70px">
|
||||
<el-form label-width="auto">
|
||||
<el-form-item prop="tag" label="标签:">
|
||||
<el-tree-select ref="tagTreeRef" style="width: 100%" v-model="showTagDialog.tagTreeTeams"
|
||||
:data="showTagDialog.tags" :default-expanded-keys="showTagDialog.tagTreeTeams" multiple
|
||||
|
||||
@@ -3,6 +3,6 @@ import Api from '@/common/Api';
|
||||
export const personApi = {
|
||||
accountInfo: Api.newGet("/sys/accounts/self"),
|
||||
updateAccount: Api.newPut("/sys/accounts/self"),
|
||||
getMsgs: Api.newGet("/sys/accounts/msgs"),
|
||||
getMsgs: Api.newGet("/msgs/self"),
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover" class="mt15 personal-edit" header="更新信息">
|
||||
<div class="personal-edit-title">基本信息</div>
|
||||
<el-form :model="accountForm" label-width="40px" class="mt35 mb35">
|
||||
<el-form :model="accountForm" label-width="auto" class="mt35 mb35">
|
||||
<el-row :gutter="35">
|
||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mb20">
|
||||
<el-form-item label="密码">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="account-dialog">
|
||||
<el-dialog :title="title" v-model="dialogVisible" :before-close="cancel" :show-close="false" width="35%"
|
||||
:destroy-on-close="true">
|
||||
<el-form :model="form" ref="accountForm" :rules="rules" label-width="85px">
|
||||
<el-form :model="form" ref="accountForm" :rules="rules" label-width="auto">
|
||||
<el-form-item prop="name" label="姓名:" required>
|
||||
<el-input v-model.trim="form.name" placeholder="请输入姓名" auto-complete="off"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
v-model:page-size="query.pageSize" v-model:page-num="query.pageNum" @pageChange="search()">
|
||||
|
||||
<template #queryRight>
|
||||
<el-button v-auth="perms.addAccount" type="primary" icon="plus"
|
||||
@click="editAccount(true)">添加</el-button>
|
||||
<el-button v-auth="perms.delAccount" :disabled="state.selectionData.length < 1"
|
||||
@click="deleteAccount()" type="danger" icon="delete">删除</el-button>
|
||||
<el-button v-auth="perms.addAccount" type="primary" icon="plus" @click="editAccount(false)">添加</el-button>
|
||||
<el-button v-auth="perms.delAccount" :disabled="state.selectionData.length < 1" @click="deleteAccount()"
|
||||
type="danger" icon="delete">删除</el-button>
|
||||
</template>
|
||||
|
||||
<template #status="{ data }">
|
||||
@@ -23,21 +22,19 @@
|
||||
</template>
|
||||
|
||||
<template #action="{ data }">
|
||||
<el-button link v-if="actionBtns[perms.addAccount]" @click="editAccount(data)"
|
||||
type="primary">编辑</el-button>
|
||||
<el-button link v-if="actionBtns[perms.addAccount]" @click="editAccount(data)" type="primary">编辑</el-button>
|
||||
|
||||
<el-button link v-if="actionBtns[perms.saveAccountRole]" @click="showRoleEdit(data)"
|
||||
type="success">角色分配</el-button>
|
||||
|
||||
<el-button link v-if="actionBtns[perms.changeAccountStatus] && data.status == 1"
|
||||
@click="changeStatus(data)" type="danger">禁用</el-button>
|
||||
<el-button link v-if="actionBtns[perms.changeAccountStatus] && data.status == 1" @click="changeStatus(data)"
|
||||
type="danger">禁用</el-button>
|
||||
|
||||
<el-button link v-if="actionBtns[perms.changeAccountStatus] && data.status == -1" type="success"
|
||||
@click="changeStatus(data)">启用</el-button>
|
||||
|
||||
<el-button link v-if="actionBtns[perms.addAccount]"
|
||||
:disabled="!data.otpSecret || data.otpSecret == '-'" @click="resetOtpSecret(data)"
|
||||
type="warning">重置OTP</el-button>
|
||||
<el-button link v-if="actionBtns[perms.addAccount]" :disabled="!data.otpSecret || data.otpSecret == '-'"
|
||||
@click="resetOtpSecret(data)" type="warning">重置OTP</el-button>
|
||||
</template>
|
||||
</page-table>
|
||||
|
||||
@@ -97,7 +94,7 @@ const perms = {
|
||||
const queryConfig = [
|
||||
TableQuery.text("username", "用户名"),
|
||||
]
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("name", "姓名"),
|
||||
TableColumn.new("username", "用户名"),
|
||||
TableColumn.new("status", "状态").isSlot(),
|
||||
@@ -107,7 +104,7 @@ const columns = [
|
||||
TableColumn.new("createTime", "创建时间").isTime(),
|
||||
TableColumn.new("modifier", "更新账号"),
|
||||
TableColumn.new("updateTime", "更新时间").isTime(),
|
||||
]
|
||||
])
|
||||
|
||||
// 该用户拥有的的操作列按钮权限
|
||||
const actionBtns = hasPerms([perms.addAccount, perms.saveAccountRole, perms.changeAccountStatus])
|
||||
@@ -166,7 +163,7 @@ const {
|
||||
|
||||
onMounted(() => {
|
||||
if (Object.keys(actionBtns).length > 0) {
|
||||
columns.push(actionColumn);
|
||||
columns.value.push(actionColumn);
|
||||
}
|
||||
search();
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-dialog :title="title" v-model="dvisible" :show-close="false" :before-close="cancel" width="750px"
|
||||
:destroy-on-close="true">
|
||||
<el-form ref="configForm" :model="form" label-width="90px">
|
||||
<el-form ref="configForm" :model="form" label-width="auto">
|
||||
<el-form-item prop="name" label="配置项:" required>
|
||||
<el-input v-model="form.name"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
:total="total" v-model:page-size="query.pageSize" v-model:page-num="query.pageNum" @pageChange="search()">
|
||||
|
||||
<template #queryRight>
|
||||
<el-button v-auth="perms.saveConfig" type="primary" icon="plus"
|
||||
@click="editConfig(false)">添加</el-button>
|
||||
<el-button v-auth="perms.saveConfig" type="primary" icon="plus" @click="editConfig(false)">添加</el-button>
|
||||
</template>
|
||||
|
||||
<template #status="{ data }">
|
||||
@@ -23,7 +22,7 @@
|
||||
|
||||
<el-dialog :before-close="closeSetConfigDialog" title="配置项设置" v-model="paramsDialog.visible" width="500px">
|
||||
<el-form v-if="paramsDialog.paramsFormItem.length > 0" ref="paramsFormRef" :model="paramsDialog.params"
|
||||
label-width="130px">
|
||||
label-width="auto">
|
||||
<el-form-item v-for="item in paramsDialog.paramsFormItem" :key="item.name" :prop="item.model"
|
||||
:label="item.name" required>
|
||||
<el-input v-if="!item.options" v-model="paramsDialog.params[item.model]" :placeholder="item.placeholder"
|
||||
@@ -35,7 +34,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form v-else ref="paramsFormRef" label-width="90px">
|
||||
<el-form v-else ref="paramsFormRef" label-width="auto">
|
||||
<el-form-item label="配置值" required>
|
||||
<el-input v-model="paramsDialog.params" :placeholder="paramsDialog.config.remark" autocomplete="off"
|
||||
clearable></el-input>
|
||||
@@ -66,14 +65,14 @@ import { hasPerms } from '@/components/auth/auth';
|
||||
const perms = {
|
||||
saveConfig: "config:save"
|
||||
}
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("name", "配置项"),
|
||||
TableColumn.new("key", "配置key"),
|
||||
TableColumn.new("value", "配置值"),
|
||||
TableColumn.new("remark", "备注"),
|
||||
TableColumn.new("modifier", "更新账号"),
|
||||
TableColumn.new("updateTime", "更新时间").isTime(),
|
||||
]
|
||||
])
|
||||
const actionColumn = TableColumn.new("action", "操作").isSlot().fixedRight().setMinWidth(130).noShowOverflowTooltip();
|
||||
const actionBtns = hasPerms([perms.saveConfig])
|
||||
|
||||
@@ -111,7 +110,7 @@ const {
|
||||
|
||||
onMounted(() => {
|
||||
if (Object.keys(actionBtns).length > 0) {
|
||||
columns.push(actionColumn);
|
||||
columns.value.push(actionColumn);
|
||||
}
|
||||
search();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="system-menu-dialog-container layout-pd">
|
||||
<el-dialog :title="title" :destroy-on-close="true" v-model="dialogVisible" width="800px">
|
||||
<el-form :model="form" :inline="true" ref="menuForm" :rules="rules" label-width="100px">
|
||||
<el-form :model="form" :inline="true" ref="menuForm" :rules="rules" label-width="auto">
|
||||
<el-row :gutter="35">
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item class="w100" prop="type" label="类型" required>
|
||||
@@ -67,7 +67,8 @@
|
||||
<el-form-item class="w100" prop="isKeepAlive">
|
||||
<template #label>
|
||||
是否缓存
|
||||
<el-tooltip effect="dark" content="选择是则会被`keep-alive`缓存(重新进入页面不会刷新页面及重新请求数据),需要路由名与vue的组件名一致" placement="top">
|
||||
<el-tooltip effect="dark"
|
||||
content="选择是则会被`keep-alive`缓存(重新进入页面不会刷新页面及重新请求数据),需要路由名与vue的组件名一致" placement="top">
|
||||
<el-icon>
|
||||
<question-filled />
|
||||
</el-icon>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="role-dialog">
|
||||
<el-dialog :title="title" v-model="dvisible" :show-close="false" :before-close="cancel" width="500px"
|
||||
:destroy-on-close="true">
|
||||
<el-form ref="roleForm" :model="form" label-width="90px">
|
||||
<el-form ref="roleForm" :model="form" label-width="auto">
|
||||
<el-form-item prop="name" label="角色名称:" required>
|
||||
<el-input v-model="form.name" auto-complete="off"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -60,7 +60,7 @@ const perms = {
|
||||
const queryConfig = [
|
||||
TableQuery.text("name", "角色名"),
|
||||
]
|
||||
const columns = [
|
||||
const columns = ref([
|
||||
TableColumn.new("name", "角色名称"),
|
||||
TableColumn.new("code", "角色code"),
|
||||
TableColumn.new("remark", "备注"),
|
||||
@@ -70,7 +70,7 @@ const columns = [
|
||||
TableColumn.new("modifier", "更新账号"),
|
||||
TableColumn.new("updateTime", "更新时间").isTime(),
|
||||
TableColumn.new("showmore", "查看更多").isSlot().setMinWidth(150),
|
||||
]
|
||||
])
|
||||
|
||||
const actionBtns = hasPerms([perms.updateRole, perms.saveRoleResource])
|
||||
const actionColumn = TableColumn.new("action", "操作").isSlot().setMinWidth(160).fixedRight()
|
||||
@@ -114,7 +114,7 @@ const {
|
||||
|
||||
onMounted(() => {
|
||||
if (Object.keys(actionBtns).length > 0) {
|
||||
columns.push(actionColumn);
|
||||
columns.value.push(actionColumn);
|
||||
}
|
||||
search();
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
db_router "mayfly-go/internal/db/router"
|
||||
machine_router "mayfly-go/internal/machine/router"
|
||||
mongo_router "mayfly-go/internal/mongo/router"
|
||||
msg_router "mayfly-go/internal/msg/router"
|
||||
redis_router "mayfly-go/internal/redis/router"
|
||||
sys_router "mayfly-go/internal/sys/router"
|
||||
tag_router "mayfly-go/internal/tag/router"
|
||||
@@ -73,6 +74,7 @@ func InitRouter() *gin.Engine {
|
||||
common_router.InitCommonRouter(api)
|
||||
|
||||
sys_router.Init(api)
|
||||
msg_router.Init(api)
|
||||
|
||||
tag_router.Init(api)
|
||||
machine_router.Init(api)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"mayfly-go/internal/db/api/vo"
|
||||
"mayfly-go/internal/db/application"
|
||||
"mayfly-go/internal/db/domain/entity"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ginx"
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
type Db struct {
|
||||
DbApp application.Db
|
||||
DbSqlExecApp application.DbSqlExec
|
||||
MsgApp sysapp.Msg
|
||||
MsgApp msgapp.Msg
|
||||
TagApp tagapp.TagTree
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package router
|
||||
import (
|
||||
"mayfly-go/internal/db/api"
|
||||
"mayfly-go/internal/db/application"
|
||||
sysapp "mayfly-go/internal/sys/application"
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
tagapp "mayfly-go/internal/tag/application"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
@@ -16,7 +16,7 @@ func InitDbRouter(router *gin.RouterGroup) {
|
||||
d := &api.Db{
|
||||
DbApp: application.GetDbApp(),
|
||||
DbSqlExecApp: application.GetDbSqlExecApp(),
|
||||
MsgApp: sysapp.GetMsgApp(),
|
||||
MsgApp: msgapp.GetMsgApp(),
|
||||
TagApp: tagapp.GetTagTreeApp(),
|
||||
}
|
||||
// 获取所有数据库列表
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"mayfly-go/internal/machine/api/vo"
|
||||
"mayfly-go/internal/machine/application"
|
||||
"mayfly-go/internal/machine/domain/entity"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ginx"
|
||||
"mayfly-go/pkg/req"
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
|
||||
type MachineFile struct {
|
||||
MachineFileApp application.MachineFile
|
||||
MsgApp sysApplication.Msg
|
||||
MsgApp msgapp.Msg
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -3,7 +3,7 @@ package router
|
||||
import (
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/application"
|
||||
sysApplication "mayfly-go/internal/sys/application"
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -14,7 +14,7 @@ func InitMachineFileRouter(router *gin.RouterGroup) {
|
||||
{
|
||||
mf := &api.MachineFile{
|
||||
MachineFileApp: application.GetMachineFileApp(),
|
||||
MsgApp: sysApplication.GetMsgApp(),
|
||||
MsgApp: msgapp.GetMsgApp(),
|
||||
}
|
||||
|
||||
// 获取指定机器文件列表
|
||||
|
||||
20
server/internal/msg/api/msg.go
Normal file
20
server/internal/msg/api/msg.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/msg/application"
|
||||
"mayfly-go/internal/msg/domain/entity"
|
||||
"mayfly-go/pkg/ginx"
|
||||
"mayfly-go/pkg/req"
|
||||
)
|
||||
|
||||
type Msg struct {
|
||||
MsgApp application.Msg
|
||||
}
|
||||
|
||||
// 获取账号接收的消息列表
|
||||
func (m *Msg) GetMsgs(rc *req.Ctx) {
|
||||
condition := &entity.Msg{
|
||||
RecipientId: int64(rc.LoginAccount.Id),
|
||||
}
|
||||
rc.ResData = m.MsgApp.GetPageList(condition, ginx.GetPageParam(rc.GinCtx), new([]entity.Msg))
|
||||
}
|
||||
13
server/internal/msg/application/application.go
Normal file
13
server/internal/msg/application/application.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/msg/infrastructure/persistence"
|
||||
)
|
||||
|
||||
var (
|
||||
msgApp = newMsgApp(persistence.GetMsgRepo())
|
||||
)
|
||||
|
||||
func GetMsgApp() Msg {
|
||||
return msgApp
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/msg/domain/entity"
|
||||
"mayfly-go/internal/msg/domain/repository"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/ws"
|
||||
"time"
|
||||
@@ -1,7 +1,7 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/msg/domain/entity"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/msg/domain/entity"
|
||||
"mayfly-go/internal/msg/domain/repository"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/gormx"
|
||||
"mayfly-go/pkg/model"
|
||||
@@ -0,0 +1,11 @@
|
||||
package persistence
|
||||
|
||||
import "mayfly-go/internal/msg/domain/repository"
|
||||
|
||||
var (
|
||||
msgRepo = newMsgRepo()
|
||||
)
|
||||
|
||||
func GetMsgRepo() repository.Msg {
|
||||
return msgRepo
|
||||
}
|
||||
21
server/internal/msg/router/msg.go
Normal file
21
server/internal/msg/router/msg.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/msg/api"
|
||||
"mayfly-go/internal/msg/application"
|
||||
"mayfly-go/pkg/req"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitMsgRouter(router *gin.RouterGroup) {
|
||||
msg := router.Group("msgs")
|
||||
a := &api.Msg{
|
||||
MsgApp: application.GetMsgApp(),
|
||||
}
|
||||
{
|
||||
msg.GET("/self", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).Handle(a.GetMsgs)
|
||||
})
|
||||
}
|
||||
}
|
||||
7
server/internal/msg/router/router.go
Normal file
7
server/internal/msg/router/router.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package router
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func Init(router *gin.RouterGroup) {
|
||||
InitMsgRouter(router)
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package api
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
msgentity "mayfly-go/internal/msg/domain/entity"
|
||||
"mayfly-go/internal/sys/api/form"
|
||||
"mayfly-go/internal/sys/api/vo"
|
||||
"mayfly-go/internal/sys/application"
|
||||
@@ -31,7 +33,7 @@ type Account struct {
|
||||
AccountApp application.Account
|
||||
ResourceApp application.Resource
|
||||
RoleApp application.Role
|
||||
MsgApp application.Msg
|
||||
MsgApp msgapp.Msg
|
||||
ConfigApp application.Config
|
||||
}
|
||||
|
||||
@@ -257,7 +259,7 @@ func (a *Account) saveLogin(account *entity.Account, ip string) {
|
||||
a.AccountApp.Update(updateAccount)
|
||||
|
||||
// 创建登录消息
|
||||
loginMsg := &entity.Msg{
|
||||
loginMsg := &msgentity.Msg{
|
||||
RecipientId: int64(account.Id),
|
||||
Msg: fmt.Sprintf("于[%s]-[%s]登录", ip, now.Format("2006-01-02 15:04:05")),
|
||||
Type: 1,
|
||||
@@ -296,14 +298,6 @@ func (a *Account) UpdateAccount(rc *req.Ctx) {
|
||||
a.AccountApp.Update(updateAccount)
|
||||
}
|
||||
|
||||
// 获取账号接收的消息列表
|
||||
func (a *Account) GetMsgs(rc *req.Ctx) {
|
||||
condition := &entity.Msg{
|
||||
RecipientId: int64(rc.LoginAccount.Id),
|
||||
}
|
||||
rc.ResData = a.MsgApp.GetPageList(condition, ginx.GetPageParam(rc.GinCtx), new([]entity.Msg))
|
||||
}
|
||||
|
||||
/** 后台账号操作 **/
|
||||
|
||||
// @router /accounts [get]
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
var (
|
||||
accountApp = newAccountApp(persistence.GetAccountRepo())
|
||||
configApp = newConfigApp(persistence.GetConfigRepo())
|
||||
msgApp = newMsgApp(persistence.GetMsgRepo())
|
||||
resourceApp = newResourceApp(persistence.GetResourceRepo())
|
||||
roleApp = newRoleApp(persistence.GetRoleRepo())
|
||||
syslogApp = newSyslogApp(persistence.GetSyslogRepo())
|
||||
@@ -21,10 +20,6 @@ func GetConfigApp() Config {
|
||||
return configApp
|
||||
}
|
||||
|
||||
func GetMsgApp() Msg {
|
||||
return msgApp
|
||||
}
|
||||
|
||||
func GetResourceApp() Resource {
|
||||
return resourceApp
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func (m *syslogAppImpl) GetPageList(condition *entity.Syslog, pageParam *model.P
|
||||
func (m *syslogAppImpl) SaveFromReq(req *req.Ctx) {
|
||||
lg := req.LoginAccount
|
||||
if lg == nil {
|
||||
return
|
||||
lg = &model.LoginAccount{Id: 0, Username: "-"}
|
||||
}
|
||||
syslog := new(entity.Syslog)
|
||||
syslog.CreateTime = time.Now()
|
||||
|
||||
@@ -5,7 +5,6 @@ import "mayfly-go/internal/sys/domain/repository"
|
||||
var (
|
||||
accountRepo = newAccountRepo()
|
||||
configRepo = newConfigRepo()
|
||||
msgRepo = newMsgRepo()
|
||||
resourceRepo = newResourceRepo()
|
||||
roleRepo = newRoleRepo()
|
||||
syslogRepo = newSyslogRepo()
|
||||
@@ -19,10 +18,6 @@ func GetConfigRepo() repository.Config {
|
||||
return configRepo
|
||||
}
|
||||
|
||||
func GetMsgRepo() repository.Msg {
|
||||
return msgRepo
|
||||
}
|
||||
|
||||
func GetResourceRepo() repository.Resource {
|
||||
return resourceRepo
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
msgapp "mayfly-go/internal/msg/application"
|
||||
"mayfly-go/internal/sys/api"
|
||||
"mayfly-go/internal/sys/application"
|
||||
"mayfly-go/pkg/req"
|
||||
@@ -14,7 +15,7 @@ func InitAccountRouter(router *gin.RouterGroup) {
|
||||
AccountApp: application.GetAccountApp(),
|
||||
ResourceApp: application.GetResourceApp(),
|
||||
RoleApp: application.GetRoleApp(),
|
||||
MsgApp: application.GetMsgApp(),
|
||||
MsgApp: msgapp.GetMsgApp(),
|
||||
ConfigApp: application.GetConfigApp(),
|
||||
}
|
||||
{
|
||||
@@ -56,10 +57,6 @@ func InitAccountRouter(router *gin.RouterGroup) {
|
||||
req.NewCtxWithGin(c).Handle(a.UpdateAccount)
|
||||
})
|
||||
|
||||
account.GET("/msgs", func(c *gin.Context) {
|
||||
req.NewCtxWithGin(c).Handle(a.GetMsgs)
|
||||
})
|
||||
|
||||
/** 后台管理接口 **/
|
||||
|
||||
// 获取所有用户列表
|
||||
|
||||
Reference in New Issue
Block a user