| | |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | const MkVercode = asyncComponent(() => import('./mkVercode')) |
| | | const MKEditor = asyncComponent(() => import('@/components/editor')) |
| | | |
| | | class MainSearch extends Component { |
| | | class MutilFormComponent extends Component { |
| | | static propTpyes = { |
| | | action: PropTypes.object, // 按钮信息、表单列表 |
| | | data: PropTypes.any, // 表格数据 |
| | |
| | | } else { |
| | | supvals.push('') |
| | | } |
| | | supvals = Array.from(new Set(supvals)) |
| | | controlFields[item.supField] = controlFields[item.supField] || [] |
| | | controlFields[item.supField].push({field: item.field, values: supvals}) |
| | | } |
| | |
| | | } |
| | | if (newval === '$empty' && item.initval) { |
| | | newval = moment().subtract(item.initval, 'days').format(_format) |
| | | } |
| | | |
| | | if (item.minDate) { |
| | | if (item.minDate === 'custom') { |
| | | if (/^\d{4}-\d{2}-\d{2}$/.test(item.minDateField)) { |
| | | item.minDate = moment(item.minDateField).format('YYYY-MM-DD') |
| | | } else { |
| | | let val = data[item.minDateField.toLowerCase()] |
| | | item.minDate = val ? moment(val).format('YYYY-MM-DD') : '' |
| | | } |
| | | |
| | | item.minDate = item.minDate === 'Invalid date' ? '' : item.minDate |
| | | } else { |
| | | item.minDate = moment().add(item.minDate, 'days').format('YYYY-MM-DD') |
| | | } |
| | | } |
| | | if (item.maxDate) { |
| | | if (item.maxDate === 'custom') { |
| | | if (/^\d{4}-\d{2}-\d{2}$/.test(item.maxDateField)) { |
| | | item.maxDate = moment(item.maxDateField).format('YYYY-MM-DD') |
| | | } else { |
| | | let val = data[item.maxDateField.toLowerCase()] |
| | | item.maxDate = val ? moment(val).format('YYYY-MM-DD') : '' |
| | | } |
| | | |
| | | item.maxDate = item.maxDate === 'Invalid date' ? '' : item.maxDate |
| | | } else { |
| | | item.maxDate = moment().add(item.maxDate, 'days').format('YYYY-MM-DD') |
| | | } |
| | | } |
| | | } else if (item.type === 'datemonth') { |
| | | if (newval !== '$empty') { |
| | |
| | | |
| | | let cell = fieldMap.get(item.field) |
| | | |
| | | // if (cell.hidden) return |
| | | |
| | | if (supItem.hidden || !item.values.includes(supItem.initval)) { |
| | | let _hidden = false |
| | | |
| | | if (supItem.hidden) { |
| | | _hidden = true |
| | | } else { |
| | | let box = [...item.values] |
| | | if (supItem.type === 'multiselect' || (supItem.type === 'checkcard' && supItem.multiple === 'true')) { |
| | | box.push(...supItem.initval.split(',')) |
| | | } else { |
| | | box.push(supItem.initval) |
| | | } |
| | | |
| | | if (box.length === Array.from(new Set(box)).length) { |
| | | _hidden = true |
| | | } |
| | | } |
| | | |
| | | if (_hidden) { |
| | | cell.hidden = true |
| | | if (cell.empty === 'hidden') { |
| | | cell.$hidden = true |
| | |
| | | }) |
| | | |
| | | item.options = fromJS(item.oriOptions).toJS() |
| | | } |
| | | item.linkSubField = null |
| | | } else if (item.type === 'switch' && item.linkSubField) { |
| | | item.options = [] |
| | | item.subFields = [] |
| | | item.linkSubField.forEach(m => { |
| | | let n = fieldMap.get(m) |
| | | if (n && ['text', 'number', 'textarea'].includes(n.type)) { |
| | | item.subFields.push({ |
| | | uuid: n.uuid, |
| | | field: m |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | if (item.subFields.length === 0) { |
| | | item.subFields = null |
| | | } else { |
| | | reFieldsVal = reFieldsVal || {} |
| | | |
| | | let val = item.initval === item.openVal ? item.openText : item.closeText |
| | | |
| | | item.subFields.forEach(n => { |
| | | reFieldsVal[n.field] = val || '' |
| | | }) |
| | | } |
| | | item.linkSubField = null |
| | | } |
| | |
| | | } |
| | | |
| | | this.record = record |
| | | let ID = this.props.data ? this.props.data.$$uuid || '' : '' |
| | | |
| | | this.setState({ formlist, ID: this.props.data ? this.props.data.$$uuid || '' : '' }, () => { |
| | | this.setState({ formlist, ID }, () => { |
| | | if (unload) return |
| | | |
| | | if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) { |
| | |
| | | } |
| | | |
| | | if (deForms.length > 0) { |
| | | if (!window.GLOB.mkHS && options.sysType === 'local' && window.GLOB.systemType !== 'production') { |
| | | this.improveSimpleActionForm(deForms) |
| | | if (action.$cache && action.setting.cache !== 'false') { |
| | | Api.getLCacheConfig(action.uuid, action.$time, this.props.BID, ID).then(res => { |
| | | if (!res.valid) { |
| | | this.getFormData(deForms) |
| | | } else { |
| | | this.resetFormList(res.data, true) |
| | | } |
| | | }) |
| | | } else { |
| | | this.improveActionForm(deForms) |
| | | this.getFormData(deForms) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getFormData = (deForms) => { |
| | | if (deForms.length === 1) { |
| | | this.improveSimpleActionForm(deForms) |
| | | } else if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { |
| | | this.improveSimpleActionForm(deForms) |
| | | } else { |
| | | this.improveActionForm(deForms) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | let deffers = [] |
| | | let mainItems = [] // 云端或单点数据 |
| | | let localItems = [] // 本地数据 |
| | | let cache = action.setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') |
| | | let cache = action.setting.cache !== 'false' && !action.$cache |
| | | let skip = false |
| | | |
| | | 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 |
| | |
| | | sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | if (window.GLOB.debugger === true) { |
| | | console.info(sql) |
| | | } |
| | | |
| | |
| | | sql = sql.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | sql = sql.replace(/@BID@/ig, `'${BID}'`) |
| | | |
| | | if (debug) { |
| | | if (window.GLOB.debugger === true) { |
| | | console.info(sql) |
| | | } |
| | | |
| | |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | skip = true |
| | | } |
| | | resolve(res) |
| | | }) |
| | |
| | | |
| | | if (window.GLOB.mkHS) { // 云端数据验证 |
| | | mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) |
| | | if (options.cloudServiceApi) { |
| | | mainparam.rduri = options.cloudServiceApi |
| | | if (window.GLOB.cloudServiceApi) { |
| | | mainparam.rduri = window.GLOB.cloudServiceApi |
| | | mainparam.userid = sessionStorage.getItem('CloudUserID') || '' |
| | | mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' |
| | | } |
| | |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | skip = true |
| | | } |
| | | resolve(res) |
| | | }) |
| | |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.resetFormList(result) |
| | | this.resetFormList(result, skip) |
| | | }) |
| | | } |
| | | |
| | |
| | | * @description 测试系统获取下拉表单选项信息 |
| | | */ |
| | | improveSimpleActionForm = (deForms) => { |
| | | let cache = this.props.action.setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud') |
| | | const { action } = this.props |
| | | |
| | | let cache = this.props.action.setting.cache !== 'false' && !action.$cache |
| | | 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 skip = false |
| | | |
| | | let deffers = deForms.map((form, index) => { |
| | | let param = { |
| | |
| | | param.LText = param.LText.replace(/@ID@/ig, `'${this.state.ID || ''}'`) |
| | | param.LText = param.LText.replace(/@BID@/ig, `'${this.props.BID || ''}'`) |
| | | |
| | | if (debug) { |
| | | if (window.GLOB.debugger) { |
| | | console.info(param.LText) |
| | | } |
| | | |
| | |
| | | message: res.message, |
| | | duration: 5 |
| | | }) |
| | | skip = true |
| | | } |
| | | resolve(res) |
| | | }) |
| | |
| | | |
| | | Promise.all(deffers).then(response => { |
| | | let result = {} |
| | | |
| | | response.forEach(res => { |
| | | result = {...result, ...res} |
| | | }) |
| | |
| | | delete result.message |
| | | delete result.status |
| | | |
| | | this.resetFormList(result) |
| | | this.resetFormList(result, skip) |
| | | }) |
| | | } |
| | | |
| | | resetFormList = (result) => { |
| | | resetFormList = (result, skip) => { |
| | | const { BID, action } = this.props |
| | | |
| | | if (action.$cache && action.setting.cache !== 'false' && !skip) { |
| | | Api.writeCacheConfig(action.uuid, fromJS(result).toJS(), BID, this.state.ID) |
| | | } |
| | | |
| | | let reFieldsVal = null |
| | | 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) { |
| | |
| | | |
| | | current.controlFields.forEach(cell => { |
| | | let m = map.get(cell.field) |
| | | m.hidden = current.hidden || !cell.values.includes(val) |
| | | |
| | | m.hidden = false |
| | | |
| | | if (current.hidden) { |
| | | m.hidden = true |
| | | } else { |
| | | let box = [...cell.values] |
| | | if (current.type === 'multiselect' || (current.type === 'checkcard' && current.multiple === 'true')) { |
| | | box.push(...val.split(',')) |
| | | } else { |
| | | box.push(val) |
| | | } |
| | | |
| | | if (box.length === Array.from(new Set(box)).length) { |
| | | m.hidden = true |
| | | } |
| | | } |
| | | |
| | | if (m.empty === 'hidden' && m.oriOptions.length === 0) { |
| | | m.hidden = true |
| | |
| | | className = 'checkcard' |
| | | 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)}/>) |
| | | content = (<MKSwitch config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>) |
| | | } else if (item.type === 'check') { |
| | | content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>) |
| | | } else if (item.type === 'checkbox') { |
| | |
| | | _item.fieldlen = item.decimal || 0 |
| | | } else if (['text', 'textarea', 'linkMain'].includes(item.type)) { |
| | | _item.value = _item.value + '' |
| | | _item.value = _item.value.replace(/\t*|\v*/g, '') // 去除制表符 |
| | | _item.value = _item.value.replace(/\t+|\v+/g, '') // 去除制表符 |
| | | |
| | | if (item.interception !== 'false') { // 去除首尾空格 |
| | | _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') |
| | |
| | | } |
| | | } |
| | | |
| | | export default Form.create()(MainSearch) |
| | | export default Form.create()(MutilFormComponent) |