king
2020-03-18 bbe52230e61c5b911da9e22e6a11c332b52baf7c
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Row, Col, Input, Button, Card, notification } from 'antd'
// import moment from 'moment'
 
import Api from '@/api'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
// import options from '@/store/options.js'
// import { verupMainTable } from './config.js'
import subtableurl from '@/assets/img/subtable.jpg'
 
import './index.scss'
 
const { Search } = Input
 
class TabManage extends Component {
  static propTpyes = {
    MenuNo: PropTypes.string,    // 菜单参数
    MenuName: PropTypes.string,  // 菜单参数
    MenuID: PropTypes.string     // 菜单Id
  }
 
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    ContainerId: Utils.getuuid(), // 菜单外层html Id
    searchKey: '',
    tabviews: null,
    cols: 8
  }
 
 
  UNSAFE_componentWillMount () {
    let docwidth = document.body.offsetWidth
    let cols = 8
 
    if (docwidth > 1500) {
      cols = 6
    } else if (docwidth > 1900) {
      cols = 4
    }
    
    this.setState({
      cols: cols
    })
  }
 
  componentDidMount () {
    Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => {
      if (res.status) {
        this.setState({
          tabviews: res.UserTemp.map(temp => {
            return {
              uuid: temp.MenuID,
              value: temp.MenuID,
              text: temp.MenuName,
              type: temp.Template,
              MenuNo: temp.MenuNo
            }
          })
        })
      } else {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 10
        })
      }
    })
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
 
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  render() {
    const { cols, tabviews } = this.state
 
    return (
      <div className="tab-manage" id={this.state.ContainerId}>
        <Row>
          <Col className="tab-search" span={6}>
            <Search placeholder="请输入标签名称" onSearch={value => {this.setState({searchKey: value})}} enterButton />
          </Col>
          <Col className="tab-thaw" span={6} offset={12}>
            <Button type="primary">标签解冻</Button>
          </Col>
        </Row>
        <Row className="tab-list">
          {tabviews && tabviews.map((tab, index) => {
            return (
              <Col span={cols} key={index}>
                <Card
                  className="tab-card"
                  title={tab.text}
                >
                  <img onClick={() => {this.previewPicture()}} src={subtableurl} alt=""/>
                  <div className="card-operation">
                    <Button type="primary">使用模板</Button>
                  </div>
                </Card>
              </Col>
            )
          })}
        </Row>
      </div>
    )
  }
}
 
export default TabManage