| | |
| | | const PrintButton = asyncComponent(() => import('./printbutton')) |
| | | const FuncMegvii = asyncComponent(() => import('./funcMegvii')) |
| | | const FuncZip = asyncComponent(() => import('./funczip')) |
| | | const EditLine = asyncComponent(() => import('./editLine')) |
| | | |
| | | class ActionList extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 主表ID |
| | | lock: PropTypes.any, // 可编辑表中按钮锁定 |
| | | BData: PropTypes.any, // 主表数据 |
| | | selectedData: PropTypes.any, // 子表中选择数据 |
| | | MenuID: PropTypes.string, // 菜单ID |
| | |
| | | |
| | | state = { |
| | | actions: [], |
| | | mores: null, |
| | | listId: '' |
| | | mores: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { setting, actions } = this.props |
| | | |
| | | let listId = (() => { |
| | | let uuid = [] |
| | | let options = '0123456789abcdefghigklmnopqrstuv' |
| | | for (let i = 0; i < 32; i++) { |
| | | uuid.push(options.substr(Math.floor(Math.random() * 0x20), 1)) |
| | | } |
| | | return uuid.join('') |
| | | })() |
| | | |
| | | if (!setting.btnlimit || setting.btnlimit >= actions.length) { |
| | | this.setState({actions: actions, listId}) |
| | | this.setState({actions: actions}) |
| | | } else { |
| | | let mores = fromJS(actions).toJS() |
| | | |
| | | this.setState({ |
| | | actions: mores.splice(0, setting.btnlimit), |
| | | mores, |
| | | listId |
| | | mores |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentDidMount() { |
| | | const { actions, listId } = this.state |
| | | |
| | | if (actions.length > 9) { |
| | | let node = document.getElementById(listId) |
| | | |
| | | // const resizeObserver = new ResizeObserver((entries) => { |
| | | |
| | | // }) |
| | | // resizeObserver.observe(node) |
| | | |
| | | let limit = 10 |
| | | let index = 1 |
| | | let check = () => { |
| | | if (node.offsetHeight > 65) { |
| | | node.classList.add('double-line') |
| | | } else if (index < limit) { |
| | | index++ |
| | | setTimeout(() => { |
| | | check() |
| | | }, 100) |
| | | } |
| | | } |
| | | |
| | | node && check() |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | getButtonList = (actions) => { |
| | | const { BID, BData, MenuID, columns, setting, selectedData, lock } = this.props |
| | | const { BID, BData, MenuID, columns, setting, selectedData } = this.props |
| | | return actions.map(item => { |
| | | if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { |
| | | return ( |
| | | <NormalButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <ExcelInButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <ExcelOutButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <PopupButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <TabButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | btn={item} |
| | | BID={BID} |
| | | BData={BData} |
| | |
| | | <NewPageButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | btn={item} |
| | | BData={BData} |
| | | selectedData={selectedData} |
| | |
| | | <ChangeUserButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <PrintButton |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | BData={BData} |
| | |
| | | <FuncMegvii |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | setting={setting} |
| | |
| | | <FuncZip |
| | | key={item.uuid} |
| | | show={item.show || 'actionList'} |
| | | disabled={lock || false} |
| | | disabled={false} |
| | | BID={BID} |
| | | btn={item} |
| | | setting={setting} |
| | | selectedData={selectedData} |
| | | /> |
| | | ) |
| | | } else if (item.funcType === 'addline' || item.funcType === 'delline') { |
| | | return ( |
| | | <EditLine |
| | | key={item.uuid} |
| | | disabled={false} |
| | | btn={item} |
| | | selectedData={selectedData} |
| | | /> |
| | | ) |
| | |
| | | |
| | | render() { |
| | | const { setting } = this.props |
| | | const { actions, mores, listId } = this.state |
| | | const { actions, mores } = this.state |
| | | |
| | | if (setting.actionfixed === 'true') { |
| | | return ( |
| | | <Affix offsetTop={48}> |
| | | <div className="button-list toolbar-button" id={listId}> |
| | | <div className="button-list toolbar-button"> |
| | | {this.getButtonList(actions)} |
| | | {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> |
| | | <div className="mk-button-more">更多<DownOutlined/></div> |
| | |
| | | ) |
| | | } else { |
| | | return ( |
| | | <div className="button-list toolbar-button" id={listId}> |
| | | <div className="button-list toolbar-button"> |
| | | {this.getButtonList(actions)} |
| | | {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> |
| | | <div className="mk-button-more">更多<DownOutlined/></div> |