| | |
| | | const Header = asyncComponent(() => import('@/mob/header')) |
| | | const MutilForm = asyncComponent(() => import('./mutilform')) |
| | | const TransForm = asyncComponent(() => import('./transform')) |
| | | const ScriptForm = asyncComponent(() => import('./scriptform')) |
| | | const SubMutilForm = asyncComponent(() => import('./submutilform')) |
| | | |
| | | let base_url = '' |
| | |
| | | title: '操作', |
| | | key: 'action', |
| | | align: 'center', |
| | | width: '230px', |
| | | render: (text, record) => ( |
| | | <div> |
| | | <Button type="link" onClick={() => this.setState({ selectTran: record, transVisible: 'edit' })} style={{color: '#8E44AD'}}>修改</Button> |
| | | <div onClick={() => this.forbid = true}> |
| | | <Button type="link" onClick={() => this.setState({ editTran: record, transVisible: 'edit' })} style={{color: '#8E44AD'}}>修改</Button> |
| | | <Button type="link" onClick={() => this.deleteTran(record)} style={{color: '#ff4d4f'}}>删除</Button> |
| | | <Button type="link" onClick={() => this.enableTran(record)} style={{color: '#26C281'}}>启用</Button> |
| | | </div> |
| | |
| | | translist: [], |
| | | tranSearchKey: '', |
| | | selectTran: null, |
| | | editTran: null, |
| | | transIndex: 1, |
| | | transTotal: 0 |
| | | transTotal: 0, |
| | | scriptcolumns: [ |
| | | { title: '关键字', dataIndex: 'KeyWords', key: 'KeyWords', align: 'left' }, |
| | | { title: '描述', dataIndex: 'Remark', key: 'Remark', align: 'left' }, |
| | | { title: '类型', dataIndex: 'TypeName', key: 'TypeName', align: 'left' }, |
| | | { title: '排序', dataIndex: 'Sort', key: 'Sort', align: 'left' }, |
| | | ], |
| | | scriptVisible: false, |
| | | scriptlist: [], |
| | | scriptSearchKey: '', |
| | | scriptIndex: 1, |
| | | scriptTotal: 0, |
| | | } |
| | | |
| | | forbid = false |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | document.body.className = '' |
| | |
| | | if (result.status) { |
| | | this.setState({ |
| | | loading: false, |
| | | translist: result.data |
| | | translist: result.data, |
| | | selectTran: null, |
| | | scriptlist: [], |
| | | transTotal: result.total |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | |
| | | }) |
| | | } |
| | | |
| | | getScriptList = () => { |
| | | const { scriptSearchKey, scriptIndex, selectTran } = this.state |
| | | |
| | | if (!selectTran || !selectTran.ID) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '缺少传输号ID!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 's_get_sVersionDetail', |
| | | dataM: 'Y', |
| | | PageSize: 10, |
| | | PageIndex: scriptIndex, |
| | | OrderCol: 'Sort desc', |
| | | BID: selectTran.ID, |
| | | } |
| | | |
| | | if (scriptSearchKey) { |
| | | param.TypeName = scriptSearchKey |
| | | param.KeyWords = scriptSearchKey |
| | | param.Remark = scriptSearchKey |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | Api.getCloudConfig(param).then(result => { |
| | | if (result.status) { |
| | | this.setState({ |
| | | loading: false, |
| | | scriptlist: result.data, |
| | | scriptTotal: result.total, |
| | | selectScriptKeys: [] |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | scriptSearch = (value) => { |
| | | this.setState({scriptSearchKey: value, scriptIndex: 1}, () => { |
| | | this.getScriptList() |
| | | }) |
| | | } |
| | | |
| | | changeScriptTable = (pagination) => { |
| | | this.setState({ |
| | | scriptIndex: pagination.current |
| | | }, () => { |
| | | this.getScriptList() |
| | | }) |
| | | } |
| | | |
| | | changeTable = (pagination) => { |
| | | this.setState({ |
| | | transIndex: pagination.current |
| | |
| | | } |
| | | |
| | | tranSearch = (value) => { |
| | | this.setState({tranSearchKey: value}, () => { |
| | | this.setState({tranSearchKey: value, transIndex: 1}, () => { |
| | | this.getTransList() |
| | | }) |
| | | } |
| | | |
| | | submitTrans = () => { |
| | | const { transVisible, selectTran } = this.state |
| | | const { transVisible, editTran } = this.state |
| | | |
| | | this.transRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | |
| | | } else { |
| | | param.func = 's_sVersion_upt' |
| | | param.ProgramName = res.ProgramName |
| | | param.ID = selectTran.ID |
| | | param.ID = editTran.ID |
| | | } |
| | | |
| | | Api.getCloudConfig(param).then(result => { |
| | |
| | | }) |
| | | } |
| | | |
| | | submitScript = () => { |
| | | // const { selectTran } = this.state |
| | | |
| | | this.scriptRef.handleConfirm().then(res => { |
| | | this.setState({ |
| | | confirmloading: true |
| | | }) |
| | | // let param = {} |
| | | // s_sVersionDetail_Add |
| | | // s_sVersionDetail_CloudAdd |
| | | |
| | | // Api.getCloudConfig(param).then(result => { |
| | | // if (result.status) { |
| | | // notification.success({ |
| | | // top: 92, |
| | | // message: '操作成功!', |
| | | // duration: 3 |
| | | // }) |
| | | // this.setState({ |
| | | // scriptIndex: 1, |
| | | // confirmloading: false, |
| | | // scriptVisible: false |
| | | // }, () => { |
| | | // this.getScriptList() |
| | | // }) |
| | | // } else { |
| | | // this.setState({ |
| | | // confirmloading: false |
| | | // }) |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: result.message, |
| | | // duration: 5 |
| | | // }) |
| | | // } |
| | | // }, () => { |
| | | // this.setState({ |
| | | // confirmloading: false |
| | | // }) |
| | | // }) |
| | | }) |
| | | } |
| | | |
| | | deleteTran = (record) => { |
| | | const _this = this |
| | | |
| | |
| | | top: 92, |
| | | message: '操作成功!', |
| | | duration: 3 |
| | | }) |
| | | |
| | | _this.setState({ |
| | | selectTran: null, |
| | | }) |
| | | _this.getTransList() |
| | | } else { |
| | |
| | | top: 92, |
| | | message: '操作成功!', |
| | | duration: 3 |
| | | }) |
| | | |
| | | _this.setState({ |
| | | selectTran: record, |
| | | }) |
| | | _this.getTransList() |
| | | } else { |
| | |
| | | |
| | | return item |
| | | }) |
| | | |
| | | if (!selectApp && applist[0]) { |
| | | selectApp = applist[0] |
| | | } |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | |
| | | this.setState({ selectApp }) |
| | | } |
| | | |
| | | onTransChange = selectedRowKeys => { |
| | | const { translist } = this.state |
| | | let selectTran = translist.filter(item => item.ID === selectedRowKeys[0])[0] |
| | | onScriptChange = selectedRowKeys => { |
| | | this.setState({ selectScriptKeys: selectedRowKeys }) |
| | | } |
| | | |
| | | this.setState({ selectTran }) |
| | | onScriptSelect = (record) => { |
| | | const { selectScriptKeys } = this.state |
| | | |
| | | if (selectScriptKeys.includes(record.ID)) { |
| | | this.setState({ selectScriptKeys: selectScriptKeys.filter(key => key !== record.ID) }) |
| | | } else { |
| | | this.setState({ selectScriptKeys: [...selectScriptKeys, record.ID]}) |
| | | } |
| | | } |
| | | |
| | | deleteScripts = () => { |
| | | const { selectScriptKeys, selectTran } = this.state |
| | | |
| | | if (selectScriptKeys.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择要删除的脚本!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let params = selectScriptKeys.map(key => { |
| | | return { |
| | | func: 's_sVersionDetail_del', |
| | | BID: selectTran.ID, |
| | | ID: key |
| | | } |
| | | }) |
| | | |
| | | const _this = this |
| | | |
| | | confirm({ |
| | | content: '确定要执行吗?', |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | let deffers = params.map((param, i) => { |
| | | return new Promise(resolve => { |
| | | setTimeout(() => { |
| | | Api.getCloudConfig(param).then(res => { |
| | | resolve(res) |
| | | }, () => { |
| | | resolve({status: false, message: '删除失败!'}) |
| | | }) |
| | | }, i * 150) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(result => { |
| | | let errorMsg = '' |
| | | result.forEach(res => { |
| | | if (!res.status) { |
| | | errorMsg = res.message |
| | | } |
| | | }) |
| | | if (errorMsg) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: errorMsg, |
| | | duration: 3 |
| | | }) |
| | | } else { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '执行成功。', |
| | | duration: 3 |
| | | }) |
| | | _this.setState({ |
| | | scriptIndex: 1 |
| | | }, () => { |
| | | _this.getScriptList() |
| | | }) |
| | | } |
| | | resolve() |
| | | }) |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | onTransChange = selectedRowKeys => { |
| | | const { translist, selectTran } = this.state |
| | | let _selectTran = translist.filter(item => item.ID === selectedRowKeys[0])[0] |
| | | |
| | | this.setState({ selectTran: _selectTran }) |
| | | |
| | | if (!selectTran || selectTran.ID !== _selectTran.ID) { |
| | | this.setState({ scriptIndex: 1 }, () => { |
| | | this.getScriptList() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | onTransSelect = (record) => { |
| | | const { selectTran } = this.state |
| | | |
| | | this.setState({ selectTran: record }) |
| | | |
| | | if (!selectTran || selectTran.ID !== record.ID) { |
| | | this.setState({ scriptIndex: 1 }, () => { |
| | | this.getScriptList() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { loading, visible, subVisible, columns, transcolumns, applist, translist, transVisible, selectApp, selectTran, selectSubApp } = this.state |
| | | const { loading, visible, subVisible, columns, transcolumns, applist, translist, transVisible, selectApp, selectTran, selectSubApp, scriptVisible, scriptlist, scriptcolumns, selectScriptKeys } = this.state |
| | | |
| | | return ( |
| | | <div className="mk-app-manage"> |
| | |
| | | <Header view="manage" /> |
| | | {loading ? |
| | | <div className="loading-mask"> |
| | | <div className="ant-spin-blur"></div> |
| | | <Spin /> |
| | | <Spin size="large" /> |
| | | </div> : null |
| | | } |
| | | <div className="view-wrap"> |
| | |
| | | pagination={{ |
| | | current: this.state.transIndex, |
| | | pageSize: 10, |
| | | total: this.state.transTotal || 0 |
| | | total: this.state.transTotal || 0, |
| | | showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条` |
| | | }} |
| | | rowSelection={{ type: 'radio', selectedRowKeys: selectTran ? [selectTran.ID] : [], onChange: this.onTransChange }} |
| | | onRow={(record) => ({ onClick: () => this.setState({ selectTran: record })})} |
| | | onRow={(record) => ({ onClick: () => { |
| | | if (this.forbid) { |
| | | this.forbid = false |
| | | return |
| | | } |
| | | this.onTransSelect(record) |
| | | }})} |
| | | onChange={this.changeTable} |
| | | /> |
| | | </div> |
| | | {/* <div className={'script-table' + (this.state.transTotal <= 10 ? ' no-footer' : '')}> |
| | | {selectTran ? <div className="script-table"> |
| | | <div className="app-action"> |
| | | <Button className="mk-green" onClick={() => this.setState({ scriptVisible: 'plus' })}>添加脚本</Button> |
| | | <Search placeholder="综合搜索" onSearch={value => this.scriptSearch(value)} enterButton /> |
| | | <Button className="mk-green" onClick={() => this.setState({ scriptVisible: true })}>添加脚本</Button> |
| | | <Button className="mk-danger" onClick={this.deleteScripts} style={{marginLeft: '15px'}}>删除</Button> |
| | | <Search placeholder="综合搜索" defaultValue={this.state.scriptSearchKey} onSearch={value => this.scriptSearch(value)} enterButton /> |
| | | </div> |
| | | <Table |
| | | rowKey="ID" |
| | | columns={transcolumns} |
| | | dataSource={translist} |
| | | columns={scriptcolumns} |
| | | dataSource={scriptlist} |
| | | pagination={{ |
| | | current: this.state.transIndex, |
| | | current: this.state.scriptIndex, |
| | | pageSize: 10, |
| | | total: this.state.transTotal || 0 |
| | | total: this.state.scriptTotal || 0, |
| | | showTotal: (total, range) => `${range[0]}-${range[1]} 共 ${total} 条` |
| | | }} |
| | | rowSelection={{ type: 'radio', selectedRowKeys: selectTran ? [selectTran.ID] : [], onChange: this.onTransChange }} |
| | | onRow={(record) => ({ onClick: () => this.setState({ selectTran: record })})} |
| | | onChange={this.changeTable} |
| | | rowSelection={{ type: 'checkbox', selectedRowKeys: selectScriptKeys, onChange: this.onScriptChange }} |
| | | onRow={(record) => ({ onClick: () => this.onScriptSelect(record)})} |
| | | onChange={this.changeScriptTable} |
| | | /> |
| | | </div> */} |
| | | </div> : null} |
| | | </div> |
| | | <div className="right-view"> |
| | | {selectApp ? <div className="app-title">{selectApp.remark}</div> : null} |
| | |
| | | title={'编辑应用'} |
| | | width={'600px'} |
| | | maskClosable={false} |
| | | visible={!!visible} |
| | | onCancel={() => this.setState({visible: false})} |
| | | visible={visible !== false} |
| | | onCancel={() => this.setState({visible: false, confirmloading: false})} |
| | | confirmLoading={this.state.confirmloading} |
| | | onOk={this.submitCard} |
| | | cancelText="取消" |
| | |
| | | title={transVisible === 'plus' ? '添加传输号' : '编辑传输号'} |
| | | width={'600px'} |
| | | maskClosable={false} |
| | | visible={!!transVisible} |
| | | onCancel={() => this.setState({transVisible: false})} |
| | | visible={transVisible !== false} |
| | | onCancel={() => this.setState({transVisible: false, confirmloading: false})} |
| | | confirmLoading={this.state.confirmloading} |
| | | onOk={this.submitTrans} |
| | | cancelText="取消" |
| | | okText="确定" |
| | | destroyOnClose |
| | | > |
| | | <TransForm type={transVisible} card={transVisible === 'edit' ? selectTran : ''} wrappedComponentRef={(inst) => this.transRef = inst} inputSubmit={this.submitTrans} /> |
| | | <TransForm type={transVisible} card={transVisible === 'edit' ? this.state.editTran : ''} wrappedComponentRef={(inst) => this.transRef = inst} inputSubmit={this.submitTrans} /> |
| | | </Modal> |
| | | <Modal |
| | | title={'添加脚本'} |
| | | width={750} |
| | | maskClosable={false} |
| | | visible={scriptVisible} |
| | | onCancel={() => this.setState({scriptVisible: false, confirmloading: false})} |
| | | confirmLoading={this.state.confirmloading} |
| | | onOk={this.submitScript} |
| | | cancelText="取消" |
| | | okText="确定" |
| | | destroyOnClose |
| | | > |
| | | <ScriptForm applist={applist} wrappedComponentRef={(inst) => this.scriptRef = inst} inputSubmit={this.submitScript} /> |
| | | </Modal> |
| | | <Modal |
| | | title={'编辑子应用'} |
| | | width={'850px'} |
| | | maskClosable={false} |
| | | visible={!!subVisible} |
| | | onCancel={() => this.setState({subVisible: false})} |
| | | visible={subVisible !== false} |
| | | onCancel={() => this.setState({subVisible: false, confirmloading: false})} |
| | | confirmLoading={this.state.confirmloading} |
| | | onOk={this.submitSubCard} |
| | | cancelText="取消" |