重构:完善配置管理的删除功能

This commit is contained in:
YunaiV 2023-03-10 08:04:14 +08:00
parent 5c675995cb
commit faaa47abdc
3 changed files with 27 additions and 8 deletions

View File

@ -30,7 +30,7 @@ export const getConfig = (id: number) => {
} }
// 根据参数键名查询参数值 // 根据参数键名查询参数值
export const getConfigKeyApi = (configKey: string) => { export const getConfigKey = (configKey: string) => {
return request.get({ url: '/infra/config/get-value-by-key?key=' + configKey }) return request.get({ url: '/infra/config/get-value-by-key?key=' + configKey })
} }
@ -45,7 +45,7 @@ export const updateConfig = (data: ConfigVO) => {
} }
// 删除参数 // 删除参数
export const deleteConfigApi = (id: number) => { export const deleteConfig = (id: number) => {
return request.delete({ url: '/infra/config/delete?id=' + id }) return request.delete({ url: '/infra/config/delete?id=' + id })
} }

View File

@ -45,7 +45,7 @@ const message = useMessage() // 消息弹窗
const modelVisible = ref(false) // const modelVisible = ref(false) //
const modelTitle = ref('') // const modelTitle = ref('') //
const formLoading = ref(false) // Loading 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = reactive({ const formData = reactive({
id: undefined, id: undefined,

View File

@ -59,7 +59,6 @@
<!-- 操作栏 --> <!-- 操作栏 -->
<!-- TODO 间隔貌似有点问题 没发现 --> <!-- TODO 间隔貌似有点问题 没发现 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<!-- TODO 芋艿图标不对 已解决 -->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
@ -72,13 +71,17 @@
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="success"
plain
@click="handleExport" @click="handleExport"
:loading="exportLoading" :loading="exportLoading"
v-hasPermi="['infra:config:export']" v-hasPermi="['infra:config:export']"
> >
<Icon icon="ep:download" class="mr-5px" /> 导出 <Icon icon="ep:download" class="mr-5px" /> 导出
</el-button> </el-button>
<el-button text @click="showSearch = !showSearch">
<Icon :icon="showSearch ? 'ep:arrow-up' : 'ep:arrow-down'" />
</el-button>
</el-col> </el-col>
<!-- TODO 芋艿右侧导航 --> <!-- TODO 芋艿右侧导航 -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" /> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
@ -123,7 +126,7 @@
<el-button <el-button
link link
type="primary" type="primary"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row.id)"
v-hasPermi="['infra:config:delete']" v-hasPermi="['infra:config:delete']"
> >
<Icon icon="ep:delete" /> 删除 <Icon icon="ep:delete" /> 删除
@ -137,11 +140,13 @@
<config-form ref="modalRef" @success="getList" /> <config-form ref="modalRef" @success="getList" />
</template> </template>
<script setup lang="ts" name="Config"> <script setup lang="ts" name="Config">
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import * as ConfigApi from '@/api/infra/config' import * as ConfigApi from '@/api/infra/config'
import ConfigForm from './form.vue' import ConfigForm from './form.vue'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
// import { Delete, Edit, Search, Download, Plus, Refresh } from '@element-plus/icons-vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
const message = useMessage() //
const { t } = useI18n() //
const showSearch = ref(true) // const showSearch = ref(true) //
const loading = ref(true) // const loading = ref(true) //
const total = ref(0) // const total = ref(0) //
@ -155,6 +160,7 @@ const queryParams = reactive({
createTime: [] createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -186,6 +192,19 @@ const openModal = (type: string, id?: number) => {
modalRef.value.openModal(type, id) modalRef.value.openModal(type, id)
} }
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ConfigApi.deleteConfig(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()