数据字典页面开发

This commit is contained in:
aoli.qu 2021-08-23 15:15:19 +08:00
parent 491d065fde
commit 8d34b5449f
13 changed files with 694 additions and 13 deletions

45
src/api/sys/dictionary.js Normal file
View File

@ -0,0 +1,45 @@
import request from '@/utils/request'
const dictionaryApi = {
add: '/sys/dictionary/add',
get: '/sys/dictionary/get',
update: '/sys/dictionary/edit',
del: '/sys/dictionary/del',
page: '/sys/dictionary/pageList'
}
export function dictionaryAdd (params) {
return request({
url: dictionaryApi.add,
method: 'post',
data: params
})
}
export function dictionaryGet (params) {
return request({
url: dictionaryApi.get,
method: 'post',
data: params
})
}
export function dictionaryUpdate (params) {
return request({
url: dictionaryApi.update,
method: 'post',
data: params
})
}
export function dictionaryDel (params) {
return request({
url: dictionaryApi.del,
method: 'post',
data: params
})
}
export function dictionaryPage (params) {
return request({
url: dictionaryApi.page,
method: 'post',
data: params
})
}

View File

@ -0,0 +1,45 @@
import request from '@/utils/request'
const dictionaryItemApi = {
add: '/sys/dictionaryItem/add',
get: '/sys/dictionaryItem/get',
update: '/sys/dictionaryItem/edit',
del: '/sys/dictionaryItem/del',
page: '/sys/dictionaryItem/pageList'
}
export function dictionaryItemAdd (params) {
return request({
url: dictionaryItemApi.add,
method: 'post',
data: params
})
}
export function dictionaryItemGet (params) {
return request({
url: dictionaryItemApi.get,
method: 'post',
data: params
})
}
export function dictionaryItemUpdate (params) {
return request({
url: dictionaryItemApi.update,
method: 'post',
data: params
})
}
export function dictionaryItemDel (params) {
return request({
url: dictionaryItemApi.del,
method: 'post',
data: params
})
}
export function dictionaryItemPage (params) {
return request({
url: dictionaryItemApi.page,
method: 'post',
data: params
})
}

View File

@ -2,7 +2,7 @@
<global-footer class="footer custom-render"> <global-footer class="footer custom-render">
<template v-slot:links></template> <template v-slot:links></template>
<template v-slot:copyright> <template v-slot:copyright>
<a href="https://one.biz.com" target="_blank">tcc出品</a> <a href="https://one.biz.com" target="_blank">XinMei出品</a>
</template> </template>
</global-footer> </global-footer>
</template> </template>

View File

@ -56,6 +56,12 @@ export const asyncRouterMap = [
name: 'SecurityResource', name: 'SecurityResource',
component: () => import('@/views/security/resource/ResourceTree'), component: () => import('@/views/security/resource/ResourceTree'),
meta: { title: '菜单管理', keepAlive: true } meta: { title: '菜单管理', keepAlive: true }
},
{
path: '/sys/dictionary',
name: 'DictionaryList',
component: () => import('@/views/sys/dictionary/DictionaryList'),
meta: { title: '数据字段', keepAlive: true }
} }
] ]
}, },
@ -69,7 +75,7 @@ export const asyncRouterMap = [
{ {
path: '/form/base-form', path: '/form/base-form',
name: 'BaseForm', name: 'BaseForm',
component: () => import('@/views/form/basicForm/index'), component: () => import('@/views/form/basicForm/Index'),
meta: { title: '基础表单', keepAlive: true, permission: [ 'form' ] } meta: { title: '基础表单', keepAlive: true, permission: [ 'form' ] }
}, },
{ {
@ -154,7 +160,7 @@ export const asyncRouterMap = [
{ {
path: '/profile/basic', path: '/profile/basic',
name: 'ProfileBasic', name: 'ProfileBasic',
component: () => import('@/views/profile/basic/index'), component: () => import('@/views/profile/basic/Index'),
meta: { title: '基础详情页', permission: [ 'profile' ] } meta: { title: '基础详情页', permission: [ 'profile' ] }
}, },
{ {
@ -226,7 +232,7 @@ export const asyncRouterMap = [
{ {
path: '/account/center', path: '/account/center',
name: 'center', name: 'center',
component: () => import('@/views/account/center/index'), component: () => import('@/views/account/center/Index'),
meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] } meta: { title: '个人中心', keepAlive: true, permission: [ 'user' ] }
}, },
{ {
@ -373,5 +379,19 @@ export const constantRouterMap = [
{ {
path: '/404', path: '/404',
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404') component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
},
{
path: '/dictionary',
component: BasicLayout,
redirect: '/sys/dictionary',
meta: { title: '词典分类' },
children: [
{
path: 'dictionaryItem/list/:id',
name: 'DictionaryItemList',
component: () => import('@/views/sys/dictionaryItem/DictionaryItemList'),
meta: { title: '词典项', keepAlive: true, permission: [ 'dictionaryItem' ] }
} }
] ]
},
]

View File

@ -17,7 +17,7 @@
<a href="_self">条款</a> <a href="_self">条款</a>
</div> </div>
<div class="copyright"> <div class="copyright">
Copyright &copy; 2021 YinMei Copyright &copy; 2021 XinMei
</div> </div>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@ const constantRouterComponents = {
// 你需要动态引入的页面组件 // 你需要动态引入的页面组件
'Workplace': () => import('@/views/dashboard/Workplace'), 'Workplace': () => import('@/views/dashboard/Workplace'),
// form // form
'BasicForm': () => import('@/views/form/basicForm/index'), 'BasicForm': () => import('@/views/form/basicForm/Index'),
'StepForm': () => import('@/views/form/stepForm/StepForm'), 'StepForm': () => import('@/views/form/stepForm/StepForm'),
'AdvanceForm': () => import('@/views/form/advancedForm/AdvancedForm'), 'AdvanceForm': () => import('@/views/form/advancedForm/AdvancedForm'),
@ -29,7 +29,7 @@ const constantRouterComponents = {
'SearchArticles': () => import('@/views/list/search/Article'), 'SearchArticles': () => import('@/views/list/search/Article'),
'SearchProjects': () => import('@/views/list/search/Projects'), 'SearchProjects': () => import('@/views/list/search/Projects'),
'SearchApplications': () => import('@/views/list/search/Applications'), 'SearchApplications': () => import('@/views/list/search/Applications'),
'ProfileBasic': () => import('@/views/profile/basic/index'), 'ProfileBasic': () => import('@/views/profile/basic/Index'),
'ProfileAdvanced': () => import('@/views/profile/advanced/Advanced'), 'ProfileAdvanced': () => import('@/views/profile/advanced/Advanced'),
// result // result
@ -42,7 +42,7 @@ const constantRouterComponents = {
'Exception500': () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'), 'Exception500': () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
// account // account
'AccountCenter': () => import('@/views/account/center/index'), 'AccountCenter': () => import('@/views/account/center/Index'),
'AccountSettings': () => import('@/views/account/settings/Index'), 'AccountSettings': () => import('@/views/account/settings/Index'),
'BaseSettings': () => import('@/views/account/settings/BaseSetting'), 'BaseSettings': () => import('@/views/account/settings/BaseSetting'),
'SecuritySettings': () => import('@/views/account/settings/Security'), 'SecuritySettings': () => import('@/views/account/settings/Security'),

View File

@ -3,10 +3,7 @@ export const printANSI = () => {
// console.clear() // console.clear()
// ASCII - ANSI Shadow // ASCII - ANSI Shadow
let text = ` let text = `
Published ${APP_VERSION}-${GIT_HASH} @ xinmei.com
Published ${APP_VERSION}-${GIT_HASH} @ tcc.com
Build date: ${BUILD_DATE}` Build date: ${BUILD_DATE}`
console.log(`%c${text}`, 'color: #fc4d50') console.log(`%c${text}`, 'color: #fc4d50')
} }

View File

@ -0,0 +1,40 @@
<template>
<a-drawer
title="词典分类详情"
width="640"
placement="right"
:visible="visible"
@close="onClose">
<a-descriptions :column="{ sm: 2, xs: 1 }">
<a-descriptions-item label="词典名称">{{ model.dictionaryName }}</a-descriptions-item>
<a-descriptions-item label="词典标识">{{ model.dictionaryCode }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ model.createTime | moment('YYYY-MM-DD HH:mm:ss') }}</a-descriptions-item>
<a-descriptions-item label="最近修改">{{ model.updateTime | moment('YYYY-MM-DD HH:mm:ss') }}</a-descriptions-item>
</a-descriptions>
</a-drawer>
</template>
<script>
import { dictionaryGet } from '@/api/sys/dictionary'
export default {
data () {
return {
model: {},
visible: false
}
},
methods: {
show (id) {
this.visible = true
dictionaryGet({ id: id }).then(data => {
this.model = data.data
})
},
onClose () {
this.model = {}
this.visible = false
}
}
}
</script>

View File

@ -0,0 +1,98 @@
<template>
<a-drawer :visible="visible" :title="modalTitle" :width="1020" @close="onCancel">
<a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row>
<a-col :span="12">
<a-form-model-item ref="dictionaryName" label="词典名称" prop="dictionaryName">
<a-input v-model="form.dictionaryName"/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item ref="dictionaryCode" label="词典标识" prop="dictionaryCode">
<a-input v-model="form.dictionaryCode"/>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
<div class="draw-button-container align-center">
<a-button @click="onCancel">取消</a-button>
<a-button type="primary" @click="onSubmit">保存</a-button>
</div>
</a-drawer>
</template>
<script>
import { dictionaryAdd, dictionaryUpdate, dictionaryGet } from '@/api/sys/dictionary'
export default {
props: {
id: {
type: String,
default: undefined
}
},
data () {
return {
modalTitle: '新增',
visible: false,
labelCol: { span: 8 },
wrapperCol: { span: 16 },
form: {
dictionaryName: '',
dictionaryCode: '',
},
rules: {
dictionaryName: [
{ required: true, message: '请输入词典名称', trigger: 'blur' },
{ max: 25, message: '长度不能超过25', trigger: 'blur' }
],
dictionaryCode: [
{ required: true, message: '请输入词典标识', trigger: 'blur' }
]
}
}
},
methods: {
add () {
this.modalTitle = '新增'
this.visible = true
this.form.id = undefined
},
edit (obj) {
this.modalTitle = '修改'
this.visible = true
dictionaryGet({ id: obj.id }).then(data => {
const form = data.data
this.form = form
})
},
onSubmit (e) {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.form.id) {
dictionaryUpdate(this.form).then(data => {
this.$emit('ok')
this.onCancel()
})
} else {
dictionaryAdd(this.form).then(data => {
this.$emit('ok')
this.onCancel()
})
}
} else {
return false
}
})
},
onCancel () {
this.$refs.ruleForm.resetFields()
delete this.form.id
this.visible = false
},
onReset () {
this.$refs.ruleForm.resetFields()
}
}
}
</script>

View File

@ -0,0 +1,126 @@
<template>
<page-header-wrapper :title="false">
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="48">
<a-col :md="6" :sm="24">
<a-form-item label="词典名称">
<a-input v-model="queryParam.dictionaryName" placeholder="请输入词典名称" @pressEnter="handleRefresh"/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-form-item label="词典编码">
<a-input v-model="queryParam.dictionaryCode" placeholder="请输入词典编码" @pressEnter="handleRefresh"/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-button type="primary" @click="handleRefresh">查询</a-button>
<a-button @click="() => {queryParam = {}, handleRefresh()}">重置</a-button>
</a-col>
<a-col :md="6" :sm="24" align="right" >
<a-button type="primary" @click="handleCreate">新增</a-button>
</a-col>
</a-row>
</a-form>
</div>
<s-table
ref="table"
size="default"
rowKey="id"
:columns="columns"
:data="loadData"
>
<template slot="action" slot-scope="text, record">
<a href="javascript:;" @click="handleEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm title="是否删除?" @confirm="() => handleDelete(record)">
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" />
<a href="javascript:;" @click="handleDetail(record.id)">详情</a>
<a-divider type="vertical" />
<router-link :to="'/dictionary/dictionaryItem/list/' + record.id">词典项</router-link>
</template>
</s-table>
<dictionary-form ref="modal" @ok="handleOk" />
<dictionary-detail ref="detail" />
</a-card>
</page-header-wrapper>
</template>
<script>
import { dictionaryPage, dictionaryDel } from '@/api/sys/dictionary'
import { STable } from '@/components'
import DictionaryForm from './DictionaryForm'
import DictionaryDetail from './DictionaryDetail'
export default {
name: 'DictionaryList',
components: {
STable,
DictionaryForm,
DictionaryDetail
},
data () {
return {
queryParam: { dictionaryName: '', dictionaryCode: '' },
selectedRowKeys: [], // key
selectedRows: [], //
columns: [
{ title: '词典名称', width: 30, dataIndex: 'dictionaryName', key: 'dictionaryName' },
{ title: '词典编码', width: 30, dataIndex: 'dictionaryCode', key: 'dictionaryCode' },
{
title: '操作',
key: 'operation',
width: 10,
align: 'right',
scopedSlots: { customRender: 'action' }
}
],
loadData: parameter => {
return dictionaryPage(Object.assign(parameter, this.queryParam))
.then(res => {
const data = res.data
return data
})
}
}
},
computed: {
rowSelection () {
return {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange
}
}
},
methods: {
//
handleCreate () {
this.$refs.modal.add()
},
//
handleEdit (record) {
this.$refs.modal.edit(record)
},
//
handleDelete (record) {
dictionaryDel({ id: record.id }).then(() => {
this.$refs.table.refresh()
})
},
//
handleOk () {
this.$refs.table.refresh()
},
//
handleDetail (id) {
this.$refs.detail.show(id)
},
handleRefresh () {
this.$refs.table.refresh(true)
}
}
}
</script>

View File

@ -0,0 +1,48 @@
<template>
<a-drawer
title="词典项详情"
width="640"
placement="right"
:visible="visible"
@close="onClose">
<a-descriptions :column="{ sm: 2, xs: 1 }">
<a-descriptions-item label="词典项名称">{{ model.name }}</a-descriptions-item>
<a-descriptions-item label="词典项值">{{ model.value }}</a-descriptions-item>
<a-descriptions-item label="所属上级">{{ model.parentid }}</a-descriptions-item>
<a-descriptions-item label="排序">{{ model.sortid }}</a-descriptions-item>
<a-descriptions-item label="描述">{{ model.description }}</a-descriptions-item>
<a-descriptions-item label="创建时间">{{ model.createTime | moment('YYYY-MM-DD HH:mm:ss') }}</a-descriptions-item>
<a-descriptions-item label="最近修改">{{ model.updateTime | moment('YYYY-MM-DD HH:mm:ss') }}</a-descriptions-item>
</a-descriptions>
</a-drawer>
</template>
<script>
import { dictionaryItemGet } from '@/api/sys/dictionaryItem'
export default {
data () {
return {
model: {},
visible: false
}
},
filters: {
statusFilter (status) {
return statusMap[status]
}
},
methods: {
show (id) {
this.visible = true
dictionaryItemGet({ id: id }).then(data => {
this.model = data.data
})
},
onClose () {
this.model = {}
this.visible = false
}
}
}
</script>

View File

@ -0,0 +1,130 @@
<template>
<a-drawer :visible="visible" :title="modalTitle" :width="720" @close="onCancel">
<a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row>
<a-col :span="12">
<a-form-model-item ref="name" label="词典项名称" prop="name">
<a-input v-model="form.name"/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item ref="value" label="词典项值" prop="value">
<a-input v-model="form.value"/>
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="12">
<a-form-model-item ref="parentid" label="所属上级" prop="parentid">
<a-input-number v-model="form.parentid" :min="0"/>
</a-form-model-item>
</a-col>
<a-col :span="12">
<a-form-model-item ref="sortid" label="排序" prop="sortid">
<a-input-number v-model="form.sortid" :min="0"/>
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-model-item ref="description" label="描述" prop="description" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
<a-textarea :autoSize="{ minRows: 3, maxRows: 10 }" v-model="form.description"/>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
<div class="draw-button-container align-center">
<a-button @click="onCancel">取消</a-button>
<a-button type="primary" @click="onSubmit">保存</a-button>
</div>
</a-drawer>
</template>
<script>
import { dictionaryItemAdd, dictionaryItemUpdate, dictionaryItemGet } from '@/api/sys/dictionaryItem'
export default {
props: {
id: {
type: String,
default: undefined
}
},
data () {
return {
modalTitle: '新增',
visible: false,
labelCol: { span: 8 },
wrapperCol: { span: 16 },
form: {
dictionaryCode: this.$route.params.id,
name: '',
value: '',
parentid: 0,
sortid: 0,
description: ''
},
rules: {
name: [
{ required: true, message: '请输入词典项名称', trigger: 'blur' }
],
value: [
{ required: true, message: '请输入词典项值', trigger: 'blur' },
{ max: 4, message: '长度不能超过4', trigger: 'blur' }
],
parentid: [
{ required: true, message: '请输入所属上级', trigger: 'blur' }
],
sortid: [
{ required: true, message: '请输入排序', trigger: 'blur' }
]
}
}
},
methods: {
add () {
this.modalTitle = '新增'
this.visible = true
this.form.id = undefined
},
edit (obj) {
this.modalTitle = '修改'
this.visible = true
dictionaryItemGet({ id: obj.id }).then(data => {
const form = data.data
this.form = form
})
},
onSubmit (e) {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.form.id) {
dictionaryItemUpdate(this.form).then(data => {
this.$emit('ok')
this.onCancel()
})
} else {
dictionaryItemAdd(this.form).then(data => {
this.$emit('ok')
this.onCancel()
})
}
} else {
return false
}
})
},
onCancel () {
this.$refs.ruleForm.resetFields()
delete this.form.id
this.visible = false
},
onReset () {
this.$refs.ruleForm.resetFields()
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,132 @@
<template>
<page-header-wrapper :title="false">
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="48">
<a-col :md="6" :sm="24">
<a-form-item label="词典项名称">
<a-input v-model="queryParam.name" placeholder="词典项名称" @pressEnter="handleRefresh"/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-form-item label="词典项值">
<a-input v-model="queryParam.value" placeholder="请输入词典项值" @pressEnter="handleRefresh"/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-button type="primary" @click="handleRefresh">查询</a-button>
<a-button @click="() => {queryParam = { dictionaryCode: this.$route.params.id }, handleRefresh()}">重置</a-button>
</a-col>
<a-col :md="6" :sm="24" align="right" >
<a-button type="primary" @click="handleCreate">新增</a-button>
</a-col>
</a-row>
</a-form>
</div>
<s-table
ref="table"
size="default"
rowKey="id"
:columns="columns"
:data="loadData"
>
<template slot="action" slot-scope="text, record">
<a href="javascript:;" @click="handleEdit(record)">修改</a>
<a-divider type="vertical" />
<a-popconfirm title="是否删除?" @confirm="() => handleDelete(record)">
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" />
<a href="javascript:;" @click="handleDetail(record.id)">详情</a>
</template>
</s-table>
<dictionaryItem-form ref="modal" @ok="handleOk" />
<dictionaryItem-detail ref="detail" />
</a-card>
</page-header-wrapper>
</template>
<script>
import { dictionaryItemPage, dictionaryItemDel } from '@/api/sys/dictionaryItem'
import { STable } from '@/components'
import DictionaryItemForm from './DictionaryItemForm'
import DictionaryItemDetail from './DictionaryItemDetail'
export default {
name: 'DictionaryItemList',
components: {
STable,
DictionaryItemForm,
DictionaryItemDetail
},
data () {
return {
queryParam: { name: '', value: '', dictionaryCode: this.$route.params.id },
selectedRowKeys: [], // key
selectedRows: [], //
columns: [
{ title: '词典项名称', width: 30, dataIndex: 'name', key: 'name' },
{ title: '词典项值', width: 30, dataIndex: 'value', key: 'value' },
{ title: '词典标识', width: 30, dataIndex: 'dictionaryCode', key: 'dictionaryCode' },
{ title: '上级', width: 30, dataIndex: 'parentId', key: 'parentId' },
{ title: '排序', width: 30, dataIndex: 'sortid', key: 'sortid' },
{
title: '操作',
key: 'operation',
width: 10,
align: 'right',
scopedSlots: { customRender: 'action' }
}
],
loadData: parameter => {
return dictionaryItemPage(Object.assign(parameter, this.queryParam))
.then(res => {
const data = res.data
return data
})
}
}
},
computed: {
rowSelection () {
return {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange
}
}
},
methods: {
//
handleCreate () {
this.$refs.modal.add()
},
//
handleEdit (record) {
this.$refs.modal.edit(record)
},
//
handleDelete (record) {
dictionaryItemDel({ id: record.id }).then(() => {
this.$refs.table.refresh()
})
},
//
handleOk () {
this.$refs.table.refresh()
},
//
handleDetail (id) {
this.$refs.detail.show(id)
},
handleRefresh () {
this.$refs.table.refresh(true)
},
//
onSelectChange (selectedRowKeys, selectedRows) {
this.selectedRowKeys = selectedRowKeys
this.selectedRows = selectedRows
}
}
}
</script>