update src/views/infra/apiAccessLog/ApiAccessLogModel.vue.
Signed-off-by: yanchangshan <5333290+yanchangshan@user.noreply.gitee.com>pull/2/head
parent
54f97dcbc3
commit
441a79e909
|
@ -1,60 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
<BasicModal v-bind="$attrs" @register="registerModal" @ok="handleSubmit">
|
||||||
<BasicForm @register="registerForm" />
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
</BasicModal>
|
</template>
|
||||||
</template>
|
<script lang="ts" setup name="ApiAccessLogModal">
|
||||||
<script lang="ts" setup name="ApiAccessLogModal">
|
|
||||||
|
|
||||||
import { ref, computed, unref } from 'vue'
|
import { ref, computed, unref } from 'vue'
|
||||||
import { BasicModal, useModalInner } from '@/components/Modal'
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
import { BasicForm, useForm } from '@/components/Form'
|
import { BasicForm, useForm } from '@/components/Form'
|
||||||
import { formSchema } from './ApiAccessLog.data'
|
import { formSchema } from './ApiAccessLog.data'
|
||||||
import { createApiAccessLogApi, getApiAccessLogApi, updatePostApi } from '@/api/infra/apiAccessLog'
|
import { getApiAccessLogApi } from '@/api/infra/apiAccessLog'
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register'])
|
const emit = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(true)
|
const isUpdate = ref(true)
|
||||||
const rowId = ref()
|
const rowId = ref()
|
||||||
|
|
||||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||||
labelWidth: 100,
|
labelWidth: 100,
|
||||||
baseColProps: { span: 24 },
|
baseColProps: { span: 24 },
|
||||||
schemas: formSchema,
|
schemas: formSchema,
|
||||||
showActionButtonGroup: false,
|
showActionButtonGroup: false,
|
||||||
actionColOptions: {
|
actionColOptions: {
|
||||||
span: 23
|
span: 23
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
resetFields()
|
resetFields()
|
||||||
setModalProps({ confirmLoading: false })
|
setModalProps({ confirmLoading: false })
|
||||||
isUpdate.value = !!data?.isUpdate
|
isUpdate.value = !!data?.isUpdate
|
||||||
|
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
const res = await getApiAccessLogApi(data.record.id)
|
const res = await getApiAccessLogApi(data.record.id)
|
||||||
rowId.value = res.id
|
rowId.value = res.id
|
||||||
setFieldsValue({
|
setFieldsValue({
|
||||||
...res
|
...res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增API访问日志表' : '编辑API访问日志表'))
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
const values = await validate()
|
const values = await validate()
|
||||||
setModalProps({ confirmLoading: true })
|
setModalProps({ confirmLoading: true })
|
||||||
if (unref(isUpdate)) {
|
closeModal()
|
||||||
await updateApiAccessLogApi(values)
|
emit('success')
|
||||||
} else {
|
} finally {
|
||||||
await createApiAccessLogApi(values)
|
setModalProps({ confirmLoading: false })
|
||||||
}
|
}
|
||||||
closeModal()
|
|
||||||
emit('success')
|
|
||||||
} finally {
|
|
||||||
setModalProps({ confirmLoading: false })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue