| | |
| | | }) |
| | | } |
| | | |
| | | handleInputNumber = (rule, value, callback, item) => { |
| | | if (item.required === 'true' && (!value && value !== 0)) { |
| | | callback() |
| | | } else if ((item.min || item.min === 0) && (value || value === 0) && value < item.min) { |
| | | callback(item.label + '最小值为' + item.min + '!') |
| | | } else if ((item.max || item.max === 0) && (value || value === 0) && value > item.max) { |
| | | callback(item.label + '最大值为' + item.max + '!') |
| | | } |
| | | } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | |
| | |
| | | let max = (item.max || item.max === 0) ? item.max : Infinity |
| | | let _initval = item.initval |
| | | let precision = (item.decimal || item.decimal === 0) ? item.decimal : null |
| | | let rules = [] |
| | | if ((item.min || item.min === 0) || (item.max || item.max === 0)) { |
| | | rules.push({ |
| | | validator: (rule, value, callback) => {this.handleInputNumber(rule, value, callback, item)} |
| | | }) |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | |
| | | { |
| | | required: item.required === 'true', |
| | | message: this.props.dict['form.required.input'] + item.label + '!' |
| | | } |
| | | }, |
| | | ...rules |
| | | ] |
| | | })( |
| | | precision === null ? |
| | |
| | | .ant-input-number { |
| | | width: 100%; |
| | | } |
| | | .ant-form-explain { |
| | | overflow:hidden; |
| | | text-overflow:ellipsis; |
| | | white-space:nowrap; |
| | | } |
| | | p { |
| | | color: #1890ff; |
| | | border-bottom: 1px solid #d9d9d9; |
| | |
| | | tooltipClass: 'middle', |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | initVal: card.field, |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | newcard.valueText = '' |
| | | newcard.orderBy = '' |
| | | newcard.orderType = 'asc' |
| | | newcard.decimal = 0 |
| | | newcard.min = '' |
| | | newcard.max = '' |
| | | newcard.readonly = 'false' |
| | | newcard.required = 'true' |
| | | newcard.focus = true |
| | |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'min', |
| | | label: '最小值', |
| | | initVal: card.min || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'max', |
| | | label: '最大值', |
| | | initVal: card.max || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'readonly', |
| | | label: this.state.dict['header.form.readonly'], |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | decimal: 0, |
| | | min: '', |
| | | max: '', |
| | | readonly: 'false', |
| | | required: 'true' |
| | | } |
| | |
| | | } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } else if (type === 'number') { |
| | | _options = [..._options, 'decimal'] |
| | | _options = [..._options, 'decimal', 'min', 'max'] |
| | | } else if (type === 'fileupload') { |
| | | _options = ['label', 'field', 'type', 'readonly', 'required'] |
| | | } |
| | |
| | | } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } else if (value === 'number') { |
| | | _options = [..._options, 'decimal'] |
| | | _options = [..._options, 'decimal', 'min', 'max'] |
| | | } else if (value === 'fileupload') { |
| | | _options = ['label', 'field', 'type', 'readonly', 'required'] |
| | | } |
| | |
| | | let rules = [] |
| | | if (item.key === 'field') { |
| | | rules = [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || 0, |
| | | initialValue: item.initVal, |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | |
| | | } |
| | | if (emptys.length > 0) { |
| | | isvalid = false |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['header.form.selectItem.error'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') { |
| | | values.options = [] |
| | | } else if (values.type === 'funcvar') { // 函数变量为只读元素 |
| | | values.readonly = 'true' |
| | | } else if (values.type === 'number' && (values.min || values.min === 0) && (values.max || values.max === 0)) { // 数值型验证最小最大值 |
| | | if (values.min > values.max) { |
| | | isvalid = false |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '最小值不可大于最大值!', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (isvalid) { |
| | | resolve(values) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.props.dict['header.form.selectItem.error'], |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } else { |
| | | reject(err) |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | decimal: 0, |
| | | min: '', |
| | | max: '', |
| | | readonly: 'false', |
| | | required: 'false' |
| | | }, { |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | decimal: 0, |
| | | min: '', |
| | | max: '', |
| | | readonly: 'false', |
| | | required: 'false' |
| | | }, { |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | decimal: 0, |
| | | min: '', |
| | | max: '', |
| | | readonly: 'false', |
| | | required: 'false' |
| | | } |
| | |
| | | tooltipClass: 'middle', |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | initVal: card.field, |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | tooltipClass: 'middle', |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |
| | |
| | | initVal: card.field, |
| | | required: true, |
| | | rules: [{ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_' |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_-]*$/ig, |
| | | message: '字段名只允许包含数字、字母、汉字以及_-' |
| | | }, { |
| | | max: 50, |
| | | message: '字段名最多50个字符!' |