king
2021-02-05 8d05744179a026a243b86e3a99296e30375ccfb0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import React, {Component} from 'react'
// import { fromJS } from 'immutable'
import { Spin, notification, Button, Table } from 'antd'
 
import Api from '@/api'
// 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'))
 
class AppManage extends Component {
  state = {
    loading: false,
    applist: [],
    columns: [
      { title: '应用名称', dataIndex: 'remark', key: 'remark', align: 'center' },
      { title: '应用参数', dataIndex: 'kei_no', key: 'kei_no', align: 'center' },
      {
        title: 'Action',
        key: 'action',
        align: 'center',
        render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>删除</Button>),
      },
    ],
    subcolumns: [
      {
        title: '应用类型', dataIndex: 'typename', key: 'typename', align: 'center'
      },
      {
        title: '语言', dataIndex: 'lang', key: 'lang', align: 'center',
        render: (text, record) => text === 'en-US' ? '英文' : '中文'
      },
      {
        title: '登录', dataIndex: 'login_types', key: 'login_types', align: 'center',
        render: (text, record) => text === 'false' ? '不需要' : '需要'
      },
      {
        title: '权限管理', dataIndex: 'role_type', key: 'role_type', align: 'center',
        render: (text, record) => text === 'false' ? '不需要' : '需要'
      },
      {
        title: '短连接', dataIndex: 'link_type', key: 'link_type', align: 'center',
        render: (text, record) => text === 'false' ? '不启用' : '启用'
      },
      {
        title: 'Action',
        key: 'action',
        align: 'center',
        render: (text, record) => (<Button type="link" style={{color: '#ff4d4f'}}>删除</Button>),
      },
    ],
    selectApp: null,
    selectSubApp: null,
    selectedRowKeys: [],
    selectedSubRowKeys: [],
  }
 
  UNSAFE_componentWillMount() {
    document.body.className = ''
    this.getAppList()
  }
 
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  getAppList = () => {
    let param = {
      func: 's_get_kei'
    }
 
    Api.getCloudConfig(param).then(result => {
      if (result.status) {
        this.setState({
          loading: false,
          applist: result.data.map(item => {
            item.sublist = item.data_detail || []
            item.sublist = item.sublist.map(cell => {
              cell.ID = cell.d_id
              return cell
            })
 
            return item
          })
        })
 
      } else {
        this.setState({
          loading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
      }
    })
  }
 
  jumpMenu = (card) => {
    let _type = 'mob'
    if (card.type === 'pc') {
      _type = 'pc'
    }
    this.props.history.replace(`/mobdesign/${card.uuid}/${_type}/${card.keiNo}/${card.name}`)
  }
 
  /**
   * 
   */
  onSelectChange = selectedRowKeys => {
    const { applist } = this.state
    let selectApp = applist.filter(item => item.ID === selectedRowKeys[0])[0]
 
    this.setState({ selectedRowKeys, selectApp })
  }
 
  /**
   * 
   */
  onSubChange = selectedSubRowKeys => {
 
    this.setState({ selectedSubRowKeys })
  }
 
  /**
   * @description 点击整行,触发切换, 判断是否可选,单选或多选,进行对应操作
   */
  changeRow = (record) => {
    this.setState({ selectedRowKeys: [record.ID], selectApp: record })
  }
 
  /**
   * @description 点击整行,触发切换, 判断是否可选,单选或多选,进行对应操作
   */
  changeSubRow = (record) => {
    this.setState({ selectedSubRowKeys: [record.ID], selectSubApp: record })
  }
 
  render () {
    const { loading, columns, applist, selectedRowKeys, selectedSubRowKeys, selectApp, subcolumns } = this.state
 
    return (
      <div className="mk-app-manage">
        <Header view="manage" />
        {loading ?
          <div className="loading-mask">
            <div className="ant-spin-blur"></div>
            <Spin />
          </div> : null
        }
        <div className="app-table">
          <div className="app-action">
            <Button className="mk-green">添加</Button>
            <Button className="mk-purple">修改</Button>
          </div>
          <Table
            rowKey="ID"
            columns={columns}
            dataSource={applist}
            pagination={false}
            rowSelection={{ type: 'radio', selectedRowKeys, onChange: this.onSelectChange }}
            onRow={(record) => ({ onClick: () => {this.changeRow(record)} })}
          />
        </div>
        <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>
          </div>
          <Table
            rowKey="ID"
            columns={subcolumns}
            dataSource={selectApp ? selectApp.sublist : []}
            pagination={false}
            rowSelection={{ type: 'radio', selectedSubRowKeys, onChange: this.onSubChange }}
            onRow={(record) => ({ onClick: () => {this.changeSubRow(record)} })}
          />
        </div>
        {/* <MobCard jumpMenu={this.jumpMenu}/> */}
      </div>
    )
  }
}
 
export default AppManage