From 2850799963a5bff04aeeb9eb73dc4eb91a0dc165 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 18 七月 2021 00:54:37 +0800 Subject: [PATCH] 2021-07-18 --- src/views/appmanage/index.jsx | 332 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 290 insertions(+), 42 deletions(-) diff --git a/src/views/appmanage/index.jsx b/src/views/appmanage/index.jsx index aef6542..463e01d 100644 --- a/src/views/appmanage/index.jsx +++ b/src/views/appmanage/index.jsx @@ -19,6 +19,7 @@ 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 = '' @@ -81,9 +82,10 @@ 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> @@ -94,9 +96,23 @@ 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 = '' @@ -138,7 +154,10 @@ if (result.status) { this.setState({ loading: false, - translist: result.data + translist: result.data, + selectTran: null, + scriptlist: [], + transTotal: result.total }) } else { this.setState({ @@ -153,6 +172,72 @@ }) } + getScriptList = () => { + const { scriptSearchKey, scriptIndex, selectTran } = this.state + + if (!selectTran || !selectTran.ID) { + notification.warning({ + top: 92, + message: '缂哄皯浼犺緭鍙稩D!', + 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 @@ -162,13 +247,13 @@ } 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({ @@ -184,7 +269,7 @@ } else { param.func = 's_sVersion_upt' param.ProgramName = res.ProgramName - param.ID = selectTran.ID + param.ID = editTran.ID } Api.getCloudConfig(param).then(result => { @@ -217,6 +302,49 @@ }) } + 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 @@ -235,10 +363,6 @@ top: 92, message: '鎿嶄綔鎴愬姛锛�', duration: 3 - }) - - _this.setState({ - selectTran: null, }) _this.getTransList() } else { @@ -276,10 +400,6 @@ top: 92, message: '鎿嶄綔鎴愬姛锛�', duration: 3 - }) - - _this.setState({ - selectTran: record, }) _this.getTransList() } else { @@ -322,6 +442,10 @@ return item }) + + if (!selectApp && applist[0]) { + selectApp = applist[0] + } this.setState({ loading: false, @@ -495,11 +619,113 @@ 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() + }) + } } /** @@ -661,7 +887,7 @@ } 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"> @@ -669,8 +895,7 @@ <Header view="manage" /> {loading ? <div className="loading-mask"> - <div className="ant-spin-blur"></div> - <Spin /> + <Spin size="large" /> </div> : null } <div className="view-wrap"> @@ -700,32 +925,41 @@ 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} @@ -813,8 +1047,8 @@ 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="鍙栨秷" @@ -827,22 +1061,36 @@ 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="鍙栨秷" -- Gitblit v1.8.0