| | |
| | | ID: '', |
| | | send_type: '', |
| | | timestamp: '', |
| | | n_id: '' |
| | | n_id: '', |
| | | focusId: '' |
| | | } |
| | | |
| | | record = {} |
| | | submitId = '' |
| | | |
| | | componentDidMount () { |
| | | const { action, unload } = this.props |
| | |
| | | item.fieldlength = item.fieldlength || 50 |
| | | |
| | | let key = item.field.toLowerCase() |
| | | |
| | | // positecgroup 表单隐藏 |
| | | if (item.tooltip && /@[a-z0-9_]+@/.test(item.tooltip)) { |
| | | let field = item.tooltip.replace(/@|\s/ig, '').toLowerCase() |
| | | |
| | | if (data[field] === 'N') { |
| | | item.hidden = true |
| | | } |
| | | |
| | | item.tooltip = '' |
| | | } |
| | | |
| | | if (item.type === 'funcvar') { |
| | | readin = false |
| | |
| | | } |
| | | |
| | | 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') { |
| | |
| | | validator: (rule, value, callback) => { |
| | | if (/'/.test(value)) { |
| | | callback('不可使用英文状态的单引号!') |
| | | } else if (/--/.test(value)) { |
| | | callback('不可使用 -- !') |
| | | // } else if (/--/.test(value)) { |
| | | // callback('不可使用 -- !') |
| | | } else { |
| | | callback() |
| | | } |
| | |
| | | validator: (rule, value, callback) => { |
| | | if (/'/.test(value)) { |
| | | callback('不可使用英文状态的单引号!') |
| | | } else if (/--/.test(value)) { |
| | | callback('不可使用 -- !') |
| | | // } else if (/--/.test(value)) { |
| | | // callback('不可使用 -- !') |
| | | } else { |
| | | callback() |
| | | } |
| | |
| | | } |
| | | |
| | | 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) => { |
| | |
| | | } else if (item.type === 'fileupload') { |
| | | className = item.readonly ? 'readonly' : '' |
| | | className += item.fileType === 'picture-card' ? ' file-upload' : '' |
| | | content = (<MKFileUpload config={item} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />) |
| | | content = (<MKFileUpload config={item} data={this.record} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />) |
| | | } else if (item.type === 'textarea') { |
| | | content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'rate') { |
| | |
| | | return fields |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | handleConfirm = (formId) => { |
| | | const { formlist, send_type, timestamp, n_id } = this.state |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | |
| | | forms.push(_item) |
| | | }) |
| | | |
| | | this.submitId = formId || '' |
| | | |
| | | resolve(forms) |
| | | }) |
| | | }) |