style: modal code style

pull/1/MERGE
xingyuv 2023-03-22 14:13:21 +08:00
parent 8ba2dae74e
commit 9a0941d6e7
21 changed files with 147 additions and 106 deletions

View File

@ -19,9 +19,7 @@ const [registerForm, { resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: passwordSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(() => {

View File

@ -0,0 +1,40 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" title="IP 查询" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup name="PostModal">
import { BasicModal, useModalInner } from '@/components/Modal'
import { BasicForm, useForm } from '@/components/Form'
import { formSchema } from './area.data'
import { getAreaByIp } from '@/api/system/area'
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps }] = useModalInner(async () => {
resetFields()
setModalProps({ confirmLoading: false })
})
async function handleSubmit() {
try {
const values = await validate()
setModalProps({ confirmLoading: true })
const res = getAreaByIp(values.ip)
if (res) {
values.result = res
setFieldsValue({ ...values })
}
// closeModal()
// emit('success')
} finally {
setModalProps({ confirmLoading: false })
}
}
</script>

View File

@ -0,0 +1,28 @@
import { BasicColumn, FormSchema } from '@/components/Table'
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'id',
width: 100
},
{
title: '名字',
dataIndex: 'name',
width: 180
}
]
export const formSchema: FormSchema[] = [
{
label: 'IP',
field: 'IP',
required: true,
component: 'Input'
},
{
label: '地址',
field: 'result',
component: 'Input'
}
]

View File

@ -1,3 +1,46 @@
<template>
<div>开发中</div>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleCreate"> IP </a-button>
</template>
</BasicTable>
<AreaModal @register="registerModal" @success="reload()" />
</div>
</template>
<script lang="ts" setup name="Area">
import { useModal } from '@/components/Modal'
import AreaModal from './AreaModal.vue'
import { BasicTable, useTable } from '@/components/Table'
import { getAreaTree } from '@/api/system/area'
import { columns } from './area.data'
import { handleTree } from '@/utils/tree'
const [registerModal, { openModal }] = useModal()
const [registerTable, { reload }] = useTable({
title: '岗位列表',
api: getList,
columns,
rowKey: 'id',
isTreeTable: true,
pagination: false,
striped: false,
useSearchForm: false,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
canResize: false
})
async function getList() {
const res = await getAreaTree()
return handleTree(res, 'id')
}
function handleCreate() {
openModal(true, {
isUpdate: false
})
}
</script>

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getDeptApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: dataFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getDictDataApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
} else {
setFieldsValue({
dictType: data.record

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: typeFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getDictTypeApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getErrorCodeApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getMailAccountApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getMailTemplateApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getMenuApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getNoticeApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getOAuth2ClientApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getPostApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getRoleApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: dataScopeFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getRoleApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getSensitiveWordApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getSmsTemplateApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getTenantApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -37,9 +37,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -54,9 +52,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
rowId.value = res.id
const menus = await listSimpleMenusApi()
menuTree.value = handleTree(menus, 'id')
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})

View File

@ -19,9 +19,7 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
baseColProps: { span: 24 },
schemas: formSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23
}
actionColOptions: { span: 23 }
})
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
@ -32,9 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
if (unref(isUpdate)) {
const res = await getUserApi(data.record.id)
rowId.value = res.id
setFieldsValue({
...res
})
setFieldsValue({ ...res })
}
})