| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox, AutoComplete, Modal } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import { formRule } from '@/utils/option.js' |
| | | import { dateOptions } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import EditTable from './modaleditable' |
| | | import { checkSQL } from '@/utils/utils-custom.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const FieldsTable = asyncComponent(() => import('./fieldtable')) |
| | | const DataTable = asyncComponent(() => import('./datatable')) |
| | | const FieldsTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | | |
| | | const modalTypeOptions = { |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl'], |
| | | number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom'], |
| | | select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'], |
| | | checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'arrange', 'marginTop', 'marginBottom'], |
| | | radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText', 'splitline', 'arrange', 'marginTop', 'marginBottom'], |
| | | checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom'], |
| | | text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl', 'inputType', 'constant', 'mkfocus'], |
| | | number: ['initval', 'readonly', 'notZero', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom', 'mkfocus', 'format'], |
| | | select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'], |
| | | checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'arrange', 'marginTop', 'marginBottom'], |
| | | radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'arrange', 'marginTop', 'marginBottom'], |
| | | checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'place', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom'], |
| | | multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'dropdown'], |
| | | link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkField', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'], |
| | | fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'compress', 'miniSet', 'splitline', 'marginTop', 'marginBottom', 'maxSize'], |
| | | switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom'], |
| | | date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'], |
| | | datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'splitline', 'marginTop', 'marginBottom'], |
| | | datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'], |
| | | cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'separator'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'], |
| | | link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkField', 'linkSubField', 'span', 'place', 'labelwidth', 'tooltip', 'extra', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'], |
| | | fileupload: ['readonly', 'required', 'hidden', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'linkSubField', 'tooltip', 'extra', 'compress', 'miniSet', 'splitline', 'marginTop', 'marginBottom', 'maxSize'], |
| | | switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'linkSubField', 'tooltip', 'extra', 'enter', 'splitline', 'marginTop', 'marginBottom'], |
| | | check: ['initval', 'openVal', 'closeVal', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'splitline', 'marginTop', 'marginBottom', 'checkTip'], |
| | | date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'declareType', 'mode', 'splitline', 'place', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'], |
| | | datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'splitline', 'place', 'marginTop', 'marginBottom'], |
| | | // datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'], |
| | | textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'place', 'count', 'placeholder', 'marginTop', 'marginBottom'], |
| | | cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'marginTop', 'marginBottom', 'separator'], |
| | | color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'colorType', 'extra', 'marginTop', 'marginBottom'], |
| | | rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'color', 'rateCount', 'character', 'place'], |
| | | hint: ['label', 'field', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], |
| | | split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline'], |
| | | formula: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'span', 'labelwidth', 'formula', 'eval', 'postfix'], |
| | | hint: ['label', 'field', 'type', 'blacklist', 'supField', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], |
| | | split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'splitctrl', 'supField', 'opacity'], |
| | | formula: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'supField', 'span', 'labelwidth', 'formula', 'eval', 'postfix'], |
| | | brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'], |
| | | funcvar: ['span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], |
| | | linkMain: ['readonly', 'required', 'hidden','declare', 'span', 'labelwidth', 'tooltip', 'interception', 'extra', 'marginTop', 'marginBottom'] |
| | | linkMain: ['readonly', 'required', 'hidden','declare', 'span', 'labelwidth', 'tooltip', 'interception', 'extra', 'place', 'marginTop', 'marginBottom'], |
| | | popSelect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'enter', 'dataSource', 'columns', 'primaryKey', 'order', 'controlField', 'laypage', 'onload', 'searchKey', 'showField', 'popWidth'], |
| | | vercode: ['label', 'field', 'type', 'blacklist', 'supField', 'readonly', 'required', 'hidden', 'span', 'labelwidth', 'tooltip', 'marginTop', 'marginBottom', 'placeholder', 'enter', 'smsId', 'phoneField', 'sendType'] |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | formlist: PropTypes.any, |
| | | standardform: PropTypes.any, |
| | | card: PropTypes.object, |
| | |
| | | |
| | | if (item.key === 'linkSubField') { |
| | | item.options.forEach(cell => { |
| | | transfield[cell.field] = cell.label |
| | | transfield[cell.field] = cell.label.replace(/^\d+、/, '') |
| | | }) |
| | | } |
| | | }) |
| | |
| | | |
| | | reRequired.field = true |
| | | |
| | | if (['hint', 'split', 'formula'].includes(type)) { |
| | | if (['hint', 'split', 'formula', 'vercode'].includes(type)) { |
| | | reRequired.field = false |
| | | shows = fromJS(modalTypeOptions[type]).toJS() |
| | | } |
| | |
| | | } |
| | | if (this.record.regular !== '') { |
| | | shows.push('regularText') |
| | | if (this.record.regular !== 'phone' && this.record.regular !== 'email') { |
| | | shows.push('regularExtra') |
| | | } |
| | | } |
| | | if (this.record.interception === 'func') { |
| | | shows.push('func') |
| | | } |
| | | } else if (type === 'number') { |
| | | reTypes.initval = 'number' |
| | |
| | | if (sessionStorage.getItem('appType') === 'mob') { // 移动端右侧扩展信息 |
| | | shows.push('placeholder') |
| | | } |
| | | } else if (type === 'vercode') { |
| | | if (this.record.enter === 'tab' || this.record.enter === 'sub') { |
| | | shows.push('tabField') |
| | | } |
| | | } else if (type === 'linkMain') { |
| | | if (this.record.declare === 'nvarchar') { |
| | | shows.push('fieldlength') |
| | | } else if (this.record.declare === 'decimal') { |
| | | shows.push('decimal') |
| | | } |
| | | if (this.record.interception === 'func') { |
| | | shows.push('func') |
| | | } |
| | | } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(type)) { |
| | | if (this.record.resourceType === '0') { // 自定义资源 |
| | |
| | | if (this.record.resourceType === '0') { // 自定义资源 |
| | | shows.push('options', 'fields') |
| | | } else if (this.record.resourceType === '1') { // 数据源 |
| | | shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database') |
| | | shows.push('dataSource', 'cardValField', 'colorField', 'fields', 'orderBy', 'orderType', 'database') |
| | | } |
| | | } else { |
| | | reRequired.fields = true |
| | | if (this.record.resourceType === '0') { // 自定义资源 |
| | | shows.push('options', 'fields', 'selectStyle') |
| | | shows.push('options', 'fields', 'selectStyle', 'border') |
| | | } else if (this.record.resourceType === '1') { // 数据源 |
| | | shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'disableField', 'database', 'selectStyle') |
| | | shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'disableField', 'database', 'selectStyle', 'border') |
| | | } |
| | | if (this.record.selectStyle === 'custom') { |
| | | shows.push('backgroundColor') |
| | |
| | | shows.push('decimal') |
| | | } |
| | | } else { |
| | | shows.push('fieldlength') |
| | | reTooltip.initval = '添加多个初始值请使用逗号分隔。' |
| | | shows.push('fieldlength', 'checkAll') |
| | | reTooltip.initval = '添加多个初始值请使用逗号分隔。' |
| | | } |
| | | |
| | | shows.push('linkField') |
| | |
| | | if (sessionStorage.getItem('appType') === 'mob') { |
| | | shows.push('hidelabel') |
| | | } |
| | | } else if (['date', 'datemonth', 'datetime'].includes(type)) { |
| | | if (this.record.readonly === 'true' && this.record.hidden !== 'true') { |
| | | shows.push('unchecked') |
| | | } |
| | | } else if (['date', 'datemonth'].includes(type)) { |
| | | if (this.record.enter === 'tab' || this.record.enter === 'sub') { |
| | | shows.push('tabField') |
| | | } |
| | | reOptions.initval = dateOptions[type] |
| | | reTypes.initval = 'select' |
| | | } else if (type === 'switch') { |
| | | if (type === 'date') { |
| | | if (this.record.minDate === 'custom') { |
| | | shows.push('minDateField') |
| | | } |
| | | if (this.record.maxDate === 'custom') { |
| | | shows.push('maxDateField') |
| | | } |
| | | } |
| | | } else if (type === 'switch' || type === 'check') { |
| | | if (this.record.enter === 'tab' || this.record.enter === 'sub') { |
| | | shows.push('tabField') |
| | | } |
| | | reOptions.initval = [ |
| | | {value: true, text: '开'}, |
| | | {value: false, text: '关'} |
| | |
| | | } else if (type === 'textarea') { |
| | | if (this.record.encryption === 'false') { |
| | | shows.push('enterReplace') |
| | | } |
| | | if (this.record.interception === 'func') { |
| | | shows.push('func') |
| | | } |
| | | } else if (type === 'popSelect') { |
| | | if (this.record.enter === 'tab' || this.record.enter === 'sub') { |
| | | shows.push('tabField') |
| | | } |
| | | } |
| | | |
| | | if (['multiselect', 'select', 'link', 'radio', 'checkbox', 'checkcard', 'cascader'].includes(type)) { |
| | | if (this.record.hidden !== 'true') { |
| | | shows.push('empty') |
| | | } |
| | | } |
| | | |
| | |
| | | reTooltip.initval = '使用$first表示默认选择第一项。' |
| | | } |
| | | |
| | | if (this.record.supField && !['hint', 'split', 'formula'].includes(type)) { |
| | | if (this.record.supField) { |
| | | shows.push('supvalue') |
| | | } |
| | | |
| | | if (this.record.hidden === 'true') { |
| | | shows = shows.filter(s => !['supField', 'supvalue', 'tooltip', 'extra', 'enter', 'tabField'].includes(s)) |
| | | } |
| | | |
| | | return { |
| | |
| | | if (value === 'text' || value === 'number') { |
| | | this.record.enter = 'sub' |
| | | _fieldval.enter = 'sub' |
| | | } else if (value === 'select' || value === 'link') { |
| | | } else if (['select', 'link', 'popSelect', 'vercode'].includes(value)) { |
| | | _fieldval.enter = 'false' |
| | | } |
| | | |
| | | if (value === 'number' || value === 'rate') { |
| | | this.record.initval = 0 |
| | | _fieldval.initval = 0 |
| | | } else if (value === 'switch') { |
| | | } else if (value === 'switch' || value === 'check') { |
| | | this.record.initval = false |
| | | _fieldval.initval = false |
| | | } |
| | |
| | | this.record.resourceType = '0' |
| | | _fieldval.resourceType = '0' |
| | | } |
| | | } else if (this.record.type === 'funcvar' && value !== 'funcvar') { |
| | | this.record.readonly = 'false' |
| | | } |
| | | |
| | | if (this.record.options.length > 0) { |
| | | if (value === 'checkcard') { |
| | | if (value === 'checkcard') { |
| | | if (this.record.options.length > 0) { |
| | | this.record.options = this.record.options.map(cell => { |
| | | cell.$value = cell.Value || '' |
| | | delete cell.Value |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | if (this.record.options[0].Text) { |
| | | let key = Utils.getuuid() |
| | | |
| | | this.record.fields = [{ |
| | | $index: 1, |
| | | align: 'left', |
| | | color: 'rgba(0, 0, 0, 0.85)', |
| | | field: 'Text', |
| | | fontSize: 14, |
| | | key: key, |
| | | uuid: key |
| | | }] |
| | | } |
| | | } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(value)) { |
| | | if (this.record.options[0] && this.record.options[0].Text) { |
| | | let key = Utils.getuuid() |
| | | |
| | | this.record.fields = [{ |
| | | $index: 1, |
| | | align: 'left', |
| | | color: 'rgba(0, 0, 0, 0.85)', |
| | | field: 'Text', |
| | | fontSize: 14, |
| | | key: key, |
| | | uuid: key |
| | | }] |
| | | } else { |
| | | this.record.fields = [] |
| | | } |
| | | } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(value)) { |
| | | if (this.record.options.length > 0) { |
| | | if (!this.record.options[0].Text && this.record.fields.length > 0) { |
| | | let field = this.record.fields[0].field |
| | | |
| | | this.record.options = this.record.options.map(cell => { |
| | | cell.Value = cell.Value || cell.$value || '' |
| | | cell.Text = cell[field] || '' |
| | | |
| | | delete cell.$value |
| | | return cell |
| | | }) |
| | | } else { |
| | | this.record.options = this.record.options.map(cell => { |
| | | cell.Value = cell.Value || cell.$value || '' |
| | | |
| | | delete cell.$value |
| | | return cell |
| | | }) |
| | | } |
| | |
| | | this.record[key] = value |
| | | } |
| | | |
| | | changeField = (data) => { |
| | | this.record.fields = data || [] |
| | | } |
| | | |
| | | changeOptions = (data) => { |
| | | this.record.options = data || [] |
| | | changeOptions = (data, key) => { |
| | | this.record[key] = data || [] |
| | | } |
| | | |
| | | changeVal = (val, type) => { |
| | |
| | | |
| | | let resource = this.props.form.getFieldValue('dataSource') || '' |
| | | |
| | | resource = `select '' as ${field},'全部' as ${text} union all \n${resource}` |
| | | if (field === text) { |
| | | resource = `select '' as ${field} union all \n${resource}` |
| | | } else { |
| | | resource = `select '' as ${field},'全部' as ${text} union all \n${resource}` |
| | | } |
| | | |
| | | this.props.form.setFieldsValue({dataSource: resource}) |
| | | } |
| | | |
| | | complete = (option) => { |
| | | let label = option.props.label |
| | | |
| | | this.props.form.setFieldsValue({label: label}) |
| | | } |
| | | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const { dict } = this.props |
| | | const { transfield } = this.state |
| | | const fields = [] |
| | | |
| | |
| | | |
| | | if (item.type === 'text') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' }, |
| | | { required: item.required, message: '请输入' + item.label + '!' }, |
| | | { |
| | | pattern: /^[^']*$/ig, |
| | | message: '不可使用英文状态的单引号!' |
| | | } |
| | | ] |
| | | if (item.key === 'field') { |
| | | if (item.rules) { |
| | | rules.push(...item.rules) |
| | | } else if (item.key === 'field') { |
| | | rules.push({ |
| | | pattern: formRule.field.pattern, |
| | | message: formRule.field.message |
| | |
| | | }) |
| | | } |
| | | |
| | | content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | if (['field', 'minDateField', 'maxDateField'].includes(item.key) && item.options && item.options.length > 0) { |
| | | content = <AutoComplete |
| | | dataSource={item.options.map((cell) => <AutoComplete.Option label={cell.label} value={cell.field} key={cell.uuid}> |
| | | {cell.field} |
| | | </AutoComplete.Option>)} |
| | | filterOption={(input, option) => option.props.children.indexOf(input) > -1} |
| | | onSelect={(val, option) => item.key === 'field' && this.complete(option)} |
| | | placeholder="" |
| | | > |
| | | <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | </AutoComplete> |
| | | } else { |
| | | content = <Input placeholder={item.placeholder || ''} autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | } |
| | | } else if (item.type === 'number') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | { required: item.required, message: '请输入' + item.label + '!' } |
| | | ] |
| | | initVal = item.initVal |
| | | |
| | |
| | | } |
| | | } else if (item.type === 'select') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | { required: item.required, message: '请选择' + item.label + '!' } |
| | | ] |
| | | |
| | | let options = item.options |
| | | if (typeof(item.options) === 'string') { |
| | | options = this.record[item.options] || [] |
| | | } |
| | | |
| | | content = <Select |
| | | showSearch |
| | | allowClear={item.allowClear === true} |
| | |
| | | onChange={(value) => {this.optionChange(item.key, value)}} |
| | | getPopupContainer={() => document.getElementById('modal-fields-form-box')} |
| | | > |
| | | {item.options.map((option, i) => |
| | | {options.map((option, i) => |
| | | <Select.Option key={`${i}`} value={option.value || option.field || ''}> |
| | | {option.text || option.label} |
| | | </Select.Option> |
| | |
| | | </Select> |
| | | } else if (item.type === 'radio') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | { required: item.required, message: '请选择' + item.label + '!' } |
| | | ] |
| | | initVal = item.initVal |
| | | |
| | |
| | | </Radio.Group> |
| | | } else if (item.type === 'checkbox') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | { required: item.required, message: '请选择' + item.label + '!' } |
| | | ] |
| | | initVal = item.initVal |
| | | |
| | |
| | | </Checkbox.Group> |
| | | } else if (item.type === 'codemirror') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | { required: item.required, message: '请输入' + item.label + '!' } |
| | | ] |
| | | span = 24 |
| | | className = 'text-area' |
| | | |
| | | if (this.record.type === 'select' || this.record.type === 'link') { |
| | | extra = <span className="add-resource-empty" onClick={this.handleEmpty}>空</span> |
| | | } |
| | | if (item.placeholder) { |
| | | extra = <><span className="resource-public-var">{item.placeholder}</span>{extra}</> |
| | | } |
| | | |
| | | content = <CodeMirror /> |
| | | } else if (item.type === 'textarea') { |
| | | span = 24 |
| | | className = 'text-msg' |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.input'] + item.label + '!' } |
| | | { required: item.required, message: '请输入' + item.label + '!' } |
| | | ] |
| | | |
| | | content = <TextArea rows={item.rows || 4}/> |
| | | } else if (item.type === 'options') { |
| | | span = 24 |
| | | className = 'text-area' |
| | | |
| | | let type = this.record.type |
| | | let linkSubFields = this.record.linkSubField || [] |
| | |
| | | linkSubFields = [] |
| | | } |
| | | } |
| | | content = <EditTable type={type} module="form" transfield={transfield} linkSubFields={linkSubFields} onChange={this.changeOptions}/> |
| | | |
| | | let columns = [] |
| | | if (type === 'link') { |
| | | columns.push({ title: 'ParentID', key: 'ParentID', strict: true }) |
| | | } |
| | | columns.push({ title: 'Value', key: 'Value', strict: true }) |
| | | columns.push({ title: 'Text', key: 'Text' }) |
| | | |
| | | linkSubFields.forEach(field => { |
| | | if (field === 'Value' || field === 'Text') return |
| | | |
| | | columns.push({ title: transfield[field] || field, key: field }) |
| | | }) |
| | | |
| | | content = <EditTable columns={columns} module="form" onChange={(data) => this.changeOptions(data, item.key)}/> |
| | | } else { |
| | | if (this.record.multiple === 'true') { |
| | | linkSubFields = [] |
| | |
| | | if (this.record.linkField) { |
| | | type = 'link' |
| | | } |
| | | content = <DataTable dict={this.props.dict} type={type} display={this.record.display} linkSubFields={linkSubFields} transfield={transfield} fields={this.record.fields || []} onChange={this.changeOptions}/> |
| | | |
| | | let columns = [] |
| | | let fields = this.record.fields || [] |
| | | let keys = ['ParentID', 'pid'] |
| | | |
| | | if (type === 'link') { |
| | | columns.push({ title: 'ParentID', key: 'ParentID', strict: true }) |
| | | } |
| | | columns.push({ title: 'Value', key: '$value', strict: true }) |
| | | |
| | | if (this.record.display === 'picture') { |
| | | columns.push({ title: 'url', key: '$url', type: 'file' }) |
| | | } else if (this.record.display === 'color') { |
| | | columns.push({ title: 'Color', key: '$color' }) |
| | | extra = <span>使用十六进制色彩代码(HEX)时,请在色值前添加 #</span> |
| | | } |
| | | |
| | | fields.forEach(item => { |
| | | keys.push(item.field) |
| | | columns.push({ title: item.field, key: item.field }) |
| | | }) |
| | | |
| | | linkSubFields.forEach(m => { |
| | | if (keys.includes(m)) return |
| | | |
| | | columns.push({ title: transfield[m] || m, key: m }) |
| | | }) |
| | | |
| | | content = <EditTable columns={columns} onChange={(data) => this.changeOptions(data, item.key)}/> |
| | | } |
| | | } else if (item.type === 'fields') { |
| | | span = 24 |
| | | className = 'text-area' |
| | | rules = [ |
| | | { required: item.required, message: '请添加' + item.label + '!' } |
| | | ] |
| | | |
| | | content = <FieldsTable onChange={this.changeField}/> |
| | | content = <FieldsTable indexShow={false} actions={['edit', 'move', 'del', 'add']} columns={item.columns} data={this.record[item.key] || []} onChange={(data) => this.changeOptions(data, item.key)}/> |
| | | } else if (item.type === 'color') { |
| | | className = 'color-form-item' |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | { required: item.required, message: '请选择' + item.label + '!' } |
| | | ] |
| | | |
| | | content = <ColorSketch allowClear={true}/> |
| | | } else if (item.type === 'icon') { |
| | | rules = [ |
| | | { required: item.required, message: dict['form.required.select'] + item.label + '!' } |
| | | { required: item.required, message: '请选择' + item.label + '!' } |
| | | ] |
| | | |
| | | content = <MkEditIcon allowClear /> |
| | |
| | | return fields |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | transfer = (options) => { |
| | | if (options.length === 0) return options |
| | | |
| | | let isNumber = true |
| | | options.forEach(item => { |
| | | if (!item.Value || isNaN(item.Value)) { |
| | | isNumber = false |
| | | } |
| | | }) |
| | | |
| | | if (isNumber) { |
| | | return options.map(item => { |
| | | item.Value = +item.Value |
| | | return item |
| | | }) |
| | | } else { |
| | | return options.map(item => { |
| | | item.Value = item.Value + '' |
| | | return item |
| | | }) |
| | | } |
| | | } |
| | | |
| | | transferCard = (options) => { |
| | | if (options.length === 0) return options |
| | | |
| | | let isNumber = true |
| | | options.forEach(item => { |
| | | if (!/^([0-9]|[1-9]\d{0,2})$/.test(item.$value)) { |
| | | isNumber = false |
| | | } |
| | | }) |
| | | |
| | | if (isNumber) { |
| | | return options.map(item => { |
| | | item.$value = +item.$value |
| | | return item |
| | | }) |
| | | } else { |
| | | return options.map(item => { |
| | | item.$value = item.$value + '' |
| | | return item |
| | | }) |
| | | } |
| | | } |
| | | |
| | | handleConfirm = (fields) => { |
| | | const { card } = this.props |
| | | // 表单提交时检查输入值是否正确 |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.uuid = this.props.card.uuid |
| | | values.uuid = card.uuid |
| | | |
| | | if (card.style) { |
| | | values.style = card.style |
| | | } |
| | | |
| | | let fieldrepet = false // 字段重复 |
| | | |
| | | fields.forEach(item => { |
| | | if (item.uuid === card.uuid || !values.field || !item.field) return |
| | | if (item.field.toLowerCase() === values.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } |
| | | }) |
| | | |
| | | if (fieldrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 下拉菜单或联动菜单 |
| | | if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(values.type)) { |
| | | if (values.resourceType === '0') { |
| | |
| | | if (values.type === 'radio' && values.linkField) { |
| | | type = 'link' |
| | | } |
| | | |
| | | values.options = this.transfer(values.options) |
| | | |
| | | if (values.options.filter(op => op.Text === '').length > 0) { |
| | | notification.warning({ |
| | |
| | | return m |
| | | }) |
| | | |
| | | values.options = this.transferCard(values.options) |
| | | |
| | | let type = values.type |
| | | if (values.linkField) { |
| | | type = 'link' |
| | |
| | | values.initval = '' |
| | | } else if (values.type === 'split') { |
| | | values.span = 24 |
| | | } else if (values.type === 'text') { |
| | | if (values.regularExtra) { |
| | | values.regularExtra = Array.from(new Set(values.regularExtra.split(''))).join('') |
| | | } |
| | | } |
| | | |
| | | ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { |
| | | if (values[item]) { |
| | | values[item] = values[item].replace(/\s*|\t*|\v*|\r*/ig, '') |
| | | values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '') |
| | | } |
| | | }) |
| | | |
| | | let error = Utils.verifySql(values.dataSource) |
| | | let pass = checkSQL(values.dataSource) |
| | | |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '数据源中不可使用' + error, |
| | | duration: 5 |
| | | }) |
| | | return |
| | | if (!pass) return |
| | | |
| | | window.GLOB.formId = card.uuid |
| | | |
| | | if (['select', 'multiselect', 'link', 'checkbox', 'radio', 'checkcard'].includes(values.type) && values.resourceType === '1' && values.dataSource) { |
| | | let _option = Utils.getSelectQueryOptions(values) |
| | | |
| | | let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) |
| | | ${_option.sql}` |
| | | |
| | | // LoginUID|SessionUid|UserID|Appkey 已替换 |
| | | sql = sql.replace(/@\$|\$@/ig, '') |
| | | |
| | | let rduri = '' |
| | | if (window.GLOB.mainSystemApi && values.database === 'sso') { |
| | | rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | resolve({values, loading: true, promise: () => new Promise((resolve, reject) => { |
| | | Api.sDebug(sql, rduri).then(result => { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | resolve() |
| | | } else { |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | reject() |
| | | } |
| | | }) |
| | | })}) |
| | | } else if (values.type === 'popSelect') { |
| | | let arrfield = values.columns.map(f => f.field) |
| | | |
| | | if (values.linkSubField && values.linkSubField.length > 0) { |
| | | values.linkSubField.forEach(n => { |
| | | if (!arrfield.includes(n)) { |
| | | arrfield.push(n) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let _datasource = values.dataSource |
| | | let sql = '' |
| | | |
| | | if (/\s/.test(_datasource)) { // 拼接别名 |
| | | _datasource = '(' + _datasource + ') tb' |
| | | } |
| | | |
| | | arrfield = arrfield.join(',') |
| | | |
| | | let _search = '' |
| | | |
| | | if (values.searchKey) { |
| | | let fields = values.searchKey.split(',').map(field => field + ' like \'%mk%\'') |
| | | _search = 'where ' + fields.join(' OR ') |
| | | } |
| | | |
| | | if (values.laypage === 'true') { |
| | | sql = `/*system_query*/select top 10 ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by ${values.order}) as rows from ${_datasource} ${_search}) tmptable where rows > 0 order by tmptable.rows ` |
| | | } else if (values.order) { |
| | | sql = `/*system_query*/select ${arrfield} from (select ${arrfield} ,ROW_NUMBER() over(order by ${values.order}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows ` |
| | | } else { |
| | | sql = `/*system_query*/select ${arrfield} from ${_datasource} ${_search} ` |
| | | } |
| | | |
| | | sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) |
| | | ${sql}` |
| | | |
| | | sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) |
| | | |
| | | resolve({values, loading: true, promise: () => new Promise((resolve, reject) => { |
| | | Api.sDebug(sql).then(result => { |
| | | if (result.status || result.ErrCode === '-2') { |
| | | resolve() |
| | | } else { |
| | | Modal.error({ |
| | | title: result.message |
| | | }) |
| | | reject() |
| | | } |
| | | }) |
| | | })}) |
| | | } else { |
| | | resolve({values}) |
| | | } |
| | | |
| | | resolve(values) |
| | | } else { |
| | | reject(err) |
| | | } |