| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Button, notification, Select, Popconfirm, Typography, Modal, Radio } from 'antd' |
| | | import { Form, Row, Col, Button, notification, Select, Popconfirm, Typography, Modal, Radio, Tooltip } from 'antd' |
| | | import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | |
| | | |
| | | class CustomForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | setting: PropTypes.object, // 设置 |
| | | scripts: PropTypes.array, // 自定义脚本列表 |
| | | searches: PropTypes.array, // 搜索条件 |
| | |
| | | } |
| | | |
| | | state = { |
| | | wrapId: Utils.getuuid(), |
| | | editItem: null, |
| | | loading: false, |
| | | usefulFields: '', |
| | | urlFields: '', |
| | | systemScripts: [], |
| | | scriptsColumns: [ |
| | | { |
| | |
| | | render: (text, record) => record.status === 'false' ? |
| | | ( |
| | | <div style={{color: '#ff4d4f'}}> |
| | | {this.props.dict['model.status.forbidden']} |
| | | 禁用 |
| | | <StopOutlined style={{marginLeft: '5px'}} /> |
| | | </div> |
| | | ) : |
| | | ( |
| | | <div style={{color: '#26C281'}}> |
| | | {this.props.dict['model.status.open']} |
| | | 启用 |
| | | <CheckCircleOutlined style={{marginLeft: '5px'}}/> |
| | | </div> |
| | | ) |
| | |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div style={{textAlign: 'center'}}> |
| | | <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> |
| | | <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> |
| | | <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title={this.props.dict['model.query.delete']} |
| | | title="确定删除吗?" |
| | | onConfirm={() => this.handleDelete(record) |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> |
| | |
| | | |
| | | let _usefulFields = [] |
| | | let scriptsColumns = fromJS(this.state.scriptsColumns).toJS() |
| | | let _urlFields = '' |
| | | |
| | | if (searches) { |
| | | searches.forEach(item => { |
| | |
| | | } else if (_usefulFields.includes(item.field)) { |
| | | _usefulFields.push(item.field + '1') |
| | | } else { |
| | | _usefulFields.push(item.field) |
| | | _usefulFields.push(item.field.replace(/,/ig, ', ')) |
| | | } |
| | | }) |
| | | |
| | | if (urlFields) { |
| | | _usefulFields.push(...urlFields) |
| | | } |
| | | |
| | | _urlFields = urlFields ? urlFields.join(', ') : '' |
| | | _usefulFields = _usefulFields.join(', ') |
| | | scriptsColumns = scriptsColumns.filter(item => { |
| | | if (item.dataIndex === 'sql') { |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | urlFields: _urlFields, |
| | | usefulFields: _usefulFields, |
| | | scripts: fromJS(scripts).toJS(), |
| | | scriptsColumns |
| | |
| | | } |
| | | |
| | | getsysScript = () => { |
| | | if (sessionStorage.getItem('mk_sys_scripts')) { |
| | | this.setState({ |
| | | systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` |
| | | |
| | | _scriptSql = Utils.formatOptions(_scriptSql) |
| | |
| | | Api.getSystemConfig(_sParam).then(res => { |
| | | if (res.status) { |
| | | let _scripts = res.data.map(item => { |
| | | let _item = { |
| | | return { |
| | | name: item.funcname, |
| | | value: window.decodeURIComponent(window.atob(item.longparam)) |
| | | } |
| | | return _item |
| | | }) |
| | | |
| | | sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) |
| | | |
| | | this.setState({ |
| | | systemScripts: _scripts |
| | |
| | | exec_type: 'y', |
| | | LText: SettingUtils.getCustomDebugSql(_scripts, this.props.regoptions) |
| | | } |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.LText = param.LText.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) |
| | | param.LText = param.LText.replace(/\n/g, ' ') |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | this.setState({loading: true}) |
| | | Api.getLocalConfig(param).then(result => { |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | this.setState({ |
| | | loading: false, |
| | |
| | | } |
| | | |
| | | scrolltop = () => { |
| | | let node = document.getElementById('model-setting-form-body').parentNode |
| | | let node = document.getElementById(this.state.wrapId).parentNode |
| | | |
| | | if (node && node.scrollTop) { |
| | | let inter = Math.ceil(node.scrollTop / 10) |
| | |
| | | render() { |
| | | const { setting, scripts } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { usefulFields, scriptsColumns, systemScripts } = this.state |
| | | const { usefulFields, scriptsColumns, systemScripts, urlFields, wrapId } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div className="modal-menu-setting-script"> |
| | | <div className="modal-menu-setting-script" id={wrapId}> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={4}> |
| | |
| | | ErrorCode(增加后缀NT表示数据不回滚,如ENT、NNT、FNT、NMNT), retmsg |
| | | </Form.Item> |
| | | </Col> |
| | | {usefulFields ? <Col span={24} className="sqlfield"> |
| | | <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, mk_departmentcode, mk_organization, login_city, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'公共值,请按照@xxx@格式使用。'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>, |
| | | <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'系统变量,系统会定义变量并赋值。'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip> |
| | | {usefulFields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'搜索条件变量,请按照@xxx@格式使用。'}>, {usefulFields}</Tooltip> : ''} |
| | | {urlFields ?<Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'url变量,请按照@xxx@格式使用。'}>, <span style={{color: '#13c2c2'}}>{urlFields}</span></Tooltip> : ''} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {!usefulFields ? <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, mk_departmentcode, mk_organization, login_city, appkey, time_id |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> |
| | | {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | <Form.Item style={{marginBottom: 0}} label="执行位置"> |
| | | {getFieldDecorator('position', { |