| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Icon, Tooltip, Select, List, notification } from 'antd' |
| | | import { Tooltip, Select, List, notification } from 'antd' |
| | | import { QuestionCircleOutlined, CloseOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | tables: [], // 系统表 |
| | | tableFields: [], // 已选表字段集 |
| | | selectedTables: [], // 已选表 |
| | |
| | | if (/^nvarchar/.test(_type)) { |
| | | try { // 存在max |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | } catch { |
| | | } catch (e) { |
| | | _length = 2048 |
| | | } |
| | | _type = 'text' |
| | |
| | | datatype: _type, |
| | | decimal: _decimal, |
| | | length: _length, |
| | | $datatype: item.FieldType.toLowerCase() |
| | | } |
| | | }) |
| | | } |
| | |
| | | this.setState({ |
| | | tableFields: _columns |
| | | }) |
| | | |
| | | this.props.updatetable(this.props.config, _columns) |
| | | window.GLOB.tableFields = _columns |
| | | }) |
| | | } |
| | | |
| | |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | let _length = 50 |
| | | |
| | | if (/^nvarchar/.test(_type)) { |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | try { // 存在max |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | } catch (e) { |
| | | _length = 2048 |
| | | } |
| | | _type = 'text' |
| | | } else if (/^int/.test(_type)) { |
| | | _type = 'number' |
| | |
| | | type: _type, |
| | | datatype: _type, |
| | | decimal: _decimal, |
| | | length: _length |
| | | length: _length, |
| | | $datatype: item.FieldType.toLowerCase() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let _columns = [...tableFields, tabmsg] |
| | | |
| | | this.setState({ |
| | | tableFields: [...tableFields, tabmsg] |
| | | tableFields: _columns |
| | | }) |
| | | |
| | | this.props.updatetable(_config, [...tableFields, tabmsg]) |
| | | window.GLOB.tableFields = _columns |
| | | |
| | | this.props.updatetable(_config) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | tableFields: _fields |
| | | }) |
| | | |
| | | this.props.updatetable({...config, tables: _tables}, _fields) |
| | | window.GLOB.tableFields = _fields |
| | | |
| | | this.props.updatetable({...config, tables: _tables}) |
| | | } |
| | | |
| | | /** |
| | |
| | | <div className="ant-col ant-form-item-label"> |
| | | <label> |
| | | <Tooltip placement="topLeft" title={dict['model.tooltip.table.guide']}> |
| | | <Icon type="question-circle" /> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {dict['header.menu.table.add']} |
| | | </Tooltip> |
| | | </label> |
| | |
| | | dataSource={selectedTables} |
| | | renderItem={(item, index) => <List.Item key={index} title={item.Remark + ' (' + item.TbName + ')'}> |
| | | {item.Remark + ' (' + item.TbName + ')'} |
| | | <Icon type="close" onClick={() => this.deleteTable(item)}/> |
| | | <CloseOutlined onClick={() => this.deleteTable(item)}/> |
| | | <div className="bottom-mask"></div> |
| | | </List.Item>} |
| | | />} |