Skip to content

Commit faaa47a

Browse files
committed
重构:完善配置管理的删除功能
1 parent 5c67599 commit faaa47a

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/api/infra/config/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const getConfig = (id: number) => {
3030
}
3131

3232
// 根据参数键名查询参数值
33-
export const getConfigKeyApi = (configKey: string) => {
33+
export const getConfigKey = (configKey: string) => {
3434
return request.get({ url: '/infra/config/get-value-by-key?key=' + configKey })
3535
}
3636

@@ -45,7 +45,7 @@ export const updateConfig = (data: ConfigVO) => {
4545
}
4646

4747
// 删除参数
48-
export const deleteConfigApi = (id: number) => {
48+
export const deleteConfig = (id: number) => {
4949
return request.delete({ url: '/infra/config/delete?id=' + id })
5050
}
5151

src/views/infra/config/form.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const message = useMessage() // 消息弹窗
4545
4646
const modelVisible = ref(false) // 弹窗的是否展示
4747
const modelTitle = ref('') // 弹窗的标题
48-
const formLoading = ref(false) // 表单的 Loading 加载:1)修改时的数据加载;2)提交的按钮禁用
48+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
4949
const formType = ref('') // 表单的类型:create - 新增;update - 修改
5050
const formData = reactive({
5151
id: undefined,

src/views/infra/config/index.vue

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
<!-- 操作栏 -->
6060
<!-- TODO 间隔貌似有点问题 没发现 -->
6161
<el-row :gutter="10" class="mb8">
62-
<!-- TODO 芋艿,图标不对 已解决 -->
6362
<el-col :span="1.5">
6463
<el-button
6564
type="primary"
@@ -72,13 +71,17 @@
7271
</el-col>
7372
<el-col :span="1.5">
7473
<el-button
75-
type="warning"
74+
type="success"
75+
plain
7676
@click="handleExport"
7777
:loading="exportLoading"
7878
v-hasPermi="['infra:config:export']"
7979
>
8080
<Icon icon="ep:download" class="mr-5px" /> 导出
8181
</el-button>
82+
<el-button text @click="showSearch = !showSearch">
83+
<Icon :icon="showSearch ? 'ep:arrow-up' : 'ep:arrow-down'" />
84+
</el-button>
8285
</el-col>
8386
<!-- TODO 芋艿:右侧导航 -->
8487
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
@@ -123,7 +126,7 @@
123126
<el-button
124127
link
125128
type="primary"
126-
@click="handleDelete(scope.row)"
129+
@click="handleDelete(scope.row.id)"
127130
v-hasPermi="['infra:config:delete']"
128131
>
129132
<Icon icon="ep:delete" /> 删除
@@ -137,11 +140,13 @@
137140
<config-form ref="modalRef" @success="getList" />
138141
</template>
139142
<script setup lang="ts" name="Config">
143+
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
140144
import * as ConfigApi from '@/api/infra/config'
141145
import ConfigForm from './form.vue'
142-
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
143-
// import { Delete, Edit, Search, Download, Plus, Refresh } from '@element-plus/icons-vue'
144146
import dayjs from 'dayjs'
147+
const message = useMessage() // 消息弹窗
148+
const { t } = useI18n() // 国际化
149+
145150
const showSearch = ref(true) // 搜索框的是否展示
146151
const loading = ref(true) // 列表的加载中
147152
const total = ref(0) // 列表的总页数
@@ -155,6 +160,7 @@ const queryParams = reactive({
155160
createTime: []
156161
})
157162
const queryFormRef = ref() // 搜索的表单
163+
const exportLoading = ref(false) // 导出的加载中
158164
159165
/** 搜索按钮操作 */
160166
const handleQuery = () => {
@@ -186,6 +192,19 @@ const openModal = (type: string, id?: number) => {
186192
modalRef.value.openModal(type, id)
187193
}
188194
195+
/** 删除按钮操作 */
196+
const handleDelete = async (id: number) => {
197+
try {
198+
// 二次确认
199+
await message.delConfirm()
200+
// 发起删除
201+
await ConfigApi.deleteConfig(id)
202+
message.success(t('common.delSuccess'))
203+
// 刷新列表
204+
await getList()
205+
} catch {}
206+
}
207+
189208
/** 初始化 **/
190209
onMounted(() => {
191210
getList()

0 commit comments

Comments
 (0)