| | |
| | | |
| | | if (result.UserRoles) { |
| | | let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] |
| | | let menukeys = [] |
| | | |
| | | result.UserRoles.forEach(role => { |
| | | role.RoleMenu.forEach(menu => { |
| | | if (!menu.MenuID) return |
| | | if (menukeys.includes(menu.MenuID)) return |
| | | _permMenus[menu.MenuID] = true |
| | | |
| | | let _type = '' |
| | |
| | | _type = pageParam.Template || _type |
| | | } |
| | | |
| | | menukeys.push(menu.MenuID) |
| | | |
| | | menulist.push({ |
| | | MenuID: menu.MenuID, |
| | | MenuName: menu.MenuName, |
| | |
| | | // import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd' |
| | | import moment from 'moment' |
| | | // import CodeMirror from '@uiw/react-codemirror' |
| | | |
| | | // import 'codemirror/theme/monokai.css' |
| | | // import 'codemirror/theme/eclipse.css' |
| | | // import 'codemirror/addon/selection/active-line' |
| | | // import 'codemirror/addon/hint/javascript-hint' |
| | | // import 'codemirror/addon/hint/show-hint' |
| | | // import 'codemirror/addon/hint/show-hint.css' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | // import SettingUtils from './utils.jsx' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | |
| | | }> |
| | | {getFieldDecorator('dataresource', { |
| | | initialValue: setting.dataresource || '' |
| | | })(<TextArea rows={4} />)} |
| | | {/* <CodeMirror |
| | | value={'code'} |
| | | options={{ |
| | | theme: 'eclipse', |
| | | lineNumbers: false, |
| | | mode: 'SQL', |
| | | extraKeys: {"Ctrl": "autocomplete"}, |
| | | styleActiveLine: true |
| | | }} |
| | | /> */} |
| | | })(<CodeMirror />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'inner' ? <Col span={8}> |
| | |
| | | .ant-form-item-control-wrapper { |
| | | width: 89%; |
| | | } |
| | | .CodeMirror { |
| | | height: 150px; |
| | | } |
| | | } |
| | | .anticon-question-circle { |
| | | color: #c49f47; |
| | |
| | | class DateGroup extends Component { |
| | | static propTpyes = { |
| | | card: PropTypes.object, // 搜索条件 |
| | | position: PropTypes.number, // 索引,用于控制季度和年的展开方向 |
| | | onGroupChange: PropTypes.func // 搜索内容切换 |
| | | } |
| | | |
| | |
| | | yearId: Utils.getuuid(), |
| | | dateRange: '', |
| | | initDateRange: '', |
| | | initType: '' |
| | | initType: '', |
| | | placement: this.props.position % 4 !== 3 ? 'bottomLeft' : 'bottomRight' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | break |
| | | default: |
| | | } |
| | | |
| | | _dateRange = [moment().subtract(_pdiffer + _val * 3, 'month').startOf('month').format('YYYY-MM-DD'), |
| | | moment().subtract(_ndiffer + _val * 3, 'month').endOf('month').format('YYYY-MM-DD')] |
| | | } else if (_type === 'year') { |
| | |
| | | |
| | | render() { |
| | | const { card } = this.props |
| | | const { active, quarterId, yearId, dateRange } = this.state |
| | | const { active, quarterId, yearId, dateRange, placement } = this.state |
| | | let tabs = {day: '日', week: '周', month: '月', quarter: '季', year: '年', customized: '自定义'} |
| | | |
| | | return ( |
| | |
| | | </span>) |
| | | } else if (tab === 'quarter') { |
| | | return ( |
| | | <Tooltip key={tab} placement="bottomLeft" overlayClassName="quarter-picker-tooltip" trigger="click" title={ |
| | | <Tooltip key={tab} placement={placement} overlayClassName={'quarter-picker-tooltip ' + placement} trigger="click" title={ |
| | | <div> |
| | | <QuarterPicker onChange={(date) => this.onChange(date, tab)}/> |
| | | <QuarterPicker card={card} onChange={(date) => this.onChange(date, tab)}/> |
| | | </div> |
| | | }> |
| | | <span id={quarterId} className={'ant-tag ant-tag-quarter ant-tag-checkable ' + (active === tab ? 'ant-tag-checkable-checked' : '')} > |
| | |
| | | ) |
| | | } else if (tab === 'year') { |
| | | return ( |
| | | <Tooltip key={tab} placement="bottomLeft" overlayClassName="year-picker-tooltip" trigger="click" title={ |
| | | <Tooltip key={tab} placement={placement} overlayClassName={'year-picker-tooltip ' + placement} trigger="click" title={ |
| | | <div> |
| | | <YearPicker onChange={(date) => this.onChange(date, tab)}/> |
| | | <YearPicker card={card} onChange={(date) => this.onChange(date, tab)}/> |
| | | </div> |
| | | }> |
| | | <span id={yearId} className={'ant-tag ant-tag-quarter ant-tag-checkable ' + (active === tab ? 'ant-tag-checkable-checked' : '')} > |
| | |
| | | class QuarterPicker extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | card: PropTypes.object, // 搜索配置 |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | year: moment().format('YYYY'), |
| | | selectQuarter: Math.ceil(moment().format('MM') / 4) |
| | | selectQuarter: Math.ceil(moment().format('MM') / 3) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { selectQuarter } = this.state |
| | | const { card } = this.props |
| | | |
| | | if (card.initval && card.initval[0]) { |
| | | let _type = card.initval[0] |
| | | let _val = parseInt(card.initval[1]) |
| | | |
| | | if (_type === 'quarter' && _val) { |
| | | this.setState({selectQuarter: selectQuarter - _val}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | changeYear = (type) => { |
| | |
| | | background: #bae7ff!important; |
| | | } |
| | | } |
| | | |
| | | .quarter-picker-tooltip.bottomRight { |
| | | .ant-calendar-quarter-picker { |
| | | left: auto; |
| | | right: 0; |
| | | } |
| | | } |
| | | .quarter-picker-tooltip { |
| | | .ant-tooltip-arrow { |
| | | display: none; |
| | |
| | | class QuarterPicker extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | card: PropTypes.object, // 搜索配置 |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { year } = this.state |
| | | const { card } = this.props |
| | | const { selectYear } = this.state |
| | | let year = this.state.year |
| | | |
| | | if (card.initval && card.initval[0]) { |
| | | let _type = card.initval[0] |
| | | let _val = parseInt(card.initval[1]) |
| | | |
| | | if (_type === 'year' && _val) { |
| | | this.setState({selectYear: selectYear - _val}) |
| | | year = Math.floor((selectYear - _val) / 10) * 10 |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | yearlist: [ |
| | |
| | | [{value: year + 2, type: ''}, {value: year + 3, type: ''}, {value: year + 4, type: ''}], |
| | | [{value: year + 5, type: ''}, {value: year + 6, type: ''}, {value: year + 7, type: ''}], |
| | | [{value: year + 8, type: ''}, {value: year + 9, type: ''}, {value: year + 10, type: 'down'}], |
| | | ] |
| | | ], |
| | | year |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | .year-picker-tooltip.bottomRight { |
| | | .ant-calendar-year-picker { |
| | | left: auto; |
| | | right: 0; |
| | | } |
| | | } |
| | | .year-picker-tooltip { |
| | | .ant-tooltip-arrow { |
| | | display: none; |
| | |
| | | fields.push( |
| | | <Col span={item.ratio || 6} key={index}> |
| | | <Form.Item label={item.label} className={item.required === 'true' ? 'group-required' : ''}> |
| | | <DateGroup ref={item.uuid} card={item} onGroupChange={this.searchChange} /> |
| | | <DateGroup ref={item.uuid} position={index} card={item} onGroupChange={this.searchChange} /> |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | |
| | | value = '' |
| | | } |
| | | } |
| | | } else { |
| | | } else if (item.type !== 'group') { |
| | | value = item.initval |
| | | } |
| | | |
| | |
| | | value: '', // 实时内容 |
| | | options: null, // mode : text/javascript、text/x-mysql ; theme : cobalt - 黑底 |
| | | fullScreen: false, |
| | | style: null |
| | | style: null, |
| | | display: true |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | this.setState({options: {...options, fullScreen: !fullScreen}, fullScreen: !fullScreen}) |
| | | } |
| | | |
| | | changeSize = () => { |
| | | changeSize = (size) => { |
| | | let _style = null |
| | | if (size === 14) { |
| | | _style = {fontSize: '14px', lineHeight: '25px'} |
| | | } else if (size === 16) { |
| | | _style = {fontSize: '16px', lineHeight: '28px'} |
| | | } else if (size === 18) { |
| | | _style = {fontSize: '18px', lineHeight: '32px'} |
| | | } else if (size === 20) { |
| | | _style = {fontSize: '20px', lineHeight: '34px'} |
| | | } |
| | | |
| | | // 切换字体大小,刷新编辑器窗口,解决调整后的选择区域错乱问题 |
| | | this.setState({style: _style, display: false, editor: null, defaultVal: this.state.value}, () => { |
| | | this.setState({display: true}) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { defaultVal, options, fullScreen, style } = this.state |
| | | const { defaultVal, options, fullScreen, style, display } = this.state |
| | | const menu = ( |
| | | <Menu> |
| | | <Menu.Item |
| | | style={!style || style.fontSize === '14px' ? {backgroundColor: '#bae7ff'} : ''} |
| | | onClick={() => {this.setState({style: {fontSize: '14px', lineHeight: '25px'}})}} |
| | | onClick={() => {this.changeSize(14)}} |
| | | > |
| | | <span style={{padding: '0 10px 0px 5px'}}>14px</span> |
| | | </Menu.Item> |
| | | <Menu.Item |
| | | style={style && style.fontSize === '16px' ? {backgroundColor: '#bae7ff'} : ''} |
| | | onClick={() => {this.setState({style: {fontSize: '16px', lineHeight: '28px'}})}} |
| | | onClick={() => {this.changeSize(16)}} |
| | | > |
| | | <span style={{padding: '0 10px 0px 5px'}}>16px</span> |
| | | </Menu.Item> |
| | | <Menu.Item |
| | | style={style && style.fontSize === '18px' ? {backgroundColor: '#bae7ff'} : ''} |
| | | onClick={() => {this.setState({style: {fontSize: '18px', lineHeight: '32px'}})}} |
| | | onClick={() => {this.changeSize(18)}} |
| | | > |
| | | <span style={{padding: '0 10px 0px 5px'}}>18px</span> |
| | | </Menu.Item> |
| | | <Menu.Item |
| | | style={style && style.fontSize === '20px' ? {backgroundColor: '#bae7ff'} : ''} |
| | | onClick={() => {this.setState({style: {fontSize: '20px', lineHeight: '34px'}})}} |
| | | onClick={() => {this.changeSize(20)}} |
| | | > |
| | | <span style={{padding: '0 10px 0px 5px'}}>20px</span> |
| | | </Menu.Item> |
| | |
| | | {fullScreen ? <Dropdown overlay={menu} placement="bottomRight"> |
| | | <Icon type="font-size" /> |
| | | </Dropdown> : null} |
| | | <CodeMirror |
| | | {display ? <CodeMirror |
| | | className="code-mirror-area" |
| | | value={defaultVal} |
| | | options={options} |
| | |
| | | this.setState({editor, value}) |
| | | this.props.onChange(value) |
| | | }} |
| | | /> |
| | | /> : null} |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | position: fixed; |
| | | z-index: 10; |
| | | } |
| | | .CodeMirror-linenumber { |
| | | font-size: 14px; |
| | | } |
| | | |
| | | // 重置模态框滚动条 |
| | | .CodeMirror-vscrollbar::-webkit-scrollbar { |
| | |
| | | if (val > 2958465 || val <= 0) { // 时间过大或小于等于0 |
| | | errors.push(_position + dict['main.excel.content.date.over']) |
| | | } else { // 时间格式化 |
| | | val = this.formatExcelDate(val) |
| | | if (val < 60) { // 1900-2-29,excel中存在,实际不存在 |
| | | val++ |
| | | } |
| | | val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') |
| | | } |
| | | } else if (typeof(val) === 'string') { |
| | | val = val.replace(/(^\s*$)|\t*|\v*/ig, '') |
| | |
| | | bottom: _sqlBottom, |
| | | errors: errors.join('; ') |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 格式化excel中的date值 |
| | | * @param {Number} number 时间值 |
| | | */ |
| | | static formatExcelDate(number) { |
| | | if (number < 60) { // 1900-2-29,excel中存在,实际不存在 |
| | | number++ |
| | | } |
| | | |
| | | return moment('19000101', 'YYYYMMDD').add(number - 2, 'days').format('YYYY-MM-DD') |
| | | // const time = new Date((number - 25569) * 24 * 3600000) |
| | | // time.setYear(time.getFullYear() - 70) |
| | | // const year = time.getFullYear() |
| | | // const month = time.getMonth() + 1 |
| | | // const date = time.getDate() - 1 |
| | | |
| | | // return `${year}-${(month < 10 ? '0' + month : month)}-${(date < 10 ? '0' + date : date)}` |
| | | } |
| | | |
| | | /** |