lodash#toSafeInteger JavaScript Examples

The following examples show how to use lodash#toSafeInteger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
constructor(props) {
    super(props);
    const {
      location: { search = '' },
      match: { params },
    } = props;
    const {
      sync = false,
      auto = false,
      prefixPatch,
      args = 'null',
      autoRefreshInterval,
      backPath,
      tenantId = getCurrentOrganizationId(),
      action,
      key,
    } = queryString.parse(search);
    this.state = {
      sync, // 是否是同步的接口
      auto, // 是否是 同步自动的接口
      backPath: backPath || undefined, // 返回地址, 如果返回地址为空, 设置为 undefined
      // 兼容 两个模式, 1: 使用者指定前缀, 2: 前缀由服务端确认
      prefixPatch, // 客户端路径前缀
      args, // 上传文件时传递的数据
      tenantId, // 租户id, 是可配置的
      autoRefreshInterval: toSafeInteger(autoRefreshInterval) || AUTO_REFRESH_DEBOUNCE,
      code: params.code,
      action,
      key,
    };
  }
Example #2
Source File: Form.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
parserSort(value) {
    return toSafeInteger(value);
  }
Example #3
Source File: Form.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
parserSort(value) {
    return toSafeInteger(value);
  }
Example #4
Source File: index.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
// 自动刷新的 定时器

  constructor(props) {
    super(props);
    const {
      sync = false,
      auto = false,
      prefixPatch,
      args = 'null',
      autoRefreshInterval,
      backPath,
      tenantId = getCurrentOrganizationId(),
      code, // 导入编码
      action, // 标题
      pathKey, // 通用导入tab页的key
    } = this.props;
    this.autoRefreshInterval = toSafeInteger(autoRefreshInterval) || AUTO_REFRESH_DEBOUNCE;
    this.state = {
      dynamicColumns: [], // 动态列
      dataSource: [], // 数据源
      pagination: false, // 后端分页
      batch: null, // 批次号
      status: null, // 状态
      defaultSheet: '', // 默认sheet
      templateTargetList: [], // 模板sheet数据
      sync, // 是否是同步的接口
      auto, // 是否是 同步自动的接口
      backPath: backPath || undefined, // 返回地址, 如果返回地址为空, 设置为 undefined
      // 兼容 两个模式, 1: 使用者指定前缀, 2: 前缀由服务端确认
      prefixPatch, // 客户端路径前缀
      fragmentFlag: 0, // 是否分片上传
      importStatus: [], // 数据导入状态
      // searchDataImportStatus: '', // 数据导入状态查询条件
      // // count: 0, // 导入数据总数
      // // ready: 0, // 已完成导入数据条数
      args: JSON.parse(args), // 上传文件时传递的数据
      historyVisible: false, //
      tenantId, // 租户id, 是可配置的
      code, // 导入编码
      action, // 标题
      key: pathKey, // 通用导入tab页的key
      languageType: [],
    };
  }
Example #5
Source File: index.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
@Bind()
  getColumns() {
    const { controllerType = [] } = this.props;
    const defaultColumns = [
      {
        title: intl.get('hiam.menuConfig.model.menuConfig.permissionSetCode').d('权限集编码'),
        dataIndex: 'code',
        width: 300,
        render: (val, record) => {
          if (record._status === 'create') {
            const { getFieldDecorator } = record.$form;
            return (
              <Form.Item>
                {getFieldDecorator('code', {
                  initialValue: record.code,
                  rules: [
                    {
                      required: true,
                      message: intl.get('hzero.common.validation.notNull', {
                        name: intl
                          .get('hiam.menuConfig.model.menuConfig.permissionSetCode')
                          .d('权限集编码'),
                      }),
                    },
                    {
                      pattern: CODE_LOWER,
                      message: intl
                        .get('hzero.common.validation.codeLower')
                        .d('全小写及数字,必须以字母、数字开头,可包含“-”、“_”、“.”、“/”'),
                    },
                    {
                      max: 128,
                      message: intl.get('hzero.common.validation.max', {
                        max: 128,
                      }),
                    },
                  ],
                })(
                  <Input
                    trim
                    style={{ width: 200 }}
                    typeCase="lower"
                    inputChinese={false}
                    disabled={record._status !== 'create'}
                  />
                )}
              </Form.Item>
            );
          } else {
            return val;
          }
        },
      },
      {
        title: intl.get('hiam.menuConfig.model.menuConfig.permissionSetName').d('权限集名称'),
        dataIndex: 'name',
        width: 160,
        render: (val, record) => {
          const { _token } = record;
          if (record._status === 'update' || record._status === 'create') {
            const { getFieldDecorator } = record.$form;
            return (
              <Form.Item>
                {getFieldDecorator('name', {
                  initialValue: record.name,
                  rules: [
                    {
                      required: true,
                      message: intl.get('hzero.common.validation.notNull', {
                        name: intl
                          .get('hiam.menuConfig.model.menuConfig.permissionSetName')
                          .d('权限集名称'),
                      }),
                    },
                    {
                      max: 128,
                      message: intl.get('hzero.common.validation.max', {
                        max: 128,
                      }),
                    },
                  ],
                })(<TLEditor field="name" token={_token} />)}
              </Form.Item>
            );
          } else {
            return val;
          }
        },
      },
      {
        title: intl.get('hiam.menuConfig.model.menuConfig.sort').d('序号'),
        dataIndex: 'sort',
        width: 80,
        render: (val, record) => {
          if (record._status === 'update' || record._status === 'create') {
            const { getFieldDecorator } = record.$form;
            return (
              <Form.Item>
                {getFieldDecorator('sort', {
                  initialValue: record.sort,
                })(<InputNumber style={{ width: 70 }} min={0} step={1} parser={toSafeInteger} />)}
              </Form.Item>
            );
          } else {
            return val;
          }
        },
      },
      {
        dataIndex: 'permissionType',
        title: intl.get('hiam.menuConfig.model.menuConfig.permissionType').d('权限类型'),
        width: 150,
        render: (value = '') => {
          const texts = {
            api: intl.get('hiam.roleManagement.view.message.api').d('API'),
            button: intl.get('hiam.roleManagement.view.message.button').d('按钮'),
            table: intl.get('hiam.roleManagement.view.message.table').d('表格列'),
            formItem: intl.get('hiam.roleManagement.view.message.formItem').d('表单项'),
            formField: intl.get('hiam.roleManagement.view.message.formField').d('表单域'),
          };
          const valueList = value.split(',') || [];
          const text = valueList.map((item) => (texts[item] ? texts[item] : '')) || [];
          return value === undefined || value === '' ? null : (
            <Tag color={value === 'api' ? 'green' : 'orange'}>{text.join()}</Tag>
          );
        },
      },
      {
        title: intl
          .get('hiam.menuConfig.model.menuConfig.controllerTypeMeaning')
          .d('权限集控制类型'),
        width: 120,
        dataIndex: 'controllerTypeMeaning',
        render: (val, record) => {
          if (
            (record._status === 'update' || record._status === 'create') &&
            record.permissionType !== 'api'
          ) {
            const { getFieldDecorator } = record.$form;
            return (
              <Form.Item>
                {getFieldDecorator('controllerType', {
                  initialValue: record.controllerType,
                })(
                  <Select style={{ width: '100%' }} allowClear>
                    {controllerType.map((item) => (
                      <Select.Option value={item.value} key={item.value}>
                        {item.meaning}
                      </Select.Option>
                    ))}
                  </Select>
                )}
              </Form.Item>
            );
          } else {
            return val;
          }
        },
      },
      {
        title: intl.get('hiam.menuConfig.model.menuConfig.description').d('描述'),
        dataIndex: 'description',
        render: (val, record) => {
          if (record._status === 'update' || record._status === 'create') {
            const { getFieldDecorator } = record.$form;
            return (
              <Form.Item>
                {getFieldDecorator('description', {
                  initialValue: record.description,
                })(<Input />)}
              </Form.Item>
            );
          } else {
            return val;
          }
        },
      },
      {
        title: intl.get('hzero.common.status').d('状态'),
        dataIndex: 'enabledFlag',
        render: enableRender,
        width: 80,
      },
      {
        title: intl.get('hzero.common.table.column.option').d('操作'),
        width: 260,
        fixed: 'right',
        render: this.operationRender,
      },
    ];
    return defaultColumns;
  }