| | |
| | | } else if (this.record.type === 'close' || this.record.type === 'reset') { |
| | | shows = ['typeName', 'label'] |
| | | } else { |
| | | shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton', 'resetForm'] // 选项列表 |
| | | |
| | | shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton'] // 选项列表 |
| | | |
| | | if (this.record.execSuccess === 'never') { |
| | | shows.push('resetForms') |
| | | } |
| | | if (this.record.intertype === 'custom') { |
| | | shows.pop() |
| | | shows.push('procMode', 'interface', 'callbackType', 'proInterface', 'method', 'cross', 'stringify', 'ContentType', 'outerBlacklist') |
| | | if (this.record.procMode === 'system') { |
| | | shows.push('sql', 'sqlType') |
| | |
| | | })( |
| | | <Select |
| | | showSearch |
| | | mode={item.mode || ''} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={(value) => {this.optionChange(item.key, value)}} |
| | | getPopupContainer={() => document.getElementById('winter')} |
| | |
| | | if (values.outerBlacklist) { |
| | | values.outerBlacklist = values.outerBlacklist.replace(/\s/ig, '') |
| | | } |
| | | if (values.resetForms && values.resetForms.length === 0) { |
| | | values.resetForms = null |
| | | } |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | |
| | | |
| | | let resets = [] |
| | | fields.forEach(item => { |
| | | if (item.hidden === 'true') return |
| | | if (item.type !== 'text' && item.type !== 'number') return |
| | | |
| | | resets.push({ |
| | | value: item.uuid, |
| | | value: item.field, |
| | | text: item.label |
| | | }) |
| | | }) |
| | | |
| | | if (card.resetForm && resets.findIndex(item => item.value === card.resetForm) === -1) { |
| | | card.resetForm = '' |
| | | } |
| | | |
| | | return [ |
| | | { |
| | |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'resetForm', |
| | | key: 'resetForms', |
| | | label: '重置表单', |
| | | tooltip: '按钮执行成功后需要重置的表单,表单会恢复默认值并聚焦。', |
| | | initVal: card.resetForm || '', |
| | | initVal: card.resetForms || [], |
| | | required: false, |
| | | allowClear: true, |
| | | mode: 'multiple', |
| | | options: resets |
| | | }, |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | mkFormSubmit = (btnId, callback) => { |
| | | mkFormSubmit = (btnId, callback, formId) => { |
| | | const { group } = this.state |
| | | |
| | | if (group.uuid !== btnId) return |
| | | |
| | | this.formRef.handleConfirm().then(res => { |
| | | this.formRef.handleConfirm(formId).then(res => { |
| | | MKEmitter.emit('triggerFormSubmit', {menuId: btnId, form: res}) |
| | | }, () => { |
| | | callback && callback() |
| | |
| | | data={data} |
| | | action={group} |
| | | unload={config.setting.supModule && !BID} |
| | | inputSubmit={() => this.mkFormSubmit(group.uuid)} |
| | | inputSubmit={(id) => this.mkFormSubmit(group.uuid, null, id)} |
| | | wrappedComponentRef={(inst) => this.formRef = inst} |
| | | /> : null} |
| | | {data ? <div className={'mk-form-action ' + (group.$button || '')}> |
| | |
| | | const { btn } = this.props |
| | | const { autoMatic } = this.state |
| | | |
| | | if (btn.resetForm) { |
| | | MKEmitter.emit('mkFC', 'reset', btn.resetForm) |
| | | if (btn.resetForms) { |
| | | MKEmitter.emit('resetForms', btn.uuid) |
| | | } |
| | | |
| | | if (this.preCallback) { |
| | |
| | | ID: '', |
| | | send_type: '', |
| | | timestamp: '', |
| | | n_id: '' |
| | | n_id: '', |
| | | focusId: '' |
| | | } |
| | | |
| | | record = {} |
| | | submitId = '' |
| | | |
| | | componentDidMount () { |
| | | const { action, unload } = this.props |
| | |
| | | } |
| | | |
| | | if (item.type === 'number') { |
| | | if (isNaN(item.initval)) { |
| | | if (isNaN(item.initval) || item.initval === '') { |
| | | item.initval = 0 |
| | | } |
| | | } else if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') { |
| | |
| | | } |
| | | |
| | | record[item.field] = item.initval |
| | | item.orgval = item.initval |
| | | |
| | | if (linkFields[item.field]) { |
| | | item.linkFields = linkFields[item.field] |
| | | } |
| | | |
| | | if (item.enter === 'tab' || item.enter === 'sub') { |
| | | if (fieldMap.has(item.tabField)) { |
| | | item.tabUuid = '' |
| | | if (item.tabField && fieldMap.has(item.tabField)) { |
| | | item.tabUuid = fieldMap.get(item.tabField).uuid |
| | | } else if (item.enter === 'tab') { |
| | | item.enter = 'false' |
| | | } else if (item.enter === 'sub') { |
| | | } else if (item.enter === 'sub' && ['text', 'number'].includes(item.type)) { |
| | | item.tabUuid = item.uuid |
| | | } |
| | | } |
| | |
| | | |
| | | this.record = record |
| | | let ID = this.props.data ? this.props.data.$$uuid || '' : '' |
| | | let focusItem = null |
| | | |
| | | this.setState({ formlist, ID }, () => { |
| | | if (action.setting.focus && fieldMap.has(action.setting.focus)) { |
| | | focusItem = fieldMap.get(action.setting.focus) |
| | | } |
| | | |
| | | this.setState({ formlist, ID, focusId: focusItem ? focusItem.uuid : '' }, () => { |
| | | if (unload) return |
| | | |
| | | if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) { |
| | | let focusItem = fieldMap.get(action.setting.focus) |
| | | |
| | | if (focusItem) { |
| | | if (focusItem.type === 'text' || focusItem.type === 'number') { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'focus', focusItem.uuid) |
| | |
| | | } |
| | | } |
| | | }) |
| | | |
| | | if (action.subButton && action.subButton.resetForms) { |
| | | MKEmitter.addListener('resetForms', this.resetForms) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('resetForms', this.resetForms) |
| | | } |
| | | |
| | | resetForms = (id) => { |
| | | const { action } = this.props |
| | | const { focusId } = this.state |
| | | |
| | | if (id !== action.uuid) return |
| | | |
| | | let formlist = fromJS(this.state.formlist).toJS() |
| | | let resetForms = action.subButton.resetForms || [] |
| | | |
| | | formlist = formlist.map(item => { |
| | | if (item.type !== 'text' && item.type !== 'number') return item |
| | | |
| | | if (resetForms.includes(item.field)) { |
| | | item.initval = item.orgval |
| | | this.record[item.field] = item.orgval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | let _list = fromJS(formlist).toJS().map(item => { |
| | | if (item.type !== 'text' && item.type !== 'number') return item |
| | | |
| | | if (resetForms.includes(item.field) && !item.hidden) { |
| | | item.hidden = true |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | formlist: _list |
| | | }, () => { |
| | | this.setState({ |
| | | formlist |
| | | }) |
| | | }) |
| | | |
| | | if (focusId || this.submitId) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'focus', this.submitId || focusId) |
| | | }, 50) |
| | | } |
| | | } |
| | | |
| | | getFormData = (deForms) => { |
| | |
| | | return fields |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | handleConfirm = (formId) => { |
| | | const { formlist, send_type, timestamp, n_id } = this.state |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | |
| | | forms.push(_item) |
| | | }) |
| | | |
| | | this.submitId = formId || '' |
| | | |
| | | resolve(forms) |
| | | }) |
| | | }) |
| | |
| | | } else { |
| | | this.props.onChange(_val, true) |
| | | } |
| | | } else if (type === 'reset') { |
| | | let _val = this.props.config.initval |
| | | |
| | | if (this.state.encryption === 'true' && _val) { |
| | | try { |
| | | _val = window.decodeURIComponent(window.atob(_val)) |
| | | } catch (e) { |
| | | _val = this.props.config.initval |
| | | } |
| | | } |
| | | |
| | | this.setState({value: _val}, () => { |
| | | this.inputRef.current.select() |
| | | }) |
| | | |
| | | this.props.onChange(this.props.config.initval) |
| | | } |
| | | } |
| | | |
| | |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | } else { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | } |
| | | } |
| | | |
| | |
| | | } else if (type === 'input') { |
| | | this.setState({value}) |
| | | this.props.onChange(value, true) |
| | | } else if (type === 'reset') { |
| | | let _val = this.props.config.initval |
| | | |
| | | this.setState({value: _val}, () => { |
| | | let node = document.getElementById(this.props.config.uuid) |
| | | node && node.select() |
| | | }) |
| | | |
| | | this.props.onChange(_val) |
| | | } |
| | | } |
| | | |
| | |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | } else { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | } |
| | | } |
| | | |
| | |
| | | if (config.enter === 'tab') { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | } else if (config.enter === 'sub') { |
| | | config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | if (config.subFields) { |
| | | setTimeout(() => { |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | }, 1000) |
| | | } else { |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | } |
| | | } |
| | | }) |
| | |
| | | if (config.enter === 'tab') { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | } else if (config.enter === 'sub') { |
| | | config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | if (config.linkFields || config.subFields || config.controlFields) { |
| | | setTimeout(() => { |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | }, 1000) |
| | | } else { |
| | | this.props.onSubmit() |
| | | this.props.onSubmit(config.tabUuid) |
| | | } |
| | | } |
| | | }) |
| | |
| | | if (config.enter === 'tab') { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | } else { |
| | | MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | this.props.onSubmit() |
| | | config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid) |
| | | this.props.onSubmit(config.tabUuid) |
| | | } |
| | | } |
| | | |
| | |
| | | if (this.record.interception === 'func') { |
| | | shows.push('func') |
| | | } |
| | | } else if (type === 'popSelect') { |
| | | if (this.record.enter === 'tab' || this.record.enter === 'sub') { |
| | | shows.push('tabField') |
| | | } |
| | | } |
| | | |
| | | if (['multiselect', 'select', 'link', 'radio', 'checkbox', 'checkcard', 'cascader'].includes(type)) { |
| | |
| | | if (value === 'text' || value === 'number') { |
| | | this.record.enter = 'sub' |
| | | _fieldval.enter = 'sub' |
| | | } else if (value === 'select' || value === 'link') { |
| | | } else if (['select', 'link', 'popSelect', 'vercode'].includes(value)) { |
| | | _fieldval.enter = 'false' |
| | | } |
| | | |