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,6 +50,10 @@
// 提交按钮
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
// 提交请求
try {
@ -68,6 +72,8 @@
actionLoading.value = false
}
}
})
}
// ========== 详情相关 ==========
const detailRef = ref() // 详情 Ref

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,6 +49,10 @@ const handleUpdate = async (row: FormVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -67,6 +71,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -62,6 +62,10 @@ const handleUpdate = async (row: UserGroupVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -81,6 +85,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
//
const getUserNickName = (userId: number) => {

View File

@ -51,6 +51,10 @@ const handleUpdate = async (row: ModelVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -69,6 +73,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
/** 流程表单的详情按钮操作 */
const handleChangeState = async (row: ModelVO) => {

View File

@ -50,6 +50,10 @@ const handleUpdate = async (row: ConfigVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -68,6 +72,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -44,6 +44,10 @@ const handleUpdate = async (row: DataSourceConfigVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -62,6 +66,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
//
const handleDelete = async (row: DataSourceConfigVO) => {

View File

@ -60,6 +60,10 @@ const handleMaster = (row: FileConfigVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -78,6 +82,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -98,6 +98,10 @@ const handleRun = (row: JobVO) => {
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -117,6 +121,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -50,6 +50,10 @@ const handleUpdate = async (row: AppVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -68,6 +72,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -50,6 +50,10 @@ const handleUpdate = async (row: MerchantVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -68,6 +72,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -48,6 +48,10 @@ const handleUpdate = async (row: OrderVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -66,6 +70,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -82,6 +82,10 @@ const handleDelete = async (data: { id: number }) => {
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -99,6 +103,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
onMounted(async () => {
await getTree()
await getUserList()

View File

@ -92,6 +92,10 @@ const setDialogTile = (type: string) => {
}
//
const submitTypeForm = async () => {
const elForm = unref(typeFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -110,7 +114,13 @@ const submitTypeForm = async () => {
actionLoading.value = false
}
}
})
}
const submitDataForm = async () => {
const elForm = unref(dataFormRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -130,6 +140,8 @@ const submitDataForm = async () => {
actionLoading.value = false
}
}
})
}
//
onMounted(async () => {
await getTypeList()

View File

@ -49,6 +49,10 @@ const handleUpdate = async (row: ErrorCodeVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -67,6 +71,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

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,6 +48,10 @@ const handleUpdate = async (row: NoticeVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -66,6 +70,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -49,6 +49,10 @@ const handleUpdate = async (row: OAuth2ClientVo) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -67,6 +71,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -50,6 +50,10 @@ const handleUpdate = async (row: PostVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -68,6 +72,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -68,6 +68,10 @@ const handleUpdate = async (row: RoleVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -86,6 +90,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -56,6 +56,10 @@ const handleUpdate = async (row: SensitiveWordVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
//
try {
@ -74,6 +78,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -49,6 +49,10 @@ const handleUpdate = async (row: SmsChannelVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -67,6 +71,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -49,6 +49,10 @@ const handleUpdate = async (row: SmsTemplateVO) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -67,6 +71,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -71,8 +71,12 @@ const handleUpdate = async (row: any) => {
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
actionLoading.value = true
// unix()
//
try {
const data = unref(formRef)?.formModel as TenantVO
data.packageId = tenantPackageId.value
@ -92,6 +96,8 @@ const submitForm = async () => {
actionLoading.value = false
}
}
})
}
// ========== ==========
const detailRef = ref() // Ref

View File

@ -76,6 +76,10 @@ const handleUpdate = async (row: any) => {
}
//
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (valid) {
loading.value = true
//
try {
@ -95,6 +99,8 @@ const submitForm = async () => {
loading.value = false
}
}
})
}
// ========== ==========
onMounted(async () => {