| | |
| | | total: null, |
| | | precards: [], |
| | | nextcards: [], |
| | | selected: 'false' |
| | | selected: 'false', |
| | | supNodes: [], |
| | | supComs: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | let _card = null |
| | | let precards = [] |
| | | let nextcards = [] |
| | | |
| | | if (_config.wrap.controlField) { |
| | | if (_config.wrap.controlVal) { |
| | | _config.wrap.controlVal = _config.wrap.controlVal.split(',') |
| | | } else { |
| | | _config.wrap.controlVal = [''] |
| | | } |
| | | } |
| | | |
| | | _config.subcards.forEach(item => { |
| | | if (item.setting.click === 'button' && !item.setting.linkbtn) { |
| | |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (_config.wrap.controlField) { |
| | | if (_config.wrap.controlVal.includes(item[_config.wrap.controlField])) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | return item |
| | | }) |
| | | |
| | |
| | | return item |
| | | }) |
| | | |
| | | let supComs = null |
| | | if (_config.wrap.supType === 'multi') { |
| | | supComs = _config.supNodes.map(item => item.componentId) |
| | | } |
| | | |
| | | _config.wrap.selStyle = _config.wrap.selStyle || 'active' |
| | | _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : '' |
| | | |
| | | _config.wrap.wrapClass = `${_config.wrap.selStyle} ${_config.wrap.cardType || ''} ${_config.wrap.scale}` |
| | | |
| | | this.setState({ |
| | | supComs, |
| | | selected, |
| | | precards, |
| | | nextcards, |
| | |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + 1 + '' |
| | | |
| | | if (config.wrap.controlField) { |
| | | if (config.wrap.controlVal.includes(item[config.wrap.controlField])) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | |
| | | * @param {*} btn // 执行的按钮 |
| | | */ |
| | | refreshByButtonResult = (menuId, position, btn, id, lines) => { |
| | | const { config, BID } = this.state |
| | | const { config, BID, supComs, supNodes } = this.state |
| | | |
| | | if (config.uuid !== menuId) return |
| | | |
| | |
| | | this.loadData() |
| | | } |
| | | |
| | | if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) { |
| | | MKEmitter.emit('reloadData', btn.syncComponentId) // 同级标签刷新 |
| | | } |
| | | |
| | | if (position === 'mainline' && config.setting.supModule) { // 主表行刷新 |
| | | MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) |
| | | } else if (position === 'popclose') { // 标签关闭刷新 |
| | | config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) |
| | | btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) |
| | | if (supComs) { |
| | | if (btn.syncComponentId && btn.syncComponentId !== config.uuid && !supComs.includes(btn.syncComponentId)) { |
| | | MKEmitter.emit('reloadData', btn.syncComponentId) // 同级标签刷新 |
| | | } |
| | | |
| | | if (position === 'mainline' || position === 'popclose') { // 主表行刷新 |
| | | let supNode = supNodes[supNodes.length - 1] |
| | | supComs.forEach((item, i) => { |
| | | setTimeout(() => { |
| | | if (supNode && supNode.key === item) { |
| | | MKEmitter.emit('reloadData', item, supNode.value) |
| | | } else { |
| | | MKEmitter.emit('reloadData', item) |
| | | } |
| | | }, i * 10) |
| | | }) |
| | | if (position === 'popclose') { // 标签关闭刷新 |
| | | btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) |
| | | } |
| | | } |
| | | } else { |
| | | if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) { |
| | | MKEmitter.emit('reloadData', btn.syncComponentId) // 同级标签刷新 |
| | | } |
| | | |
| | | if (position === 'mainline' && config.setting.supModule) { // 主表行刷新 |
| | | MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) |
| | | } else if (position === 'popclose') { // 标签关闭刷新 |
| | | config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty')) |
| | | btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) |
| | | } |
| | | } |
| | | } |
| | | |
| | | checkTopLine = () => { |
| | | const { config, data } = this.state |
| | | |
| | | if (!data || data.length === 0) { |
| | | if (!data || data.length === 0 || data[0].$disabled) { |
| | | this.setState({ |
| | | activeKey: '', |
| | | selectKeys: [], |
| | |
| | | } |
| | | |
| | | resetParentParam = (MenuID, id, data) => { |
| | | const { config } = this.state |
| | | const { config, supComs } = this.state |
| | | |
| | | if (!config.setting.supModule || config.setting.supModule !== MenuID) return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { |
| | | this.loadData() |
| | | }) |
| | | if (supComs) { |
| | | if (!supComs.includes(MenuID)) return |
| | | let supNodes = this.state.supNodes.filter(item => item.key !== MenuID) |
| | | let bid = '' |
| | | let _data = null |
| | | |
| | | if (id) { |
| | | supNodes.push({key: MenuID, value: id, data}) |
| | | } |
| | | if (supNodes.length > 0) { |
| | | bid = supNodes[supNodes.length - 1].value |
| | | _data = supNodes[supNodes.length - 1].data |
| | | } |
| | | |
| | | if (bid !== this.state.BID || bid !== '') { |
| | | this.setState({ BID: bid, BData: _data, pageIndex: 1 }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } else { |
| | | if (!config.setting.supModule || config.setting.supModule !== MenuID) return |
| | | if (id !== this.state.BID || id !== '') { |
| | | this.setState({ BID: id, BData: data, pageIndex: 1 }, () => { |
| | | this.loadData() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | const { mainSearch, menuType } = this.props |
| | | const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state |
| | | |
| | | if (config.setting.supModule && !BID) { // BID 不存在时,不做查询 |
| | | if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 不存在时,不做查询 |
| | | this.setState({ |
| | | activeKey: '', |
| | | selectKeys: [], |
| | |
| | | item.$$BID = BID || '' |
| | | item.$$BData = BData || '' |
| | | item.$Index = index + start + '' |
| | | |
| | | if (config.wrap.controlField) { |
| | | if (config.wrap.controlVal.includes(item[config.wrap.controlField])) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }), |
| | | total: result.total, |
| | |
| | | const { config, selectKeys, selectedData, activeKey, data } = this.state |
| | | |
| | | if (!config.wrap.cardType) return |
| | | if (item.$disabled) return |
| | | |
| | | let _selectKeys = [] |
| | | let _selectedData = [] |
| | |
| | | _selectKeys = selectKeys.filter(key => key !== index) |
| | | _selectedData = selectedData.filter(cell => cell.key !== index) |
| | | _activeKey = _selectKeys.slice(-1)[0] |
| | | _item = selectedData.slice(-1)[0] || '' |
| | | _item = _selectedData.slice(-1)[0] || '' |
| | | } else if (selectKeys.indexOf(index) > -1) { |
| | | _selectKeys = selectKeys.filter(key => key !== index) |
| | | _selectedData = selectedData.filter(cell => cell.key !== index) |
| | | _activeKey = activeKey |
| | | _item = selectedData.filter(cell => cell.key === activeKey)[0] || '' |
| | | _item = _selectedData.filter(cell => cell.key === activeKey)[0] || '' |
| | | } else { |
| | | _selectKeys = [...selectKeys, index] |
| | | _selectedData = [...selectedData, item] |
| | |
| | | |
| | | render() { |
| | | const { config, precards, nextcards, loading, data, pageIndex, total, card, activeKey, BID, BData, selectedData, selectKeys } = this.state |
| | | |
| | | if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) return null |
| | | |
| | | let _total = 0 |
| | | let switchable = false |
| | |
| | | selectedData={selectedData} |
| | | /> : null |
| | | } |
| | | <div className={`data-zoom ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}> |
| | | <div className={`data-zoom ${config.wrap.wrapClass}`}> |
| | | {switchable ? <div className={'prev-page ' + (pageIndex === 1 ? 'disabled' : '')} onClick={this.prevPage}><div><div><img src={preImg} alt=""/></div></div></div> : null} |
| | | <Row className="card-row-list"> |
| | | {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null} |
| | | {precards.map((item, index) => ( |
| | | <Col key={'pre' + index} className="extend-card" span={item.setting.width || 6}> |
| | | <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$type: 'extendCard'}}/> |
| | | <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}}/> |
| | | </Col> |
| | | ))} |
| | | {data && data.map((item, index) => ( |
| | | <Col className={(activeKey === index ? ' active' : (selectKeys.indexOf(index) > -1 ? ' selected' : '')) + (card.setting.click ? ' pointer' : '')} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}> |
| | | <CardItem card={card} cards={config} data={item}/> |
| | | </Col> |
| | | ))} |
| | | {data && data.map((item, index) => { |
| | | let className = card.setting.click ? 'mk-card pointer ' : 'mk-card ' |
| | | if (item.$disabled) { |
| | | className = 'mk-disabled' |
| | | } else if (activeKey === index) { |
| | | className += 'active' |
| | | } else if (selectKeys.indexOf(index) > -1) { |
| | | className += 'selected' |
| | | } |
| | | |
| | | return ( |
| | | <Col className={className} key={index} span={card.setting.width} onClick={() => {this.changeCard(index, item)}}> |
| | | <CardItem card={card} cards={config} data={item}/> |
| | | </Col> |
| | | ) |
| | | })} |
| | | {nextcards.map((item, index) => ( |
| | | <Col key={'next' + index} className="extend-card" span={item.setting.width || 6}> |
| | | <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$type: 'extendCard'}}/> |
| | | <CardItem card={item} cards={config} data={{$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}}/> |
| | | </Col> |
| | | ))} |
| | | </Row> |