feat: 添加提交前验证

This commit is contained in:
xingyu 2022-10-17 11:24:22 +08:00
parent aa983a6fa9
commit 855d23aec3
26 changed files with 548 additions and 397 deletions

View File

@ -50,23 +50,29 @@
// 提交按钮
const submitForm = async () => {
actionLoading.value = true
// 提交请求
try {
const data = unref(formRef)?.formModel as ${simpleClassName}VO
if (actionType.value === 'create') {
await ${simpleClassName}Api.create${simpleClassName}Api(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ${simpleClassName}Api.update${simpleClassName}Api(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
// 提交请求
try {
const data = unref(formRef)?.formModel as ${simpleClassName}VO
if (actionType.value === 'create') {
await ${simpleClassName}Api.create${simpleClassName}Api(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ${simpleClassName}Api.update${simpleClassName}Api(data)
ElMessage.success(t('common.updateSuccess'))
}
// 操作成功,重新加载列表
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
// 操作成功,重新加载列表
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== 详情相关 ==========

View File

@ -128,12 +128,18 @@ service.interceptors.response.use(
const refreshTokenRes = await refreshToken()
// 2.1 刷新成功,则回放队列的请求 + 当前请求
setToken(refreshTokenRes.data)
requestList.forEach((cb: any) => cb())
;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken()
requestList.forEach((cb: any) => {
cb()
})
requestList = []
return service(response.config)
} catch (e) {
// 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。
// 2.2 刷新失败,只回放队列的请求
requestList.forEach((cb: any) => cb())
requestList.forEach((cb: any) => {
cb()
})
// 提示是否要登出。即不回放当前请求!不然会形成递归
return handleAuthorized()
} finally {
@ -194,10 +200,7 @@ service.interceptors.response.use(
)
const refreshToken = async () => {
return await service({
url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken(),
method: 'post'
})
return await axios.post(base_url + '/system/auth/refresh-token?refreshToken=' + getRefreshToken())
}
const handleAuthorized = () => {
const { t } = useI18n()

View File

@ -111,6 +111,10 @@ const handleLogin = async (params) => {
}
loginData.loginForm.captchaVerification = params.captchaVerification
const res = await LoginApi.loginApi(loginData.loginForm)
if (!res) {
loginLoading.value = false
return
}
setToken(res)
if (!redirect.value) {
redirect.value = '/'

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: FormVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FormVO
if (actionType.value === 'create') {
await FormApi.createFormApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await FormApi.updateFormApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FormVO
if (actionType.value === 'create') {
await FormApi.createFormApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await FormApi.updateFormApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -62,24 +62,30 @@ const handleUpdate = async (row: UserGroupVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as UserGroupVO
data.memberUserIds = userIds.value
if (actionType.value === 'create') {
await UserGroupApi.createUserGroupApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await UserGroupApi.updateUserGroupApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as UserGroupVO
data.memberUserIds = userIds.value
if (actionType.value === 'create') {
await UserGroupApi.createUserGroupApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await UserGroupApi.updateUserGroupApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
//

View File

@ -51,23 +51,29 @@ const handleUpdate = async (row: ModelVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as ModelVO
if (actionType.value === 'create') {
await ModelApi.createModelApi(data)
message.success(t('common.createSuccess'))
} else {
await ModelApi.updateModelApi(data)
message.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as ModelVO
if (actionType.value === 'create') {
await ModelApi.createModelApi(data)
message.success(t('common.createSuccess'))
} else {
await ModelApi.updateModelApi(data)
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
/** 流程表单的详情按钮操作 */

View File

@ -50,23 +50,29 @@ const handleUpdate = async (row: ConfigVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as ConfigVO
if (actionType.value === 'create') {
await ConfigApi.createConfigApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ConfigApi.updateConfigApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as ConfigVO
if (actionType.value === 'create') {
await ConfigApi.createConfigApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ConfigApi.updateConfigApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -44,23 +44,29 @@ const handleUpdate = async (row: DataSourceConfigVO) => {
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as DataSourceConfigVO
if (actionType.value === 'create') {
await DataSourceConfiggApi.createDataSourceConfigApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await DataSourceConfiggApi.updateDataSourceConfigApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as DataSourceConfigVO
if (actionType.value === 'create') {
await DataSourceConfiggApi.createDataSourceConfigApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await DataSourceConfiggApi.updateDataSourceConfigApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
//

View File

@ -60,23 +60,29 @@ const handleMaster = (row: FileConfigVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FileConfigVO
if (actionType.value === 'create') {
await FileConfigApi.createFileConfigApi(data)
message.success(t('common.createSuccess'))
} else {
await FileConfigApi.updateFileConfigApi(data)
message.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as FileConfigVO
if (actionType.value === 'create') {
await FileConfigApi.createFileConfigApi(data)
message.success(t('common.createSuccess'))
} else {
await FileConfigApi.updateFileConfigApi(data)
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -98,24 +98,30 @@ const handleRun = (row: JobVO) => {
}
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as JobVO
data.cronExpression = cronExpression.value
if (actionType.value === 'create') {
await JobApi.createJobApi(data)
message.success(t('common.createSuccess'))
} else {
await JobApi.updateJobApi(data)
message.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as JobVO
data.cronExpression = cronExpression.value
if (actionType.value === 'create') {
await JobApi.createJobApi(data)
message.success(t('common.createSuccess'))
} else {
await JobApi.updateJobApi(data)
message.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -50,23 +50,29 @@ const handleUpdate = async (row: AppVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as AppVO
if (actionType.value === 'create') {
await AppApi.createAppApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await AppApi.updateAppApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as AppVO
if (actionType.value === 'create') {
await AppApi.createAppApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await AppApi.updateAppApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -50,23 +50,29 @@ const handleUpdate = async (row: MerchantVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as MerchantVO
if (actionType.value === 'create') {
await MerchantApi.createMerchantApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await MerchantApi.updateMerchantApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as MerchantVO
if (actionType.value === 'create') {
await MerchantApi.createMerchantApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await MerchantApi.updateMerchantApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -48,23 +48,29 @@ const handleUpdate = async (row: OrderVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as OrderVO
if (actionType.value === 'create') {
await OrderApi.createOrderApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await OrderApi.updateOrderApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as OrderVO
if (actionType.value === 'create') {
await OrderApi.createOrderApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await OrderApi.updateOrderApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -82,22 +82,28 @@ const handleDelete = async (data: { id: number }) => {
}
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as DeptVO
data.parentId = deptParentId.value
data.leaderUserId = leaderUserId.value
if (formTitle.value.startsWith('新增')) {
await DeptApi.createDeptApi(data)
} else if (formTitle.value.startsWith('修改')) {
await DeptApi.updateDeptApi(data)
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as DeptVO
data.parentId = deptParentId.value
data.leaderUserId = leaderUserId.value
if (formTitle.value.startsWith('新增')) {
await DeptApi.createDeptApi(data)
} else if (formTitle.value.startsWith('修改')) {
await DeptApi.updateDeptApi(data)
}
//
dialogVisible.value = false
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
} finally {
loading.value = false
}
})
}
onMounted(async () => {
await getTree()

View File

@ -92,43 +92,55 @@ const setDialogTile = (type: string) => {
}
//
const submitTypeForm = async () => {
actionLoading.value = true
//
try {
const data = unref(typeFormRef)?.formModel as DictTypeVO
if (actionType.value === 'typeCreate') {
await DictTypeApi.createDictTypeApi(data)
ElMessage.success(t('common.createSuccess'))
} else if (actionType.value === 'typeUpdate') {
await DictTypeApi.updateDictTypeApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(typeFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(typeFormRef)?.formModel as DictTypeVO
if (actionType.value === 'typeCreate') {
await DictTypeApi.createDictTypeApi(data)
ElMessage.success(t('common.createSuccess'))
} else if (actionType.value === 'typeUpdate') {
await DictTypeApi.updateDictTypeApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
await getTypeList()
dialogVisible.value = false
} finally {
actionLoading.value = false
}
}
//
await getTypeList()
dialogVisible.value = false
} finally {
actionLoading.value = false
}
})
}
const submitDataForm = async () => {
actionLoading.value = true
//
try {
const data = unref(dataFormRef)?.formModel as DictDataVO
if (actionType.value === 'dataCreate') {
data.dictType = parentType.value
await DictDataApi.createDictDataApi(data)
ElMessage.success(t('common.createSuccess'))
} else if (actionType.value === 'dataUpdate') {
await DictDataApi.updateDictDataApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(dataFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(dataFormRef)?.formModel as DictDataVO
if (actionType.value === 'dataCreate') {
data.dictType = parentType.value
await DictDataApi.createDictDataApi(data)
ElMessage.success(t('common.createSuccess'))
} else if (actionType.value === 'dataUpdate') {
await DictDataApi.updateDictDataApi(data)
ElMessage.success(t('common.updateSuccess'))
}
await getDataList()
//
dialogVisible.value = false
} finally {
actionLoading.value = false
}
}
await getDataList()
//
dialogVisible.value = false
} finally {
actionLoading.value = false
}
})
}
//
onMounted(async () => {

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: ErrorCodeVO) => {
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as ErrorCodeVO
if (actionType.value === 'create') {
await ErrorCodeApi.createErrorCodeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ErrorCodeApi.updateErrorCodeApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as ErrorCodeVO
if (actionType.value === 'create') {
await ErrorCodeApi.createErrorCodeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ErrorCodeApi.updateErrorCodeApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
// ========== ==========

View File

@ -127,7 +127,7 @@ const handleDelete = async (row: MenuVO) => {
await getList()
}
//
function isExternal(path: string) {
const isExternal = (path: string) => {
return /^(https?:|mailto:|tel:)/.test(path)
}
const submitForm = async () => {

View File

@ -48,23 +48,29 @@ const handleUpdate = async (row: NoticeVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as NoticeVO
if (actionType.value === 'create') {
await NoticeApi.createNoticeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await NoticeApi.updateNoticeApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as NoticeVO
if (actionType.value === 'create') {
await NoticeApi.createNoticeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await NoticeApi.updateNoticeApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: OAuth2ClientVo) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as OAuth2ClientVo
if (actionType.value === 'create') {
await ClientApi.createOAuth2ClientApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ClientApi.updateOAuth2ClientApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as OAuth2ClientVo
if (actionType.value === 'create') {
await ClientApi.createOAuth2ClientApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await ClientApi.updateOAuth2ClientApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -50,23 +50,29 @@ const handleUpdate = async (row: PostVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as PostVO
if (actionType.value === 'create') {
await PostApi.createPostApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await PostApi.updatePostApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as PostVO
if (actionType.value === 'create') {
await PostApi.createPostApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await PostApi.updatePostApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -68,23 +68,29 @@ const handleUpdate = async (row: RoleVO) => {
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as RoleVO
if (actionType.value === 'create') {
await RoleApi.createRoleApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await RoleApi.updateRoleApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as RoleVO
if (actionType.value === 'create') {
await RoleApi.createRoleApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await RoleApi.updateRoleApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
// ========== ==========

View File

@ -56,23 +56,29 @@ const handleUpdate = async (row: SensitiveWordVO) => {
//
const submitForm = async () => {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as SensitiveWordVO
if (actionType.value === 'create') {
await SensitiveWordApi.createSensitiveWordApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SensitiveWordApi.updateSensitiveWordApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as SensitiveWordVO
if (actionType.value === 'create') {
await SensitiveWordApi.createSensitiveWordApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SensitiveWordApi.updateSensitiveWordApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: SmsChannelVO) => {
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsChannelVO
if (actionType.value === 'create') {
await SmsChannelApi.createSmsChannelApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SmsChannelApi.updateSmsChannelApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsChannelVO
if (actionType.value === 'create') {
await SmsChannelApi.createSmsChannelApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SmsChannelApi.updateSmsChannelApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
// ========== ==========

View File

@ -49,23 +49,29 @@ const handleUpdate = async (row: SmsTemplateVO) => {
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsTemplateVO
if (actionType.value === 'create') {
await SmsTemplateApi.createSmsTemplateApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SmsTemplateApi.updateSmsTemplateApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as SmsTemplateVO
if (actionType.value === 'create') {
await SmsTemplateApi.createSmsTemplateApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await SmsTemplateApi.updateSmsTemplateApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
// ========== ==========

View File

@ -71,26 +71,32 @@ const handleUpdate = async (row: any) => {
//
const submitForm = async () => {
actionLoading.value = true
// unix()
try {
const data = unref(formRef)?.formModel as TenantVO
data.packageId = tenantPackageId.value
if (actionType.value === 'create') {
data.expireTime = dayjs(data.expireTime).valueOf().toString()
await TenantApi.createTenantApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
data.expireTime = dayjs(data.expireTime).valueOf().toString()
await TenantApi.updateTenantApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
const data = unref(formRef)?.formModel as TenantVO
data.packageId = tenantPackageId.value
if (actionType.value === 'create') {
data.expireTime = dayjs(data.expireTime).valueOf().toString()
await TenantApi.createTenantApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
data.expireTime = dayjs(data.expireTime).valueOf().toString()
await TenantApi.updateTenantApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
actionLoading.value = false
}
})
}
// ========== ==========

View File

@ -76,24 +76,30 @@ const handleUpdate = async (row: any) => {
}
//
const submitForm = async () => {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as TenantPackageVO
data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
if (actionType.value === 'create') {
await TenantPackageApi.createTenantPackageTypeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await TenantPackageApi.updateTenantPackageTypeApi(data)
ElMessage.success(t('common.updateSuccess'))
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
const data = unref(formRef)?.formModel as TenantPackageVO
data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
if (actionType.value === 'create') {
await TenantPackageApi.createTenantPackageTypeApi(data)
ElMessage.success(t('common.createSuccess'))
} else {
await TenantPackageApi.updateTenantPackageTypeApi(data)
ElMessage.success(t('common.updateSuccess'))
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
}
//
dialogVisible.value = false
await getList()
} finally {
loading.value = false
}
})
}
// ========== ==========