| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Table, Popconfirm, Typography } from 'antd' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | // import SettingUtils from '../utils.jsx' |
| | | import Api from '@/api' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const { Paragraph } = Typography |
| | | const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | |
| | | class CustomForm extends Component { |
| | | static propTpyes = { |
| | |
| | | { |
| | | title: 'SQL', |
| | | dataIndex: 'sql', |
| | | width: '70%', |
| | | render: (text) => ( |
| | | <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> |
| | | ) |
| | | width: '73%', |
| | | render: (text) => { |
| | | let title = text.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | | text = title ? text.replace(title, '') : text |
| | | |
| | | return ( |
| | | <div> |
| | | {title ? <span style={{color: '#a50'}}>{title}</span> : null} |
| | | <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | { |
| | | title: '状态', |
| | | dataIndex: 'status', |
| | | width: '10%', |
| | | width: '12%', |
| | | render: (text, record) => record.status === 'false' ? |
| | | ( |
| | | <div> |
| | |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '20%', |
| | | width: '15%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div> |
| | | (<div style={{textAlign: 'center'}}> |
| | | <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> |
| | | <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> |
| | | <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> |
| | | <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | handleCancel = () => { |
| | | this.setState({ |
| | |
| | | } |
| | | } |
| | | |
| | | handleUpDown = (record, direction) => { |
| | | let scripts = fromJS(this.state.scripts).toJS() |
| | | let index = 0 |
| | | |
| | | scripts = scripts.filter((item, i) => { |
| | | if (item.uuid === record.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | return item.uuid !== record.uuid |
| | | }) |
| | | if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { |
| | | return |
| | | } |
| | | |
| | | if (direction === 'up') { |
| | | scripts.splice(index - 1, 0, record) |
| | | } else { |
| | | scripts.splice(index + 1, 0, record) |
| | | } |
| | | |
| | | changeScripts = (scripts) => { |
| | | this.setState({scripts}) |
| | | this.props.scriptsUpdate(scripts) |
| | | } |
| | |
| | | } |
| | | |
| | | return ( |
| | | <div> |
| | | <Form {...formItemLayout} className="modal-menu-setting-script"> |
| | | <div className="modal-menu-setting-script"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {setting.tableName ? <Col span={8}> |
| | | <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}> |
| | |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | <Table |
| | | bordered |
| | | rowKey="uuid" |
| | | className="custom-table" |
| | | dataSource={scripts} |
| | | columns={scriptsColumns} |
| | | pagination={false} |
| | | /> |
| | | <EditTable data={scripts} actions={[]} columns={scriptsColumns} onChange={this.changeScripts}/> |
| | | </div> |
| | | ) |
| | | } |