| | |
| | | wrapStyle: wrapStyle, |
| | | card: _card, |
| | | search: _config.$searches, |
| | | arr_field: _config.columns.map(col => col.field).join(','), |
| | | arr_field: _config.columns.map(col => col.field).join(',') |
| | | }) |
| | | } |
| | | |
| | |
| | | opens = [] |
| | | } |
| | | |
| | | let total = result.total || 0 |
| | | if (config.setting.custompage && data.length) { |
| | | total = data[data.length - 1].mk_total || 0 |
| | | } |
| | | |
| | | this.setState({ |
| | | activeKey: '', |
| | | selectKeys: [], |
| | | opens: opens, |
| | | selectedData: [], |
| | | data: data, |
| | | total: result.total, |
| | | total: total, |
| | | loading: false |
| | | }) |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | let data = fromJS(this.state.data).toJS() |
| | | let selectedData = fromJS(this.state.selectedData).toJS() |
| | | let selectKeys = fromJS(this.state.selectKeys).toJS() |
| | | let activeKey = this.state.activeKey |
| | | |
| | | if (result.data && result.data[0]) { |
| | | let _data = result.data[0] |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | |
| | | try { |
| | | data = data.map(item => { |
| | | if (item[config.setting.primaryKey] === _data[config.setting.primaryKey]) { |
| | | let children = [] |
| | | data = data.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | let children = [] |
| | | |
| | | if (_data[config.setting.subdata]) { |
| | | let _children = _data[config.setting.subdata] |
| | | if (_data[config.setting.subdata]) { |
| | | let _children = _data[config.setting.subdata] |
| | | |
| | | delete _data[config.setting.subdata] |
| | | delete _data[config.setting.subdata] |
| | | |
| | | _children.forEach((cell, i) => { |
| | | cell.key = i |
| | | cell.$$uuid = cell[config.setting.subKey] || '' |
| | | cell.$$parentId = _data[config.setting.primaryKey] || '' |
| | | cell.$$BID = _data[config.setting.primaryKey] || '' |
| | | cell.$$BData = {..._data} |
| | | cell.$Index = i + 1 + '' |
| | | _children.forEach((cell, i) => { |
| | | cell.key = i |
| | | cell.$$uuid = cell[config.setting.subKey] || '' |
| | | cell.$$parentId = _data[config.setting.primaryKey] || '' |
| | | cell.$$BID = _data[config.setting.primaryKey] || '' |
| | | cell.$$BData = {..._data} |
| | | cell.$Index = i + 1 + '' |
| | | |
| | | if (cell.$$uuid) { |
| | | children.push(cell) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | _data.children = children |
| | | |
| | | _data.key = item.key |
| | | _data.$$uuid = _data[config.setting.primaryKey] || '' |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | if (cell.$$uuid) { |
| | | children.push(cell) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | _data.children = children |
| | | _data.key = item.key |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | if (!_data.$Index) { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | } catch (e) { |
| | | console.warn('数据查询错误') |
| | | return |
| | | } |
| | | |
| | | MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) |
| | | } |
| | | selectedData = selectedData.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | return _data |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | data: data, |
| | | loading: false |
| | | }) |
| | | this.setState({ |
| | | data: data, |
| | | selectedData: selectedData, |
| | | loading: false |
| | | }) |
| | | |
| | | if (_data.key === activeKey) { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) |
| | | } |
| | | } else { |
| | | let index = data.findIndex(item => item.$$uuid === id) |
| | | |
| | | if (index === -1) { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | data = data.filter(item => item.$$uuid !== id) |
| | | data = data.map((item, i) => { |
| | | item.key = i |
| | | return item |
| | | }) |
| | | |
| | | let trans = activeKey === index |
| | | let _item = null |
| | | |
| | | if (config.wrap.cardType) { |
| | | selectKeys = selectKeys.filter(key => key !== index) |
| | | selectKeys = selectKeys.map(key => key > index ? key - 1 : key) |
| | | |
| | | selectedData = selectKeys.map(key => data[key]).filter(Boolean) |
| | | |
| | | activeKey = selectKeys.length ? selectKeys[selectKeys.length - 1] : '' |
| | | |
| | | if (trans && selectedData.length) { |
| | | _item = selectedData[selectedData.length - 1] |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | data: data, |
| | | activeKey: activeKey, |
| | | selectKeys: selectKeys, |
| | | selectedData: selectedData, |
| | | loading: false |
| | | }) |
| | | |
| | | if (trans) { |
| | | MKEmitter.emit('resetSelectLine', config.uuid, (_item ? _item.$$uuid : ''), _item) |
| | | } |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | |
| | | if (activeKey === index) return |
| | | |
| | | _selectedData = [item] |
| | | _selectKeys = [index] |
| | | _activeKey = index |
| | | } |
| | | |