Vue3 重构:Review 字典数据界面
This commit is contained in:
parent
2b52683e3c
commit
40bd2c57f8
@ -1,36 +1,49 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
import type { DictDataVO, DictDataPageReqVO, DictDataExportReqVO } from './types'
|
|
||||||
|
export type DictDataVO = {
|
||||||
|
id: number | undefined
|
||||||
|
sort: number | undefined
|
||||||
|
label: string
|
||||||
|
value: string
|
||||||
|
dictType: string
|
||||||
|
status: number
|
||||||
|
colorType: string
|
||||||
|
cssClass: string
|
||||||
|
remark: string
|
||||||
|
createTime: Date
|
||||||
|
}
|
||||||
|
|
||||||
// 查询字典数据(精简)列表
|
// 查询字典数据(精简)列表
|
||||||
export const listSimpleDictDataApi = () => {
|
export const listSimpleDictData = () => {
|
||||||
return request.get({ url: '/system/dict-data/list-all-simple' })
|
return request.get({ url: '/system/dict-data/list-all-simple' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询字典数据列表
|
// 查询字典数据列表
|
||||||
export const getDictDataPageApi = (params: DictDataPageReqVO) => {
|
export const getDictDataPage = (params: PageParam) => {
|
||||||
return request.get({ url: '/system/dict-data/page', params })
|
return request.get({ url: '/system/dict-data/page', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询字典数据详情
|
// 查询字典数据详情
|
||||||
export const getDictDataApi = (id: number) => {
|
export const getDictData = (id: number) => {
|
||||||
return request.get({ url: '/system/dict-data/get?id=' + id })
|
return request.get({ url: '/system/dict-data/get?id=' + id })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增字典数据
|
// 新增字典数据
|
||||||
export const createDictDataApi = (data: DictDataVO) => {
|
export const createDictData = (data: DictDataVO) => {
|
||||||
return request.post({ url: '/system/dict-data/create', data })
|
return request.post({ url: '/system/dict-data/create', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改字典数据
|
// 修改字典数据
|
||||||
export const updateDictDataApi = (data: DictDataVO) => {
|
export const updateDictData = (data: DictDataVO) => {
|
||||||
return request.put({ url: '/system/dict-data/update', data })
|
return request.put({ url: '/system/dict-data/update', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除字典数据
|
// 删除字典数据
|
||||||
export const deleteDictDataApi = (id: number) => {
|
export const deleteDictData = (id: number) => {
|
||||||
return request.delete({ url: '/system/dict-data/delete?id=' + id })
|
return request.delete({ url: '/system/dict-data/delete?id=' + id })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出字典类型数据
|
// 导出字典类型数据
|
||||||
export const exportDictDataApi = (params: DictDataExportReqVO) => {
|
export const exportDictDataApi = (params) => {
|
||||||
return request.get({ url: '/system/dict-data/export', params })
|
return request.get({ url: '/system/dict-data/export', params })
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,44 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
import type { DictTypeVO, DictTypePageReqVO, DictTypeExportReqVO } from './types'
|
|
||||||
|
export type DictTypeVO = {
|
||||||
|
id: number | undefined
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
status: number
|
||||||
|
remark: string
|
||||||
|
createTime: Date
|
||||||
|
}
|
||||||
|
|
||||||
// 查询字典(精简)列表
|
// 查询字典(精简)列表
|
||||||
export const listSimpleDictTypeApi = () => {
|
export const listSimpleDictType = () => {
|
||||||
return request.get({ url: '/system/dict-type/list-all-simple' })
|
return request.get({ url: '/system/dict-type/list-all-simple' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询字典列表
|
// 查询字典列表
|
||||||
export const getDictTypePageApi = (params: DictTypePageReqVO) => {
|
export const getDictTypePage = (params: PageParam) => {
|
||||||
return request.get({ url: '/system/dict-type/page', params })
|
return request.get({ url: '/system/dict-type/page', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询字典详情
|
// 查询字典详情
|
||||||
export const getDictTypeApi = (id: number) => {
|
export const getDictType = (id: number) => {
|
||||||
return request.get({ url: '/system/dict-type/get?id=' + id })
|
return request.get({ url: '/system/dict-type/get?id=' + id })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增字典
|
// 新增字典
|
||||||
export const createDictTypeApi = (data: DictTypeVO) => {
|
export const createDictType = (data: DictTypeVO) => {
|
||||||
return request.post({ url: '/system/dict-type/create', data })
|
return request.post({ url: '/system/dict-type/create', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改字典
|
// 修改字典
|
||||||
export const updateDictTypeApi = (data: DictTypeVO) => {
|
export const updateDictType = (data: DictTypeVO) => {
|
||||||
return request.put({ url: '/system/dict-type/update', data })
|
return request.put({ url: '/system/dict-type/update', data })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除字典
|
// 删除字典
|
||||||
export const deleteDictTypeApi = (id: number) => {
|
export const deleteDictType = (id: number) => {
|
||||||
return request.delete({ url: '/system/dict-type/delete?id=' + id })
|
return request.delete({ url: '/system/dict-type/delete?id=' + id })
|
||||||
}
|
}
|
||||||
// 导出字典类型
|
// 导出字典类型
|
||||||
export const exportDictTypeApi = (params: DictTypeExportReqVO) => {
|
export const exportDictType = (params) => {
|
||||||
return request.get({ url: '/system/dict-type/export', params })
|
return request.get({ url: '/system/dict-type/export', params })
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
export type DictTypeVO = {
|
|
||||||
id: number | undefined
|
|
||||||
name: string
|
|
||||||
type: string
|
|
||||||
status: number | undefined
|
|
||||||
remark: string
|
|
||||||
createTime: Date
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DictTypePageReqVO = {
|
|
||||||
pageNo: number
|
|
||||||
pageSize: number
|
|
||||||
name: string
|
|
||||||
type: string
|
|
||||||
status: number | undefined
|
|
||||||
createTime: Date[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DictTypeExportReqVO = {
|
|
||||||
name: string
|
|
||||||
type: string
|
|
||||||
status: number
|
|
||||||
createTime: Date[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DictDataVO = {
|
|
||||||
id: number | undefined
|
|
||||||
sort: number | undefined
|
|
||||||
label: string
|
|
||||||
value: string
|
|
||||||
dictType: string
|
|
||||||
status: number
|
|
||||||
colorType: string
|
|
||||||
cssClass: string
|
|
||||||
remark: string
|
|
||||||
createTime: Date | undefined
|
|
||||||
}
|
|
||||||
export type DictDataPageReqVO = {
|
|
||||||
pageNo: number
|
|
||||||
pageSize: number
|
|
||||||
label: string
|
|
||||||
dictType: string
|
|
||||||
status: number | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
export type DictDataExportReqVO = {
|
|
||||||
label: string
|
|
||||||
dictType: string
|
|
||||||
status: number
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ import { store } from '../index'
|
|||||||
import { DictDataVO } from '@/api/system/dict/types'
|
import { DictDataVO } from '@/api/system/dict/types'
|
||||||
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
||||||
const { wsCache } = useCache('sessionStorage')
|
const { wsCache } = useCache('sessionStorage')
|
||||||
import { listSimpleDictDataApi } from '@/api/system/dict/dict.data'
|
import { listSimpleDictData } from '@/api/system/dict/dict.data'
|
||||||
|
|
||||||
export interface DictValueType {
|
export interface DictValueType {
|
||||||
value: any
|
value: any
|
||||||
@ -44,7 +44,7 @@ export const useDictStore = defineStore('dict', {
|
|||||||
this.dictMap = dictMap
|
this.dictMap = dictMap
|
||||||
this.isSetDict = true
|
this.isSetDict = true
|
||||||
} else {
|
} else {
|
||||||
const res = await listSimpleDictDataApi()
|
const res = await listSimpleDictData()
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const dictDataMap = new Map<string, any>()
|
const dictDataMap = new Map<string, any>()
|
||||||
res.forEach((dictData: DictDataVO) => {
|
res.forEach((dictData: DictDataVO) => {
|
||||||
@ -74,7 +74,7 @@ export const useDictStore = defineStore('dict', {
|
|||||||
},
|
},
|
||||||
async resetDict() {
|
async resetDict() {
|
||||||
wsCache.delete(CACHE_KEY.DICT_CACHE)
|
wsCache.delete(CACHE_KEY.DICT_CACHE)
|
||||||
const res = await listSimpleDictDataApi()
|
const res = await listSimpleDictData()
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const dictDataMap = new Map<string, any>()
|
const dictDataMap = new Map<string, any>()
|
||||||
res.forEach((dictData: DictDataVO) => {
|
res.forEach((dictData: DictDataVO) => {
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
import { PropType } from 'vue'
|
import { PropType } from 'vue'
|
||||||
import { DictTypeVO } from '@/api/system/dict/types'
|
import { DictTypeVO } from '@/api/system/dict/types'
|
||||||
import { CodegenColumnVO } from '@/api/infra/codegen/types'
|
import { CodegenColumnVO } from '@/api/infra/codegen/types'
|
||||||
import { listSimpleDictTypeApi } from '@/api/system/dict/dict.type'
|
import { listSimpleDictType } from '@/api/system/dict/dict.type'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
info: {
|
info: {
|
||||||
@ -125,7 +125,7 @@ const props = defineProps({
|
|||||||
/** 查询字典下拉列表 */
|
/** 查询字典下拉列表 */
|
||||||
const dictOptions = ref<DictTypeVO[]>()
|
const dictOptions = ref<DictTypeVO[]>()
|
||||||
const getDictOptions = async () => {
|
const getDictOptions = async () => {
|
||||||
const res = await listSimpleDictTypeApi()
|
const res = await listSimpleDictType()
|
||||||
dictOptions.value = res
|
dictOptions.value = res
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
<el-form-item label="数据标签" prop="label">
|
<el-form-item label="数据标签" prop="label">
|
||||||
<el-input v-model="formData.label" placeholder="请输入数据标签" />
|
<el-input v-model="formData.label" placeholder="请输入数据标签" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="数据键值" prop="value">
|
<el-form-item label="数据键值" prop="value">
|
||||||
<el-input v-model="formData.value" placeholder="请输入数据键值" />
|
<el-input v-model="formData.value" placeholder="请输入数据键值" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -61,9 +60,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
||||||
|
|
||||||
import * as DictDataApi from '@/api/system/dict/dict.data'
|
import * as DictDataApi from '@/api/system/dict/dict.data'
|
||||||
import { DictDataVO } from '@/api/system/dict/types'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
@ -73,15 +71,14 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
|
|||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
sort: 0,
|
sort: undefined,
|
||||||
label: '',
|
label: '',
|
||||||
value: '',
|
value: '',
|
||||||
dictType: '',
|
dictType: '',
|
||||||
status: 0,
|
status: CommonStatusEnum.ENABLE,
|
||||||
colorType: '',
|
colorType: '',
|
||||||
cssClass: '',
|
cssClass: '',
|
||||||
remark: '',
|
remark: ''
|
||||||
createTime: undefined
|
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
label: [{ required: true, message: '数据标签不能为空', trigger: 'blur' }],
|
label: [{ required: true, message: '数据标签不能为空', trigger: 'blur' }],
|
||||||
@ -91,7 +88,6 @@ const formRules = reactive({
|
|||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
// 数据标签回显样式
|
// 数据标签回显样式
|
||||||
|
|
||||||
const colorTypeOptions = readonly([
|
const colorTypeOptions = readonly([
|
||||||
{
|
{
|
||||||
value: 'default',
|
value: 'default',
|
||||||
@ -129,7 +125,7 @@ const openModal = async (type: string, id?: number) => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
formData.value = await DictDataApi.getDictDataApi(id)
|
formData.value = await DictDataApi.getDictData(id)
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
@ -147,12 +143,12 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formData.value as DictDataVO
|
const data = formData.value as DictDataApi.DictDataVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await DictDataApi.createDictDataApi(data)
|
await DictDataApi.createDictData(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await DictDataApi.updateDictDataApi(data)
|
await DictDataApi.updateDictData(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
modelVisible.value = false
|
modelVisible.value = false
|
||||||
@ -171,11 +167,10 @@ const resetForm = () => {
|
|||||||
label: '',
|
label: '',
|
||||||
value: '',
|
value: '',
|
||||||
dictType: '',
|
dictType: '',
|
||||||
status: 0,
|
status: CommonStatusEnum.ENABLE,
|
||||||
colorType: '',
|
colorType: '',
|
||||||
cssClass: '',
|
cssClass: '',
|
||||||
remark: '',
|
remark: ''
|
||||||
createTime: undefined
|
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<content-wrap>
|
<content-wrap>
|
||||||
<el-form :model="queryParams" ref="queryFormRef" size="small" :inline="true" label-width="68px">
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
<el-form-item label="字典名称" prop="dictType">
|
<el-form-item label="字典名称" prop="dictType">
|
||||||
<el-select v-model="queryParams.dictType">
|
<el-select v-model="queryParams.dictType">
|
||||||
<el-option
|
<el-option
|
||||||
@ -46,7 +52,10 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</content-wrap>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
|
<content-wrap>
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list">
|
||||||
<el-table-column label="字典编码" align="center" prop="id" />
|
<el-table-column label="字典编码" align="center" prop="id" />
|
||||||
<el-table-column label="字典标签" align="center" prop="label" />
|
<el-table-column label="字典标签" align="center" prop="label" />
|
||||||
@ -59,12 +68,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="颜色类型" align="center" prop="colorType" />
|
<el-table-column label="颜色类型" align="center" prop="colorType" />
|
||||||
<el-table-column label="CSS Class" align="center" prop="cssClass" />
|
<el-table-column label="CSS Class" align="center" prop="cssClass" />
|
||||||
<el-table-column
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
label="备注"
|
|
||||||
align="center"
|
|
||||||
prop="remark"
|
|
||||||
:show-overflow-tooltip="tableTooltipConfig"
|
|
||||||
/>
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="创建时间"
|
label="创建时间"
|
||||||
align="center"
|
align="center"
|
||||||
@ -72,21 +76,28 @@
|
|||||||
width="180"
|
width="180"
|
||||||
:formatter="dateFormatter"
|
:formatter="dateFormatter"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
|
type="primary"
|
||||||
@click="openModal('update', scope.row.id)"
|
@click="openModal('update', scope.row.id)"
|
||||||
v-hasPermi="['system:dict:update']"
|
v-hasPermi="['system:dict:update']"
|
||||||
><Icon icon="ic:outline-mode" class="mr-5px" />修改</el-button
|
|
||||||
>
|
>
|
||||||
<el-button link @click="handleDelete(scope.row.id)" v-hasPermi="['system:dict:delete']"
|
修改
|
||||||
><Icon icon="material-symbols:delete-forever-sharp" class="mr-5px" />删除</el-button
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['system:dict:delete']"
|
||||||
>
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
<Pagination
|
<Pagination
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:page="queryParams.pageNo"
|
||||||
@ -94,30 +105,24 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</content-wrap>
|
</content-wrap>
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<data-form ref="modalRef" @success="getList" />
|
<data-form ref="modalRef" @success="getList" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="Data">
|
<script setup lang="ts" name="Data">
|
||||||
import * as DictDataApi from '@/api/system/dict/dict.data'
|
import * as DictDataApi from '@/api/system/dict/dict.data'
|
||||||
import { listSimpleDictTypeApi } from '@/api/system/dict/dict.type'
|
import * as DictTypeApi from '@/api/system/dict/dict.data'
|
||||||
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import DataForm from './data.form.vue'
|
import DataForm from './data.form.vue'
|
||||||
import { DictTypeVO } from '@/api/system/dict/types'
|
import type { DictTypeVO } from '@/api/system/dict/dict.type'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
const route = useRoute() // 路由
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
const simpleDictList = ref<DictTypeVO[]>()
|
const simpleDictList = ref<DictTypeVO[]>()
|
||||||
|
|
||||||
const tableTooltipConfig = readonly({
|
|
||||||
appendTo: 'body'
|
|
||||||
})
|
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
const list = ref([]) // 列表的数据
|
const list = ref([]) // 列表的数据
|
||||||
@ -135,18 +140,13 @@ const exportLoading = ref(false) // 导出的加载中
|
|||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await DictDataApi.getDictDataPageApi(queryParams)
|
const data = await DictDataApi.getDictDataPage(queryParams)
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 查询字典(精简)列表
|
|
||||||
const getSimpleDictList = async () => {
|
|
||||||
const data = await listSimpleDictTypeApi()
|
|
||||||
simpleDictList.value = data
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
@ -172,7 +172,7 @@ const handleDelete = async (id: number) => {
|
|||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
// 发起删除
|
// 发起删除
|
||||||
await DictDataApi.deleteDictDataApi(id)
|
await DictDataApi.deleteDictData(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
@ -194,10 +194,15 @@ const handleExport = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 查询字典(精简)列表 */
|
||||||
|
const getSimpleDictList = async () => {
|
||||||
|
simpleDictList.value = await DictTypeApi.listSimpleDictData()
|
||||||
|
}
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList()
|
getList()
|
||||||
})
|
|
||||||
// 查询字典(精简)列表
|
// 查询字典(精简)列表
|
||||||
getSimpleDictList()
|
getSimpleDictList()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
||||||
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
||||||
import { DictTypeVO } from '@/api/system/dict/types'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ const formData = ref({
|
|||||||
id: undefined,
|
id: undefined,
|
||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
status: 0,
|
status: CommonStatusEnum.ENABLE,
|
||||||
remark: ''
|
remark: ''
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
@ -74,7 +75,7 @@ const openModal = async (type: string, id?: number) => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
formData.value = await DictTypeApi.getDictTypeApi(id)
|
formData.value = await DictTypeApi.getDictType(id)
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
@ -92,12 +93,12 @@ const submitForm = async () => {
|
|||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formData.value as DictTypeVO
|
const data = formData.value as DictTypeApi.DictTypeVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await DictTypeApi.createDictTypeApi(data)
|
await DictTypeApi.createDictType(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await DictTypeApi.updateDictTypeApi(data)
|
await DictTypeApi.updateDictType(data)
|
||||||
message.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
modelVisible.value = false
|
modelVisible.value = false
|
||||||
@ -114,7 +115,7 @@ const resetForm = () => {
|
|||||||
id: undefined,
|
id: undefined,
|
||||||
type: '',
|
type: '',
|
||||||
name: '',
|
name: '',
|
||||||
status: undefined,
|
status: CommonStatusEnum.ENABLE,
|
||||||
remark: ''
|
remark: ''
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
<content-wrap>
|
<content-wrap>
|
||||||
<el-form :model="queryParams" ref="queryFormRef" size="small" :inline="true" label-width="68px">
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
<el-form-item label="字典名称" prop="name">
|
<el-form-item label="字典名称" prop="name">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.name"
|
v-model="queryParams.name"
|
||||||
@ -63,20 +70,14 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</content-wrap>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
|
<content-wrap>
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list">
|
||||||
<el-table-column label="字典编号" align="center" prop="id" />
|
<el-table-column label="字典编号" align="center" prop="id" />
|
||||||
<el-table-column label="字典名称" align="center" prop="name" show-overflow-tooltip />
|
<el-table-column label="字典名称" align="center" prop="name" show-overflow-tooltip />
|
||||||
<el-table-column label="字典类型" align="center" show-overflow-tooltip>
|
<el-table-column label="字典类型" align="center" prop="type" width="300" />
|
||||||
<template #default="scope">
|
|
||||||
<div>
|
|
||||||
<router-link :to="'/dict/type/data/' + scope.row.type">
|
|
||||||
<span>{{ scope.row.type }}</span>
|
|
||||||
</router-link>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="状态" align="center" prop="status">
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
@ -90,22 +91,31 @@
|
|||||||
prop="createTime"
|
prop="createTime"
|
||||||
width="180"
|
width="180"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
|
type="primary"
|
||||||
@click="openModal('update', scope.row.id)"
|
@click="openModal('update', scope.row.id)"
|
||||||
v-hasPermi="['system:dict:update']"
|
v-hasPermi="['system:dict:update']"
|
||||||
><Icon icon="ic:outline-mode" class="mr-5px" />修改</el-button
|
|
||||||
>
|
>
|
||||||
<el-button link @click="handleDelete(scope.row.id)" v-hasPermi="['system:dict:delete']"
|
修改
|
||||||
><Icon icon="material-symbols:delete-forever-sharp" class="mr-5px" />删除</el-button
|
</el-button>
|
||||||
|
<router-link :to="'/dict/type/data/' + scope.row.type">
|
||||||
|
<el-button link type="primary">数据</el-button>
|
||||||
|
</router-link>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['system:dict:delete']"
|
||||||
>
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
<Pagination
|
<Pagination
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNo"
|
v-model:page="queryParams.pageNo"
|
||||||
@ -113,25 +123,24 @@
|
|||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</content-wrap>
|
</content-wrap>
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<dict-type-form ref="modalRef" @success="getList" />
|
<dict-type-form ref="modalRef" @success="getList" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="Dict">
|
<script setup lang="ts" name="Dict">
|
||||||
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
|
||||||
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
||||||
import DictTypeForm from './form.vue'
|
import DictTypeForm from './form.vue'
|
||||||
import { DictTypePageReqVO } from '@/api/system/dict/types'
|
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
const total = ref(0) // 列表的总页数
|
const total = ref(0) // 列表的总页数
|
||||||
|
|
||||||
const list = ref([]) // 字典表格数据
|
const list = ref([]) // 字典表格数据
|
||||||
const queryParams = reactive<DictTypePageReqVO>({
|
const queryParams = reactive({
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
name: '',
|
name: '',
|
||||||
@ -146,7 +155,7 @@ const exportLoading = ref(false) // 导出的加载中
|
|||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await DictTypeApi.getDictTypePageApi(queryParams)
|
const data = await DictTypeApi.getDictTypePage(queryParams)
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
} finally {
|
} finally {
|
||||||
@ -178,7 +187,7 @@ const handleDelete = async (id: number) => {
|
|||||||
// 删除的二次确认
|
// 删除的二次确认
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
// 发起删除
|
// 发起删除
|
||||||
await DictTypeApi.deleteDictTypeApi(id)
|
await DictTypeApi.deleteDictType(id)
|
||||||
message.success(t('common.delSuccess'))
|
message.success(t('common.delSuccess'))
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await getList()
|
await getList()
|
||||||
@ -192,7 +201,7 @@ const handleExport = async () => {
|
|||||||
await message.exportConfirm()
|
await message.exportConfirm()
|
||||||
// 发起导出
|
// 发起导出
|
||||||
exportLoading.value = true
|
exportLoading.value = true
|
||||||
const data = await DictTypeApi.exportDictTypeApi(queryParams)
|
const data = await DictTypeApi.exportDictType(queryParams)
|
||||||
download.excel(data, '字典类型.xls')
|
download.excel(data, '字典类型.xls')
|
||||||
} catch {
|
} catch {
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user