字典管理ok

This commit is contained in:
仲么了
2024-01-25 11:04:07 +08:00
parent bdc5a452f3
commit 6c8b73eee1
8 changed files with 305 additions and 79 deletions

View File

@@ -0,0 +1,34 @@
import request from '@/utils/request'
export function dictDataUpdate(data: any) {
return request({
url: '/system-boot/dictData/update',
method: 'post',
data: data
})
}
export function dictDataDelete(data: any) {
return request({
url: '/system-boot/dictData/delete',
method: 'post',
data: data
})
}
export function dictDataGetTypeIdData(data: any) {
return request({
url: '/system-boot/dictData/getTypeIdData',
method: 'post',
data: data
})
}
export function dictDataAdd(data) {
return request({
url: '/system-boot/dictData/add',
method: 'post',
data: data
})
}

View File

@@ -62,7 +62,7 @@ const init = async () => {
data.forEach((item: any) => { data.forEach((item: any) => {
item.routePath = item.routePath[0] == '/' ? item.routePath.substring(1, item.routePath.length) : item.routePath item.routePath = item.routePath[0] == '/' ? item.routePath.substring(1, item.routePath.length) : item.routePath
item.path = item.routePath item.path = item.routePath
item.name = item.title item.name = item.routePath
item.keepalive = item.routePath item.keepalive = item.routePath
item.component = item.routeName || '/src/views/Event-boot/Region/overview.vue' item.component = item.routeName || '/src/views/Event-boot/Region/overview.vue'
item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu' item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu'
@@ -74,7 +74,6 @@ const init = async () => {
} }
handlerMenu(res.data) handlerMenu(res.data)
handleAdminRoute(res.data) handleAdminRoute(res.data)
// 预跳转到上次路径
if (route.params.to) { if (route.params.to) {
const lastRoute = JSON.parse(route.params.to as string) const lastRoute = JSON.parse(route.params.to as string)
if (lastRoute.path != adminBaseRoutePath) { if (lastRoute.path != adminBaseRoutePath) {
@@ -83,7 +82,6 @@ const init = async () => {
return return
} }
} }
// 跳转到第一个菜单 // 跳转到第一个菜单
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes) let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
if (firstRoute) routePush(firstRoute.path) if (firstRoute) routePush(firstRoute.path)

View File

@@ -24,7 +24,7 @@ export const adminBaseRoute = {
meta: { meta: {
title: `pagesTitle.loading` title: `pagesTitle.loading`
} }
}, }
] ]
} }

View File

@@ -14,8 +14,8 @@
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import Area from '@/components/form/area/index.vue' import Area from '@/components/form/area/index.vue'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import Echart from '@/views/Event-boot/Region/components/echart.vue' import Echart from '@/views/pms/Event-boot/Region/components/echart.vue'
import Tableabove from '@/views/Event-boot/Region/components/Tableabove.vue' import Tableabove from '@/views/pms/Event-boot/Region/components/Tableabove.vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import { onMounted, reactive, ref, provide } from 'vue' import { onMounted, reactive, ref, provide } from 'vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'

View File

@@ -1,7 +1,12 @@
<template> <template>
<div class='default-main'> <div class='dictiontary-list-detail'>
<TableHeader> <TableHeader>
<template #select> <template #select>
<el-page-header @back="$emit('close')" style='display: flex;align-items: center'>
<template #content>
<span class='text-large font-600 mr-3'> {{ props.detail.name }}详情信息 </span>
</template>
</el-page-header>
<el-form-item label='过滤筛选'> <el-form-item label='过滤筛选'>
<el-input <el-input
style='width: 240px' style='width: 240px'
@@ -12,11 +17,11 @@
</el-form-item> </el-form-item>
</template> </template>
<template #operation> <template #operation>
<el-button :icon='Plus' type='primary' @click='add'>新增字典类型</el-button> <el-button :icon='Plus' type='primary' @click='add'>新增</el-button>
</template> </template>
</TableHeader> </TableHeader>
<Table ref='tableRef' /> <Table ref='tableRef' />
<PopupEdit ref='popupEditRef'></PopupEdit> <PopupDetailEdit ref='popupEditRef'></PopupDetailEdit>
</div> </div>
</template> </template>
<script setup lang='ts'> <script setup lang='ts'>
@@ -26,49 +31,54 @@ import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import PopupEdit from './popupEdit.vue' import PopupDetailEdit from './popupDetailEdit.vue'
import { dictTypeDelete } from '@/api/system-boot/dictType' import { dictTypeDelete } from '@/api/system-boot/dictType'
import router from '@/router' import { dictDataDelete } from '@/api/system-boot/dicData'
defineOptions({ defineOptions({
name: 'setting/dictionary/list/detail' name: 'setting/dictionary/list/detail'
}) })
interface Props {
detail: anyObj
}
const props = withDefaults(defineProps<Props>(), {
detail: () => {
return {}
}
})
const popupEditRef = ref() const popupEditRef = ref()
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/system-boot/dictType/list', url: '/system-boot/dictData/getTypeIdData',
method: 'POST', method: 'POST',
column: [ column: [
{ title: '序号', type: 'seq', width: '60' },
{ title: '名称', field: 'name' }, { title: '名称', field: 'name' },
{ title: '编码', field: 'code' }, { title: '编码', field: 'code' },
{ title: '开启等级', field: 'openLevelName' }, { title: '排序', field: 'sort' },
{ title: '开启算法', field: 'openDescribeName' }, { title: '计算值', field: 'value' },
{ title: '事件等级', field: 'levelName' },
{ title: '算法描述', field: 'algoDescribe' },
{ title: '状态', field: 'stateName' }, { title: '状态', field: 'stateName' },
{ title: '字典描述', field: 'remark' },
{ title: '创建时间', field: 'createTime' },
{ title: '更新时间', field: 'updateTime' },
{ {
title: '操作', title: '操作',
width: '180', width: '180',
render: 'buttons', render: 'buttons',
fixed: 'right', fixed: 'right',
buttons: [ buttons: [
{
title: '查看',
type: 'primary',
icon: 'el-icon-ZoomIn',
render: 'tipButton',
click: row => {
}
},
{ {
title: '编辑', title: '编辑',
type: 'primary', type: 'primary',
icon: 'el-icon-EditPen', icon: 'el-icon-EditPen',
render: 'tipButton', render: 'tipButton',
click: row => { click: row => {
popupEditRef.value.open('编辑字典类型', row) popupEditRef.value.open('编辑', {
...row,
openDescribe: props.detail.openDescribe,
openLevel: props.detail.openLevel,
typeName: props.detail.name + row.name,
typeId: props.detail.id
})
} }
}, },
{ {
@@ -83,7 +93,7 @@ const tableStore = new TableStore({
title: '确定删除该字典类型吗?' title: '确定删除该字典类型吗?'
}, },
click: row => { click: row => {
dictTypeDelete([row.id]).then(() => { dictDataDelete([row.id]).then(() => {
ElMessage.success('删除成功') ElMessage.success('删除成功')
tableStore.index() tableStore.index()
}) })
@@ -95,8 +105,25 @@ const tableStore = new TableStore({
loadCallback: () => { loadCallback: () => {
tableStore.table.data.forEach((item: any) => { tableStore.table.data.forEach((item: any) => {
item.stateName = item.state === 1 ? '正常' : '删除' item.stateName = item.state === 1 ? '正常' : '删除'
item.openLevelName = item.openLevel === 1 ? '开启' : '不开启' switch (item.level) {
item.openDescribeName = item.openDescribe === 1 ? '开启' : '不开启' case 0:
item.levelName = '普通'
break
case 1:
item.levelName = '中等'
break
case 2:
item.levelName = '严重'
break
default:
item.levelName = '未知'
break
}
for (let key in item) {
if (typeof item[key] !== 'number') {
item[key] = item[key] || '/'
}
}
}) })
} }
}) })
@@ -104,11 +131,34 @@ const tableStore = new TableStore({
provide('tableStore', tableStore) provide('tableStore', tableStore)
tableStore.table.params.searchValue = '' tableStore.table.params.searchValue = ''
tableStore.table.params.searchState = 0 tableStore.table.params.searchState = 0
tableStore.table.params.typeId = props.detail.id
if (props.detail.openLevel !== 1) {
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'levelName' )
}
if (props.detail.openDescribe !== 1) {
tableStore.table.column = tableStore.table.column.filter((item: any) => item.field !== 'algoDescribe')
}
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
const add = () => { const add = () => {
popupEditRef.value.open('新增字典类型')
popupEditRef.value.open('新增', {
openLevel: props.detail.openLevel,
openDescribe: props.detail.openDescribe,
typeName: props.detail.name,
typeId: props.detail.id
})
} }
</script> </script>
<style lang='scss'>
.dictiontary-list-detail {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #fff;
}
</style>

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class='default-main'> <div class='default-main' style='position: relative;'>
<TableHeader> <TableHeader>
<template #select> <template #select>
<el-form-item label='过滤筛选'> <el-form-item label='过滤筛选'>
@@ -17,6 +17,7 @@
</TableHeader> </TableHeader>
<Table ref='tableRef' /> <Table ref='tableRef' />
<PopupEdit ref='popupEditRef'></PopupEdit> <PopupEdit ref='popupEditRef'></PopupEdit>
<Detail ref='detailRef' :detail='detail' @close='detail = null' v-if='detail'></Detail>
</div> </div>
</template> </template>
<script setup lang='ts'> <script setup lang='ts'>
@@ -28,14 +29,13 @@ import TableHeader from '@/components/table/header/index.vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import PopupEdit from './popupEdit.vue' import PopupEdit from './popupEdit.vue'
import { dictTypeDelete } from '@/api/system-boot/dictType' import { dictTypeDelete } from '@/api/system-boot/dictType'
import router from '@/router/index' import Detail from './detail.vue'
defineOptions({ defineOptions({
name: 'setting/dictionary/list' name: 'system-boot/dictType/list'
}) })
const popupEditRef = ref() const popupEditRef = ref()
const detail = ref<anyObj | null>(null)
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/system-boot/dictType/list', url: '/system-boot/dictType/list',
method: 'POST', method: 'POST',
@@ -61,12 +61,7 @@ const tableStore = new TableStore({
icon: 'el-icon-ZoomIn', icon: 'el-icon-ZoomIn',
render: 'tipButton', render: 'tipButton',
click: row => { click: row => {
// router.push({ detail.value = row
// path: '/admin/setting/dictionary/list/detail',
// params: {
// id: row.id
// }
// })
} }
}, },
{ {
@@ -78,7 +73,6 @@ const tableStore = new TableStore({
popupEditRef.value.open('编辑字典类型', row) popupEditRef.value.open('编辑字典类型', row)
} }
}, },
{ {
title: '删除', title: '删除',
type: 'danger', type: 'danger',
@@ -118,4 +112,4 @@ onMounted(() => {
const add = () => { const add = () => {
popupEditRef.value.open('新增字典类型') popupEditRef.value.open('新增字典类型')
} }
</script> </script>

View File

@@ -0,0 +1,135 @@
<template>
<el-dialog class='cn-operate-dialog' v-model='dialogVisible' :title='title'>
<el-scrollbar>
<el-form :inline='false' :model='form' label-width='120px' :rules='rules' ref='formRef'>
<el-form-item label='名称:' class='top' prop='name'>
<el-input v-model='form.name'></el-input>
</el-form-item>
<el-form-item label='计算值:' class='top'>
<el-input v-model='form.value'></el-input>
</el-form-item>
<el-form-item class='top' label='对应算法:' prop='algoDescribe' v-if='form.openDescribe == 1'>
<el-input v-model='form.algoDescribe' placeholder='请输入数字'></el-input>
</el-form-item>
<el-form-item class='top'
label='编码:'
prop='code'
>
<el-input v-model='form.code'></el-input>
</el-form-item>
<el-form-item label='排序:' prop='sort' class='top'>
<el-input-number v-model='form.sort' :min='0' />
</el-form-item>
<el-form-item
v-if='form.openLevel === 1'
label='事件等级:'
>
<el-select v-model='form.level' placeholder='选择开启等级'>
<el-option
v-for='item in EventOpenLevel'
:key='item.value'
:label='item.label'
:value='item.value'
>
</el-option>
</el-select>
</el-form-item>
</el-form>
</el-scrollbar>
<template #footer>
<span class='dialog-footer'>
<el-button @click='dialogVisible = false'>取消</el-button>
<el-button type='primary' @click='submit'>确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang='ts' setup>
import { ref, inject } from 'vue'
import { reactive } from 'vue'
import TableStore from '@/utils/tableStore'
import { ElMessage } from 'element-plus'
import { add, update } from '@/api/user-boot/role'
import { useAdminInfo } from '@/stores/adminInfo'
import { dictDataAdd, dictDataUpdate } from '@/api/system-boot/dicData'
defineOptions({
name: 'diction/list/detail/popupDetailEdit'
})
const adminInfo = useAdminInfo()
const tableStore = inject('tableStore') as TableStore
const formRef = ref()
// do not use same name with ref
const form = reactive({
algoDescribe: '',
code: '',
level: 0,
name: '',
value: '',
sort: 0,
typeId: '',
openLevel: 0,
openDescribe: 0,
typeName: '',
id: ''
})
const EventOpenLevel = [
{ value: 0, label: '普通' },
{ value: 1, label: '中等' },
{ value: 2, label: '严重' }
]
const rules = {
algoDescribe: [
{ required: false, message: '对应算法不能为空', trigger: 'blur' },
{
pattern: /^\d+$|^\d+[.]?\d+$/,
message: '请您数字对应算法',
trigger: 'blur'
}
],
name: [
{ required: true, message: '名称不能为空', trigger: 'blur' }
],
code: [
{ required: true, message: '编码不能为空', trigger: 'blur' }
],
sort: [
{ required: true, message: '排序不能为空', trigger: 'blur' }
]
}
const dialogVisible = ref(false)
const title = ref('新增')
const open = (text: string, data: anyObj) => {
dialogVisible.value = true
if (text === '编辑') {
for (let key in form) {
form[key] = data[key] === '/' ? '' : data[key]
}
} else if (text === '新增') {
for (let key in form) {
form[key] = ''
}
form.level = 0
form.sort = 0
form.typeId = data.typeId
form.openLevel = data.openLevel
form.typeName = data.typeName
form.openDescribe = data.openDescribe
}
title.value = form.typeName + text
}
const submit = async () => {
await formRef.value.validate()
if (form.id) {
await dictDataUpdate(form)
} else {
await dictDataAdd(form)
}
ElMessage.success('保存成功')
tableStore.index()
dialogVisible.value = false
}
defineExpose({ open })
</script>

View File

@@ -1,68 +1,68 @@
<template> <template>
<div @keyup.enter="onSubmit(formRef)"> <div @keyup.enter='onSubmit(formRef)'>
<div @contextmenu.stop="" id="bubble" class="bubble"> <div @contextmenu.stop='' id='bubble' class='bubble'>
<canvas id="bubble-canvas" class="bubble-canvas"></canvas> <canvas id='bubble-canvas' class='bubble-canvas'></canvas>
</div> </div>
<div class="login-image"></div> <div class='login-image'></div>
<div class="login-container-form"> <div class='login-container-form'>
<div class="title-container"> <div class='title-container'>
<div class="title"> <div class='title'>
<span style="font-size: 28px">电能质量数据监测云平台</span> <span style='font-size: 28px'>电能质量数据监测云平台</span>
</div> </div>
</div> </div>
<el-form :rules="rules" ref="formRef" size="large" class="login-form" :model="form"> <el-form :rules='rules' ref='formRef' size='large' class='login-form' :model='form'>
<el-form-item prop="username"> <el-form-item prop='username'>
<el-input <el-input
ref="usernameRef" ref='usernameRef'
v-model="form.username" v-model='form.username'
type="text" type='text'
clearable clearable
placeholder="用户名" placeholder='用户名'
autocomplete="off" autocomplete='off'
> >
<template #prefix> <template #prefix>
<span class="iconfont icon-yonghu" style="color: #003078"></span> <span class='iconfont icon-yonghu' style='color: #003078'></span>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop='password'>
<el-input <el-input
ref="passwordRef" ref='passwordRef'
v-model="form.password" v-model='form.password'
type="password" type='password'
placeholder="密码" placeholder='密码'
show-password show-password
autocomplete="off" autocomplete='off'
> >
<template #prefix> <template #prefix>
<span class="iconfont icon-mima" style="color: #003078"></span> <span class='iconfont icon-mima' style='color: #003078'></span>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
:loading="state.submitLoading" :loading='state.submitLoading'
class="submit-btn" class='submit-btn'
round round
type="info" type='info'
@click="onSubmit(formRef)" @click='onSubmit(formRef)'
> >
登录 登录
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div class="copy-right"> <div class='copy-right'>
<span>版权所有 @ 南京灿能电力自动化股份有限公司</span> <span>版权所有 @ 南京灿能电力自动化股份有限公司</span>
<br /> <br />
<img style="width: 20px; height: 20px; position: absolute" src="@/assets/login/jhui.png" /> <img style='width: 20px; height: 20px; position: absolute' src='@/assets/login/jhui.png' />
<span>  苏公网安备 32011502011902</span> <span>  苏公网安备 32011502011902</span>
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang='ts'>
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue' import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
import * as pageBubble from '@/utils/pageBubble' import * as pageBubble from '@/utils/pageBubble'
import { sm3Digest } from '@/assets/commjs/sm3.js' import { sm3Digest } from '@/assets/commjs/sm3.js'
@@ -74,6 +74,7 @@ import type { FormInstance, InputInstance, FormRules } from 'element-plus'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ADMIN_INFO } from '@/stores/constant/cacheKey' import { ADMIN_INFO } from '@/stores/constant/cacheKey'
import { Local } from '@/utils/storage' import { Local } from '@/utils/storage'
const router = useRouter() const router = useRouter()
let timer: number let timer: number
@@ -82,13 +83,14 @@ const usernameRef = ref<InputInstance>()
const passwordRef = ref<InputInstance>() const passwordRef = ref<InputInstance>()
const userInfo = useAdminInfo() const userInfo = useAdminInfo()
Local.remove(ADMIN_INFO)
Local.remove(ADMIN_INFO) Local.remove(ADMIN_INFO)
userInfo.removeToken() userInfo.removeToken()
interface RuleForm { interface RuleForm {
username: string username: string
password: string password: string
} }
const state = reactive({ const state = reactive({
showCaptcha: false, showCaptcha: false,
submitLoading: false submitLoading: false
@@ -137,7 +139,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
imageCode: '', imageCode: '',
verifyCode: 0 verifyCode: 0
}).then(res => { }).then(res => {
res.data.loginName = encrypt(form.username) res.data.loginName = encrypt(form.username)
userInfo.dataFill(res.data) userInfo.dataFill(res.data)
state.submitLoading = false state.submitLoading = false
router.push({ router.push({
@@ -153,7 +155,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang='scss'>
.bubble { .bubble {
position: relative; position: relative;
width: 100%; width: 100%;
@@ -192,21 +194,25 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
border-radius: 30px; border-radius: 30px;
transform: translate(-85%, -50%); transform: translate(-85%, -50%);
box-shadow: 3px 3px 2px 2px #011b2bab; box-shadow: 3px 3px 2px 2px #011b2bab;
.title-container { .title-container {
position: relative; position: relative;
width: 398px; width: 398px;
max-width: 100%; max-width: 100%;
padding: 20px 0 0; padding: 20px 0 0;
margin: 0 auto; margin: 0 auto;
.title { .title {
margin-bottom: 20px; margin-bottom: 20px;
font-size: 33px; font-size: 33px;
font-weight: 600; font-weight: 600;
color: rgba(255, 255, 255, 0.85); color: rgba(255, 255, 255, 0.85);
text-align: center; text-align: center;
& :v-deep .svg-icon { & :v-deep .svg-icon {
// color: $; // color: $;
} }
.logo { .logo {
width: 46px; width: 46px;
height: 46px; height: 46px;
@@ -216,6 +222,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
} }
} }
} }
.login-form { .login-form {
position: relative; position: relative;
width: 368px; width: 368px;
@@ -224,6 +231,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
margin: 0 auto; margin: 0 auto;
margin-bottom: 20px; margin-bottom: 20px;
overflow: hidden; overflow: hidden;
&.el-input { &.el-input {
input { input {
height: 40px; height: 40px;
@@ -232,6 +240,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
line-height: 40px; line-height: 40px;
border-radius: 5px; border-radius: 5px;
} }
.el-input__prefix, .el-input__prefix,
.el-input__suffix { .el-input__suffix {
width: 40px; width: 40px;
@@ -242,14 +251,17 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
vertical-align: -0.25em; vertical-align: -0.25em;
} }
} }
.el-input__prefix { .el-input__prefix {
left: 0; left: 0;
} }
.el-input__suffix { .el-input__suffix {
right: 0; right: 0;
} }
} }
} }
.copy-right { .copy-right {
position: absolute; position: absolute;
bottom: 10px; bottom: 10px;
@@ -258,9 +270,11 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
color: rgb(233, 229, 229); color: rgb(233, 229, 229);
text-align: center; text-align: center;
} }
:v-deep.el-form-item--large { :v-deep.el-form-item--large {
margin-bottom: 15px; margin-bottom: 15px;
} }
.submit-btn { .submit-btn {
width: 100%; width: 100%;
margin-top: 0px; margin-top: 0px;
@@ -268,6 +282,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
background: #4d6ea1; background: #4d6ea1;
border-radius: 0; border-radius: 0;
} }
@media screen and (max-width: 720px) { @media screen and (max-width: 720px) {
.login { .login {
display: flex; display: flex;