| | |
| | | if (res.FDName && res.FDName.length > 0) { |
| | | tabmsg.columns = res.FDName.map(item => { |
| | | let _type = item.FieldType.toLowerCase() |
| | | let _datatype = item.FieldType.toLowerCase() |
| | | let _decimal = 0 |
| | | let _length = 50 |
| | | if (/^nvarchar/.test(_type)) { |
| | | try { // 存在max |
| | | _length = +_type.match(/\d+/)[0] || 50 |
| | | } catch (e) { |
| | | _length = 2048 |
| | | _length = 4000 |
| | | } |
| | | _type = 'text' |
| | | } else if (/^int/.test(_type)) { |
| | |
| | | } else { |
| | | _type = 'text' |
| | | } |
| | | |
| | | if (/^nvarchar/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^nvarchar/, 'Nvarchar') |
| | | } else if (/^decimal/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^decimal/, 'Decimal') |
| | | } else if (/^int/.test(_datatype)) { |
| | | _datatype = _datatype.replace(/^int/, 'Int') |
| | | } |
| | | |
| | | return { |
| | | field: item.FieldName || '', |
| | |
| | | datatype: _type, |
| | | decimal: _decimal, |
| | | length: _length, |
| | | $datatype: item.FieldType.toLowerCase() |
| | | $datatype: _datatype |
| | | } |
| | | }) |
| | | } |
| | |
| | | if (type === 'search') { |
| | | // 添加搜索条件,字段集中存在搜索条件字段,使用搜索条件对象替换字段集,设置数据类型 |
| | | config.search.forEach(item => { |
| | | if (item.field && columns.has(item.field.toLowerCase())) { |
| | | let _datatype = columns.get(item.field.toLowerCase()).datatype |
| | | columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) |
| | | if (item.field) { |
| | | if (/,/.test(item.field)) { |
| | | item.field.split(',').forEach(n => { |
| | | if (columns.has(n.toLowerCase())) { |
| | | let _datatype = columns.get(n.toLowerCase()).datatype |
| | | columns.set(n.toLowerCase(), {...item, field: n, origin: true, datatype: _datatype}) |
| | | } |
| | | }) |
| | | } else { |
| | | if (columns.has(item.field.toLowerCase())) { |
| | | let _datatype = columns.get(item.field.toLowerCase()).datatype |
| | | columns.set(item.field.toLowerCase(), {...item, origin: true, datatype: _datatype}) |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } else if (type === 'columns') { |
| | |
| | | |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | | // 获取已选字段集合 |
| | | let cards = selectCards |
| | | let columnsMap = new Map() |
| | | cards.forEach(card => { |
| | | columnsMap.set(card.field.toLowerCase(), card) |
| | | }) |
| | | |
| | | let items = [] |
| | | let keys = [] |
| | | if (type === 'search') { |
| | |
| | | label: item.label, |
| | | field: item.field, |
| | | Hide: 'false', |
| | | IsSort: 'true', |
| | | type: item.type, |
| | | IsSort: 'false', |
| | | type: item.type === 'number' ? 'number' : 'text', |
| | | Width: item.type === 'number' ? 80 : 120 |
| | | } |
| | | |
| | |
| | | newcard.decimal = item.decimal |
| | | } else { |
| | | newcard.fieldlength = item.length || 50 |
| | | } |
| | | |
| | | if (item.type === 'date') { |
| | | newcard.textFormat = 'YYYY-MM-DD' |
| | | } else if (item.type === 'datetime') { |
| | | newcard.textFormat = 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | |
| | | items.push(newcard) |
| | |
| | | field: item.field, |
| | | datatype: _t |
| | | } |
| | | |
| | | items.unshift(newcard) |
| | | keys.push(item.field.toLowerCase()) |
| | | }) |
| | |
| | | decimal: item.decimal, |
| | | orderType: 'asc', |
| | | readonly: 'false', |
| | | required: 'true' |
| | | required: 'true', |
| | | readin: 'top' |
| | | } |
| | | |
| | | if (/^icon|images?$/ig.test(item.field)) { |
| | |
| | | newcard.span = 24 |
| | | newcard.labelwidth = 16.2 |
| | | } |
| | | } else if (item.type === 'text') { |
| | | newcard.fieldlength = item.length || 50 |
| | | } |
| | | |
| | | items.push(newcard) |