| | |
| | | |
| | | const MKCheckCard = asyncComponent(() => import('./mkCheckCard')) |
| | | const MKSwitch = asyncComponent(() => import('./mkSwitch')) |
| | | const MKCheck = asyncComponent(() => import('./mkCheck')) |
| | | const MKCheckbox = asyncComponent(() => import('./mkCheckbox')) |
| | | const MKRadio = asyncComponent(() => import('./mkRadio')) |
| | | const MKDatePicker = asyncComponent(() => import('./mkDatePicker')) |
| | |
| | | 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 { |
| | |
| | | data: PropTypes.any, // 表格数据 |
| | | BID: PropTypes.any, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | unload: PropTypes.any, // 下拉菜单不加载数据 |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | } |
| | | |
| | | state = { |
| | | formlist: [], // 表单项 |
| | | ID: '', |
| | | send_type: '', |
| | | timestamp: '', |
| | | n_id: '' |
| | | } |
| | | |
| | | record = {} |
| | | |
| | | componentDidMount () { |
| | | const { action } = this.props |
| | | const { action, unload } = this.props |
| | | |
| | | let data = {} |
| | | let BData = {} |
| | |
| | | delete item.style.marginRight |
| | | } |
| | | |
| | | if (item.type === 'split' && item.splitctrl) { |
| | | if (data.hasOwnProperty(item.splitctrl.toLowerCase()) && data[item.splitctrl.toLowerCase()] === '') { |
| | | return false |
| | | } |
| | | } |
| | | |
| | | if (item.type === 'split' || item.type === 'formula') return true |
| | | if (item.type === 'hint') { |
| | | if (item.field && data[item.field.toLowerCase()]) { |
| | |
| | | } |
| | | delete item.field |
| | | return true |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | } else if (item.type === 'date') { |
| | | item.precision = item.precision || 'day' |
| | | } else if (item.type === 'datetime') { |
| | | item.type = 'date' |
| | | 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', 'check', '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 || {} |
| | | item.style.color = 'transparent' |
| | | item.style.opacity = 0 |
| | | item.style.width = 1 |
| | | item.style.display = 'inline-block' |
| | | } |
| | | |
| | | // 数据自动填充 |
| | |
| | | }) |
| | | } |
| | | item.oriOptions = fromJS(item.options).toJS() |
| | | |
| | | if (item.empty === 'hidden' && item.oriOptions.length === 0) { |
| | | item.hidden = true |
| | | } |
| | | if (item.type === 'checkcard' && item.readonly && item.unchecked === 'hidden') { |
| | | let selectKeys = item.initval |
| | | if (item.multiple === 'true') { |
| | | selectKeys = selectKeys ? selectKeys.split(',') : [] |
| | | item.options = item.options.filter(item => selectKeys.includes(item.$value)) |
| | | } else { |
| | | item.options = item.options.filter(item => selectKeys === item.$value) |
| | | } |
| | | item.oriOptions = fromJS(item.options).toJS() |
| | | if (item.options.length === 0) { |
| | | item.hidden = true |
| | | } |
| | | } |
| | | } |
| | | |
| | | let newval = '$empty' |
| | |
| | | if (newval === '$empty' && item.initval) { |
| | | newval = moment().subtract(item.initval, 'month').format('YYYY-MM') |
| | | } |
| | | } else if (item.type === 'switch') { // 开关只接收固定值 |
| | | } else if (item.type === 'switch' || item.type === 'check') { // 开关勾选框只接收固定值 |
| | | if (newval !== '$empty' && (newval === item.closeVal || newval === item.openVal)) { |
| | | |
| | | } else if (item.initval === true) { |
| | |
| | | }) |
| | | } else if (item.regular === 'email') { |
| | | _rules.push({ |
| | | pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, |
| | | pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, |
| | | message: item.regularText || '请正确输入邮箱地址' |
| | | }) |
| | | } |
| | |
| | | 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', |
| | |
| | | |
| | | let cell = fieldMap.get(item.field) |
| | | |
| | | if (cell.hidden) return |
| | | |
| | | // if (cell.hidden) return |
| | | |
| | | if (supItem.hidden || !item.values.includes(supItem.initval)) { |
| | | cell.hidden = true |
| | | if (cell.empty === 'hidden') { |
| | | cell.$hidden = true |
| | | } |
| | | fieldMap.set(item.field, cell) |
| | | } |
| | | |
| | |
| | | item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.value === '') |
| | | } |
| | | |
| | | if (['select', 'link', 'radio'].includes(item.type) && item.resourceType === '0') { // 选中第一项 |
| | | if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { |
| | | item.initval = item.options[0] ? item.options[0].value : '' |
| | | if (['select', 'link', 'radio'].includes(item.type)) { // 选中第一项 |
| | | if (/^\s*\$first\s*$/.test(item.initval)) { |
| | | item.$first = true |
| | | item.initval = '' |
| | | } |
| | | if (item.resourceType === '0') { // 选中第一项 |
| | | if (item.$first) { |
| | | item.initval = item.options[0] ? item.options[0].value : '' |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { |
| | | record[item.field] = '' |
| | | } else { |
| | | record[item.field] = item.initval |
| | | } |
| | | record[item.field] = item.initval |
| | | |
| | | if (linkFields[item.field]) { |
| | | item.linkFields = linkFields[item.field] |
| | |
| | | |
| | | this.record = record |
| | | |
| | | this.setState({ formlist }, () => { |
| | | this.setState({ formlist, ID: this.props.data ? this.props.data.$$uuid || '' : '' }, () => { |
| | | if (unload) return |
| | | |
| | | if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'focus', fieldMap.get(action.setting.focus).uuid) |
| | |
| | | let cache = action.setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') |
| | | |
| | | let _sql = `Declare @mk_organization nvarchar(512) select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n` |
| | | let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` |
| | | let _sso = _sql |
| | | |
| | | deForms.forEach(item => { |
| | | if (item.database === 'sso') { |
| | | let sql = _sso + item.base_sql |
| | | _sso = '' |
| | | |
| | | sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | console.info(sql) |
| | | } |
| | |
| | | } else { |
| | | let sql = _sql + item.base_sql |
| | | _sql = '' |
| | | |
| | | sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | console.info(sql) |
| | | } |
| | |
| | | LText: localItems.join(' union all '), |
| | | obj_name: '', |
| | | arr_field: '', |
| | | table_type: 'Y', |
| | | BID: BID || '' |
| | | table_type: 'Y' |
| | | } |
| | | |
| | | if (param.LText) { |
| | |
| | | LText: mainItems.join(' union all '), |
| | | obj_name: '', |
| | | arr_field: '', |
| | | table_type: 'Y', |
| | | BID: BID || '' |
| | | table_type: 'Y' |
| | | } |
| | | |
| | | if (mainparam.LText) { |
| | |
| | | improveSimpleActionForm = (deForms) => { |
| | | let cache = this.props.action.setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') |
| | | let _sql = `Declare @mk_organization nvarchar(512) select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n` |
| | | let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` |
| | | |
| | | let deffers = deForms.map((form, index) => { |
| | | let param = { |
| | | func: 'sPC_Get_SelectedList', |
| | | LText: _sql + form.base_sql, |
| | | obj_name: form.field, |
| | | arr_field: form.arr_field, |
| | | BID: this.props.BID || '' |
| | | arr_field: form.arr_field |
| | | } |
| | | |
| | | param.LText = param.LText.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | param.LText = param.LText.replace(/@BID@/ig, `'${this.props.BID || ''}'`) |
| | | |
| | | if (debug) { |
| | | console.info(param.LText) |
| | |
| | | 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() |
| | | let all = false |
| | | result[item.field].forEach(cell => { |
| | | let _cell = { key: Utils.getuuid() , ParentID: ''} |
| | | |
| | |
| | | if (item.type !== 'checkcard') { |
| | | _cell.value = cell[item.valueField] |
| | | _cell.label = cell[item.valueText] + '' |
| | | if (!_cell.label || map.has(_cell.ParentID + _cell.value)) return |
| | | if (map.has(_cell.ParentID + _cell.value)) return |
| | | if (!_cell.label) { |
| | | if (!all) { |
| | | _cell.label = '全部' |
| | | all = true |
| | | } else { |
| | | return |
| | | } |
| | | } |
| | | |
| | | map.set(_cell.ParentID + _cell.value, 0) |
| | | } else { |
| | | _cell.$value = cell[item.cardValField] |
| | | _cell = {..._cell, ...cell} |
| | | |
| | | if (item.urlField) { |
| | | _cell.$url = cell[item.urlField] || '' |
| | | } else if (item.colorField) { |
| | | _cell.$color = cell[item.colorField] || '' |
| | | } |
| | | |
| | | if (map.has(_cell.ParentID + _cell.$value)) return |
| | | |
| | |
| | | item.options = item.oriOptions |
| | | } |
| | | |
| | | if (['select', 'link', 'radio'].includes(item.type) && typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) { // 选中第一项 |
| | | if (['select', 'link', 'radio'].includes(item.type) && item.$first) { // 选中第一项 |
| | | item.initval = item.options[0] ? item.options[0].value : '' |
| | | this.record[item.field] = item.initval |
| | | } |
| | |
| | | item.subFields.forEach(n => { |
| | | reFieldsVal[n.field] = option[n.field] |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (item.empty === 'hidden' && item.oriOptions.length > 0 && !item.$hidden) { |
| | | item.hidden = false |
| | | } |
| | | if (item.type === 'checkcard' && item.readonly && item.unchecked === 'hidden') { |
| | | let selectKeys = item.initval |
| | | if (item.multiple === 'true') { |
| | | selectKeys = selectKeys ? selectKeys.split(',') : [] |
| | | item.options = item.options.filter(item => selectKeys.includes(item.$value)) |
| | | } else { |
| | | item.options = item.options.filter(item => selectKeys === item.$value) |
| | | } |
| | | item.oriOptions = fromJS(item.options).toJS() |
| | | if (item.options.length === 0) { |
| | | item.hidden = true |
| | | } else { |
| | | item.hidden = false |
| | | } |
| | | } |
| | | } |
| | |
| | | current.controlFields.forEach(cell => { |
| | | let m = map.get(cell.field) |
| | | m.hidden = current.hidden || !cell.values.includes(val) |
| | | |
| | | if (m.empty === 'hidden' && m.oriOptions.length === 0) { |
| | | m.hidden = true |
| | | } |
| | | |
| | | if (m.hidden) { |
| | | m.initval = this.record[m.field] |
| | |
| | | content = (<MKCheckCard config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>) |
| | | } else if (item.type === 'switch') { |
| | | content = (<MKSwitch config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>) |
| | | } else if (item.type === 'check') { |
| | | content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>) |
| | | } else if (item.type === 'checkbox') { |
| | | content = (<MKCheckbox config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'radio') { |
| | |
| | | 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 => { |
| | |
| | | _item.value = _item.value.slice(-item.fieldlength) |
| | | } |
| | | } |
| | | } else if (item.type.indexOf('date') > -1) { |
| | | if (item.declareType === 'nvarchar(50)') { |
| | | _item.type = 'text' |
| | | } |
| | | } else if (item.type === 'datemonth') { |
| | | _item.type = 'text' |
| | | } else if (item.type === 'date') { |
| | | _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date' |
| | | } 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) |
| | | }) |
| | | }) |
| | | } |