From c71b5c29fea2b90ffac2045ce45bc1bd74236446 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 二月 2021 09:57:02 +0800 Subject: [PATCH] 2021-02-18 --- src/views/mobmanage/index.jsx | 132 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 112 insertions(+), 20 deletions(-) diff --git a/src/views/mobmanage/index.jsx b/src/views/mobmanage/index.jsx index b5249f3..261e72c 100644 --- a/src/views/mobmanage/index.jsx +++ b/src/views/mobmanage/index.jsx @@ -1,19 +1,20 @@ import React, {Component} from 'react' // import { fromJS } from 'immutable' -import { Spin, notification, Button, Table } from 'antd' +import { Spin, notification, Button, Table, Modal } from 'antd' import Api from '@/api' -// import Utils from '@/utils/utils.js' +import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' import './index.scss' const Header = asyncComponent(() => import('@/mob/header')) -// const MobCard = asyncComponent(() => import('@/mob/mobcard')) +const MutilForm = asyncComponent(() => import('./mutilform')) class AppManage extends Component { state = { loading: false, applist: [], + appsublist: [], columns: [ { title: '搴旂敤鍚嶇О', dataIndex: 'remark', key: 'remark', align: 'center' }, { title: '搴旂敤鍙傛暟', dataIndex: 'kei_no', key: 'kei_no', align: 'center' }, @@ -21,7 +22,7 @@ title: 'Action', key: 'action', align: 'center', - render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), + render: (text, record) => (<Button type="link" onClick={() => this.deleteApp(record)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), }, ], subcolumns: [ @@ -48,7 +49,12 @@ title: 'Action', key: 'action', align: 'center', - render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>鍒犻櫎</Button>), + render: (text, record) => ( + <div> + <Button type="link" onClick={() => this.deleteSubApp(record)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button> + <Button type="link" onClick={() => this.jumpMenu(record)}>缂栬緫搴旂敤</Button> + </div> + ) }, ], selectApp: null, @@ -104,12 +110,21 @@ }) } + deleteApp = (record) => { + console.log(record) + } + + deleteSubApp = (record) => { + console.log(record) + } + jumpMenu = (card) => { - let _type = 'mob' - if (card.type === 'pc') { - _type = 'pc' - } - this.props.history.replace(`/mobdesign/${card.uuid}/${_type}/${card.keiNo}/${card.name}`) + console.log(card) + // let _type = 'mob' + // if (card.type === 'pc') { + // _type = 'pc' + // } + // this.props.history.replace(`/mobdesign/${card.uuid}/${_type}/${card.keiNo}/${card.name}`) } /** @@ -126,7 +141,6 @@ * */ onSubChange = selectedSubRowKeys => { - this.setState({ selectedSubRowKeys }) } @@ -134,7 +148,7 @@ * @description 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝 鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 */ changeRow = (record) => { - this.setState({ selectedRowKeys: [record.ID], selectApp: record }) + this.setState({ selectedRowKeys: [record.ID], selectApp: record, appsublist: record.sublist || [] }) } /** @@ -144,8 +158,72 @@ this.setState({ selectedSubRowKeys: [record.ID], selectSubApp: record }) } + trigerApp = (type) => { + if ((type === 'appedit' && !this.state.selectApp) || (type === 'subappedit' && !this.state.selectSubApp)) { + notification.warning({ + top: 92, + message: '璇烽�夋嫨闇�瑕佺紪杈戠殑搴旂敤锛�', + duration: 5 + }) + return + } + + this.setState({ + visible: type + }) + } + + + submitCard = () => { + const { card } = this.state + + this.mobcardRef.handleConfirm().then(res => { + this.setState({ + confirmloading: true + }) + + let param = { + func: 's_kei_addupt', + ID: card ? card.uuid : Utils.getuuid(), + TypeName: res.type, + remark: res.name, + kei_no: res.keiNo + } + + Api.getCloudConfig(param).then(result => { + if (result.status) { + notification.success({ + top: 92, + message: card ? '淇敼鎴愬姛锛�' : '娣诲姞鎴愬姛锛�', + duration: 5 + }) + + this.setState({ + confirmloading: false, + visible: false, + loading: true + }) + this.getMobCards() + } else { + this.setState({ + confirmloading: false + }) + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }, () => { + this.setState({ + confirmloading: false + }) + }) + }) + } + render () { - const { loading, columns, applist, selectedRowKeys, selectedSubRowKeys, selectApp, subcolumns } = this.state + const { loading, visible, columns, applist, appsublist, selectedRowKeys, selectedSubRowKeys, subcolumns, selectApp, selectSubApp } = this.state return ( <div className="mk-app-manage"> @@ -158,8 +236,8 @@ } <div className="app-table"> <div className="app-action"> - <Button className="mk-green">娣诲姞</Button> - <Button className="mk-purple">淇敼</Button> + <Button className="mk-green" onClick={() => this.trigerApp('appplus')}>娣诲姞</Button> + <Button className="mk-purple" onClick={() => this.trigerApp('appedit')}>淇敼</Button> </div> <Table rowKey="ID" @@ -173,19 +251,33 @@ <div className="app-table"> <div className="sub-app-title"><span>瀛愬簲鐢�</span></div> <div className="app-action"> - <Button className="mk-green">娣诲姞</Button> - <Button className="mk-purple">淇敼</Button> + <Button className="mk-green" onClick={() => this.trigerApp('subappplus')}>娣诲姞</Button> + <Button className="mk-purple" onClick={() => this.trigerApp('subappedit')}>淇敼</Button> </div> <Table rowKey="ID" columns={subcolumns} - dataSource={selectApp ? selectApp.sublist : []} + dataSource={appsublist} pagination={false} - rowSelection={{ type: 'radio', selectedSubRowKeys, onChange: this.onSubChange }} + rowSelection={{ type: 'radio', selectedRowKeys: selectedSubRowKeys, onChange: this.onSubChange }} onRow={(record) => ({ onClick: () => {this.changeSubRow(record)} })} /> </div> - {/* <MobCard jumpMenu={this.jumpMenu}/> */} + <Modal + // className="mob-card-modal" + title={'缂栬緫搴旂敤'} + width={'600px'} + maskClosable={false} + visible={!!visible} + onCancel={() => this.setState({visible: ''})} + confirmLoading={this.state.confirmloading} + onOk={this.submitCard} + cancelText="鍙栨秷" + okText="纭畾" + destroyOnClose + > + <MutilForm card={visible === 'appedit' ? selectApp : (visible === 'subappedit' ? selectSubApp : '')} wrappedComponentRef={(inst) => this.mobcardRef = inst} inputSubmit={this.submitCard} /> + </Modal> </div> ) } -- Gitblit v1.8.0