| | |
| | | |
| | | const { Option } = Select |
| | | |
| | | // **悲观者往往正确,乐观者往往成功 |
| | | class TablesComponent extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, // 容器Id |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | tables: [], // 系统表 |
| | | tableFields: [], // 已选表字段集 |
| | | selectedTables: [], // 已选表 |
| | |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证 |
| | | |
| | | Api.getSystemConfig(param).then(res => { |
| | | if (res.status) { |
| | |
| | | columns: res.FDName.map(item => { |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | let _length = 50 |
| | | if (/^nvarchar/.test(_type)) { |
| | | try { // 存在max |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | } catch { |
| | | _length = 2048 |
| | | } |
| | | _type = 'text' |
| | | } else if (/^int/.test(_type)) { |
| | | _type = 'number' |
| | | } else if (/^decimal/.test(_type)) { |
| | | _decimal = _type.split(',')[1] |
| | | _decimal = parseInt(_decimal) |
| | | if (_decimal > 4) { |
| | | _decimal = 4 |
| | | } |
| | | _type = 'number' |
| | | } else if (/^decimal/.test(_type)) { |
| | | _decimal = _type.split(',')[1] |
| | | _decimal = parseInt(_decimal) |
| | | if (_decimal > 4) { |
| | | _decimal = 4 |
| | | } |
| | | _type = 'number' |
| | | } else if (/^datetime/.test(_type)) { |
| | | _type = 'datetime' |
| | |
| | | label: item.FieldDec, |
| | | type: _type, |
| | | datatype: _type, |
| | | decimal: _decimal |
| | | decimal: _decimal, |
| | | length: _length, |
| | | } |
| | | }) |
| | | } |
| | |
| | | }) |
| | | |
| | | let _config = {...config, tables: [...selectedTables, _table]} |
| | | |
| | | |
| | | Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => { |
| | | if (res.status) { |
| | | let tabmsg = { |
| | | tableName: _table.name, |
| | | tableName: _table.TbName, |
| | | columns: res.FDName.map(item => { |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | let _length = 50 |
| | | if (/^nvarchar/.test(_type)) { |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | _type = 'text' |
| | | } else if (/^int/.test(_type)) { |
| | | _type = 'number' |
| | |
| | | label: item.FieldDec, |
| | | type: _type, |
| | | datatype: _type, |
| | | decimal: _decimal |
| | | decimal: _decimal, |
| | | length: _length |
| | | } |
| | | }) |
| | | } |
| | |
| | | */ |
| | | deleteTable = (table) => { |
| | | const { config } = this.props |
| | | const {selectedTables, tableFields} = this.state |
| | | const { selectedTables, tableFields } = this.state |
| | | |
| | | let _tables = selectedTables.filter(item => item.TbName !== table.TbName) |
| | | let _fields = tableFields.filter(item => item.tableName !== table.TbName) |
| | |
| | | value={dict['header.menu.table.placeholder']} |
| | | onChange={this.onTableChange} |
| | | showArrow={false} |
| | | getPopupContainer={() => document.getElementById(containerId)} |
| | | getPopupContainer={() => containerId ? document.getElementById(containerId) : document.body} |
| | | filterOption={(input, option) => { |
| | | return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || |
| | | option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 |