| | |
| | | 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) |
| | | }) |
| | | }) |