2023-02-11 00:44:00 +08:00
|
|
|
|
<template>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
<!-- 搜索工作栏 -->
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<content-wrap>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
<el-form
|
|
|
|
|
class="-mb-15px"
|
|
|
|
|
:model="queryParams"
|
|
|
|
|
ref="queryFormRef"
|
|
|
|
|
:inline="true"
|
|
|
|
|
label-width="68px"
|
|
|
|
|
>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<el-form-item label="字典名称" prop="name">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.name"
|
|
|
|
|
placeholder="请输入字典名称"
|
|
|
|
|
clearable
|
|
|
|
|
@keyup.enter="handleQuery"
|
2023-03-20 00:20:24 +08:00
|
|
|
|
class="!w-240px"
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="字典类型" prop="type">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.type"
|
|
|
|
|
placeholder="请输入字典类型"
|
|
|
|
|
clearable
|
|
|
|
|
@keyup.enter="handleQuery"
|
2023-03-20 00:20:24 +08:00
|
|
|
|
class="!w-240px"
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="状态" prop="status">
|
2023-03-20 00:20:24 +08:00
|
|
|
|
<el-select v-model="queryParams.status" placeholder="字典状态" clearable class="!w-240px">
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
|
|
|
|
|
:key="parseInt(dict.value)"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value"
|
2023-02-11 00:44:00 +08:00
|
|
|
|
/>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="创建时间" prop="createTime">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="queryParams.createTime"
|
|
|
|
|
value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
type="daterange"
|
|
|
|
|
start-placeholder="开始日期"
|
|
|
|
|
end-placeholder="结束日期"
|
|
|
|
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
2023-03-20 00:20:24 +08:00
|
|
|
|
class="!w-240px"
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
|
|
|
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
2023-04-02 23:52:56 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
plain
|
|
|
|
|
@click="openModal('create')"
|
|
|
|
|
v-hasPermi="['system:dict:create']"
|
|
|
|
|
>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="success"
|
|
|
|
|
plain
|
|
|
|
|
@click="handleExport"
|
|
|
|
|
:loading="exportLoading"
|
|
|
|
|
v-hasPermi="['system:dict:export']"
|
|
|
|
|
>
|
|
|
|
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
</content-wrap>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
|
2023-03-19 22:14:55 +08:00
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<content-wrap>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<el-table v-loading="loading" :data="list">
|
|
|
|
|
<el-table-column label="字典编号" align="center" prop="id" />
|
|
|
|
|
<el-table-column label="字典名称" align="center" prop="name" show-overflow-tooltip />
|
2023-03-19 22:14:55 +08:00
|
|
|
|
<el-table-column label="字典类型" align="center" prop="type" width="300" />
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="备注" align="center" prop="remark" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
label="创建时间"
|
|
|
|
|
:formatter="dateFormatter"
|
|
|
|
|
align="center"
|
|
|
|
|
prop="createTime"
|
|
|
|
|
width="180"
|
2023-02-11 00:44:00 +08:00
|
|
|
|
/>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<el-table-column label="操作" align="center">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-button
|
|
|
|
|
link
|
2023-03-19 22:14:55 +08:00
|
|
|
|
type="primary"
|
2023-03-19 16:48:27 +08:00
|
|
|
|
@click="openModal('update', scope.row.id)"
|
|
|
|
|
v-hasPermi="['system:dict:update']"
|
|
|
|
|
>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
修改
|
|
|
|
|
</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']"
|
2023-03-19 16:48:27 +08:00
|
|
|
|
>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
<!-- 分页 -->
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<Pagination
|
|
|
|
|
:total="total"
|
|
|
|
|
v-model:page="queryParams.pageNo"
|
|
|
|
|
v-model:limit="queryParams.pageSize"
|
|
|
|
|
@pagination="getList"
|
|
|
|
|
/>
|
|
|
|
|
</content-wrap>
|
2023-03-19 22:14:55 +08:00
|
|
|
|
|
2023-03-19 16:48:27 +08:00
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
|
|
<dict-type-form ref="modalRef" @success="getList" />
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
2023-03-19 16:48:27 +08:00
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
|
<script setup lang="ts" name="Dict">
|
2023-03-19 16:48:27 +08:00
|
|
|
|
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
|
|
|
|
|
import { dateFormatter } from '@/utils/formatTime'
|
2023-03-19 22:14:55 +08:00
|
|
|
|
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
2023-03-19 16:48:27 +08:00
|
|
|
|
import DictTypeForm from './form.vue'
|
|
|
|
|
import download from '@/utils/download'
|
2023-02-11 00:44:00 +08:00
|
|
|
|
const message = useMessage() // 消息弹窗
|
2023-03-19 16:48:27 +08:00
|
|
|
|
const { t } = useI18n() // 国际化
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2023-03-19 16:48:27 +08:00
|
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
|
const list = ref([]) // 字典表格数据
|
2023-03-19 22:14:55 +08:00
|
|
|
|
const queryParams = reactive({
|
2023-03-19 16:48:27 +08:00
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
name: '',
|
|
|
|
|
type: '',
|
|
|
|
|
status: undefined,
|
|
|
|
|
createTime: []
|
2023-02-11 00:44:00 +08:00
|
|
|
|
})
|
2023-03-19 16:48:27 +08:00
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
|
|
|
|
|
|
|
/** 查询字典类型列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2023-03-19 22:14:55 +08:00
|
|
|
|
const data = await DictTypeApi.getDictTypePage(queryParams)
|
2023-03-19 16:48:27 +08:00
|
|
|
|
list.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2023-03-19 16:48:27 +08:00
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
getList()
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
const resetQuery = () => {
|
|
|
|
|
queryFormRef.value.resetFields()
|
|
|
|
|
handleQuery()
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2023-03-19 16:48:27 +08:00
|
|
|
|
|
|
|
|
|
/** 添加/修改操作 */
|
|
|
|
|
const modalRef = ref()
|
|
|
|
|
const openModal = (type: string, id?: number) => {
|
|
|
|
|
modalRef.value.openModal(type, id)
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2023-03-19 16:48:27 +08:00
|
|
|
|
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (id: number) => {
|
|
|
|
|
try {
|
|
|
|
|
// 删除的二次确认
|
|
|
|
|
await message.delConfirm()
|
|
|
|
|
// 发起删除
|
2023-03-19 22:14:55 +08:00
|
|
|
|
await DictTypeApi.deleteDictType(id)
|
2023-03-19 16:48:27 +08:00
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getList()
|
|
|
|
|
} catch {}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
const handleExport = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 导出的二次确认
|
|
|
|
|
await message.exportConfirm()
|
|
|
|
|
// 发起导出
|
|
|
|
|
exportLoading.value = true
|
2023-03-19 22:14:55 +08:00
|
|
|
|
const data = await DictTypeApi.exportDictType(queryParams)
|
2023-03-19 16:48:27 +08:00
|
|
|
|
download.excel(data, '字典类型.xls')
|
|
|
|
|
} catch {
|
|
|
|
|
} finally {
|
|
|
|
|
exportLoading.value = false
|
|
|
|
|
}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-19 16:48:27 +08:00
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getList()
|
2023-02-12 22:15:20 +08:00
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</script>
|