Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 #5251

Open
3 tasks done
zxj176381 opened this issue Dec 27, 2024 · 1 comment

Comments

@zxj176381
Copy link

zxj176381 commented Dec 27, 2024

Version

Vben Admin V5

Description

{
      fieldName: 'aiSceneSessionExpressList',
      component: 'TableItem',
      labelWidth: 0,
      formItemClass: 'lg:col-span-6',
      componentProps: {
        minHeight: 300,
        tableTitle: '课文生词列表',
        tableTitleHelp: '点击表格中某一项即可进入编辑状态',
        columns: [
          {
            field: 'orderNo',
            title: '顺序号',
            width: 120,
            editRender: {
              name: 'input',
              placeholder: '请输入',
            },
          },
        ],
        editRules: {
          orderNo: [{ required: true, message: '必须填写' }],
        },
      },
    },
<template #aiSceneSessionExpressList="slotProps">
    <TableItem v-bind="slotProps" />
</template>

子组件主要代码

async function validate() {
  const errMap = await gridApi.grid.validate(true);
  return !errMap;
}

defineExpose({
  validate,
});

Proposed Solution

我想通过 editRules 传到子组件里,
TableItem 是插槽中的自定义组件,抛出了一个 validate 事件,我应该怎么做呢˛

Alternatives Considered

No response

Additional Context

No response

Validations

  • Read the docs
  • Ensure the code is up to date. (Some issues have been fixed in the latest version)
  • I have searched the existing issues and checked that my issue does not duplicate any existing issues.
@zxj176381 zxj176381 changed the title FEATURE: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件是否是通过的 FEATURE: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 Dec 27, 2024
@zxj176381
Copy link
Author

这个应该怎么做,困扰我好久了,我不想单独去针对每个去在 submit 时去校验

@zxj176381 zxj176381 changed the title FEATURE: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 BUG: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 Jan 2, 2025
@zxj176381 zxj176381 changed the title BUG: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 Bug: vbenForm 我如何通过子组件暴露的校验方法 告诉 form 我这个组件校验是否是通过的 Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant