From ab941662167dc16d4b4e73522b275f47f4a89ff0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 06 九月 2020 23:22:19 +0800 Subject: [PATCH] 2020-09-06 --- src/templates/sharecomponent/settingcomponent/settingform/datasource/index.scss | 22 ++ src/menu/components/chart/antv-bar/index.jsx | 1 src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx | 25 +- src/templates/sharecomponent/settingcomponent/settingform/datasource/utils.jsx | 84 ++++++++++ src/tabviews/zshare/actionList/newpagebutton/index.jsx | 6 src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx | 297 +++++++++++++++++++++++++++++++++++++ src/menu/actioncomponent/formconfig.jsx | 10 + src/menu/datasource/verifycard/settingform/index.jsx | 4 src/menu/actioncomponent/index.jsx | 21 ++ 9 files changed, 451 insertions(+), 19 deletions(-) diff --git a/src/menu/actioncomponent/formconfig.jsx b/src/menu/actioncomponent/formconfig.jsx index 9359dc4..985a7e8 100644 --- a/src/menu/actioncomponent/formconfig.jsx +++ b/src/menu/actioncomponent/formconfig.jsx @@ -395,7 +395,15 @@ value: 'false', text: '闈炲繀濉�' }] - } + }, + // { + // type: 'select', + // key: 'linkcomponents', + // label: '', + // initVal: card.Ot || 'requiredSgl', + // required: true, + // options: [] + // } ] if (type === 'chart') { diff --git a/src/menu/actioncomponent/index.jsx b/src/menu/actioncomponent/index.jsx index 6c626c7..e5de539 100644 --- a/src/menu/actioncomponent/index.jsx +++ b/src/menu/actioncomponent/index.jsx @@ -28,7 +28,6 @@ type: PropTypes.string, // 鑿滃崟绫诲瀷锛屼富琛ㄦ垨瀛愯〃 menu: PropTypes.object, // 鑿滃崟淇℃伅锛堣彍鍗昳d锛岃彍鍗曞弬鏁帮紝鑿滃崟鍚嶇О锛� config: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 - usefulFields: PropTypes.array, // 鑷畾涔夊嚱鏁板彲鐢ㄥ瓧娈� tabs: PropTypes.array, // 鎵�鏈夋爣绛� setSubConfig: PropTypes.func, // 璁剧疆瀛愰厤缃俊鎭� updateaction: PropTypes.func // 鑿滃崟閰嶇疆鏇存柊 @@ -84,8 +83,7 @@ * @description 鎸夐挳缂栬緫锛岃幏鍙栨寜閽〃鍗曚俊鎭� */ handleAction = (card) => { - const { menu } = this.props - const { config } = this.props + const { menu, config } = this.props let ableField = menu.permFuncField ? menu.permFuncField.join(', ') : '' let functip = <div> @@ -104,6 +102,23 @@ }) } + // let modules = [] + + // menu.components.forEach(item => { + // if (item.uuid === config.uuid) return + + // modules.push({ + // value: item.uuid, + // text: item.setting.name + // }) + // }) + + // if (supModule && supModule !== 'empty') { + // if (modules.filter(item => item.value === supModule).length === 0) { + // supModule = '' + // } + // } + if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { let _param = { func: 'sPC_Get_FunMenu', diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx index 581a96b..417665f 100644 --- a/src/menu/components/chart/antv-bar/index.jsx +++ b/src/menu/components/chart/antv-bar/index.jsx @@ -590,7 +590,6 @@ menu={config} config={card} tabs={[]} - usefulFields={config.permFuncField || []} // setSubConfig={(_btn) => this.setSubConfig(_btn, 'button')} updateaction={this.updateComponent} /> diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 7a5eccd..b448831 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -24,12 +24,12 @@ } UNSAFE_componentWillMount () { - const { menu, setting } = this.props + const { menu, setting, config } = this.props let supModule = setting.supModule || '' let modules = [] menu.components.forEach(item => { - if (!item.switchable || !item.setting || !item.setting.name) return + if (!item.switchable || !item.setting || !item.setting.name || item.uuid === config.uuid) return modules.push({ value: item.uuid, diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index f5d9049..8dbcaf1 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -108,9 +108,11 @@ } else if (btn.pageTemplate === 'custom') { let url = btn.url if (btn.Ot === 'requiredSgl' && btn.joint !== 'false') { - url = url + `?id=${Id}&appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` + url = url + `?id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` + } else if (btn.Ot === 'requiredSgl' && btn.joint === 'false') { + url = url + `?id=${Id}` } else if (btn.joint !== 'false') { - url = url + `?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` + url = url + `?appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` } window.open(url) diff --git a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx index 4a382aa..9969166 100644 --- a/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx +++ b/src/templates/sharecomponent/columncomponent/dragcolumn/index.jsx @@ -2,7 +2,7 @@ import { useDrop } from 'react-dnd' import { is, fromJS } from 'immutable' import update from 'immutability-helper' -import { Icon } from 'antd' +import { Icon, Popover } from 'antd' import Utils from '@/utils/utils.js' import Card from './card' import './index.scss' @@ -153,16 +153,21 @@ /> ))} {i === (columns.length - 1) && gridBtn && gridBtn.display ? - <div className="page-card" style={{flex: gridBtn.Width}}> - <div style={{cursor: 'default'}}> - <span className="ant-table-header-column"> - <div className="ant-table-column-sorters" title={gridBtn.label} style={{textAlign: gridBtn.Align}}> - <span className="ant-table-column-title">{gridBtn.label}</span> - </div> - </span> + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <Icon className="edit" type="edit" onClick={handleGridBtn}/> </div> - <Icon className="edit" type="edit" onClick={handleGridBtn}/> - </div> : null + } trigger="hover"> + <div className="page-card" style={{flex: gridBtn.Width}}> + <div style={{cursor: 'default'}}> + <span className="ant-table-header-column"> + <div className="ant-table-column-sorters" title={gridBtn.label} style={{textAlign: gridBtn.Align}}> + <span className="ant-table-column-title">{gridBtn.label}</span> + </div> + </span> + </div> + </div> + </Popover> : null } </div> ))} diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx new file mode 100644 index 0000000..705111e --- /dev/null +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx @@ -0,0 +1,297 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification } from 'antd' +import moment from 'moment' + +import Api from '@/api' +import { formRule } from '@/utils/option.js' +import Utils from '@/utils/utils.js' +import CodeMirror from '@/templates/zshare/codemirror' +import './index.scss' + +class SettingForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + menuId: PropTypes.string, // 鑿滃崟Id + permFuncField: PropTypes.any, // 鑿滃崟Id + setting: PropTypes.object, // 鏁版嵁婧愰厤缃� + columns: PropTypes.array, // 鍒楄缃� + scripts: PropTypes.array, // 鑷畾涔夎剼鏈� + } + + state = { + interType: this.props.setting.interType || 'inner', + } + + handleConfirm = () => { + const { setting } = this.props + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + return new Promise((resolve, reject) => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + // 鏁版嵁婧愬墠绔獙璇� + if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && !values.dataresource) { + notification.warning({ + top: 92, + message: '璇峰~鍐欏唴閮ㄥ嚱鏁版垨鏁版嵁婧愶紒', + duration: 5 + }) + reject() + return + } else if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && values.dataresource) { + let _quot = values.dataresource.match(/'{1}/g) + let _lparen = values.dataresource.match(/\({1}/g) + let _rparen = values.dataresource.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + reject() + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + reject() + return + } else if (/--/ig.test(values.dataresource)) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + reject() + return + } + + let error = Utils.verifySql(values.dataresource) + + if (error) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, + duration: 5 + }) + reject() + return + } + } + + // 鏁版嵁婧愪繚瀛� + if ( + values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && + /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource + ) { + let param = { + func: 's_DataSrc_Save', + LText: values.dataresource, + MenuID: this.props.menuId + } + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + Api.getLocalConfig(param) + } + + resolve(values) + } else { + reject(err) + } + }) + }) + } + + onRadioChange = (e, key) => { + let value = e.target.value + + if (key === 'interType') { + this.setState({ + interType: value + }) + } + } + + render() { + const { setting, permFuncField } = this.props + const { getFieldDecorator } = this.props.form + const { interType } = this.state + + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + let tooltip = null + let rules = [] + + if (permFuncField && permFuncField.length > 0) { + tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + permFuncField.join(', ') + let str = '^(' + permFuncField.join('|') + ')' + let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') + + rules.push({ + pattern: _patten, + message: formRule.func.innerMessage + }) + } + + return ( + <div className="model-datasource-setting-form-box"> + <Form {...formItemLayout} className="model-setting-form"> + <Row gutter={24}> + <Col span={8}> + <Form.Item label="琛ㄥ悕"> + {getFieldDecorator('tableName', { + initialValue: setting.tableName, + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '琛ㄥ悕!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label="鎺ュ彛绫诲瀷"> + {getFieldDecorator('interType', { + initialValue: interType, + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '鎺ュ彛绫诲瀷!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio value="inner">鍐呴儴</Radio> + <Radio value="outer">澶栭儴</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {interType === 'inner' ? <Col span={8}> + <Form.Item label={tooltip ? + <Tooltip placement="topLeft" title={tooltip}> + <Icon type="question-circle" /> + 鍐呴儴鍑芥暟 + </Tooltip> : '鍐呴儴鍑芥暟' + }> + {getFieldDecorator('innerFunc', { + initialValue: setting.innerFunc || '', + rules: rules + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="鎺ュ彛鍦板潃"> + {getFieldDecorator('interface', { + initialValue: setting.interface || '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '鎺ュ彛鍦板潃!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="澶栭儴鍑芥暟"> + {getFieldDecorator('outerFunc', { + initialValue: setting.outerFunc || '', + rules: [ + + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'inner' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> + <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={ + <Tooltip placement="topLeft" title={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> + <Icon type="question-circle" /> + 鏁版嵁婧� + </Tooltip> + }> + {getFieldDecorator('dataresource', { + initialValue: setting.dataresource || '' + })(<CodeMirror />)} + </Form.Item> + </Col> : null} + {interType === 'inner' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}> + <Icon type="question-circle" /> + 鏌ヨ绫诲瀷 + </Tooltip> + }> + {getFieldDecorator('queryType', { + initialValue: setting.queryType || 'query' + })( + <Radio.Group> + <Radio value="query">鏌ヨ</Radio> + <Radio value="statistics">缁熻</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {/* <Col span={8}> + <Form.Item label="涓婚敭"> + {getFieldDecorator('primaryKey', { + initialValue: setting.primaryKey || '' + })( + <Select> + {columns.map((option, i) => + <Select.Option key={i} value={option.field}> + {option.label} + </Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> */} + {interType === 'inner' ? <Col span={8}> + <Form.Item label="榛樿sql"> + {getFieldDecorator('execute', { + initialValue: setting.execute || 'true' + })( + <Radio.Group> + <Radio value="true">鎵ц</Radio> + <Radio value="false">涓嶆墽琛�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + <Col span={8}> + <Form.Item label="鍒濆鍖�"> + {getFieldDecorator('onload', { + initialValue: setting.onload || 'true' + })( + <Radio.Group> + <Radio value="true">鍔犺浇鏁版嵁</Radio> + <Radio value="false">涓嶅姞杞芥暟鎹�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + </Row> + </Form> + </div> + ) + } +} + +export default Form.create()(SettingForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.scss b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.scss new file mode 100644 index 0000000..fcd8fff --- /dev/null +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.scss @@ -0,0 +1,22 @@ +.model-datasource-setting-form-box { + position: relative; + + .model-setting-form { + .data-source { + .ant-form-item-label { + width: 11%; + } + .ant-form-item-control-wrapper { + width: 89%; + } + .CodeMirror { + height: 150px; + } + } + .anticon-question-circle { + color: #c49f47; + margin-right: 3px; + } + } + +} \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/utils.jsx new file mode 100644 index 0000000..ebd508d --- /dev/null +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/utils.jsx @@ -0,0 +1,84 @@ + +export default class SettingUtils { + /** + * @description 鐢熸垚椤甸潰鏌ヨ璇彞 + * @return {String} arr_field 鏄剧ず鍒楀瓧娈� + * @return {String} search 鎼滅储鏉′欢 + * @return {Object} setting 椤甸潰璁剧疆 + * @return {Array} regoptions 鎼滅储鏉′欢姝e垯鏇挎崲 + */ + static getDebugSql (setting, arr_field, regoptions, search) { + let sql = '' + let _dataresource = setting.dataresource + let _customScript = setting.customScript + + if (setting.interType === 'inner' && !setting.innerFunc && setting.default === 'false') { + _dataresource = '' + } + + if (_dataresource) { + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + } + if (_customScript) { + _customScript = _customScript.replace(/@\$|\$@/ig, '') + } + + // 姝e垯鏇挎崲 + let _regoptions = regoptions.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) + let _search = search + + if (setting.queryType === 'statistics' && _dataresource) { + _regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + }) + + _search = '' + } + + if (_customScript) { + _regoptions.push({ + reg: new RegExp('@orderBy@', 'ig'), + value: setting.order + }) + if (setting.laypage !== 'false') { + _regoptions.push({ + reg: new RegExp('@pageSize@', 'ig'), + value: 10 + }, { + reg: new RegExp('@pageIndex@', 'ig'), + value: 1 + }) + } + _regoptions.forEach(item => { + _customScript = _customScript.replace(item.reg, item.value) + }) + } + + // 鏁版嵁婧愬鐞�, 瀛樺湪鏄剧ず鍒楁椂 + if (arr_field && _dataresource) { + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + _dataresource = `select ${setting.laypage !== 'false' ? 'top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage !== 'false' ? 'where rows > 0' : ''} order by tmptable.rows` + } + + if (_customScript) { + sql = `${_customScript} + ${_dataresource} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } else { + sql = _dataresource + } + + return sql + } +} \ No newline at end of file -- Gitblit v1.8.0