perf:前端部分事件优化使用try/finally,编辑获取数据增加校验
This commit is contained in:
parent
ff0990331c
commit
7f4c0d3fa1
@ -143,7 +143,7 @@ const signIn = async () => {
|
|||||||
} else {
|
} else {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ const telephoneCodeLogin = async () => {
|
|||||||
} else {
|
} else {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ const getSMSCode = async () => {
|
|||||||
ElMessage.error('发送失败,请联系管理员')
|
ElMessage.error('发送失败,请联系管理员')
|
||||||
SMSCodeStatus.value = true
|
SMSCodeStatus.value = true
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} finally {
|
||||||
SMSCodeStatus.value = true
|
SMSCodeStatus.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ const save = async () => {
|
|||||||
} else {
|
} else {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,8 @@ const save = async () => {
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const data = await write?.getFormData()
|
const data = await write?.getFormData()
|
||||||
const res = ref({})
|
|
||||||
try {
|
try {
|
||||||
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addMenuListApi(data)
|
res.value = await addMenuListApi(data)
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
|
@ -56,12 +56,14 @@ const addAction = () => {
|
|||||||
// 编辑事件
|
// 编辑事件
|
||||||
const updateAction = async (row: any) => {
|
const updateAction = async (row: any) => {
|
||||||
const res = await getRoleApi(row.id)
|
const res = await getRoleApi(row.id)
|
||||||
|
if (res) {
|
||||||
dialogTitle.value = '编辑'
|
dialogTitle.value = '编辑'
|
||||||
tableObject.currentRow = res.data
|
tableObject.currentRow = res.data
|
||||||
defaultCheckedKeys.value = res.data.menus.map((item: any) => item.id)
|
defaultCheckedKeys.value = res.data.menus.map((item: any) => item.id)
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
actionType.value = 'edit'
|
actionType.value = 'edit'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 删除事件
|
// 删除事件
|
||||||
const delData = async (row: any) => {
|
const delData = async (row: any) => {
|
||||||
@ -82,8 +84,8 @@ const save = async () => {
|
|||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
data.menu_ids = write?.getTreeCheckedKeys()
|
data.menu_ids = write?.getTreeCheckedKeys()
|
||||||
const res = ref({})
|
|
||||||
try {
|
try {
|
||||||
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addRoleListApi(data)
|
res.value = await addRoleListApi(data)
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
|
@ -95,12 +95,14 @@ const addAction = () => {
|
|||||||
// 编辑事件
|
// 编辑事件
|
||||||
const updateAction = async (row: any) => {
|
const updateAction = async (row: any) => {
|
||||||
const res = await getUserApi(row.id)
|
const res = await getUserApi(row.id)
|
||||||
|
if (res) {
|
||||||
dialogTitle.value = '编辑'
|
dialogTitle.value = '编辑'
|
||||||
res.data.role_ids = res.data.roles.map((item: any) => item.id)
|
res.data.role_ids = res.data.roles.map((item: any) => item.id)
|
||||||
tableObject.currentRow = res.data
|
tableObject.currentRow = res.data
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
actionType.value = 'edit'
|
actionType.value = 'edit'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 删除事件
|
// 删除事件
|
||||||
const delDatas = async (row: any) => {
|
const delDatas = async (row: any) => {
|
||||||
|
@ -62,12 +62,14 @@ const searchSetSchemaList = ref([] as FormSetPropsType[])
|
|||||||
|
|
||||||
const getOptions = async () => {
|
const getOptions = async () => {
|
||||||
const res = await getIssueCategoryOptionsApi()
|
const res = await getIssueCategoryOptionsApi()
|
||||||
|
if (res) {
|
||||||
searchSetSchemaList.value.push({
|
searchSetSchemaList.value.push({
|
||||||
field: 'category_id',
|
field: 'category_id',
|
||||||
path: 'componentProps.options',
|
path: 'componentProps.options',
|
||||||
value: res.data
|
value: res.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getOptions()
|
getOptions()
|
||||||
|
|
||||||
|
@ -95,11 +95,13 @@ const addAction = async () => {
|
|||||||
// 编辑事件
|
// 编辑事件
|
||||||
const updateAction = async (row: any) => {
|
const updateAction = async (row: any) => {
|
||||||
const res = await getIssueCategoryApi(row.id)
|
const res = await getIssueCategoryApi(row.id)
|
||||||
|
if (res) {
|
||||||
dialogTitle.value = '编辑'
|
dialogTitle.value = '编辑'
|
||||||
tableObject.currentRow = res.data
|
tableObject.currentRow = res.data
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
actionType.value = 'edit'
|
actionType.value = 'edit'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 删除事件
|
// 删除事件
|
||||||
const delData = async (row: any) => {
|
const delData = async (row: any) => {
|
||||||
@ -116,8 +118,8 @@ const save = async () => {
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
let data = await write?.getFormData()
|
let data = await write?.getFormData()
|
||||||
const res = ref({})
|
|
||||||
try {
|
try {
|
||||||
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addIssueCategoryApi(data)
|
res.value = await addIssueCategoryApi(data)
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Echart } from '@/components/Echart'
|
import { Echart } from '@/components/Echart'
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { EChartsOption } from 'echarts'
|
import { PropType, ref, watch } from 'vue'
|
||||||
import { PropType, ref, watch, reactive } from 'vue'
|
|
||||||
import { CenterTopPropsType } from '../typers'
|
import { CenterTopPropsType } from '../typers'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -123,8 +122,6 @@ watch(
|
|||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// const lineOptions: EChartsOption = reactive()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -38,12 +38,14 @@ const searchSetSchemaList = ref([] as FormSetPropsType[])
|
|||||||
|
|
||||||
const getOptions = async () => {
|
const getOptions = async () => {
|
||||||
const res = await getDictTypeOptionsApi()
|
const res = await getDictTypeOptionsApi()
|
||||||
|
if (res) {
|
||||||
searchSetSchemaList.value.push({
|
searchSetSchemaList.value.push({
|
||||||
field: 'dict_type_id',
|
field: 'dict_type_id',
|
||||||
path: 'componentProps.options',
|
path: 'componentProps.options',
|
||||||
value: res.data
|
value: res.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getOptions()
|
getOptions()
|
||||||
|
|
||||||
@ -81,11 +83,13 @@ const addAction = () => {
|
|||||||
// 编辑事件
|
// 编辑事件
|
||||||
const updateAction = async (row: any) => {
|
const updateAction = async (row: any) => {
|
||||||
const res = await getDictDetailsApi(row.id)
|
const res = await getDictDetailsApi(row.id)
|
||||||
|
if (res) {
|
||||||
dialogTitle.value = '编辑'
|
dialogTitle.value = '编辑'
|
||||||
tableObject.currentRow = res.data
|
tableObject.currentRow = res.data
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
actionType.value = 'edit'
|
actionType.value = 'edit'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 删除事件
|
// 删除事件
|
||||||
const delData = async (row: any) => {
|
const delData = async (row: any) => {
|
||||||
@ -106,6 +110,7 @@ const save = async () => {
|
|||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
data.dict_type_id = dictType
|
data.dict_type_id = dictType
|
||||||
|
try {
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addDictDetailsListApi(data)
|
res.value = await addDictDetailsListApi(data)
|
||||||
@ -120,6 +125,9 @@ const save = async () => {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,13 @@ const addAction = () => {
|
|||||||
// 编辑事件
|
// 编辑事件
|
||||||
const updateAction = async (row: any) => {
|
const updateAction = async (row: any) => {
|
||||||
const res = await getDictTypeApi(row.id)
|
const res = await getDictTypeApi(row.id)
|
||||||
|
if (res) {
|
||||||
dialogTitle.value = '编辑'
|
dialogTitle.value = '编辑'
|
||||||
tableObject.currentRow = res.data
|
tableObject.currentRow = res.data
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
actionType.value = 'edit'
|
actionType.value = 'edit'
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 删除事件
|
// 删除事件
|
||||||
const delData = async (row: any) => {
|
const delData = async (row: any) => {
|
||||||
|
@ -40,13 +40,16 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = await putSystemSettingsApi(data)
|
const res = await putSystemSettingsApi(data)
|
||||||
if (res) {
|
if (res) {
|
||||||
getData()
|
getData()
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,10 @@ const tabs = ref([] as Recordable[])
|
|||||||
|
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
const res = await getSystemSettingsTabsApi({ classify: 'web' })
|
const res = await getSystemSettingsTabsApi({ classify: 'web' })
|
||||||
|
if (res) {
|
||||||
tabs.value = res.data
|
tabs.value = res.data
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getList()
|
getList()
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user