From b77c5e22f1ff192d9b09dda8d2376ba40641451c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 06 八月 2020 12:06:50 +0800 Subject: [PATCH] 2020-08-06 --- src/tabviews/zshare/dategroup/yearpicker/index.jsx | 18 +++++ src/mob/datasource/verifycard/settingform/index.scss | 3 + src/tabviews/zshare/dategroup/quarterpicker/index.jsx | 17 +++++ src/tabviews/zshare/dategroup/yearpicker/index.scss | 6 ++ src/components/header/index.jsx | 4 + src/mob/datasource/verifycard/settingform/index.jsx | 23 ------- src/templates/zshare/codemirror/index.scss | 3 + src/tabviews/zshare/dategroup/index.jsx | 15 ++-- src/tabviews/zshare/topSearch/index.jsx | 4 src/tabviews/zshare/dategroup/quarterpicker/index.scss | 7 ++ src/templates/zshare/codemirror/index.jsx | 33 ++++++++--- src/utils/utils.js | 24 +------ 12 files changed, 94 insertions(+), 63 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index efb021e..d3638de 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -574,10 +574,12 @@ 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 = '' @@ -601,6 +603,8 @@ _type = pageParam.Template || _type } + menukeys.push(menu.MenuID) + menulist.push({ MenuID: menu.MenuID, MenuName: menu.MenuName, diff --git a/src/mob/datasource/verifycard/settingform/index.jsx b/src/mob/datasource/verifycard/settingform/index.jsx index 33115ba..f88e485 100644 --- a/src/mob/datasource/verifycard/settingform/index.jsx +++ b/src/mob/datasource/verifycard/settingform/index.jsx @@ -3,21 +3,12 @@ // 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 = { @@ -258,17 +249,7 @@ }> {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}> diff --git a/src/mob/datasource/verifycard/settingform/index.scss b/src/mob/datasource/verifycard/settingform/index.scss index 1b8226b..f9bc3f3 100644 --- a/src/mob/datasource/verifycard/settingform/index.scss +++ b/src/mob/datasource/verifycard/settingform/index.scss @@ -9,6 +9,9 @@ .ant-form-item-control-wrapper { width: 89%; } + .CodeMirror { + height: 150px; + } } .anticon-question-circle { color: #c49f47; diff --git a/src/tabviews/zshare/dategroup/index.jsx b/src/tabviews/zshare/dategroup/index.jsx index 28efdd9..64a37cf 100644 --- a/src/tabviews/zshare/dategroup/index.jsx +++ b/src/tabviews/zshare/dategroup/index.jsx @@ -13,6 +13,7 @@ class DateGroup extends Component { static propTpyes = { card: PropTypes.object, // 鎼滅储鏉′欢 + position: PropTypes.number, // 绱㈠紩锛岀敤浜庢帶鍒跺搴﹀拰骞寸殑灞曞紑鏂瑰悜 onGroupChange: PropTypes.func // 鎼滅储鍐呭鍒囨崲 } @@ -22,7 +23,8 @@ yearId: Utils.getuuid(), dateRange: '', initDateRange: '', - initType: '' + initType: '', + placement: this.props.position % 4 !== 3 ? 'bottomLeft' : 'bottomRight' } UNSAFE_componentWillMount() { @@ -63,7 +65,6 @@ 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') { @@ -162,7 +163,7 @@ 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 ( @@ -185,9 +186,9 @@ </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' : '')} > @@ -197,9 +198,9 @@ ) } 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' : '')} > diff --git a/src/tabviews/zshare/dategroup/quarterpicker/index.jsx b/src/tabviews/zshare/dategroup/quarterpicker/index.jsx index 86e6761..91dff77 100644 --- a/src/tabviews/zshare/dategroup/quarterpicker/index.jsx +++ b/src/tabviews/zshare/dategroup/quarterpicker/index.jsx @@ -7,12 +7,27 @@ 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) => { diff --git a/src/tabviews/zshare/dategroup/quarterpicker/index.scss b/src/tabviews/zshare/dategroup/quarterpicker/index.scss index 086f3a7..62fab02 100644 --- a/src/tabviews/zshare/dategroup/quarterpicker/index.scss +++ b/src/tabviews/zshare/dategroup/quarterpicker/index.scss @@ -25,7 +25,12 @@ background: #bae7ff!important; } } - +.quarter-picker-tooltip.bottomRight { + .ant-calendar-quarter-picker { + left: auto; + right: 0; + } +} .quarter-picker-tooltip { .ant-tooltip-arrow { display: none; diff --git a/src/tabviews/zshare/dategroup/yearpicker/index.jsx b/src/tabviews/zshare/dategroup/yearpicker/index.jsx index 10b2b88..94c2bf6 100644 --- a/src/tabviews/zshare/dategroup/yearpicker/index.jsx +++ b/src/tabviews/zshare/dategroup/yearpicker/index.jsx @@ -7,6 +7,7 @@ class QuarterPicker extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� + card: PropTypes.object, // 鎼滅储閰嶇疆 onChange: PropTypes.func } @@ -16,7 +17,19 @@ } 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: [ @@ -24,7 +37,8 @@ [{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 }) } diff --git a/src/tabviews/zshare/dategroup/yearpicker/index.scss b/src/tabviews/zshare/dategroup/yearpicker/index.scss index 566824c..e71283e 100644 --- a/src/tabviews/zshare/dategroup/yearpicker/index.scss +++ b/src/tabviews/zshare/dategroup/yearpicker/index.scss @@ -32,6 +32,12 @@ } } +.year-picker-tooltip.bottomRight { + .ant-calendar-year-picker { + left: auto; + right: 0; + } +} .year-picker-tooltip { .ant-tooltip-arrow { display: none; diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index b38f024..08caa46 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -459,7 +459,7 @@ 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> ) @@ -506,7 +506,7 @@ value = '' } } - } else { + } else if (item.type !== 'group') { value = item.initval } diff --git a/src/templates/zshare/codemirror/index.jsx b/src/templates/zshare/codemirror/index.jsx index 9c3a7c5..28cd658 100644 --- a/src/templates/zshare/codemirror/index.jsx +++ b/src/templates/zshare/codemirror/index.jsx @@ -28,7 +28,8 @@ value: '', // 瀹炴椂鍐呭 options: null, // mode : text/javascript銆乼ext/x-mysql ; theme : cobalt - 榛戝簳 fullScreen: false, - style: null + style: null, + display: true } UNSAFE_componentWillMount () { @@ -78,35 +79,49 @@ 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> @@ -120,7 +135,7 @@ {fullScreen ? <Dropdown overlay={menu} placement="bottomRight"> <Icon type="font-size" /> </Dropdown> : null} - <CodeMirror + {display ? <CodeMirror className="code-mirror-area" value={defaultVal} options={options} @@ -128,7 +143,7 @@ this.setState({editor, value}) this.props.onChange(value) }} - /> + /> : null} </div> ) } diff --git a/src/templates/zshare/codemirror/index.scss b/src/templates/zshare/codemirror/index.scss index 2aa854e..9b80e11 100644 --- a/src/templates/zshare/codemirror/index.scss +++ b/src/templates/zshare/codemirror/index.scss @@ -56,6 +56,9 @@ position: fixed; z-index: 10; } + .CodeMirror-linenumber { + font-size: 14px; + } // 閲嶇疆妯℃�佹婊氬姩鏉� .CodeMirror-vscrollbar::-webkit-scrollbar { diff --git a/src/utils/utils.js b/src/utils/utils.js index ef7a9e2..3fa55b7 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -815,7 +815,10 @@ 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锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦� + 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, '') @@ -980,25 +983,6 @@ bottom: _sqlBottom, errors: errors.join('; ') } - } - - /** - * @description 鏍煎紡鍖杄xcel涓殑date鍊� - * @param {Number} number 鏃堕棿鍊� - */ - static formatExcelDate(number) { - if (number < 60) { // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦� - 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)}` } /** -- Gitblit v1.8.0