跳到内容
SCRM DOC

JInput 输入框组件使用指南

前端组件FormJInput创建于2025-03-22更新于 2026-04-22

JInput 输入框组件

支持查询条件增强的输入框组件,可自动添加模糊匹配前缀后缀。

基本用法

<template>
  <JInput v-model:value="username" placeholder="请输入用户名" />
</template>

<script setup lang="ts">
import { ref } from 'vue';

const username = ref('');
</script>

Props 属性

属性类型默认值说明
valuestring''输入框值
typestringJINPUT_QUERY_LIKE查询类型
placeholderstring''占位符
trimbooleanfalse是否自动去除首尾空格

查询类型

JInput 通过 type 属性支持多种查询条件模式:

类型值说明输入转换示例
JINPUT_QUERY_LIKE模糊查询(默认)abc → *abc*
JINPUT_QUERY_NE不等于abc → !abc
JINPUT_QUERY_GE大于等于100 → >=100
JINPUT_QUERY_LE小于等于100 → <=100

在 BasicForm 中使用

<script setup lang="ts">
import { useForm } from '@/components/Form';

const [registerForm, { getFieldsValue }] = useForm({
  schemas: [
    {
      field: 'username',
      label: '用户名',
      component: 'JInput',
      componentProps: {
        type: 'like', // 模糊查询
      },
    },
    {
      field: 'amount',
      label: '金额',
      component: 'JInput',
      componentProps: {
        type: 'ge', // 大于等于
      },
    },
  ],
});
</script>

搜索表单示例

<template>
  <BasicForm @register="registerForm" />
</template>

<script setup lang="ts">
import { useForm } from '@/components/Form';

const [registerForm, { getFieldsValue }] = useForm({
  schemas: [
    {
      field: 'name',
      label: '姓名',
      component: 'JInput',
      componentProps: {
        placeholder: '支持模糊搜索',
      },
    },
    {
      field: 'code',
      label: '编码',
      component: 'JInput',
      componentProps: {
        type: 'ne', // 不等于
        placeholder: '排除指定编码',
      },
    },
  ],
  labelWidth: 100,
  showActionButtonGroup: true,
});

// 搜索时会自动转换值:输入 "test" 后,实际查询值为 "*test*"
</script>

使用场景

1. 模糊搜索

<JInput v-model:value="name" type="like" placeholder="姓名模糊搜索" />
<!-- 输入:张三  →  输出:*张三* -->

2. 范围查询

<JInput v-model:value="minPrice" type="ge" placeholder="最低价格" />
<!-- 输入:100  →  输出:>=100 -->

<JInput v-model:value="maxPrice" type="le" placeholder="最高价格" />
<!-- 输入:1000  →  输出:<=1000 -->

3. 自动去除空格

<JInput v-model:value="keyword" :trim="true" placeholder="关键词" />

相关文件

  • 组件路径:@/components/Form/src/jeecg/components/JInput.vue
  • 枚举定义:@/enums/jeecgEnum.ts

相关组件

  • [[09. BasicForm 表单]] - 表单容器组件
  • [[08. BasicTable 表格]] - 表格组件
  • [[12. JPopup 弹出选择]] - 弹出选择组件
页面信息›
已优化是

本页目录