| | |
| | | |
| | | let _actions = config.action.filter(item => item.position === 'toolbar') // 过滤工具栏按钮(未经过权限过滤) |
| | | let _tab = config.tabs.filter(tab => tab.supMenu === 'mainTable') // 检查是否有与主表关联的子表 |
| | | |
| | | let supmenus = {} |
| | | config.tabgroups.forEach(group => { |
| | | if (config[group] && config[group].length > 0) { |
| | | config[group] = config[group].map(tab => { |
| | | if (tab.subtabs.length > 0) { |
| | | if (tab.subtabs && tab.subtabs.length > 0) { |
| | | tab.subtabs.forEach(id => { |
| | | supmenus[id] = tab.uuid |
| | | }) |
| | |
| | | let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) |
| | | let deffers = [] |
| | | searchlist.forEach(item => { |
| | | if (item.type !== 'select' && item.type !== 'link') return |
| | | if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return |
| | | if (item.setAll === 'true') { |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.setState({searchlist}) |
| | | }) |
| | | } |
| | |
| | | let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) |
| | | let deffers = [] |
| | | searchlist.forEach(item => { |
| | | if (item.type !== 'select' && item.type !== 'link') return |
| | | if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return |
| | | if (item.setAll === 'true') { |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | |
| | | let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) |
| | | let deffers = [] |
| | | searchlist.forEach(item => { |
| | | if (item.type !== 'select' && item.type !== 'link') return |
| | | if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return |
| | | if (item.setAll === 'true') { |
| | | item.options.unshift({ |
| | | key: Utils.getuuid(), |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'multiselect') { // 多选 |
| | | let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, { |
| | | initialValue: _initval, |
| | | rules: [ |
| | | { |
| | | required: item.required === 'true', |
| | | message: this.props.dict['form.required.select'] + item.label + '!' |
| | | } |
| | | ] |
| | | })( |
| | | <Select |
| | | showSearch |
| | | mode="multiple" |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | > |
| | | {item.options.map(option => |
| | | <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'date') { // 时间搜索 |
| | | let _initval = this.props.data ? this.props.data[item.field] : '' |
| | | if (_initval) { |
| | |
| | | key: key, |
| | | value: values[key] |
| | | }) |
| | | } else if (this.state.datatype[key] === 'multiselect') { |
| | | search.push({ |
| | | type: this.state.datatype[key], |
| | | readonly: this.state.readtype[key], |
| | | key: key, |
| | | value: values[key] ? values[key].join(',') : '' |
| | | }) |
| | | } else { |
| | | search.push({ |
| | | type: this.state.datatype[key], |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd' |
| | | import moment from 'moment' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | const {MonthPicker, WeekPicker, RangePicker} = DatePicker |
| | |
| | | } |
| | | |
| | | state = { |
| | | match: null, // 搜索条件匹配规则 |
| | | match: null, // 搜索条件匹配规则 |
| | | style: null, |
| | | searchlist: null |
| | | searchlist: null, |
| | | formId: Utils.getuuid() |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps() { |
| | | let searchlist = JSON.parse(JSON.stringify(this.props.searchlist)) |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | let searchlist = JSON.parse(JSON.stringify(nextProps.searchlist)) |
| | | let _list = [] |
| | | let fieldMap = new Map() |
| | | |
| | |
| | | getFields() { |
| | | const { getFieldDecorator } = this.props.form |
| | | const fields = [] |
| | | |
| | | this.state.searchlist.forEach((item, index) => { |
| | | if (item.hidden) return |
| | | |
| | | if (item.type === 'text') { // 文本搜索 |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | |
| | | {getFieldDecorator(item.field, {initialValue: item.initval })( |
| | | <Select |
| | | showSearch |
| | | // onChange={this.searchChange} |
| | | onChange={(value) => {this.selectChange(item, value)}} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | getPopupContainer={() => document.getElementById(this.state.formId)} |
| | | > |
| | | {item.options.map(option => |
| | | <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> |
| | | {item.options.map((option, i) => |
| | | <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'multiselect') { // 下拉多选 |
| | | let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] |
| | | fields.push( |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: _initval })( |
| | | <Select |
| | | showSearch |
| | | mode="multiple" |
| | | // onChange={(value) => {this.selectChange(item, value)}} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | getPopupContainer={() => document.getElementById(this.state.formId)} |
| | | > |
| | | {item.options.map((option, i) => |
| | | <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'days') : null })( |
| | | <DatePicker onChange={this.searchChange} /> |
| | | <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval, 'month') : null })( |
| | | <MonthPicker onChange={this.searchChange} /> |
| | | <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | <Col span={6} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, {initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null })( |
| | | <WeekPicker onChange={this.searchChange} /> |
| | | <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | placeholder={['开始日期', '结束日期']} |
| | | renderExtraFooter={() => 'extra footer'} |
| | | onChange={this.searchChange} |
| | | getCalendarContainer={() => document.getElementById(this.state.formId)} |
| | | /> |
| | | )} |
| | | </Form.Item> |
| | |
| | | value: _value, |
| | | match: this.state.match[key] |
| | | }) |
| | | } else if (this.state.style[key] === 'multiselect') { |
| | | search.push({ |
| | | type: this.state.style[key], |
| | | key: key.replace(/@tail@$/, ''), |
| | | value: values[key], |
| | | match: this.state.match[key] |
| | | }) |
| | | } else { |
| | | search.push({ |
| | | type: this.state.style[key], |
| | |
| | | |
| | | render() { |
| | | return ( |
| | | <Form className="ant-advanced-search-form top-search" onSubmit={this.handleSearch}> |
| | | <Form className="ant-advanced-search-form top-search" id={this.state.formId} onSubmit={this.handleSearch}> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | </Form> |
| | | ) |
| | |
| | | } |
| | | .ant-form-item-control-wrapper { |
| | | flex: 1; |
| | | width: calc(100% - 100px); |
| | | } |
| | | .ant-form-item-label { |
| | | width: 100px; |
| | |
| | | padding: 4px 20px 4px 5px; |
| | | font-size: 13px; |
| | | } |
| | | .ant-select-dropdown { |
| | | z-index: 10 !important; |
| | | } |
| | | .ant-calendar-picker-container { |
| | | z-index: 10 !important; |
| | | } |
| | | } |
| | |
| | | let isupdate = false |
| | | |
| | | if (res.type === 'search') { |
| | | if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { |
| | | if ((res.values.type === 'multiselect' || res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { |
| | | let _datasource = res.values.dataSource |
| | | |
| | | if (/\s/.test(_datasource)) { |
| | |
| | | * @description 设置可配置按钮 |
| | | */ |
| | | setSubConfig = (btn, type) => { |
| | | console.log(btn) |
| | | const { menu } = this.props |
| | | const { config, originMenu } = this.state |
| | | |
| | |
| | | } |
| | | |
| | | let selectval = '' |
| | | if (card.type === 'select' || card.type === 'link') { |
| | | if (card.type === 'multiselect' || card.type === 'select' || card.type === 'link') { |
| | | if (card.initval) { |
| | | let _option = card.options.filter(option => option.Value === card.initval)[0] |
| | | if (_option) { |
| | |
| | | {card.type === 'number' && |
| | | <InputNumber defaultValue={card.initval} precision={card.decimal} /> |
| | | } |
| | | {(card.type === 'select' || card.type === 'link') && |
| | | {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') && |
| | | <Select defaultValue={selectval}></Select> |
| | | } |
| | | {card.type === 'date' && |
| | |
| | | value: 'select', |
| | | text: this.state.dict['header.form.select'] |
| | | }, { |
| | | value: 'multiselect', |
| | | text: this.state.dict['header.form.multiselect'] |
| | | }, { |
| | | value: 'link', |
| | | text: this.state.dict['header.form.link'] |
| | | }, { |
| | |
| | | this.formRef.handleConfirm().then(res => { |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | if ((res.type === 'select' || res.type === 'link') && res.resourceType === '1') { |
| | | if ((res.type === 'multiselect' || res.type === 'select' || res.type === 'link') && res.resourceType === '1') { |
| | | let _datasource = res.dataSource |
| | | |
| | | if (/\s/.test(_datasource)) { |
| | |
| | | let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal |
| | | let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required'] // 默认显示项 |
| | | |
| | | if ((type === 'select' || type === 'link') && resourceType === '0') { // 选择类型、自定义资源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'options'] |
| | | } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 选择类型、自定义资源 |
| | | _options = [..._options, 'resourceType', 'options'] |
| | | } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } else if (type === 'number') { |
| | | _options = [..._options, 'decimal'] |
| | | } |
| | | |
| | | if (type === 'select' || type === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (type === 'link') { // 关联类型、增加关联字段 |
| | |
| | | if (key === 'type') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required'] |
| | | |
| | | if ((value === 'select' || value === 'link') && this.state.resourceType === '0') { // 选择类型、自定义资源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'options'] |
| | | } else if ((value === 'select' || value === 'link') && this.state.resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 选择类型、自定义资源 |
| | | _options = [..._options, 'resourceType', 'options'] |
| | | } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 选择类型、数据源 |
| | | _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } else if (value === 'number') { |
| | | _options = [..._options, 'decimal'] |
| | | } |
| | | |
| | | if (value === 'select' || value === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (value === 'link') { |
| | |
| | | const { openType } = this.state |
| | | let value = e.target.value |
| | | if (key === 'resourceType') { |
| | | let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'setAll', 'readonly', 'required'] |
| | | let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required'] |
| | | if (value === '0') { |
| | | _options = [..._options, 'options'] |
| | | } else if (value === '1') { |
| | | _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] |
| | | } |
| | | |
| | | if (openType === 'select' || openType === 'link') { |
| | | _options.push('setAll') |
| | | } |
| | | |
| | | if (openType === 'link') { |
| | |
| | | values.id = this.props.card.id |
| | | values.uuid = this.props.card.uuid |
| | | // 下拉菜单或关联菜单 |
| | | if ((values.type === 'select' || values.type === 'link') && values.resourceType === '0') { |
| | | if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') { |
| | | values.options = this.refs.editTable.state.dataSource |
| | | values.dataSource = '' |
| | | let emptys = [] |
| | | if (values.type === 'select') { |
| | | if (values.type === 'multiselect' || values.type === 'select') { |
| | | emptys = values.options.filter(op => !(op.Value && op.Text)) |
| | | } else { |
| | | emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID)) |
| | |
| | | if (emptys.length > 0) { |
| | | isvalid = false |
| | | } |
| | | } else if ((values.type === 'select' || values.type === 'link') && values.resourceType === '1') { |
| | | } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') { |
| | | values.options = [] |
| | | } |
| | | |
| | |
| | | let isupdate = false |
| | | |
| | | if (res.type === 'search') { |
| | | if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { |
| | | if ((res.values.type === 'multiselect' || res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { |
| | | let _datasource = res.values.dataSource |
| | | |
| | | if (/\s/.test(_datasource)) { |
| | |
| | | values.id = this.props.card.id |
| | | values.uuid = this.props.card.uuid |
| | | // 下拉菜单或关联菜单 |
| | | if ((values.type === 'select' || values.type === 'link') && values.resourceType === '0') { |
| | | if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') { |
| | | values.options = this.refs.editTable.state.dataSource |
| | | values.dataSource = '' |
| | | let emptys = [] |
| | | if (values.type === 'select') { |
| | | if (values.type === 'multiselect' || values.type === 'select') { |
| | | emptys = values.options.filter(op => !(op.Value && op.Text)) |
| | | } else { |
| | | emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID)) |
| | |
| | | if (emptys.length > 0) { |
| | | isvalid = false |
| | | } |
| | | } else if ((values.type === 'select' || values.type === 'link') && values.resourceType === '1') { |
| | | } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') { |
| | | values.options = [] |
| | | } |
| | | |
| | |
| | | } |
| | | item.value = _val ? [moment().subtract(_val[0], 'days').format('YYYY-MM-DD'), |
| | | moment().subtract(_val[1], 'days').format('YYYY-MM-DD')] : '' |
| | | } else if (item.type === 'multiselect') { |
| | | item.value = item.value ? item.value.split(',').filter(Boolean) : [] |
| | | } |
| | | newsearches.push(item) |
| | | }) |
| | |
| | | item.key.split(',').forEach(field => { // 综合搜索,所字段拼接 |
| | | newsearches[field] = item.value |
| | | }) |
| | | } else if (item.type === 'multiselect') { |
| | | newsearches[item.key] = item.value.join(',') |
| | | } else { |
| | | newsearches[item.key] = item.value |
| | | } |
| | |
| | | |
| | | let searchText = '' |
| | | searches.forEach(item => { |
| | | if (!item.value) return |
| | | if (!item.value || (item.type === 'multiselect' && item.value.length === 0)) return |
| | | |
| | | searchText += (searchText !== '' ? ' AND ' : '') |
| | | if (item.type === 'text') { |
| | | let str = item.match === '=' ? '' : '%' |
| | |
| | | let str = item.match === '=' ? '' : '%' |
| | | |
| | | searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\'' |
| | | } else if (item.type === 'multiselect') { |
| | | let str = item.match === '=' ? '' : '%' |
| | | let options = item.value.map(val => { |
| | | return item.key + ' ' + item.match + ' \'' + str + val + str + '\'' |
| | | }) |
| | | |
| | | searchText += '(' + options.join(' OR ') + ')' |
| | | } else if (item.type === 'date') { |
| | | let _val = item.value |
| | | let timetail = ' 00:00:00.000' |