feat: code style
parent
e3ca40287b
commit
a2f79279c0
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? '编辑' : '新增'" @ok="handleSubmit">
|
||||||
<BasicForm @register="registerForm" />
|
<BasicForm @register="registerForm" />
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="PostModal">
|
<script lang="ts" setup name="PostModal">
|
||||||
import { ref, computed, unref } from 'vue'
|
import { ref, 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 './post.data'
|
import { formSchema } from './post.data'
|
||||||
|
@ -14,7 +14,7 @@ const emit = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(true)
|
const isUpdate = ref(true)
|
||||||
|
|
||||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||||
labelWidth: 100,
|
labelWidth: 120,
|
||||||
baseColProps: { span: 24 },
|
baseColProps: { span: 24 },
|
||||||
schemas: formSchema,
|
schemas: formSchema,
|
||||||
showActionButtonGroup: false,
|
showActionButtonGroup: false,
|
||||||
|
@ -25,15 +25,12 @@ 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 getPost(data.record.id)
|
const res = await getPost(data.record.id)
|
||||||
setFieldsValue({ ...res })
|
setFieldsValue({ ...res })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增岗位' : '编辑岗位'))
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
const values = await validate()
|
const values = await validate()
|
||||||
|
|
|
@ -57,7 +57,6 @@ const [registerTable, { getForm, reload }] = useTable({
|
||||||
},
|
},
|
||||||
useSearchForm: true,
|
useSearchForm: true,
|
||||||
showTableSetting: true,
|
showTableSetting: true,
|
||||||
showIndexColumn: false,
|
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 140,
|
width: 140,
|
||||||
title: t('common.action'),
|
title: t('common.action'),
|
||||||
|
@ -67,16 +66,11 @@ const [registerTable, { getForm, reload }] = useTable({
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleCreate() {
|
function handleCreate() {
|
||||||
openModal(true, {
|
openModal(true, { isUpdate: false })
|
||||||
isUpdate: false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEdit(record: Recordable) {
|
function handleEdit(record: Recordable) {
|
||||||
openModal(true, {
|
openModal(true, { record, isUpdate: true })
|
||||||
record,
|
|
||||||
isUpdate: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleExport() {
|
async function handleExport() {
|
||||||
|
|
Loading…
Reference in New Issue