| | |
| | | visible: false, |
| | | editform: null, |
| | | formlist: null, |
| | | sqlVerifing: false, |
| | | standardform: null |
| | | sqlVerifing: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | * @description 表单编辑 |
| | | */ |
| | | handleForm = (_item) => { |
| | | const { card, appType } = this.state |
| | | const { card } = this.state |
| | | let _form = fromJS(_item).toJS() |
| | | let _inputfields = [] |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | card.subcards[0].fields.forEach((item, i) => { |
| | | if (_form.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || _form.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | }) |
| | | }) |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = card.subcards[0].fields[index + 1] || null |
| | | } else { |
| | | standardform = card.subcards[0].fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let _fields = _linkableFields.map(cell => cell.field) |
| | | card.columns.forEach(col => { |
| | | if (col.field && !_fields.includes(col.field)) { |
| | |
| | | _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (appType !== 'mob' && !_form.span && standardform && standardform.span) { |
| | | _form.span = standardform.span |
| | | _form.labelwidth = standardform.labelwidth |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | editform: _form, |
| | | formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) |
| | |
| | | handleSubmit = () => { |
| | | let _config = fromJS(this.state.card).toJS() |
| | | |
| | | this.formRef.handleConfirm(_config.subcards[0].fields).then(res => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | _config.subcards[0].fields = _config.subcards[0].fields.map(item => { |
| | | delete item.focus |
| | | |
| | |
| | | card={this.state.editform} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={card.subcards[0].fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | visible: false, |
| | | editform: null, |
| | | formlist: null, |
| | | sqlVerifing: false, |
| | | standardform: null |
| | | sqlVerifing: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | * @description 表单编辑 |
| | | */ |
| | | handleForm = (_item) => { |
| | | const { card, group, appType } = this.state |
| | | const { card, group } = this.state |
| | | let _form = fromJS(_item).toJS() |
| | | let _inputfields = [] |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | group.fields.forEach((item, i) => { |
| | | if (_form.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || _form.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | }) |
| | | }) |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = group.fields[index + 1] || null |
| | | } else { |
| | | standardform = group.fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let _fields = _linkableFields.map(cell => cell.field) |
| | | card.columns.forEach(col => { |
| | | if (col.field && !_fields.includes(col.field)) { |
| | |
| | | _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (appType !== 'mob' && !_form.span && standardform && standardform.span) { |
| | | _form.span = standardform.span |
| | | _form.labelwidth = standardform.labelwidth |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | editform: _form, |
| | | formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) |
| | |
| | | handleSubmit = () => { |
| | | let _config = fromJS(this.state.group).toJS() |
| | | |
| | | this.formRef.handleConfirm(_config.fields).then(res => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | _config.fields = _config.fields.map(item => { |
| | | delete item.focus |
| | | |
| | |
| | | card={this.state.editform} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={group.fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | visible: false, |
| | | editform: null, |
| | | formlist: null, |
| | | sqlVerifing: false, |
| | | standardform: null |
| | | sqlVerifing: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | * @description 表单编辑 |
| | | */ |
| | | handleForm = (_item) => { |
| | | const { card, group, appType } = this.state |
| | | const { card, group } = this.state |
| | | let _form = fromJS(_item).toJS() |
| | | let _inputfields = [] |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | group.fields.forEach((item, i) => { |
| | | if (_form.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || _form.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | }) |
| | | }) |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = group.fields[index + 1] || null |
| | | } else { |
| | | standardform = group.fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let _fields = _linkableFields.map(cell => cell.field) |
| | | card.columns.forEach(col => { |
| | | if (col.field && !_fields.includes(col.field)) { |
| | |
| | | _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (appType !== 'mob' && !_form.span && standardform && standardform.span) { |
| | | _form.span = standardform.span |
| | | _form.labelwidth = standardform.labelwidth |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | editform: _form, |
| | | formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) |
| | |
| | | handleSubmit = () => { |
| | | let _config = fromJS(this.state.group).toJS() |
| | | |
| | | this.formRef.handleConfirm(_config.fields).then(res => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | _config.fields = _config.fields.map(item => { |
| | | delete item.focus |
| | | |
| | |
| | | card={this.state.editform} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={group.fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | originConfig: null, // 原始菜单 |
| | | sqlVerifing: false, // sql验证 |
| | | showField: false, // 显示表单字段值 |
| | | standardform: null, |
| | | saving: false |
| | | } |
| | | |
| | |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | config.fields.forEach((item, i) => { |
| | | if (card.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || card.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | label: item.label + '-表单' |
| | | }) |
| | | }) |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = config.fields[index + 1] || null |
| | | } else { |
| | | standardform = config.fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let columns = componentConfig.columns |
| | | if (btn.$sub) { |
| | |
| | | card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (!card.span && standardform && standardform.span) { |
| | | card.span = standardform.span |
| | | card.labelwidth = standardform.labelwidth |
| | | } else if (!card.span) { |
| | | card.span = 12 |
| | | card.labelwidth = 33.3 |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | card: card, |
| | | formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns) |
| | |
| | | card={card} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={config.fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | originConfig: null, // 原始菜单 |
| | | sqlVerifing: false, // sql验证 |
| | | showField: false, // 显示表单字段值 |
| | | standardform: null, |
| | | saving: false |
| | | } |
| | | |
| | |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | config.fields.forEach((item, i) => { |
| | | if (card.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || card.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | }) |
| | | }) |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = config.fields[index + 1] || null |
| | | } else { |
| | | standardform = config.fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let columns = componentConfig.columns |
| | | if (btn.$sub) { |
| | | columns = componentConfig.subColumns || [] |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | card: card, |
| | | formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns) |
| | |
| | | card={card} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={config.fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | |
| | | MKEmitter.removeListener('mkFC', this.mkFormFocus) |
| | | } |
| | | |
| | | mkFormFocus = (type, uuid) => { |
| | | mkFormFocus = (type, uuid, val, level) => { |
| | | if (uuid !== this.props.config.uuid) return |
| | | if (type !== 'focus') return |
| | | |
| | | if (type === 'focus') { |
| | | let _div = document.getElementById(uuid) |
| | | _div && _div.click && _div.click() |
| | | } else if (type === 'input' && (!level || level < 10)) { |
| | | let _level = level || 1 |
| | | this.selectChange(val, _level++) |
| | | } |
| | | } |
| | | |
| | | mkFormHandle = (uuid, parentId, level) => { |
| | |
| | | } |
| | | } |
| | | |
| | | selectChange = (val) => { |
| | | selectChange = (val, level) => { |
| | | const { config } = this.state |
| | | let other = {} |
| | | |
| | |
| | | option && config.subFields.forEach((n, i) => { |
| | | other[n.field] = option[n.field] |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field]) |
| | | MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field], level) |
| | | }, i * 5) |
| | | }) |
| | | } |
| | |
| | | value={value} |
| | | dropdownMatchSelectWidth={config.dropdown !== 'false'} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.selectChange} |
| | | onSelect={(val) => this.selectChange(val)} |
| | | onChange={(val) => val === undefined && this.selectChange('')} |
| | | disabled={config.readonly} |
| | | > |
| | |
| | | let _tabfields = [] |
| | | let _linkableFields = [] |
| | | let _linksupFields = [] |
| | | let standardform = null |
| | | let index = null |
| | | |
| | | config.fields.forEach((item, i) => { |
| | | if (card.uuid === item.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | if (!item.field || card.field === item.field) return |
| | | |
| | | if (['text', 'number', 'textarea', 'color'].includes(item.type)) { |
| | | if (['text', 'number', 'textarea', 'select'].includes(item.type)) { |
| | | _inputfields.push({ |
| | | field: item.field, |
| | | label: item.label |
| | |
| | | label: item.label + '-表单' |
| | | }) |
| | | }) |
| | | |
| | | if (index !== null) { |
| | | if (index === 0) { |
| | | standardform = config.fields[index + 1] || null |
| | | } else { |
| | | standardform = config.fields[index - 1] || null |
| | | } |
| | | } |
| | | |
| | | let _fields = _linkableFields.map(cell => cell.field) |
| | | if (subTabConfig) { |
| | |
| | | card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | if (!card.span && standardform && standardform.span) { |
| | | card.span = standardform.span |
| | | card.labelwidth = standardform.labelwidth |
| | | } else if (!card.span) { |
| | | card.span = 12 |
| | | card.labelwidth = 33.3 |
| | | } |
| | | |
| | | this.setState({ |
| | | standardform, |
| | | visible: true, |
| | | card: card, |
| | | formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields) |
| | |
| | | card={this.state.card} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | standardform={this.state.standardform} |
| | | fields={config.fields} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> |
| | | </Modal> |
| | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | formlist: PropTypes.any, |
| | | standardform: PropTypes.any, |
| | | fields: PropTypes.array, |
| | | card: PropTypes.object, |
| | | inputSubmit: PropTypes.any |
| | | } |
| | |
| | | changeVal = (val, type) => { |
| | | if (type !== 'span' || ![24, 12, 8, 6].includes(val)) return |
| | | |
| | | const { standardform } = this.props |
| | | const { card, fields } = this.props |
| | | |
| | | if (!standardform || ![24, 12, 8, 6].includes(standardform.span) || !standardform.labelwidth) return |
| | | let index = fields.findIndex(item => card.uuid === item.uuid) |
| | | let stform = fields[index - 1] |
| | | |
| | | if (!stform || ![24, 12, 8, 6].includes(stform.span) || !stform.labelwidth) return |
| | | |
| | | let labelwidth = null |
| | | |
| | | if (standardform.span === val) { |
| | | labelwidth = standardform.labelwidth |
| | | } else if (standardform.span > val) { |
| | | if (stform.span === val) { |
| | | labelwidth = stform.labelwidth |
| | | } else if (stform.span > val) { |
| | | labelwidth = 33.3 |
| | | } else { |
| | | switch(standardform.span) { |
| | | switch(stform.span) { |
| | | case 12: |
| | | labelwidth = 16.2 |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | handleConfirm = (fields) => { |
| | | const { card } = this.props |
| | | handleConfirm = () => { |
| | | const { card, fields } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |