feat: add message hook

This commit is contained in:
xingyu
2022-07-21 17:42:25 +08:00
parent 0cb6dd585b
commit 1179ca1a8a
8 changed files with 128 additions and 79 deletions

View File

@ -8,7 +8,8 @@ import type { ApiErrorLogVO } from '@/api/infra/apiErrorLog/types'
import { allSchemas } from './apiErrorLog.data'
import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useMessage } from '@/hooks/web/useMessage'
const message = useMessage()
const { t } = useI18n() // 国际化
// ========== 列表相关 ==========
@ -36,14 +37,11 @@ const handleDetail = (row: ApiErrorLogVO) => {
}
// 异常处理操作
const handleProcessClick = (row: ApiErrorLogVO, processSttatus: number, type: string) => {
ElMessageBox.confirm('确认标记为' + type + '?', t('common.reminder'), {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
type: 'warning'
})
message
.confirm('确认标记为' + type + '?', t('common.reminder'))
.then(async () => {
ApiErrorLogApi.updateApiErrorLogPageApi(row.id, processSttatus).then(() => {
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
getList()
})
})

View File

@ -10,7 +10,8 @@ import ImportTable from './components/ImportTable.vue'
import Preview from './components/Preview.vue'
import download from '@/utils/download'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useMessage } from '@/hooks/web/useMessage'
const message = useMessage()
const { t } = useI18n() // 国际化
const { push } = useRouter()
// ========== 列表相关 ==========
@ -37,14 +38,12 @@ const handleEditTable = (row: CodegenTableVO) => {
const handleSynchDb = (row: CodegenTableVO) => {
// 基于 DB 同步
const tableName = row.tableName
ElMessageBox.confirm('确认要强制同步' + tableName + '表结构吗?', t('common.reminder'), {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
type: 'warning'
}).then(async () => {
await CodegenApi.syncCodegenFromDBApi(row.id)
ElMessage.success('同步成功')
})
message
.confirm('确认要强制同步' + tableName + '表结构吗?', t('common.reminder'))
.then(async () => {
await CodegenApi.syncCodegenFromDBApi(row.id)
message.success('同步成功')
})
}
// 生成代码操作
const handleGenTable = (row: CodegenTableVO) => {

View File

@ -1,7 +1,6 @@
<script setup lang="ts">
import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { ElMessage, ElMessageBox } from 'element-plus'
import { DICT_TYPE } from '@/utils/dict'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
@ -9,6 +8,8 @@ import { FormExpose } from '@/components/Form'
import type { FileConfigVO } from '@/api/infra/fileConfig/types'
import { rules, allSchemas } from './fileConfig.data'
import * as FileConfigApi from '@/api/infra/fileConfig'
import { useMessage } from '@/hooks/web/useMessage'
const message = useMessage()
const { t } = useI18n() // 国际化
// ========== 列表相关 ==========
@ -49,16 +50,12 @@ const handleUpdate = async (row: FileConfigVO) => {
// 主配置操作
const handleMaster = (row: FileConfigVO) => {
ElMessageBox.confirm('是否确认修改配置【 ' + row.name + ' 】为主配置?', t('common.reminder'), {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
type: 'warning'
})
message
.confirm('是否确认修改配置【 ' + row.name + ' 】为主配置?', t('common.reminder'))
.then(async () => {
await FileConfigApi.updateFileConfigMasterApi(row.id)
await getList()
})
.catch(() => {})
}
// 提交按钮
@ -69,10 +66,10 @@ const submitForm = async () => {
const data = unref(formRef)?.formModel as FileConfigVO
if (actionType.value === 'create') {
await FileConfigApi.createFileConfigApi(data)
ElMessage.success(t('common.createSuccess'))
message.success(t('common.createSuccess'))
} else {
await FileConfigApi.updateFileConfigApi(data)
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
}
// 操作成功,重新加载列表
dialogVisible.value = false

View File

@ -9,8 +9,9 @@ import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { FormExpose } from '@/components/Form'
import { rules, allSchemas } from './job.data'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'
import { useMessage } from '@/hooks/web/useMessage'
const message = useMessage()
const { t } = useI18n() // 国际化
const { push } = useRouter()
// ========== 列表相关 ==========
@ -64,18 +65,11 @@ const handleJobLog = (row: JobVO) => {
}
// 执行一次
const handleRun = (row: JobVO) => {
ElMessageBox.confirm('确认要立即执行一次' + row.name + '?', t('common.reminder'), {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
type: 'warning'
message.confirm('确认要立即执行一次' + row.name + '?', t('common.reminder')).then(async () => {
await JobApi.runJobApi(row.id)
message.success('执行成功')
getList()
})
.then(async () => {
JobApi.runJobApi(row.id).then(() => {
ElMessage.success('执行成功')
getList()
})
})
.catch(() => {})
}
// 提交按钮
const submitForm = async () => {
@ -85,10 +79,10 @@ const submitForm = async () => {
const data = unref(formRef)?.formModel as JobVO
if (actionType.value === 'create') {
await JobApi.createJobApi(data)
ElMessage.success(t('common.createSuccess'))
message.success(t('common.createSuccess'))
} else {
await JobApi.updateJobApi(data)
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
}
// 操作成功,重新加载列表
dialogVisible.value = false