| | |
| | | const MKColor = asyncComponent(() => import('./mkColor')) |
| | | const MkFormula = asyncComponent(() => import('./mkFormula')) |
| | | const MkCascader = asyncComponent(() => import('./mkCascader')) |
| | | const MkVercode = asyncComponent(() => import('./mkVercode')) |
| | | const MKEditor = asyncComponent(() => import('@/components/editor')) |
| | | |
| | | class MainSearch extends Component { |
| | |
| | | |
| | | state = { |
| | | formlist: [], // 表单项 |
| | | ID: '' |
| | | ID: '', |
| | | send_type: '', |
| | | timestamp: '', |
| | | n_id: '' |
| | | } |
| | | |
| | | record = {} |
| | |
| | | item.precision = 'second' |
| | | } |
| | | |
| | | if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color'].includes(item.type)) return false |
| | | if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color', 'vercode'].includes(item.type)) return false |
| | | |
| | | if (/^\s+$/.test(item.label)) { |
| | | item.style = item.style || {} |
| | |
| | | message: formRule.input.formMessage.replace('@max', item.fieldlength) |
| | | } |
| | | ] |
| | | } else if (item.type === 'linkMain') { |
| | | } else if (item.type === 'linkMain' || item.type === 'vercode') { |
| | | item.rules = [ |
| | | { |
| | | required: item.required === 'true', |
| | |
| | | content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'rate') { |
| | | content = (<Rate count={item.rateCount} disabled={item.readonly} style={{color: item.color || '#fadb14'}} onChange={(val) => this.recordChange({[item.field]: val})} character={item.character ? <MkIcon type={item.character}/> : <StarFilled />} allowHalf={item.allowHalf}/>) |
| | | } else if (item.type === 'vercode') { |
| | | content = (<MkVercode config={item} record={this.record} onSend={(send_type, timestamp, n_id) => this.setState({send_type, timestamp, n_id})} onChange={(val) => this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit}/>) |
| | | } else if (item.type === 'brafteditor') { |
| | | content = (<MKEditor config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | label = item.hidelabel !== 'true' ? label : '' |
| | |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { formlist } = this.state |
| | | const { formlist, send_type, timestamp, n_id } = this.state |
| | | |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | |
| | | reject(err) |
| | | return |
| | | } |
| | | let search = [] |
| | | let forms = [] |
| | | let record = {...this.record, ...values} |
| | | |
| | | formlist.forEach(item => { |
| | |
| | | if (item.declareType === 'nvarchar(50)') { |
| | | _item.type = 'text' |
| | | } |
| | | } else if (item.type === 'vercode') { |
| | | _item.type = 'text' |
| | | forms.push({ |
| | | type: 'text', |
| | | readin: false, |
| | | writein: false, |
| | | fieldlen: 50, |
| | | key: 'mk_timestamp', |
| | | value: timestamp || '' |
| | | }) |
| | | |
| | | forms.push({ |
| | | type: 'text', |
| | | readin: false, |
| | | writein: false, |
| | | fieldlen: 50, |
| | | key: 'mk_send_type', |
| | | value: send_type || '' |
| | | }) |
| | | |
| | | forms.push({ |
| | | type: 'text', |
| | | readin: false, |
| | | writein: false, |
| | | fieldlen: 50, |
| | | key: 'mk_n_id', |
| | | value: n_id || '' |
| | | }) |
| | | } |
| | | |
| | | search.push(_item) |
| | | forms.push(_item) |
| | | }) |
| | | |
| | | resolve(search) |
| | | resolve(forms) |
| | | }) |
| | | }) |
| | | } |