import{_ as n,c as s,a as t,o as p}from"./app-CDlLWk6N.js";const e={};function o(l,a){return p(),s("div",null,a[0]||(a[0]=[t(`

表单封装

其实,在前端框架中,所有的表单页面,都是基于SimpleForm的封装,无论是主表还是明细表,最外层封装都是SimpleForm(二开使用的是可以复用的SimpleFormSetup),如果需要实现多个子表单的效果,只需要在对应位置插入标题或者布局组件即可。

默认情况下,SimpleForm是对第一层元素循环,同时处理显隐、响应式布局以及响应式布局的换行,对于非slot组件,都是将属性传给SimpleFormItem

<template>
    <Form ref="formRef" :label-col="getProps?.labelCol" :labelAlign="getProps?.labelAlign" :layout="getProps?.layout" :model="formModel" :wrapper-col="getProps?.wrapperCol" @keypress.enter="handleEnterPress">
        <Row v-bind="getRow">
            <template v-for="schema in getSchemas" :key="schema.field">
                <Col v-if="getIfShow(schema, formModel[schema.field])" v-show="getIsShow(schema, formModel[schema.field])" :span="getColWidth(schema)">
                    <div v-if="schema?.componentProps.respBreakLine" style="width: 100%; height: 1px"></div>
                    <template v-if="showComponent(schema) && schema.type !== 'slot'">
                        <SimpleFormItem v-model:value="formModel[schema.field]" :form-api="formApi" :isWorkFlow="isWorkFlow" :refreshFieldObj="refreshFieldObj" :schema="schema" />
                    </template>
                    <template v-if="schema.type === 'slot'"><!-- 无关代码省略 --></template>
                </Col>
            </template>
        </Row>

        <div :style="{ textAlign: getProps.buttonLocation }">
            <!-- 表单可以配置显示提交和清空按钮 也可以在前后添加按钮 -->
            <slot name="buttonBefore"></slot>
            <a-button v-if="getProps.showSubmitButton" type="primary" @click="handleSubmit">{{ t('提交') }}</a-button>
            <!-- 无关代码省略 -->
            <slot name="buttonAfter"></slot>
        </div>
    </Form>
</template>

对于完全使用useForm或者SimpleForm构建表单的,封装也提供了提交和清除按钮,但是页面形式的表单或者审批页面不用这2个按钮,而是用的工具栏里的封装。

`,5)]))}const u=n(e,[["render",o]]),i=JSON.parse('{"path":"/front_dev/components.html","title":"表单封装","lang":"en-US","frontmatter":{},"headers":[],"git":{"updatedTime":1743940801000,"contributors":[{"name":"gaoyunqi","username":"","email":"gaoyunqi@gdyd.com","commits":2}],"changelog":[{"hash":"ade1311d7bba455235b42db2e5f325116e3b86f4","time":1743940801000,"email":"gaoyunqi@gdyd.com","author":"gaoyunqi","message":"更新pc端前端文档"},{"hash":"6d1f2ad492629141aa9a6c3928f16e820688a85b","time":1743498223000,"email":"gaoyunqi@gdyd.com","author":"gaoyunqi","message":"更新前端文档:传值和显示隐藏部分"}]},"filePathRelative":"front_dev/components.md"}');export{u as comp,i as data};