| | |
| | | confirmLoading: false, |
| | | execAction: null, |
| | | loadingUuid: '', |
| | | configMap: {} |
| | | configMap: {}, |
| | | loadingNumber: '' |
| | | } |
| | | |
| | | refreshdata = (item, type) => { |
| | |
| | | confirm({ |
| | | title: this.props.dict['main.action.confirm.tip'], |
| | | onOk() { |
| | | _this.setState({ |
| | | loadingUuid: item.uuid |
| | | }) |
| | | |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(item, data, resolve) |
| | | }) |
| | |
| | | } |
| | | |
| | | // 循环调用外部接口(包括内部及回调函数) |
| | | this.outerLoopRequest(_params, btn, _resolve) |
| | | this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) |
| | | } |
| | | } |
| | | |
| | |
| | | if (!params && params.length === 0) return |
| | | |
| | | let param = params.shift() |
| | | |
| | | this.setState({ |
| | | loadingNumber: params.length || '' |
| | | }) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | |
| | | /** |
| | | * @description 外部请求循环执行 |
| | | */ |
| | | outerLoopRequest = (params, btn, _resolve) => { |
| | | outerLoopRequest = (params, btn, _resolve, widthNumber) => { |
| | | if (!params && params.length === 0) return |
| | | |
| | | let param = params.shift() |
| | | let _outParam = null |
| | | let _localParam = null |
| | | |
| | | if (widthNumber) { |
| | | this.setState({ |
| | | loadingNumber: params.length || '' |
| | | }) |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | // 内部请求 |
| | |
| | | this.execSuccess(btn, response) |
| | | _resolve() |
| | | } else { |
| | | this.outerLoopRequest(params, btn, _resolve) |
| | | this.outerLoopRequest(params, btn, _resolve, widthNumber) |
| | | } |
| | | } else { |
| | | this.execError(response, btn) |
| | |
| | | this.execSuccess(btn, res) |
| | | _resolve() |
| | | } else { |
| | | this.outerLoopRequest(params, btn, _resolve) |
| | | this.outerLoopRequest(params, btn, _resolve, widthNumber) |
| | | } |
| | | } else { |
| | | this.execError(res, btn) |
| | |
| | | this.execSuccess(btn, res) |
| | | _resolve() |
| | | } else { |
| | | this.outerLoopRequest(params, btn, _resolve) |
| | | this.outerLoopRequest(params, btn, _resolve, widthNumber) |
| | | } |
| | | } else { |
| | | this.execError(res, btn) |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | loadingUuid: '' |
| | | loadingUuid: '', |
| | | loadingNumber: '' |
| | | }) |
| | | |
| | | this.refreshdata(btn, 'success') |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | loadingUuid: '' |
| | | loadingUuid: '', |
| | | loadingNumber: '' |
| | | }) |
| | | |
| | | this.refreshdata(btn, 'error') |
| | |
| | | confirm({ |
| | | title: this.props.dict['main.action.confirm.tip'], |
| | | onOk() { |
| | | _this.setState({ |
| | | loadingUuid: execAction.uuid |
| | | }) |
| | | |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(execAction, tabledata, resolve, result) |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loadingUuid } = this.state |
| | | const { loadingUuid, loadingNumber } = this.state |
| | | |
| | | return ( |
| | | <div className="button-list toolbar-button"> |
| | | {this.props.actions.map((item, index) => { |
| | | if (loadingUuid === item.uuid) { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | loading |
| | | >{item.label}</Button> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | >{item.label}</Button> |
| | | ) |
| | | let label = item.label |
| | | if (loadingUuid === item.uuid && loadingNumber !== '') { |
| | | label = label + '(' + loadingNumber + ')' |
| | | } |
| | | return ( |
| | | <Button |
| | | className={'mk-btn mk-' + item.class} |
| | | icon={item.icon} |
| | | key={'action' + index} |
| | | onClick={() => {this.actionTrigger(item)}} |
| | | loading={loadingUuid === item.uuid} |
| | | >{label}</Button> |
| | | ) |
| | | })} |
| | | {this.getModels()} |
| | | </div> |