lodash#join JavaScript Examples

The following examples show how to use lodash#join. 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
/**
   * 渲染表单行
   * @param {Object[]} rowFields - 一行对应的字段
   */
  renderRow({ rowFields }) {
    const { disableStyle } = this.props;
    return (
      <Row
        type="flex"
        key={join(map(rowFields, field => field.fieldCode), '-')}
        className={disableStyle === 'value' ? 'row-disabled' : ''}
      >
        {map(rowFields, field =>
          this.renderComposeFormField({
            field,
            disableStyle,
          })
        )}
      </Row>
    );
  }
Example #2
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
/**
   * 渲染表单行
   * @param {Object[]} rowFields - 一行对应的字段
   */
  renderRow({ rowFields }) {
    const { wrapperFieldComponent } = this.props;
    return (
      <Row type="flex" key={join(map(rowFields, field => field[fieldNameProp]), '-')}>
        {map(rowFields, field => {
          if (isFunction(wrapperFieldComponent)) {
            return wrapperFieldComponent(
              this.renderComposeFormField({
                field,
              }),
              field
            );
          }
          return this.renderComposeFormField({
            field,
          });
        })}
      </Row>
    );
  }
Example #3
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
// 导出
  /**
   * 获取导出字段查询参数
   */
  @Bind()
  getExportQueryParams() {
    const { checkedKeys } = this.state;
    const fieldsValue = this.filterForm ? this.filterForm.getFieldsValue() : {};
    return {
      ...fieldsValue,
      authorityTypeQueryParams: join(checkedKeys, ','),
    };
  }
Example #4
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
// 导出

  /**
   * 获取导出字段查询参数
   */
  @Bind()
  getExportQueryParams() {
    const { checkedKeys } = this.state;
    let fieldsValue = {};
    if (this.filterFormRef) {
      fieldsValue = this.filterFormRef.props.form.getFieldsValue();
      fieldsValue.startDateActive = fieldsValue.startDateActive
        ? fieldsValue.startDateActive.format(DEFAULT_DATE_FORMAT)
        : undefined;
      fieldsValue.endDateActive = fieldsValue.endDateActive
        ? fieldsValue.endDateActive.format(DEFAULT_DATE_FORMAT)
        : undefined;
    }
    return {
      ...fieldsValue,
      authorityTypeQueryParams: join(checkedKeys, ','),
    };
  }
Example #5
Source File: index.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
// 定时报表
  @Bind()
  handleCreateRequest(fieldsValue = {}) {
    const { reportDataId } = this.state;
    const {
      form,
      dispatch,
      reportQuery: { detail = {} },
    } = this.props;
    const { paramsData = {} } = detail[reportDataId] || {};
    const { reportUuid } = paramsData;
    const { startDate, endDate, ...others } = fieldsValue;
    this.form.validateFields((err1) => {
      if (!err1) {
        const fieldValues = isUndefined(this.form)
          ? {}
          : filterNullValueObject(this.form.getFieldsValue());

        form.validateFields((err, values) => {
          const { fCodeTenant, ...othersData } = values;
          const valueData = { ...othersData, 'f-templateCode': fCodeTenant };
          const newValues = filter(valueData, (item) => !isUndefined(item));
          let strParam;
          map(fieldValues, (value, key) => {
            if (isArray(value) && value.length > 0) {
              const separator = `&${key}=`;
              if (strParam) {
                strParam = `${separator}${join(value, separator)}&${strParam}`;
              } else {
                strParam = `${separator}${join(value, separator)}`;
              }
              if (isEmpty(newValues)) {
                strParam = strParam.substring(1);
              }
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            } else if (isArray(value) && value.length === 0) {
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            }
          });
          if (!err) {
            dispatch({
              type: 'reportQuery/createRequest',
              payload: {
                strParam,
                reportUuid,
                ...fieldValues,
                ...valueData,
                startDate: startDate ? moment(startDate).format(DEFAULT_DATETIME_FORMAT) : null,
                endDate: endDate ? moment(endDate).format(DEFAULT_DATETIME_FORMAT) : null,
                tenantId: currentTenantId,
                ...others,
              },
            }).then((res) => {
              if (res) {
                notification.success();
                this.handleCloseDrawer();
              }
            });
          }
        });
      }
    });
  }
Example #6
Source File: index.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
// 定时报表
  @Bind()
  handleCreateRequest(fieldsValue = {}) {
    const { reportDataId } = this.state;
    const {
      form,
      dispatch,
      reportQuery: { detail = {} },
    } = this.props;
    const { paramsData = {} } = detail[reportDataId] || {};
    const { reportUuid } = paramsData;
    const { startDate, endDate, ...others } = fieldsValue;
    this.form.validateFields((err1) => {
      if (!err1) {
        const fieldValues = isUndefined(this.form)
          ? {}
          : filterNullValueObject(this.form.getFieldsValue());

        form.validateFields((err, values) => {
          const { fCodeTenant, ...othersData } = values;
          const valueData = { ...othersData, 'f-templateCode': fCodeTenant };
          const newValues = filter(valueData, (item) => !isUndefined(item));
          let strParam;
          map(fieldValues, (value, key) => {
            if (isArray(value) && value.length > 0) {
              const separator = `&${key}=`;
              if (strParam) {
                strParam = `${separator}${join(value, separator)}&${strParam}`;
              } else {
                strParam = `${separator}${join(value, separator)}`;
              }
              if (isEmpty(newValues)) {
                strParam = strParam.substring(1);
              }
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            } else if (isArray(value) && value.length === 0) {
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            }
          });
          if (!err) {
            dispatch({
              type: 'reportQuery/createRequest',
              payload: {
                strParam,
                reportUuid,
                ...fieldValues,
                ...valueData,
                startDate: startDate ? moment(startDate).format(DEFAULT_DATETIME_FORMAT) : null,
                endDate: endDate ? moment(endDate).format(DEFAULT_DATETIME_FORMAT) : null,
                tenantId: currentTenantId,
                ...others,
              },
            }).then((res) => {
              if (res) {
                notification.success();
                this.handleCloseDrawer();
              }
            });
          }
        });
      }
    });
  }
Example #7
Source File: index.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
/**
   * 渲染编辑表单
   */
  renderEditForm() {
    const { form, initialValue = {}, customizeForm } = this.props;
    const { idd = [], gender = [] } = this.props;
    const emailError = form.getFieldError('email');
    const sameEmail = initialValue.email === form.getFieldValue('email');
    const phoneError = form.getFieldError('phone');
    const samePhone = initialValue.phone === form.getFieldValue('phone');
    const dateFormat = getDateFormat();
    return customizeForm(
      { code: 'HIAM.SUB_ACCOUND.EDIT.FORM_EDIT', dataSource: initialValue, form },
      <Form>
        <Row>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={
                <span>
                  {intl.get('hiam.subAccount.model.user.loginName').d('账号')}&nbsp;
                  <Tooltip
                    title={intl
                      .get('hiam.subAccount.view.message.loginName.tooltip')
                      .d('不输入账户则自动生成')}
                  >
                    <Icon type="question-circle-o" />
                  </Tooltip>
                </span>
              }
            >
              {form.getFieldDecorator('loginName', {
                initialValue: initialValue.loginName,
                rules: [
                  {
                    max: 30,
                    message: intl.get('hzero.common.validation.max', {
                      max: 30,
                    }),
                  },
                  // {
                  //   pattern: CODE,
                  //   message: intl
                  //     .get('hzero.common.validation.code')
                  //     .d('大小写及数字,必须以字母、数字开头,可包含“-”、“_”、“.”、“/”'),
                  // },
                ],
              })(<Input disabled={initialValue.loginName !== undefined} />)}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.realName').d('名称')}
            >
              {form.getFieldDecorator('realName', {
                initialValue: initialValue.realName,
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl.get('hiam.subAccount.model.user.realName').d('名称'),
                    }),
                  },
                  {
                    max: 40,
                    message: intl.get('hzero.common.validation.max', {
                      max: 40,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col key="birthday" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              key="birthday"
              label={intl.get('hiam.subAccount.model.user.birthday').d('出生日期')}
            >
              {form.getFieldDecorator('birthday', {
                initialValue: initialValue.birthday
                  ? moment(initialValue.birthday, DEFAULT_DATE_FORMAT)
                  : undefined,
              })(<DatePicker format={dateFormat} style={{ width: '100%' }} placeholder="" />)}
            </Form.Item>
          </Col>
          <Col key="nickname" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.nickname').d('昵称')}
            >
              {form.getFieldDecorator('nickname', {
                initialValue: initialValue.nickname,
                rules: [
                  {
                    max: 10,
                    message: intl.get('hzero.common.validation.max', {
                      max: 10,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col key="gender" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hzero.common.gender').d('性别')}
            >
              {form.getFieldDecorator('gender', {
                initialValue: isUndefined(initialValue.gender) ? '' : `${initialValue.gender}`,
              })(
                <Select allowClear>
                  {map(gender, item => (
                    <Select.Option value={item.value} key={item.value}>
                      {item.meaning}
                    </Select.Option>
                  ))}
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col key="country" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.countryId').d('国家')}
            >
              {form.getFieldDecorator('countryId', {
                initialValue: initialValue.countryId,
              })(
                <Lov
                  code="HPFM.COUNTRY"
                  onChange={this.changeCountryId}
                  textValue={initialValue.countryName}
                  queryParams={{ enabledFlag: 1 }}
                  // textField="tenantName"
                  // disabled={!isCreate}
                />
              )}
            </Form.Item>
          </Col>
          <Col key="regionId" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.regionId').d('地区')}
            >
              {form.getFieldDecorator('regionId', {
                initialValue: initialValue.regionId,
              })(
                <Lov
                  code="HPFM.REGION"
                  queryParams={{
                    countryId: form.getFieldValue('countryId'),
                  }}
                  textValue={initialValue.regionName}
                  // textField="tenantName"
                  // disabled={!isCreate}
                />
              )}
            </Form.Item>
          </Col>
          <Col key="addressDetail" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.addressDetail').d('详细地址')}
            >
              {form.getFieldDecorator('addressDetail', {
                initialValue: initialValue.addressDetail,
                rules: [
                  {
                    max: 50,
                    message: intl.get('hzero.common.validation.max', {
                      max: 50,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              hasFeedback
              help={
                // eslint-disable-next-line no-nested-ternary
                emailError
                  ? join(emailError)
                  : (sameEmail && initialValue.email && initialValue.emailCheckFlag) ||
                    !form.getFieldValue('email')
                  ? ''
                  : intl.get('hiam.subAccount.view.validation.emailNotCheck').d('邮箱未验证')
              }
              validateStatus={
                // eslint-disable-next-line no-nested-ternary
                emailError
                  ? 'error'
                  : // eslint-disable-next-line no-nested-ternary
                  sameEmail && initialValue.email && initialValue.emailCheckFlag
                  ? 'success'
                  : form.getFieldValue('email')
                  ? 'warning'
                  : undefined
              }
              label={intl.get('hiam.subAccount.model.user.email').d('邮箱')}
            >
              {form.getFieldDecorator('email', {
                initialValue: initialValue.email,
                rules: [
                  {
                    pattern: EMAIL,
                    message: intl.get('hzero.common.validation.email').d('邮箱格式不正确'),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.phone').d('手机号码')}
              hasFeedback
              help={
                // eslint-disable-next-line no-nested-ternary
                phoneError
                  ? join(phoneError)
                  : initialValue.phoneCheckFlag
                  ? ''
                  : intl.get('hiam.subAccount.view.validation.phoneNotCheck').d('手机号码未验证')
              }
              validateStatus={
                // eslint-disable-next-line no-nested-ternary
                phoneError
                  ? 'error'
                  : samePhone && initialValue.phoneCheckFlag
                  ? 'success'
                  : 'warning'
              }
            >
              {form.getFieldDecorator('phone', {
                initialValue: initialValue.phone,
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl.get('hiam.subAccount.model.user.phone').d('手机号码'),
                    }),
                  },
                  {
                    pattern:
                      form.getFieldValue('internationalTelCode') === '+86'
                        ? PHONE
                        : NOT_CHINA_PHONE,
                    message: intl.get('hzero.common.validation.phone').d('手机格式不正确'),
                  },
                ],
              })(
                <Input
                  addonBefore={form.getFieldDecorator('internationalTelCode', {
                    initialValue:
                      initialValue.internationalTelCode || (idd[0] && idd[0].value) || '+86',
                  })(
                    <Select onChange={this.reValidationPhone}>
                      {map(idd, r => (
                        <Select.Option key={r.value} value={r.value}>
                          {r.meaning}
                        </Select.Option>
                      ))}
                    </Select>
                  )}
                />
              )}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hzero.common.date.active.from').d('有效日期从')}
            >
              {form.getFieldDecorator('startDateActive', {
                initialValue: initialValue.startDateActive && moment(initialValue.startDateActive),
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl
                        .get('hiam.subAccount.model.subAccount.startDateActive')
                        .d('有效日期从'),
                    }),
                  },
                ],
              })(
                <DatePicker
                  allowClear={false}
                  format={dateFormat}
                  style={{ width: '100%' }}
                  placeholder={null}
                  disabledDate={currentDate =>
                    form.getFieldValue('endDateActive') &&
                    moment(form.getFieldValue('endDateActive')).isBefore(currentDate, 'day')
                  }
                />
              )}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hzero.common.date.active.to').d('有效日期至')}
            >
              {form.getFieldDecorator('endDateActive', {
                initialValue: initialValue.endDateActive && moment(initialValue.endDateActive),
              })(
                <DatePicker
                  format={dateFormat}
                  style={{ width: '100%' }}
                  placeholder={null}
                  disabledDate={currentDate =>
                    form.getFieldValue('startDateActive') &&
                    moment(form.getFieldValue('startDateActive')).isAfter(currentDate, 'day')
                  }
                />
              )}
            </Form.Item>
          </Col>
          <Col {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.enabled').d('冻结')}
            >
              {form.getFieldDecorator('enabled', {
                initialValue: !!initialValue.enabled,
              })(<Switch checkedValue={false} unCheckedValue />)}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    );
  }
Example #8
Source File: EditModal.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
renderForm() {
    const {
      path,
      form,
      editRecord = {},
      isCreate = true,
      isAdmin = true,
      roleRemoveLoading,
      idd = [],
      gender = [],
      currentUser: { currentRoleCode = '' },
      passwordTipMsg = {},
    } = this.props;
    const {
      selectedRowKeys = [],
      dataSource = [],
      pagination = false,
      roleTableFetchLoading,
    } = this.state;
    const rowSelection = {
      selectedRowKeys,
      onChange: this.handleRowSelectChange,
      getCheckboxProps: (record) => ({
        disabled: (isAdmin && record._isRemote) || record.manageableFlag === 0,
      }),
    };
    const isSiteFlag = currentRoleCode === 'role/site/default/administrator';
    const emailError = form.getFieldError('email');
    const sameEmail = editRecord.email === form.getFieldValue('email');
    const phoneError = form.getFieldError('phone');
    const samePhone = editRecord.phone === form.getFieldValue('phone');
    const dateFormat = getDateFormat();
    const roleColumns = this.getRoleColumns(isSiteFlag);
    // eslint-disable-next-line no-nested-ternary
    const roleNode = isSiteFlag ? (
      <React.Fragment key="role-no-same-user-btn">
        <Row style={{ textAlign: 'right', marginBottom: 16 }}>
          <Col span={23}>
            <ButtonPermission
              permissionList={[
                {
                  code: `${path}.button.deleteUser`,
                  type: 'button',
                  meaning: '子账户管理-删除用户',
                },
              ]}
              style={
                editRecord.userType === 'P' || isCreate ? { marginRight: 8 } : { display: 'none' }
              }
              onClick={this.handleRoleRemove}
              disabled={selectedRowKeys.length === 0}
              loading={roleRemoveLoading}
            >
              {intl.get('hzero.common.button.delete').d('删除')}
            </ButtonPermission>
            <ButtonPermission
              style={
                editRecord.userType !== 'P' && !isCreate
                  ? { display: 'none' }
                  : { display: 'inline' }
              }
              permissionList={[
                {
                  code: `${path}.button.createUser`,
                  type: 'button',
                  meaning: '子账户管理-新建用户',
                },
              ]}
              type="primary"
              onClick={this.handleRoleCreate}
            >
              {intl.get('hzero.common.button.create').d('新建')}
            </ButtonPermission>
          </Col>
          <Col span={1} />
        </Row>
        <Row type="flex">
          <Col span={3} />
          <Col span={20} className={styles['rule-table']}>
            <EditTable
              bordered
              rowKey="id"
              dataSource={dataSource}
              pagination={pagination}
              loading={roleTableFetchLoading}
              columns={roleColumns}
              scroll={{ x: tableScrollWidth(roleColumns) }}
              onChange={this.handleRoleTableChange}
              rowSelection={rowSelection}
            />
          </Col>
        </Row>
      </React.Fragment>
    ) : isAdmin ? (
      <Col key="role-same-user">
        <Form.Item
          label={intl.get('hiam.subAccount.view.message.title.role').d('角色')}
          {...EDIT_FORM_ITEM_LAYOUT_COL_3}
        >
          <EditTable
            bordered
            pagination={false}
            rowKey="id"
            columns={roleColumns}
            scroll={{ x: tableScrollWidth(roleColumns) }}
            rowSelection={rowSelection}
            dataSource={dataSource}
          />
        </Form.Item>
      </Col>
    ) : (
      <React.Fragment key="role-no-same-user-btn">
        <Row style={{ textAlign: 'right', marginBottom: 16 }}>
          <Col span={23}>
            <ButtonPermission
              permissionList={[
                {
                  code: `${path}.button.deleteDiffUser`,
                  type: 'button',
                  meaning: '子账户管理-删除用户',
                },
              ]}
              style={
                editRecord.userType === 'P' || isCreate ? { marginRight: 8 } : { display: 'none' }
              }
              onClick={this.handleRoleRemove}
              disabled={selectedRowKeys.length === 0}
            >
              {intl.get('hzero.common.button.delete').d('删除')}
            </ButtonPermission>
            <ButtonPermission
              permissionList={[
                {
                  code: `${path}.button.createDiffUser`,
                  type: 'button',
                  meaning: '子账户管理-新建用户',
                },
              ]}
              type="primary"
              onClick={this.handleRoleCreate}
              style={
                editRecord.userType !== 'P' && !isCreate
                  ? { display: 'none' }
                  : { display: 'inline' }
              }
            >
              {intl.get('hzero.common.button.create').d('新建')}
            </ButtonPermission>
          </Col>
          <Col span={1} />
        </Row>
        <Row type="flex">
          <Col span={3} />
          <Col span={20} className={styles['rule-table']}>
            <EditTable
              bordered
              rowKey="id"
              dataSource={dataSource}
              pagination={pagination}
              loading={roleTableFetchLoading}
              columns={roleColumns}
              scroll={{ x: tableScrollWidth(roleColumns) }}
              onChange={this.handleRoleTableChange}
              rowSelection={isAdmin ? null : rowSelection}
            />
          </Col>
        </Row>
      </React.Fragment>
    );

    return (
      <Form>
        <Row type="flex">
          <Col key="loginName" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={
                <span>
                  {intl.get('hiam.subAccount.model.user.loginName').d('账号')}&nbsp;
                  <Tooltip
                    title={intl
                      .get('hiam.subAccount.view.message.loginName.tooltip')
                      .d('不输入账户则自动生成')}
                  >
                    <Icon type="question-circle-o" />
                  </Tooltip>
                </span>
              }
            >
              {form.getFieldDecorator('loginName', {
                initialValue: editRecord.loginName,
                rules: [
                  {
                    max: 30,
                    message: intl.get('hzero.common.validation.max', {
                      max: 30,
                    }),
                  },
                  isCreate && {
                    pattern: CODE,
                    message: intl
                      .get('hzero.common.validation.code')
                      .d('大小写及数字,必须以字母、数字开头,可包含“-”、“_”、“.”、“/”'),
                  },
                ].filter(Boolean),
              })(<Input disabled={!isCreate} />)}
            </Form.Item>
          </Col>
          <Col key="realName" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.realName').d('名称')}
            >
              {form.getFieldDecorator('realName', {
                initialValue: editRecord.realName,
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl.get('hiam.subAccount.model.user.realName').d('名称'),
                    }),
                  },
                  {
                    max: 40,
                    message: intl.get('hzero.common.validation.max', {
                      max: 40,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col key="birthday" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              key="birthday"
              label={intl.get('hiam.subAccount.model.user.birthday').d('出生日期')}
            >
              {form.getFieldDecorator('birthday', {
                initialValue: editRecord.birthday
                  ? moment(editRecord.birthday, DEFAULT_DATE_FORMAT)
                  : undefined,
              })(<DatePicker format={dateFormat} style={{ width: '100%' }} placeholder="" />)}
            </Form.Item>
          </Col>
          <Col key="nickname" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.nickname').d('昵称')}
            >
              {form.getFieldDecorator('nickname', {
                initialValue: editRecord.nickname,
                rules: [
                  {
                    max: 10,
                    message: intl.get('hzero.common.validation.max', {
                      max: 10,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col key="gender" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hzero.common.gender').d('性别')}
            >
              {form.getFieldDecorator('gender', {
                initialValue: isUndefined(editRecord.gender) ? '' : `${editRecord.gender}`,
              })(
                <Select allowClear>
                  {map(gender, (item) => (
                    <Select.Option value={item.value} key={item.value}>
                      {item.meaning}
                    </Select.Option>
                  ))}
                </Select>
              )}
            </Form.Item>
          </Col>
          <Col key="country" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.countryId').d('国家')}
            >
              {form.getFieldDecorator('countryId', {
                initialValue: editRecord.countryId,
              })(
                <Lov
                  code="HPFM.COUNTRY"
                  onChange={this.changeCountryId}
                  textValue={editRecord.countryName}
                  queryParams={{ enabledFlag: 1 }}
                  // textField="tenantName"
                  // disabled={!isCreate}
                />
              )}
            </Form.Item>
          </Col>
          <Col key="regionId" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.regionId').d('地区')}
            >
              {form.getFieldDecorator('regionId', {
                initialValue: editRecord.regionId,
              })(
                <Lov
                  code="HPFM.REGION"
                  queryParams={{
                    countryId: form.getFieldValue('countryId'),
                  }}
                  textValue={editRecord.regionName}
                  // textField="tenantName"
                  // disabled={!isCreate}
                />
              )}
            </Form.Item>
          </Col>
          <Col key="addressDetail" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.addressDetail').d('详细地址')}
            >
              {form.getFieldDecorator('addressDetail', {
                initialValue: editRecord.addressDetail,
                rules: [
                  {
                    max: 50,
                    message: intl.get('hzero.common.validation.max', {
                      max: 50,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          {isCreate && (
            <Col key="tenant" {...FORM_COL_2_LAYOUT}>
              <Form.Item
                {...MODAL_FORM_ITEM_LAYOUT}
                label={intl.get('hiam.subAccount.model.user.tenant').d('所属租户')}
              >
                {form.getFieldDecorator('organizationId', {
                  initialValue: editRecord.organizationId,
                  rules: [
                    {
                      required: true,
                      message: intl.get('hzero.common.validation.notNull', {
                        name: intl.get('hiam.subAccount.model.user.tenant').d('所属租户'),
                      }),
                    },
                  ],
                })(
                  <Lov
                    code="HPFM.TENANT"
                    textValue={editRecord.tenantName}
                    textField="tenantName"
                    disabled={!isCreate}
                    onChange={this.tenantChange}
                  />
                )}
              </Form.Item>
            </Col>
          )}
          <Col {...FORM_COL_2_LAYOUT} key="email">
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.email').d('邮箱')}
              {...(isCreate
                ? {}
                : {
                    hasFeedback: true,
                    // eslint-disable-next-line no-nested-ternary
                    help: emailError
                      ? join(emailError)
                      : (sameEmail && editRecord.email && editRecord.emailCheckFlag) ||
                        !form.getFieldValue('email')
                      ? ''
                      : intl.get('hiam.subAccount.view.validation.emailNotCheck').d('邮箱未验证'),
                    // eslint-disable-next-line no-nested-ternary
                    validateStatus: emailError
                      ? 'error'
                      : // eslint-disable-next-line no-nested-ternary
                      sameEmail && editRecord.email && editRecord.emailCheckFlag
                      ? 'success'
                      : form.getFieldValue('email')
                      ? 'warning'
                      : undefined,
                  })}
            >
              {form.getFieldDecorator('email', {
                initialValue: editRecord.email,
                rules: [
                  {
                    pattern: EMAIL,
                    message: intl.get('hzero.common.validation.email').d('邮箱格式不正确'),
                  },
                  {
                    max: 128,
                    message: intl.get('hzero.common.validation.max', {
                      max: 128,
                    }),
                  },
                ],
              })(<Input />)}
            </Form.Item>
          </Col>
          <Col key="phone" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hiam.subAccount.model.user.phone').d('手机号码')}
              {...(isCreate
                ? {}
                : {
                    hasFeedback: true,
                    // eslint-disable-next-line no-nested-ternary
                    help: phoneError
                      ? join(phoneError)
                      : editRecord.phoneCheckFlag
                      ? ''
                      : intl
                          .get('hiam.subAccount.view.validation.phoneNotCheck')
                          .d('手机号码未验证'),
                    // eslint-disable-next-line no-nested-ternary
                    validateStatus: phoneError
                      ? 'error'
                      : samePhone && editRecord.phoneCheckFlag
                      ? 'success'
                      : 'warning',
                  })}
            >
              {form.getFieldDecorator('phone', {
                initialValue: editRecord.phone,
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl.get('hiam.subAccount.model.user.phone').d('手机号码'),
                    }),
                  },
                  {
                    pattern:
                      form.getFieldValue('internationalTelCode') === '+86'
                        ? PHONE
                        : NOT_CHINA_PHONE,
                    message: intl.get('hzero.common.validation.phone').d('手机格式不正确'),
                  },
                ],
              })(
                <Input
                  addonBefore={form.getFieldDecorator('internationalTelCode', {
                    initialValue:
                      editRecord.internationalTelCode || (idd[0] && idd[0].value) || '+86',
                  })(
                    <Select onChange={this.reValidationPhone}>
                      {map(idd, (r) => (
                        <Select.Option key={r.value} value={r.value}>
                          {r.meaning}
                        </Select.Option>
                      ))}
                    </Select>
                  )}
                />
              )}
            </Form.Item>
          </Col>
          {isCreate && (
            <Col key="password" {...FORM_COL_2_LAYOUT}>
              <Form.Item
                {...MODAL_FORM_ITEM_LAYOUT}
                label={
                  <span>
                    {intl.get('hiam.subAccount.model.user.password').d('密码')}&nbsp;
                    <Tooltip
                      title={intl
                        .get('hiam.subAccount.view.message.password.tooltip')
                        .d('不输入密码则使用默认密码')}
                    >
                      <Icon type="question-circle-o" />
                    </Tooltip>
                  </span>
                }
              >
                {form.getFieldDecorator('password', {
                  rules: [
                    {
                      validator: (_, value, callback) => {
                        validatePasswordRule(value, callback, {
                          ...passwordTipMsg,
                          loginName: form.getFieldValue('loginName'),
                        });
                      },
                    },
                    {
                      max: 110,
                      message: intl.get('hzero.common.validation.max', {
                        max: 110,
                      }),
                    },
                  ],
                })(
                  <Input
                    type="password"
                    autocomplete="new-password"
                    onChange={this.validatePasswordRepeatForPassword}
                  />
                )}
              </Form.Item>
            </Col>
          )}
          <Col key="startDateActive" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              label={intl.get('hzero.common.date.active.from').d('有效日期从')}
            >
              {form.getFieldDecorator('startDateActive', {
                initialValue: editRecord.startDateActive
                  ? moment(editRecord.startDateActive, DEFAULT_DATE_FORMAT)
                  : undefined,
                rules: [
                  {
                    required: true,
                    message: intl.get('hzero.common.validation.notNull', {
                      name: intl.get('hzero.common.date.active.from').d('有效日期从'),
                    }),
                  },
                ],
              })(
                <DatePicker
                  format={dateFormat}
                  style={{ width: '100%' }}
                  placeholder={null}
                  disabledDate={(currentDate) =>
                    form.getFieldValue('endDateActive') &&
                    moment(form.getFieldValue('endDateActive')).isBefore(currentDate, 'day')
                  }
                />
              )}
            </Form.Item>
          </Col>
          <Col key="endDateActive" {...FORM_COL_2_LAYOUT}>
            <Form.Item
              {...MODAL_FORM_ITEM_LAYOUT}
              key="endDateActive"
              label={intl.get('hzero.common.date.active.to').d('有效日期至')}
            >
              {form.getFieldDecorator('endDateActive', {
                initialValue: editRecord.endDateActive
                  ? moment(editRecord.endDateActive, DEFAULT_DATE_FORMAT)
                  : undefined,
              })(
                <DatePicker
                  format={dateFormat}
                  style={{ width: '100%' }}
                  placeholder=""
                  disabledDate={(currentDate) =>
                    form.getFieldValue('startDateActive') &&
                    moment(form.getFieldValue('startDateActive')).isAfter(currentDate, 'day')
                  }
                />
              )}
            </Form.Item>
          </Col>
          {isCreate || (
            <Col key="tenant" {...FORM_COL_2_LAYOUT}>
              <Form.Item
                {...MODAL_FORM_ITEM_LAYOUT}
                label={intl.get('hiam.subAccount.model.user.tenant').d('所属租户')}
              >
                {form.getFieldDecorator('organizationId', {
                  initialValue: editRecord.organizationId,
                  rules: [
                    {
                      required: true,
                      message: intl.get('hzero.common.validation.notNull', {
                        name: intl.get('hiam.subAccount.model.user.tenant').d('所属租户'),
                      }),
                    },
                  ],
                })(
                  <Lov code="HPFM.TENANT" textValue={editRecord.tenantName} disabled={!isCreate} />
                )}
              </Form.Item>
            </Col>
          )}
          {isCreate || (
            <Col key="enabled" {...FORM_COL_2_LAYOUT}>
              <Form.Item
                {...MODAL_FORM_ITEM_LAYOUT}
                label={intl.get('hiam.subAccount.model.user.enabled').d('冻结')}
              >
                {form.getFieldDecorator('enabled', {
                  initialValue: isUndefined(editRecord.enabled) ? true : editRecord.enabled,
                })(<Switch checkedValue={false} unCheckedValue />)}
              </Form.Item>
            </Col>
          )}
        </Row>
        <Row>{roleNode}</Row>
      </Form>
    );
  }
Example #9
Source File: ButtonEdit.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
getValidateLevel2PageData(validateData, attrConfig) {
    const { propsValue = {} } = this.state;
    const editParams = propsValue.params;
    // 获取参数
    if (editParams && editParams.length) {
      // 有参数
      const validateParams = getEditTableData(editParams);
      if (!validateParams.length) {
        return Promise.reject(new Error('参数校验失败'));
      }
      const paramsStream = [];
      for (let i = 0; i < validateParams.length; i += 1) {
        paramsStream.push(validateParams[i].paramName);
        paramsStream.push(validateParams[i].paramType);
        paramsStream.push(validateParams[i].paramValue);
      }
      // eslint-disable-next-line no-param-reassign
      validateData.params = paramsStream.join(paramSep);
    }
    // 获取订阅事件
    const editSubEvents = propsValue.subEvents;
    if (editSubEvents && editSubEvents.length) {
      // 有参数
      const validateSubEvents = getEditTableData(editSubEvents);
      if (!validateSubEvents.length) {
        return Promise.reject(new Error('按钮校验失败'));
      }
      const subEventsConfig = [];
      const subEvents = [];
      for (let i = 0; i < validateSubEvents.length; i += 1) {
        // modalBtn 是一个数组存储的数据
        subEvents.push({
          attributeType: DataType.String,
          value: `${validateSubEvents[i].subEventListen}${subEventSep}${validateSubEvents[i].subEventAction}`,
        });
        subEventsConfig.push({
          attributeName: `${subEventPrefix}[${i}]`,
          attributeType: DataType.String,
          value: `${validateSubEvents[i].subEventListen}${subEventSep}${validateSubEvents[i].subEventAction}`,
        });
      }
      // eslint-disable-next-line no-param-reassign
      validateData.subEvents = subEvents;
      attrConfig.push({
        attributeName: 'subEvents',
        value: subEventsConfig,
      });
    }
    // 获取Modal按钮 和 事件
    const editModalBtns = propsValue.modalBtns;
    if (editModalBtns && editModalBtns.length) {
      // 有参数
      const validateModalBtns = getEditTableData(editModalBtns);
      if (!validateModalBtns.length) {
        return Promise.reject(new Error('按钮校验失败'));
      }
      const modalBtnsConfig = [];
      const modalBtns = [];
      for (let i = 0; i < validateModalBtns.length; i += 1) {
        // modalBtn 是一个数组存储的数据
        modalBtns.push({
          attributeType: DataType.String,
          value: `${validateModalBtns[i].btnName}${modalBtnSep}${validateModalBtns[i].btnType}${modalBtnSep}${validateModalBtns[i].btnAction}`,
        });
        modalBtnsConfig.push({
          attributeName: `${modalBtnPrefix}[${i}]`,
          attributeType: DataType.String,
          value: `${validateModalBtns[i].btnName}${modalBtnSep}${validateModalBtns[i].btnType}${modalBtnSep}${validateModalBtns[i].btnAction}`,
        });
      }
      // eslint-disable-next-line no-param-reassign
      validateData.modalBtns = modalBtns;
      attrConfig.push({
        attributeName: 'modalBtns',
        value: modalBtnsConfig,
      });
    }
    attrConfig.push({
      attributeName: 'openType',
      attributeType: DataType.String,
      value: validateData.openType,
    });
    attrConfig.push({
      [attributeNameProp]: 'pageCode',
      [attributeValueProp]: validateData.pageCode,
      [attributeTypeProp]: DataType.String,
    });
    attrConfig.push({
      [attributeNameProp]: 'pageMeaning',
      [attributeTypeProp]: DataType.String,
      [attributeValueProp]: validateData.pageMeaning,
    });
    attrConfig.push({
      [attributeNameProp]: 'params',
      [attributeValueProp]: validateData.params,
      [attributeTypeProp]: DataType.String,
    });
    // 滑出
    if (validateData.openType === ACTION_PAGE_TYPE.drawer) {
      attrConfig.push({
        [attributeNameProp]: 'openPageTypeDrawer',
        [attributeValueProp]: validateData.openPageTypeDrawer,
        [attributeTypeProp]: DataType.Number,
      });
    }
    // 弹出
    if (validateData.openType === ACTION_PAGE_TYPE.modal) {
      attrConfig.push({
        [attributeNameProp]: 'openPageTypeModal',
        [attributeValueProp]: validateData.openPageTypeModal,
        [attributeTypeProp]: DataType.String,
      });
    }
    return Promise.resolve();
  }
Example #10
Source File: index.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
// 生成报表
  @Bind()
  buildReport(pageParams = {}) {
    const { reportDataId } = this.state;
    const {
      form,
      dispatch,
      dateFormat,
      dateTimeFormat,
      reportQuery: { detail = {} },
    } = this.props;
    const { paramsData = {} } = detail[reportDataId] || {};
    const { reportUuid, formElements, reportTypeCode } = paramsData;
    this.form.validateFields((err1) => {
      if (!err1) {
        const fieldValues = isUndefined(this.form)
          ? {}
          : filterNullValueObject(this.form.getFieldsValue());

        form.validateFields((err, values) => {
          const { fCodeTenant, ...others } = values;
          const valueData = { ...others, 'f-templateCode': fCodeTenant };
          const newValues = filter(valueData, (item) => !isUndefined(item));
          let strParam = '';
          map(fieldValues, (value, key) => {
            if (isArray(value) && value.length > 0) {
              const separator = `&${key}=`;
              if (strParam) {
                strParam = `${separator}${join(value, separator)}&${strParam}`;
              } else {
                strParam = `${separator}${join(value, separator)}`;
              }
              if (isEmpty(newValues)) {
                strParam = strParam.substring(1);
              }
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            } else if (isArray(value) && value.length === 0) {
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            }
          });
          const formatFieldValues = { ...fieldValues };
          for (const key of Object.keys(fieldValues)) {
            if (isObject(fieldValues[key]) && moment(fieldValues[key]).isValid()) {
              // TODO: 处理日期时间的格式化
              formElements.forEach((n) => {
                if (n.name === key) {
                  if (n.type === 'DatePicker') {
                    formatFieldValues[key] = moment(fieldValues[key]).format(dateFormat);
                  } else if (n.type === 'DatetimePicker') {
                    formatFieldValues[key] = moment(fieldValues[key]).format(dateTimeFormat);
                  }
                }
              });
            }
          }
          if (!err) {
            if (reportTypeCode !== 'C') {
              dispatch({
                type: 'reportQuery/buildReport',
                payload: {
                  // type: reportTypeCode,
                  strParam,
                  reportUuid,
                  ...formatFieldValues,
                  ...valueData,
                  ...pageParams,
                },
              }).then((res) => {
                if (res) {
                  this.setState({ reportData: res }, () => {
                    if (reportTypeCode === 'ST') {
                      this.handleScrollDom();
                    }
                  });
                }
              });
            } else if (reportTypeCode === 'C') {
              const params = { strParam, ...formatFieldValues, ...valueData, ...pageParams };
              this.setState({
                EChartsVisible: true,
                uuidKey: uuid(),
                chartParams: params,
              });
            }
          }
        });
      }
    });
  }
Example #11
Source File: index.js    From hzero-front with Apache License 2.0 4 votes vote down vote up
// 生成报表
  @Bind()
  buildReport(pageParams = {}) {
    const { reportDataId } = this.state;
    const {
      form,
      dispatch,
      dateFormat,
      dateTimeFormat,
      reportQuery: { detail = {} },
    } = this.props;
    const { paramsData = {} } = detail[reportDataId] || {};
    const { reportUuid, formElements, reportTypeCode } = paramsData;
    this.form.validateFields((err1) => {
      if (!err1) {
        const fieldValues = isUndefined(this.form)
          ? {}
          : filterNullValueObject(this.form.getFieldsValue());

        form.validateFields((err, values) => {
          const { fCodeTenant, ...othersData } = values;
          const valueData = { ...othersData, 'f-templateCode': fCodeTenant };
          const newValues = filter(valueData, (item) => !isUndefined(item));
          let strParam = '';
          map(fieldValues, (value, key) => {
            if (isArray(value) && value.length > 0) {
              const separator = `&${key}=`;
              if (strParam) {
                strParam = `${separator}${join(value, separator)}&${strParam}`;
              } else {
                strParam = `${separator}${join(value, separator)}`;
              }
              if (isEmpty(newValues)) {
                strParam = strParam.substring(1);
              }
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            } else if (isArray(value) && value.length === 0) {
              // eslint-disable-next-line no-param-reassign
              delete fieldValues[key];
            }
          });
          const formatFieldValues = { ...fieldValues };
          for (const key of Object.keys(fieldValues)) {
            if (isObject(fieldValues[key]) && moment(fieldValues[key]).isValid()) {
              // TODO: 处理日期时间的格式化
              formElements.forEach((n) => {
                if (n.name === key) {
                  if (n.type === 'DatePicker') {
                    formatFieldValues[key] = moment(fieldValues[key]).format(dateFormat);
                  } else if (n.type === 'DatetimePicker') {
                    formatFieldValues[key] = moment(fieldValues[key]).format(dateTimeFormat);
                  }
                }
              });
            }
          }
          if (!err) {
            if (reportTypeCode !== 'C') {
              dispatch({
                type: 'reportQuery/buildReport',
                payload: {
                  // type: reportTypeCode,
                  strParam,
                  reportUuid,
                  ...formatFieldValues,
                  ...values,
                  ...pageParams,
                },
              }).then((res) => {
                if (res) {
                  this.setState({ reportData: res }, () => {
                    if (reportTypeCode === 'ST') {
                      this.handleScrollDom();
                    }
                  });
                }
              });
            } else if (reportTypeCode === 'C') {
              const params = { strParam, ...formatFieldValues, ...values, ...pageParams };
              this.setState({
                EChartsVisible: true,
                uuidKey: uuid(),
                chartParams: params,
              });
            }
          }
        });
      }
    });
  }