feat: form 表单

pull/4/MERGE
xingyu 2023-04-12 22:36:06 +08:00
parent ca4c704cd8
commit 7afe98c05c
2 changed files with 124 additions and 1 deletions

View File

@ -0,0 +1,54 @@
import { BasicColumn, FormSchema, useRender } from '@/components/Table'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'id',
width: 100
},
{
title: '表单名',
dataIndex: 'name',
width: 180
},
{
title: '状态',
dataIndex: 'status',
width: 180,
customRender: ({ text }) => {
return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS)
}
},
{
title: '备注',
dataIndex: 'remark',
width: 180
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
customRender: ({ text }) => {
return useRender.renderDate(text)
}
}
]
export const searchFormSchema: FormSchema[] = [
{
label: '表单名',
field: 'name',
component: 'Input',
colProps: { span: 8 }
},
{
label: '状态',
field: 'status',
component: 'Select',
componentProps: {
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
},
colProps: { span: 8 }
}
]

View File

@ -1,3 +1,72 @@
<template>
<div>开发中</div>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" v-auth="['system:post:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:post:update', onClick: handleEdit.bind(null, record) },
{
icon: IconEnum.DELETE,
color: 'error',
label: t('action.delete'),
auth: 'system:post:delete',
popConfirm: {
title: t('common.delMessage'),
placement: 'left',
confirm: handleDelete.bind(null, record)
}
}
]"
/>
</template>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup name="Form">
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { deleteForm, getFormPage } from '@/api/bpm/form'
import { columns, searchFormSchema } from './form.data'
const { t } = useI18n()
const { createMessage } = useMessage()
const [registerTable, { reload }] = useTable({
title: '流程表单列表',
api: getFormPage,
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
useSearchForm: true,
showTableSetting: true,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right'
}
})
function handleCreate() {
// openModal(true, { isUpdate: false })
}
function handleEdit(record: Recordable) {
console.info(record)
// openModal(true, { record, isUpdate: true })
}
async function handleDelete(record: Recordable) {
await deleteForm(record.id)
createMessage.success(t('common.delSuccessText'))
reload()
}
</script>