| | |
| | | data = [] |
| | | } |
| | | |
| | | let _width = '40%' |
| | | let fields = [] |
| | | let dataItem = data[0] || '' |
| | | |
| | | if (type === 'link') { |
| | | _width = '27%' |
| | | } else if (type === 'select') { |
| | | _width = Math.floor(80 / (linkSubFields.length + 2)) + '%' |
| | | if (type === 'select' || type === 'radio') { |
| | | fields = linkSubFields.map(cell => { |
| | | return { |
| | | title: cell.label, |
| | | dataIndex: cell.field, |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem[cell.field]) === 'number' ? 'number' : 'string' |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | let columns = [ |
| | | { |
| | | title: 'Value', |
| | | dataIndex: 'Value', |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.Value) === 'number' ? 'number' : 'string' |
| | | }, |
| | | { |
| | | title: 'Text', |
| | | dataIndex: 'Text', |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.Text) === 'number' ? 'number' : 'string' |
| | | }, |
| | |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '20%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | this.state.dataSource.length >= 1 ? ( |
| | |
| | | columns.unshift({ |
| | | title: 'ParentID', |
| | | dataIndex: 'ParentID', |
| | | width: '27%', |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.ParentID) === 'number' ? 'number' : 'string' |
| | | }) |
| | |
| | | |
| | | resetColumn = (type, linkSubFields) => { |
| | | let dataSource = JSON.parse(JSON.stringify(this.state.dataSource)) |
| | | let _width = '40%' |
| | | let fields = [] |
| | | |
| | | if (type === 'select' && linkSubFields.length > this.state.linkSubFields) { |
| | | if ((type === 'select' || type === 'radio') && linkSubFields.length > this.state.linkSubFields) { |
| | | let addcol = linkSubFields[linkSubFields.length - 1] |
| | | dataSource = dataSource.map(data => { |
| | | data[addcol.field] = data.Text |
| | |
| | | |
| | | let dataItem = dataSource ? dataSource[0] : '' |
| | | |
| | | if (type === 'link') { |
| | | _width = '27%' |
| | | } else if (type === 'select') { |
| | | _width = Math.floor(80 / (linkSubFields.length + 2)) + '%' |
| | | if (type === 'select' || type === 'radio') { |
| | | fields = linkSubFields.map(field => { |
| | | return { |
| | | title: field.label, |
| | | dataIndex: field.field, |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem[field.field]) === 'number' ? 'number' : 'string' |
| | | } |
| | |
| | | { |
| | | title: 'Value', |
| | | dataIndex: 'Value', |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.Value) === 'number' ? 'number' : 'string' |
| | | }, |
| | | { |
| | | title: 'Text', |
| | | dataIndex: 'Text', |
| | | width: _width, |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.Text) === 'number' ? 'number' : 'string' |
| | | }, |
| | |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '20%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | this.state.dataSource.length >= 1 ? ( |
| | |
| | | columns.unshift({ |
| | | title: 'ParentID', |
| | | dataIndex: 'ParentID', |
| | | width: '27%', |
| | | editable: true, |
| | | datatype: dataItem && typeof(dataItem.ParentID) === 'number' ? 'number' : 'string' |
| | | }) |