| | |
| | | record = {} |
| | | |
| | | componentDidMount () { |
| | | const { data, BData, action } = this.props |
| | | const { action } = this.props |
| | | |
| | | let data = {} |
| | | let BData = {} |
| | | let linkFields = {} // 关联菜单 |
| | | let controlFields = {} // 控制表单 |
| | | let deForms = [] // 需要动态获取下拉菜单的表单 |
| | |
| | | let formlist = fromJS(action.fields).toJS() |
| | | let fieldMap = new Map() |
| | | let check = action.setting.formType === 'check' |
| | | |
| | | if (this.props.data) { |
| | | Object.keys(this.props.data).forEach(key => { |
| | | data[key.toLowerCase()] = this.props.data[key] |
| | | }) |
| | | } |
| | | if (this.props.BData) { |
| | | Object.keys(this.props.BData).forEach(key => { |
| | | BData[key.toLowerCase()] = this.props.BData[key] |
| | | }) |
| | | } |
| | | |
| | | formlist = formlist.filter(item => { |
| | | if (item.supField) { // 多层表单控制 |
| | |
| | | |
| | | if (item.type === 'split' || item.type === 'formula') return true |
| | | if (item.type === 'hint') { |
| | | if (item.field && data && data[item.field]) { |
| | | item.message = data[item.field] |
| | | if (item.field && data[item.field.toLowerCase()]) { |
| | | item.message = data[item.field.toLowerCase()] |
| | | } |
| | | delete item.field |
| | | return true |
| | |
| | | item.writein = item.writein !== 'false' |
| | | item.hidden = item.hidden === 'true' |
| | | item.fieldlength = item.fieldlength || 50 |
| | | |
| | | let key = item.field.toLowerCase() |
| | | |
| | | if (item.type === 'funcvar') { |
| | | readin = false |
| | |
| | | |
| | | let newval = '$empty' |
| | | |
| | | if (readin && data && data.hasOwnProperty(item.field)) { |
| | | newval = data[item.field] |
| | | if (readin && data.hasOwnProperty(key)) { |
| | | newval = data[key] |
| | | } |
| | | if (item.type === 'linkMain') { |
| | | newval = BData && BData[item.field] ? BData[item.field] : '$empty' |
| | | newval = BData[key] || '$empty' |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | let format = 'YYYY-MM-DD' |
| | | let _format = 'YYYY-MM-DD HH:mm:ss' |
| | |
| | | if (item.regular) { |
| | | if (item.regular === 'number') { |
| | | _rules.push({ |
| | | pattern: /^[0-9.-]*$/ig, |
| | | pattern: /^[0-9.-]*$/, |
| | | message: formRule.input.numbermsg |
| | | }) |
| | | } else if (item.regular === 'letter') { |
| | | _rules.push({ |
| | | pattern: /^[a-zA-Z]*$/ig, |
| | | pattern: /^[a-zA-Z]*$/, |
| | | message: formRule.input.lettermsg |
| | | }) |
| | | } else if (item.regular === 'letter_number') { |
| | | _rules.push({ |
| | | pattern: /^[a-zA-Z0-9]*$/, |
| | | message: '请输入数字或字母' |
| | | }) |
| | | } else if (item.regular === 'letter&number') { |
| | | _rules.push({ |
| | | pattern: /^[a-zA-Z0-9@_.]*$/ig, |
| | | pattern: /^[a-zA-Z0-9@_.]*$/, |
| | | message: '请输入数字、字母以及@_.' |
| | | }) |
| | | } else if (item.regular === 'phone') { |
| | | _rules.push({ |
| | | pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ig, |
| | | pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/, |
| | | message: '请正确输入手机号' |
| | | }) |
| | | } else if (item.regular === 'email') { |
| | |
| | | }) |
| | | } else if (item.regular === 'funcname') { |
| | | _rules.push({ |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, |
| | | pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/, |
| | | message: formRule.input.funcname |
| | | }) |
| | | } |
| | |
| | | |
| | | if (fieldMap.has(item.linkField)) { |
| | | item.supInitVal = fieldMap.get(item.linkField).initval || '' |
| | | } else if (data && data.hasOwnProperty(item.linkField)) { |
| | | item.supInitVal = data[item.linkField] |
| | | } else if (data.hasOwnProperty(item.linkField.toLowerCase())) { |
| | | item.supInitVal = data[item.linkField.toLowerCase()] |
| | | } |
| | | |
| | | item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.value === '') |
| | |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (form.database === 'sso' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | return ( |
| | | new Promise(resolve => { |
| | |
| | | let _formlist = fromJS(this.state.formlist).toJS().map(item => { |
| | | if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && result[item.field] && result[item.field].length > 0) { |
| | | let options = [] |
| | | let map = new Map() |
| | | result[item.field].forEach(cell => { |
| | | let _cell = { key: Utils.getuuid() } |
| | | let _cell = { key: Utils.getuuid() , ParentID: ''} |
| | | |
| | | if (item.linkField && cell[item.linkField] !== undefined) { |
| | | _cell.ParentID = cell[item.linkField] |
| | | } |
| | | |
| | | if (item.type !== 'checkcard') { |
| | | _cell.value = cell[item.valueField] |
| | | _cell.label = cell[item.valueText] |
| | | if (!_cell.label && _cell.label !== 0) return |
| | | _cell.label = cell[item.valueText] + '' |
| | | if (!_cell.label || map.has(_cell.ParentID + _cell.value)) return |
| | | |
| | | map.set(_cell.ParentID + _cell.value, 0) |
| | | } else { |
| | | _cell.$value = cell[item.cardValField] |
| | | _cell = {..._cell, ...cell} |
| | | |
| | | if (map.has(_cell.ParentID + _cell.$value)) return |
| | | |
| | | map.set(_cell.ParentID + _cell.$value, 0) |
| | | } |
| | | |
| | | if (item.linkField) { |
| | | _cell.ParentID = cell[item.linkField] === undefined ? '' : cell[item.linkField] |
| | | } |
| | | |
| | | if (item.subFields) { |
| | | item.subFields.forEach(m => { |
| | | _cell[m.field] = cell[m.field] === undefined ? '' : cell[m.field] |
| | |
| | | } else if (item.type === 'textarea') { |
| | | 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} onChange={(val) => this.recordChange({[item.field]: val})} character={item.character ? <MkIcon type={item.character}/> : <StarFilled />} allowHalf={item.allowHalf}/>) |
| | | 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 === 'brafteditor') { |
| | | content = (<MKEditor config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | label = item.hidelabel !== 'true' ? label : '' |
| | |
| | | if (item.interception === 'true') { // 去除首尾空格 |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | | } |
| | | if (item.type === 'text') { // 特殊字段替换 |
| | | _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey) |
| | | _item.value = _item.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')) |
| | | _item.value = _item.value.replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) |
| | | if (item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 特殊字段替换 |
| | | _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) |
| | | } |
| | | } else if (item.type.indexOf('date') > -1) { |
| | | if (item.declareType === 'nvarchar(50)') { |