SchemaUiUtils

addRequired

批量操作 schema 对象中的必填字段

参数说明

参数说明类型
schemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { addRequired } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}

addRequired(schema, ['fullname', 'sex'])

removeRequired

批量操作 schema 对象移除必填字段

参数说明

参数说明类型
schemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { removeRequired } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}

removeRequired(schema, ['fullname', 'sex'])

addDisabled

批量操作 ui-schema 对象中设置不可用字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { addDisabled } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}

// 初始化默认值
const uiSchema = {
  fullname: {
    disabled: false,
  },
  sex: {
    disabled: false,
  },
}
addDisabled(uiSchema, ['fullname', 'sex'])

removeDisabled

批量操作 ui-schema 对象中设置移除不可用字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { removeDisabled } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}

// 初始化默认值
const uiSchema = {
  fullname: {
    disabled: true,
  },
  sex: {
    disabled: true,
  },
}
removeDisabled(uiSchema, ['fullname', 'sex'])

addHidden

批量操作 ui-schema 对象中设置隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { addHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    visible: true,
  },
  sex: {
    visible: true,
  },
}
addHidden(uiSchema, ['fullname', 'sex'])

removeHidden

批量操作 ui-schema 对象中设置移除隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { removeHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    visible: false,
  },
  sex: {
    visible: false,
  },
}
removeHidden(uiSchema, ['fullname', 'sex'])

addFormItemHidden

批量操作 ui-schema 对象中设置表单状态下隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { addFormItemHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    formItemVisible: true, // 设置表单状态下,不隐藏
  },
  sex: {
    formItemVisible: false, // 设置表单状态下,隐藏
  },
}
addFormItemHidden(uiSchema, ['fullname', 'sex'])

removeFormItemHidden

批量操作 ui-schema 对象中设置移除设置表单状态的隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { removeFormItemHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    formItemVisible: true, // 设置表单状态下,不隐藏
    // ...SchemaUiUtils.formItemHidden() // 设置表单状态下,隐藏
  },
  sex: {
    formItemVisible: false, // 设置表单状态下,隐藏
  },
}
removeFormItemHidden(uiSchema, ['fullname', 'sex'])

addTableItemHidden

批量操作 ui-schema 对象中设置表格状态下隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { addTableItemHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    columnVisible: true, // 设置表单状态下,不隐藏
  },
  sex: {
    columnVisible: false, // 设置表单状态下,隐藏
  },
}
addTableItemHidden(uiSchema, ['fullname', 'sex'])

removeTableItemHidden

批量操作 ui-schema 对象中设置移除设置表单状态的隐藏字段

参数说明

参数说明类型
uiSchemaSchema 对象Object
operKeys需要操作的属性 KeyArray
import { removeTableItemHidden } from 'setaria-business-framework'

const schema = {
  properties: {
    fullname: { type: 'string', title: '用户名' },
    sex: { type: 'string', title: '性别' },
    status: {
      type: 'integer',
      title: '状态',
    },
    username: { type: 'string', title: '用户姓名' },
    usernum: { type: 'string', title: '用户号' },
    whomodified: { type: 'string', title: '编辑人' },
    workDate: {
      type: 'string',
      description: '',
      format: 'date-time',
      title: '工作时间',
    },
  },
}
const uiSchema = {
  fullname: {
    formItemVisible: true, // 设置表单状态下,不隐藏
    // ...SchemaUiUtils.formItemHidden() // 设置表单状态下,隐藏
  },
  sex: {
    formItemVisible: false, // 设置表单状态下,隐藏
  },
}
removeTableItemHidden(uiSchema, ['fullname', 'sex'])

formatPriceType

快捷设置 scehma 内容为为货币类型

import { formatPriceType } from 'setaria-business-framework'

const schema = {
   "UserAccount": {
    "title": "User",
    "required": [],
    "type": "object",
    "properties": {
      "accountMoney": { // 金额型
        "title": "账号金额"
        ...formatPriceType, // Util提供方法
      },
    },
    "description": ""
  },
}

formatDateTimeType

快捷设置 scehma 内容为为日期时间类型

import { formatDateTimeType } from 'setaria-business-framework'

const schema = {
  UserAccount: {
    title: 'User',
    required: [],
    type: 'object',
    properties: {
      createdTime: {
        // 日期时间型
        type: 'string',
        title: '创建时间',
        ...formatDateTimeType,
      },
    },
    description: '',
  },
}

formatDateType

快捷设置 scehma 内容为为日期类型

import { formatDateType } from 'setaria-business-framework'

const schema = {
  UserAccount: {
    title: 'User',
    required: [],
    type: 'object',
    properties: {
      createdTime: {
        // 日期型
        type: 'string',
        title: '创建时间',
        ...formatDateType,
      },
    },
    description: '',
  },
}